Re: questions about ASN.1
- From: "Tom St Denis" <tomstdenis@xxxxxxxxx>
- Date: 27 Nov 2006 03:55:02 -0800
yawnmoth wrote:
Say I'm trying to decode the following:
http://www.geocities.com/terra1024/paypal_cert_pem.txt
openssl asn1parse -inform PEM -in paypal_cert_pem.txt -i
:-)
I remove the ---- stuff from the start and end and do a base64 decode.
The first few bytes are as follows:
30:82:03:a1:30:82:03:0a:a0
My interpretation of that is this. There's a constructed SEQUENCE of
929 bytes containing a constructed SEQUENCE of 778 bytes. This second
constructed SEQUENCE contains a constructed Context-specific class.
Is this correct? If so, then is there such a thing as a primitive
sequence?
Yes, your decoding of the SEQUENCE headers sounds right. Not that I
know about the context specific stuff (though my use of ASN1 is
limited to crypto). There are also SEQUENCE OF, SET and SET OF types
to look at :-) (though the set is tag 0x11 not 0x10).
Also, how do I decode something with a Context-specific class?
<http://www.columbia.edu/~ariel/ssleay/layman.html> suggests that
Universal classes can be decoded in any number of ways. The tag is the
ultimate determiner of how something gets decoded. So what about
Context-specific classes?
Dunno off hand. Decoding is easy. Interpreting is harder :-)
Especially when there are DEFAULT and OPTIONAL components.
In the case of x509 it seems to include a set of sequences of the form
SEQUENCE {
ID OBJECT IDENTIFIER,
value TYPE, -- e.g. PRINTABLESTRING, T61STRING, UTCTIME
}
So you'd decode these and use the ID to figure out what the value means
(hint: think key-value pairings).
To be more accurate, the BER/DER encoding rules use "octet"
and not byte, an important distinction.
What is the distinction?
byte is not strictly eight bits. A byte is typically associated with a
"char" which can change in shape and size depending on the platform.
That said, thanks for the help, thus far, Tom St Denis and Jeff Jacoby!
NP.
I have a "ASN.1 Flexi" decoder in LibTomCrypt that can decode any ASN.1
structure that it can identify the tags from. The eventual goal was to
use it for 509 certs which can come in all shapes and sizes. Currently
I lack a few of the *String types required like UNICODE and T61String
(I've just recently added UTF8 to the CVS).
You may want to take a look at that for ideas. It's not perfect, but
imho a decent start. And given that it's public domain it's ripe for
the picking :-)
Tom
.
- References:
- questions about ASN.1
- From: yawnmoth
- Re: questions about ASN.1
- From: yawnmoth
- questions about ASN.1
- Prev by Date: Re: Poly1305 vs. UMAC vs. new MAC1071
- Next by Date: Re: Programs for breaking Classic Ciphers
- Previous by thread: Re: questions about ASN.1
- Next by thread: Re: questions about ASN.1
- Index(es):
Relevant Pages
|
|