summaryrefslogtreecommitdiffstats
path: root/node_modules/parse-asn1
diff options
context:
space:
mode:
authorGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
committerGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
commite06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch)
tree55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/parse-asn1
downloadwebsite_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip
api, login, auth
Diffstat (limited to 'node_modules/parse-asn1')
-rw-r--r--node_modules/parse-asn1/LICENSE13
-rw-r--r--node_modules/parse-asn1/README.md8
-rw-r--r--node_modules/parse-asn1/aesid.json13
-rw-r--r--node_modules/parse-asn1/asn1.js122
-rw-r--r--node_modules/parse-asn1/certificate.js89
-rw-r--r--node_modules/parse-asn1/fixProc.js31
-rw-r--r--node_modules/parse-asn1/index.js107
-rw-r--r--node_modules/parse-asn1/package.json65
8 files changed, 448 insertions, 0 deletions
diff --git a/node_modules/parse-asn1/LICENSE b/node_modules/parse-asn1/LICENSE
new file mode 100644
index 0000000..e0efcf2
--- /dev/null
+++ b/node_modules/parse-asn1/LICENSE
@@ -0,0 +1,13 @@
+Copyright (c) 2017, crypto-browserify contributors
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/node_modules/parse-asn1/README.md b/node_modules/parse-asn1/README.md
new file mode 100644
index 0000000..9cd4c15
--- /dev/null
+++ b/node_modules/parse-asn1/README.md
@@ -0,0 +1,8 @@
+# parse-asn1
+
+[![TRAVIS](https://secure.travis-ci.org/crypto-browserify/parse-asn1.png)](http://travis-ci.org/crypto-browserify/parse-asn1)
+[![NPM](http://img.shields.io/npm/v/parse-asn1.svg)](https://www.npmjs.org/package/parse-asn1)
+
+[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
+
+utility library for parsing asn1 files for use with browserify-sign.
diff --git a/node_modules/parse-asn1/aesid.json b/node_modules/parse-asn1/aesid.json
new file mode 100644
index 0000000..24f653b
--- /dev/null
+++ b/node_modules/parse-asn1/aesid.json
@@ -0,0 +1,13 @@
+{"2.16.840.1.101.3.4.1.1": "aes-128-ecb",
+"2.16.840.1.101.3.4.1.2": "aes-128-cbc",
+"2.16.840.1.101.3.4.1.3": "aes-128-ofb",
+"2.16.840.1.101.3.4.1.4": "aes-128-cfb",
+"2.16.840.1.101.3.4.1.21": "aes-192-ecb",
+"2.16.840.1.101.3.4.1.22": "aes-192-cbc",
+"2.16.840.1.101.3.4.1.23": "aes-192-ofb",
+"2.16.840.1.101.3.4.1.24": "aes-192-cfb",
+"2.16.840.1.101.3.4.1.41": "aes-256-ecb",
+"2.16.840.1.101.3.4.1.42": "aes-256-cbc",
+"2.16.840.1.101.3.4.1.43": "aes-256-ofb",
+"2.16.840.1.101.3.4.1.44": "aes-256-cfb"
+} \ No newline at end of file
diff --git a/node_modules/parse-asn1/asn1.js b/node_modules/parse-asn1/asn1.js
new file mode 100644
index 0000000..6cac822
--- /dev/null
+++ b/node_modules/parse-asn1/asn1.js
@@ -0,0 +1,122 @@
+// from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js
+// Fedor, you are amazing.
+'use strict'
+
+var asn1 = require('asn1.js')
+
+exports.certificate = require('./certificate')
+
+var RSAPrivateKey = asn1.define('RSAPrivateKey', function () {
+ this.seq().obj(
+ this.key('version').int(),
+ this.key('modulus').int(),
+ this.key('publicExponent').int(),
+ this.key('privateExponent').int(),
+ this.key('prime1').int(),
+ this.key('prime2').int(),
+ this.key('exponent1').int(),
+ this.key('exponent2').int(),
+ this.key('coefficient').int()
+ )
+})
+exports.RSAPrivateKey = RSAPrivateKey
+
+var RSAPublicKey = asn1.define('RSAPublicKey', function () {
+ this.seq().obj(
+ this.key('modulus').int(),
+ this.key('publicExponent').int()
+ )
+})
+exports.RSAPublicKey = RSAPublicKey
+
+var PublicKey = asn1.define('SubjectPublicKeyInfo', function () {
+ this.seq().obj(
+ this.key('algorithm').use(AlgorithmIdentifier),
+ this.key('subjectPublicKey').bitstr()
+ )
+})
+exports.PublicKey = PublicKey
+
+var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () {
+ this.seq().obj(
+ this.key('algorithm').objid(),
+ this.key('none').null_().optional(),
+ this.key('curve').objid().optional(),
+ this.key('params').seq().obj(
+ this.key('p').int(),
+ this.key('q').int(),
+ this.key('g').int()
+ ).optional()
+ )
+})
+
+var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () {
+ this.seq().obj(
+ this.key('version').int(),
+ this.key('algorithm').use(AlgorithmIdentifier),
+ this.key('subjectPrivateKey').octstr()
+ )
+})
+exports.PrivateKey = PrivateKeyInfo
+var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () {
+ this.seq().obj(
+ this.key('algorithm').seq().obj(
+ this.key('id').objid(),
+ this.key('decrypt').seq().obj(
+ this.key('kde').seq().obj(
+ this.key('id').objid(),
+ this.key('kdeparams').seq().obj(
+ this.key('salt').octstr(),
+ this.key('iters').int()
+ )
+ ),
+ this.key('cipher').seq().obj(
+ this.key('algo').objid(),
+ this.key('iv').octstr()
+ )
+ )
+ ),
+ this.key('subjectPrivateKey').octstr()
+ )
+})
+
+exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo
+
+var DSAPrivateKey = asn1.define('DSAPrivateKey', function () {
+ this.seq().obj(
+ this.key('version').int(),
+ this.key('p').int(),
+ this.key('q').int(),
+ this.key('g').int(),
+ this.key('pub_key').int(),
+ this.key('priv_key').int()
+ )
+})
+exports.DSAPrivateKey = DSAPrivateKey
+
+exports.DSAparam = asn1.define('DSAparam', function () {
+ this.int()
+})
+
+var ECPrivateKey = asn1.define('ECPrivateKey', function () {
+ this.seq().obj(
+ this.key('version').int(),
+ this.key('privateKey').octstr(),
+ this.key('parameters').optional().explicit(0).use(ECParameters),
+ this.key('publicKey').optional().explicit(1).bitstr()
+ )
+})
+exports.ECPrivateKey = ECPrivateKey
+
+var ECParameters = asn1.define('ECParameters', function () {
+ this.choice({
+ namedCurve: this.objid()
+ })
+})
+
+exports.signature = asn1.define('signature', function () {
+ this.seq().obj(
+ this.key('r').int(),
+ this.key('s').int()
+ )
+})
diff --git a/node_modules/parse-asn1/certificate.js b/node_modules/parse-asn1/certificate.js
new file mode 100644
index 0000000..0ee17a2
--- /dev/null
+++ b/node_modules/parse-asn1/certificate.js
@@ -0,0 +1,89 @@
+// from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js
+// thanks to @Rantanen
+
+'use strict'
+
+var asn = require('asn1.js')
+
+var Time = asn.define('Time', function () {
+ this.choice({
+ utcTime: this.utctime(),
+ generalTime: this.gentime()
+ })
+})
+
+var AttributeTypeValue = asn.define('AttributeTypeValue', function () {
+ this.seq().obj(
+ this.key('type').objid(),
+ this.key('value').any()
+ )
+})
+
+var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () {
+ this.seq().obj(
+ this.key('algorithm').objid(),
+ this.key('parameters').optional(),
+ this.key('curve').objid().optional()
+ )
+})
+
+var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () {
+ this.seq().obj(
+ this.key('algorithm').use(AlgorithmIdentifier),
+ this.key('subjectPublicKey').bitstr()
+ )
+})
+
+var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () {
+ this.setof(AttributeTypeValue)
+})
+
+var RDNSequence = asn.define('RDNSequence', function () {
+ this.seqof(RelativeDistinguishedName)
+})
+
+var Name = asn.define('Name', function () {
+ this.choice({
+ rdnSequence: this.use(RDNSequence)
+ })
+})
+
+var Validity = asn.define('Validity', function () {
+ this.seq().obj(
+ this.key('notBefore').use(Time),
+ this.key('notAfter').use(Time)
+ )
+})
+
+var Extension = asn.define('Extension', function () {
+ this.seq().obj(
+ this.key('extnID').objid(),
+ this.key('critical').bool().def(false),
+ this.key('extnValue').octstr()
+ )
+})
+
+var TBSCertificate = asn.define('TBSCertificate', function () {
+ this.seq().obj(
+ this.key('version').explicit(0).int().optional(),
+ this.key('serialNumber').int(),
+ this.key('signature').use(AlgorithmIdentifier),
+ this.key('issuer').use(Name),
+ this.key('validity').use(Validity),
+ this.key('subject').use(Name),
+ this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo),
+ this.key('issuerUniqueID').implicit(1).bitstr().optional(),
+ this.key('subjectUniqueID').implicit(2).bitstr().optional(),
+ this.key('extensions').explicit(3).seqof(Extension).optional()
+ )
+})
+
+var X509Certificate = asn.define('X509Certificate', function () {
+ this.seq().obj(
+ this.key('tbsCertificate').use(TBSCertificate),
+ this.key('signatureAlgorithm').use(AlgorithmIdentifier),
+ this.key('signatureValue').bitstr()
+ )
+})
+
+module.exports = X509Certificate
diff --git a/node_modules/parse-asn1/fixProc.js b/node_modules/parse-asn1/fixProc.js
new file mode 100644
index 0000000..4684971
--- /dev/null
+++ b/node_modules/parse-asn1/fixProc.js
@@ -0,0 +1,31 @@
+// adapted from https://github.com/apatil/pemstrip
+var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m
+var startRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m
+var fullRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m
+var evp = require('evp_bytestokey')
+var ciphers = require('browserify-aes')
+var Buffer = require('safe-buffer').Buffer
+module.exports = function (okey, password) {
+ var key = okey.toString()
+ var match = key.match(findProc)
+ var decrypted
+ if (!match) {
+ var match2 = key.match(fullRegex)
+ decrypted = Buffer.from(match2[2].replace(/[\r\n]/g, ''), 'base64')
+ } else {
+ var suite = 'aes' + match[1]
+ var iv = Buffer.from(match[2], 'hex')
+ var cipherText = Buffer.from(match[3].replace(/[\r\n]/g, ''), 'base64')
+ var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key
+ var out = []
+ var cipher = ciphers.createDecipheriv(suite, cipherKey, iv)
+ out.push(cipher.update(cipherText))
+ out.push(cipher.final())
+ decrypted = Buffer.concat(out)
+ }
+ var tag = key.match(startRegex)[1]
+ return {
+ tag: tag,
+ data: decrypted
+ }
+}
diff --git a/node_modules/parse-asn1/index.js b/node_modules/parse-asn1/index.js
new file mode 100644
index 0000000..54da47d
--- /dev/null
+++ b/node_modules/parse-asn1/index.js
@@ -0,0 +1,107 @@
+var asn1 = require('./asn1')
+var aesid = require('./aesid.json')
+var fixProc = require('./fixProc')
+var ciphers = require('browserify-aes')
+var compat = require('pbkdf2')
+var Buffer = require('safe-buffer').Buffer
+module.exports = parseKeys
+
+function parseKeys (buffer) {
+ var password
+ if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) {
+ password = buffer.passphrase
+ buffer = buffer.key
+ }
+ if (typeof buffer === 'string') {
+ buffer = Buffer.from(buffer)
+ }
+
+ var stripped = fixProc(buffer, password)
+
+ var type = stripped.tag
+ var data = stripped.data
+ var subtype, ndata
+ switch (type) {
+ case 'CERTIFICATE':
+ ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo
+ // falls through
+ case 'PUBLIC KEY':
+ if (!ndata) {
+ ndata = asn1.PublicKey.decode(data, 'der')
+ }
+ subtype = ndata.algorithm.algorithm.join('.')
+ switch (subtype) {
+ case '1.2.840.113549.1.1.1':
+ return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der')
+ case '1.2.840.10045.2.1':
+ ndata.subjectPrivateKey = ndata.subjectPublicKey
+ return {
+ type: 'ec',
+ data: ndata
+ }
+ case '1.2.840.10040.4.1':
+ ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der')
+ return {
+ type: 'dsa',
+ data: ndata.algorithm.params
+ }
+ default: throw new Error('unknown key id ' + subtype)
+ }
+ // throw new Error('unknown key type ' + type)
+ case 'ENCRYPTED PRIVATE KEY':
+ data = asn1.EncryptedPrivateKey.decode(data, 'der')
+ data = decrypt(data, password)
+ // falls through
+ case 'PRIVATE KEY':
+ ndata = asn1.PrivateKey.decode(data, 'der')
+ subtype = ndata.algorithm.algorithm.join('.')
+ switch (subtype) {
+ case '1.2.840.113549.1.1.1':
+ return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der')
+ case '1.2.840.10045.2.1':
+ return {
+ curve: ndata.algorithm.curve,
+ privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey
+ }
+ case '1.2.840.10040.4.1':
+ ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der')
+ return {
+ type: 'dsa',
+ params: ndata.algorithm.params
+ }
+ default: throw new Error('unknown key id ' + subtype)
+ }
+ // throw new Error('unknown key type ' + type)
+ case 'RSA PUBLIC KEY':
+ return asn1.RSAPublicKey.decode(data, 'der')
+ case 'RSA PRIVATE KEY':
+ return asn1.RSAPrivateKey.decode(data, 'der')
+ case 'DSA PRIVATE KEY':
+ return {
+ type: 'dsa',
+ params: asn1.DSAPrivateKey.decode(data, 'der')
+ }
+ case 'EC PRIVATE KEY':
+ data = asn1.ECPrivateKey.decode(data, 'der')
+ return {
+ curve: data.parameters.value,
+ privateKey: data.privateKey
+ }
+ default: throw new Error('unknown key type ' + type)
+ }
+}
+parseKeys.signature = asn1.signature
+function decrypt (data, password) {
+ var salt = data.algorithm.decrypt.kde.kdeparams.salt
+ var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10)
+ var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')]
+ var iv = data.algorithm.decrypt.cipher.iv
+ var cipherText = data.subjectPrivateKey
+ var keylen = parseInt(algo.split('-')[1], 10) / 8
+ var key = compat.pbkdf2Sync(password, salt, iters, keylen, 'sha1')
+ var cipher = ciphers.createDecipheriv(algo, key, iv)
+ var out = []
+ out.push(cipher.update(cipherText))
+ out.push(cipher.final())
+ return Buffer.concat(out)
+}
diff --git a/node_modules/parse-asn1/package.json b/node_modules/parse-asn1/package.json
new file mode 100644
index 0000000..dd667cf
--- /dev/null
+++ b/node_modules/parse-asn1/package.json
@@ -0,0 +1,65 @@
+{
+ "_from": "parse-asn1@^5.1.5",
+ "_id": "parse-asn1@5.1.6",
+ "_inBundle": false,
+ "_integrity": "sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==",
+ "_location": "/parse-asn1",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "parse-asn1@^5.1.5",
+ "name": "parse-asn1",
+ "escapedName": "parse-asn1",
+ "rawSpec": "^5.1.5",
+ "saveSpec": null,
+ "fetchSpec": "^5.1.5"
+ },
+ "_requiredBy": [
+ "/browserify-sign",
+ "/public-encrypt"
+ ],
+ "_resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz",
+ "_shasum": "385080a3ec13cb62a62d39409cb3e88844cdaed4",
+ "_spec": "parse-asn1@^5.1.5",
+ "_where": "/home/pruss/Dev/3-minute-website/node_modules/browserify-sign",
+ "author": "",
+ "bugs": {
+ "url": "https://github.com/crypto-browserify/parse-asn1/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {
+ "asn1.js": "^5.2.0",
+ "browserify-aes": "^1.0.0",
+ "evp_bytestokey": "^1.0.0",
+ "pbkdf2": "^3.0.3",
+ "safe-buffer": "^5.1.1"
+ },
+ "deprecated": false,
+ "description": "utility library for parsing asn1 files for use with browserify-sign.",
+ "devDependencies": {
+ "standard": "^14.3.4",
+ "tape": "^5.0.1"
+ },
+ "files": [
+ "asn1.js",
+ "aesid.json",
+ "certificate.js",
+ "fixProc.js",
+ "index.js"
+ ],
+ "homepage": "https://github.com/crypto-browserify/parse-asn1#readme",
+ "license": "ISC",
+ "main": "index.js",
+ "name": "parse-asn1",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/crypto-browserify/parse-asn1.git"
+ },
+ "scripts": {
+ "standard": "standard",
+ "test": "npm run standard && npm run unit",
+ "unit": "node ./test"
+ },
+ "version": "5.1.6"
+}