droopycom has asked for the wisdom of the Perl Monks concerning the following question:
I have the following ASN.1 grammar:
When I do a decode my pem file with this, the BIT STRING seems to be stored as an array (or ref to array) with 2 elements, but I cant figure out what those two elements are really containing...SubjectPublicKeyInfo ::= SEQUENCE { algorithm AlgorithmIdentifier, subjectPublicKey BIT STRING }
Any idea ?
Thanks.
Update --- Ok I figured it out:
A BIT STRING is stored as an array with two elements.
- The first element contain the bit strings data
- The second element contain the bit string length
When encoding a bitstring, using Convert::ASN1::encode, you can specify it two ways (at least)
The first call will encode the bitstring "0101010101010101" (16 bits)$asn->prepare(q< str BIT STRING >) # Method1: length is multiple of 8 $asn->encode(str => "UU"); # Method2: length is explicit $asn->encode(str => ["UU", 12]);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Convert::PEM and BIT STRING
by zentara (Cardinal) on Sep 19, 2008 at 20:01 UTC | |
|
Re: Convert::PEM and BIT STRING
by zentara (Cardinal) on Sep 19, 2008 at 18:12 UTC | |
by droopycom (Initiate) on Sep 19, 2008 at 18:38 UTC | |
by BrowserUk (Patriarch) on Sep 19, 2008 at 19:35 UTC |