-
-
Notifications
You must be signed in to change notification settings - Fork 647
Open
Description
When dissecting ASN1 blobs, the value of a bitstring can lead to different parsing results, which require additional effort to handle. For example the following script parses two ed25519 public keys.
jsrsasign@www-02:~$ cat split-horizon.mjs
#!/usr/bin/env node
import { inspect } from 'node:util';
import jsrsasign from 'jsrsasign/jsrsasign.js'
//let hex = "30 2a 30 05 06 032b6570 03 21 00 1d1e7ef143ec237e244448868e7178f7e1307982d736ab91a6547360c33bdb99";
let hex = "302a300506032b65700321001d1e7ef143ec237e244448868e7178f7e1307982d736ab91a6547360c33bdb99";
let obj = jsrsasign.ASN1HEX.parse(hex);
console.log(`obj: ${inspect(obj, null, 8)}`);
//let hex = "30 2a 30 05 06 032b6570 03 21 00 7a9288f0ef40453a028f8dc868fb5f38e24ec75ea5a92c3c38cfbb61c11bbd1b";
hex = "302a300506032b65700321007a9288f0ef40453a028f8dc868fb5f38e24ec75ea5a92c3c38cfbb61c11bbd1b";
obj = jsrsasign.ASN1HEX.parse(hex);
console.log(`obj: ${inspect(obj, null, 8)}`);
Running this script shows two different result structures, although I would expect them to be equal.
jsrsasign@www-02:~$ node split-horizon.mjs
obj: {
seq: [
{ seq: [ { oid: 'id-Ed25519' } ] },
{
bitstr: {
obj: {
asn1: {
tlv: '1d1e7ef143ec237e244448868e7178f7e1307982d736ab91a6547360c33bdb99'
}
}
}
}
]
}
obj: {
seq: [
{ seq: [ { oid: 'id-Ed25519' } ] },
{
bitstr: {
hex: '007a9288f0ef40453a028f8dc868fb5f38e24ec75ea5a92c3c38cfbb61c11bbd1b'
}
}
]
}
Please add the hex
attribute to bitstr
, even when parse()
peeks into it and detects a TLV structure. Or alternatively, add an optional parameter to parse()
to suppress peeking into the ASN1 bitstr
completely.
Metadata
Metadata
Assignees
Labels
No labels