Skip to content

Instantly share code, notes, and snippets.

@lucashenning
Created November 3, 2020 12:26
Show Gist options
  • Save lucashenning/005d247a5956533b770537fdc701121c to your computer and use it in GitHub Desktop.
Save lucashenning/005d247a5956533b770537fdc701121c to your computer and use it in GitHub Desktop.
Parse a DER encoded public key with ASN1.js
const EcdsaPubKey = asn1.define('EcdsaPubKey', function(this: any) {
// https://tools.ietf.org/html/rfc5480#section-2
this.seq().obj(
this.key('algo').seq().obj(
this.key('algorithm').objid(),
this.key('parameters').objid(),
),
this.key('pubKey').bitstr() // <-- this is what we want
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment