Hi,
I have the following ASN.1 grammar:
SubjectPublicKeyInfo ::= SEQUENCE {
algorithm AlgorithmIdentifier,
subjectPublicKey BIT STRING
}
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...
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)
$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]);
The first call will encode the bitstring "0101010101010101" (16 bits)
The second call will encode the bitstring "010101010101" (12 bits)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.