001package org.apache.commons.ssl.org.bouncycastle.asn1; 002 003import java.io.IOException; 004 005public class DEROctetString 006 extends ASN1OctetString 007{ 008 /** 009 * @param string the octets making up the octet string. 010 */ 011 public DEROctetString( 012 byte[] string) 013 { 014 super(string); 015 } 016 017 public DEROctetString( 018 ASN1Encodable obj) 019 throws IOException 020 { 021 super(obj.toASN1Primitive().getEncoded(ASN1Encoding.DER)); 022 } 023 024 boolean isConstructed() 025 { 026 return false; 027 } 028 029 int encodedLength() 030 { 031 return 1 + StreamUtil.calculateBodyLength(string.length) + string.length; 032 } 033 034 void encode( 035 ASN1OutputStream out) 036 throws IOException 037 { 038 out.writeEncoded(BERTags.OCTET_STRING, string); 039 } 040 041 static void encode( 042 DEROutputStream derOut, 043 byte[] bytes) 044 throws IOException 045 { 046 derOut.writeEncoded(BERTags.OCTET_STRING, bytes); 047 } 048}