DEROctetString.java revision e6bf3e8dfa2804891a82075cb469b736321b4827
1package org.bouncycastle.asn1;
2
3import java.io.IOException;
4
5public class DEROctetString
6    extends ASN1OctetString
7{
8    /**
9     * @param string the octets making up the octet string.
10     */
11    public DEROctetString(
12        byte[]  string)
13    {
14        super(string);
15    }
16
17    public DEROctetString(
18        ASN1Encodable obj)
19        throws IOException
20    {
21        super(obj.toASN1Primitive().getEncoded(ASN1Encoding.DER));
22    }
23
24    boolean isConstructed()
25    {
26        return false;
27    }
28
29    int encodedLength()
30    {
31        return 1 + StreamUtil.calculateBodyLength(string.length) + string.length;
32    }
33
34    void encode(
35        ASN1OutputStream out)
36        throws IOException
37    {
38        out.writeEncoded(BERTags.OCTET_STRING, string);
39    }
40
41    static void encode(
42        DEROutputStream derOut,
43        byte[]          bytes)
44        throws IOException
45    {
46        derOut.writeEncoded(BERTags.OCTET_STRING, bytes);
47    }
48}
49