Last active
August 29, 2015 14:02
-
-
Save muromec/fa3d896be964bb1a9f4c to your computer and use it in GitHub Desktop.
ASN1.js bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var asn1 = require('asn1.js'); | |
var broken = function() { | |
var B = asn1.define('B', function() { | |
this.seq().obj( // NO implicit tag here | |
this.key('b').octstr() | |
); | |
}); | |
var A = asn1.define('Bug', function() { | |
this.seq().obj( | |
this.implicit(0).use(B) | |
) | |
}); | |
return A.decode(coded, 'der'); | |
} | |
var works = function(coded) { | |
var B = asn1.define('B', function() { | |
this.seq().implicit(0).obj( // IMPLICIT tag copied from parent | |
this.key('b').octstr() | |
); | |
}); | |
var A = asn1.define('Bug', function() { | |
this.seq().obj( | |
this.implicit(0).use(B) | |
) | |
}); | |
return A.decode(coded, 'der'); | |
} | |
var coded = new Buffer('300720050403313233', 'hex'); | |
works(coded); | |
console.log("ok"); | |
broken(coded); | |
console.log("ok?"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment