react / wstein / node_modules / browserify / node_modules / crypto-browserify / node_modules / public-encrypt / node_modules / parse-asn1 / asn1.js
80555 views// from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js1// Fedor, you are amazing.23var asn1 = require('asn1.js');45var RSAPrivateKey = asn1.define('RSAPrivateKey', function() {6this.seq().obj(7this.key('version').int(),8this.key('modulus').int(),9this.key('publicExponent').int(),10this.key('privateExponent').int(),11this.key('prime1').int(),12this.key('prime2').int(),13this.key('exponent1').int(),14this.key('exponent2').int(),15this.key('coefficient').int()16);17});18exports.RSAPrivateKey = RSAPrivateKey;1920var RSAPublicKey = asn1.define('RSAPublicKey', function() {21this.seq().obj(22this.key('modulus').int(),23this.key('publicExponent').int()24);25});26exports.RSAPublicKey = RSAPublicKey;2728var PublicKey = asn1.define('SubjectPublicKeyInfo', function() {29this.seq().obj(30this.key('algorithm').use(AlgorithmIdentifier),31this.key('subjectPublicKey').bitstr()32);33});34exports.PublicKey = PublicKey;3536var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function() {37this.seq().obj(38this.key('algorithm').objid(),39this.key('none').null_().optional(),40this.key('curve').objid().optional(),41this.key('params').seq().obj(42this.key('p').int(),43this.key('q').int(),44this.key('g').int()45).optional()46);47});4849var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function() {50this.seq().obj(51this.key('version').int(),52this.key('algorithm').use(AlgorithmIdentifier),53this.key('subjectPrivateKey').octstr()54);55});56exports.PrivateKey = PrivateKeyInfo;57var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function() {58this.seq().obj(59this.key('algorithm').seq().obj(60this.key('id').objid(),61this.key('decrypt').seq().obj(62this.key('kde').seq().obj(63this.key('id').objid(),64this.key('kdeparams').seq().obj(65this.key('salt').octstr(),66this.key('iters').int()67)68),69this.key('cipher').seq().obj(70this.key('algo').objid(),71this.key('iv').octstr()72)73)74),75this.key('subjectPrivateKey').octstr()76);77});7879exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo;8081var DSAPrivateKey = asn1.define('DSAPrivateKey', function() {82this.seq().obj(83this.key('version').int(),84this.key('p').int(),85this.key('q').int(),86this.key('g').int(),87this.key('pub_key').int(),88this.key('priv_key').int()89);90});91exports.DSAPrivateKey = DSAPrivateKey;9293exports.DSAparam = asn1.define('DSAparam', function () {94this.int();95});96var ECPrivateKey = asn1.define('ECPrivateKey', function() {97this.seq().obj(98this.key('version').int(),99this.key('privateKey').octstr(),100this.key('parameters').optional().explicit(0).use(ECParameters),101this.key('publicKey').optional().explicit(1).bitstr()102);103});104exports.ECPrivateKey = ECPrivateKey;105var ECParameters = asn1.define('ECParameters', function() {106this.choice({107namedCurve: this.objid()108});109});110111exports.signature = asn1.define('signature', function() {112this.seq().obj(113this.key('r').int(),114this.key('s').int()115);116});117118119