Search code examples
javabouncycastlederasn.1

read a DER Application Specific (asn1-java-bouncycastle)


I'm trying to translate with a Bouncy castle asn1 libraries an object of type DER ApplicationSpecific (or maybe it's an array?) but I m not able to navigate the structure. With the simple following code ( arr is my byte array)

ASN1InputStream bIn = new ASN1InputStream (new ByteArrayInputStream (
arr);
DERApplicationSpecific primitive = (DERApplicationSpecific) bIn.readObject 
();
System.out.println (ASN1Dump.dumpAsString (primitive));

I get this print:

DER ApplicationSpecific [21] (432b30363a3435223b6461796c696768742d736176696e672d74696d653d223031223b6e6574776f726b2d70726f7669646564bf1f818f313d800103813832363230333036323436323439313737343632303535)

I can guess that this is an array of 21 elements but I can not go deeper Can anyone help me? Thank you very much.


Solution

  • I can not go deeper Can anyone help me?

    Most likely not, as name of object suggests, it is application specific.

    21 in string output means tag value, not number of sub elements.

    You can call getContents() to obtain underlying byte array and getApplicationTag() to obtain tag value (21 in your case).

    How to interpret that data, it is not known without more details.