Closed felix closed 9 years ago
der._peekTag() needs to find it, or, Node.decode() needs to test for state.use !== null
and act accordingly.
I think.
Hm... I wonder if it is ok in ASN.1 to have an optional use of some struct without explicit/implicit tagging. Do you have any examples of this in RFCs, or whatever?
I am doing a lot from RFC 4210 which has some different examples:
in 5.1.1:
protectionAlg [1] AlgorithmIdentifier OPTIONAL
in 5.3.4:
certifiedKeyPair CertifiedKeyPair OPTIONAL
neither of which work with optional()
and use()
. But perhaps my implicit/explicit options are wrong:
var PKIHeader = asn.define('PKIHeader', function() {
this.key('header').seq().obj(
this.key('pvno').int(),
this.key('sender').use(rfc3280.GeneralName),
this.key('recipient').use(rfc3280.GeneralName),
this.key('protectionAlg').explicit(1).optional().use(rfc3280.AlgorithmIdentifier),
...
var CertResponse = asn.define('CertResponse', function() {
this.seq().obj(
this.key('certReqId').int(),
this.key('status').use(PKIStatusInfo),
this.key('certifiedKeyPair').optional().use(CertifiedKeyPair),
...
First one has [1]
which means EXPLICIT (or IMPLICIT, I always confuse these two).
5.3.4 looks legit, though. I'll look into how it could be fixed. Thank you for the report!
Oh, I see that the first one does not work for you either... It is rather odd, but I'm going to check it too.
Yeah, neither work for me. It just means I have to copy schemas inline rather than 'use'ing them which become a hassle.
I have landed your test and fixed it in asn1.js@2.1.2 . May I ask you to give it a try with both of your last samples from RFC, and let me know if they work for you? If they don't please submit a new test case ;) It will help a lot!
It all works, fantastic! Thanks.
Cool, thank you!
Encoding seems to work, decoding does not work. A test case is here https://github.com/felix/asn1.js/commit/ea45c619f70b00e20762b433c5494a37077da263