first commit

This commit is contained in:
Stefan Hacker
2026-04-03 09:38:48 +02:00
commit 37ad745546
47450 changed files with 3120798 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+8
View File
@@ -0,0 +1,8 @@
# `@peculiar/asn1-rsa`
[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/PeculiarVentures/asn1-schema/master/packages/rsa/LICENSE.md)
[![npm version](https://badge.fury.io/js/%40peculiar%2Fasn1-rsa.svg)](https://badge.fury.io/js/%40peculiar%2Fasn1-rsa)
[![NPM](https://nodei.co/npm/@peculiar/asn1-rsa.png)](https://nodei.co/npm/@peculiar/asn1-rsa/)
[RFC 8017](https://tools.ietf.org/html/rfc8017) RSA Cryptography Specifications Version 2.2
+39
View File
@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sha512_256WithRSAEncryption = exports.sha512_224WithRSAEncryption = exports.sha512WithRSAEncryption = exports.sha384WithRSAEncryption = exports.sha256WithRSAEncryption = exports.sha224WithRSAEncryption = exports.sha1WithRSAEncryption = exports.md5WithRSAEncryption = exports.md2WithRSAEncryption = exports.rsaEncryption = exports.pSpecifiedEmpty = exports.mgf1SHA1 = exports.sha512_256 = exports.sha512_224 = exports.sha512 = exports.sha384 = exports.sha256 = exports.sha224 = exports.sha1 = exports.md4 = exports.md2 = void 0;
const asn1_schema_1 = require("@peculiar/asn1-schema");
const asn1_x509_1 = require("@peculiar/asn1-x509");
const oid = require("./object_identifiers");
function create(algorithm) {
return new asn1_x509_1.AlgorithmIdentifier({ algorithm, parameters: null });
}
exports.md2 = create(oid.id_md2);
exports.md4 = create(oid.id_md5);
exports.sha1 = create(oid.id_sha1);
exports.sha224 = create(oid.id_sha224);
exports.sha256 = create(oid.id_sha256);
exports.sha384 = create(oid.id_sha384);
exports.sha512 = create(oid.id_sha512);
exports.sha512_224 = create(oid.id_sha512_224);
exports.sha512_256 = create(oid.id_sha512_256);
exports.mgf1SHA1 = new asn1_x509_1.AlgorithmIdentifier({
algorithm: oid.id_mgf1,
parameters: asn1_schema_1.AsnConvert.serialize(exports.sha1),
});
exports.pSpecifiedEmpty = new asn1_x509_1.AlgorithmIdentifier({
algorithm: oid.id_pSpecified,
parameters: asn1_schema_1.AsnConvert.serialize(asn1_schema_1.AsnOctetStringConverter.toASN(new Uint8Array([
0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18,
0x90, 0xaf, 0xd8, 0x07, 0x09,
]).buffer)),
});
exports.rsaEncryption = create(oid.id_rsaEncryption);
exports.md2WithRSAEncryption = create(oid.id_md2WithRSAEncryption);
exports.md5WithRSAEncryption = create(oid.id_md5WithRSAEncryption);
exports.sha1WithRSAEncryption = create(oid.id_sha1WithRSAEncryption);
exports.sha224WithRSAEncryption = create(oid.id_sha512_224WithRSAEncryption);
exports.sha256WithRSAEncryption = create(oid.id_sha512_256WithRSAEncryption);
exports.sha384WithRSAEncryption = create(oid.id_sha384WithRSAEncryption);
exports.sha512WithRSAEncryption = create(oid.id_sha512WithRSAEncryption);
exports.sha512_224WithRSAEncryption = create(oid.id_sha512_224WithRSAEncryption);
exports.sha512_256WithRSAEncryption = create(oid.id_sha512_256WithRSAEncryption);
+9
View File
@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./parameters"), exports);
tslib_1.__exportStar(require("./algorithms"), exports);
tslib_1.__exportStar(require("./object_identifiers"), exports);
tslib_1.__exportStar(require("./other_prime_info"), exports);
tslib_1.__exportStar(require("./rsa_private_key"), exports);
tslib_1.__exportStar(require("./rsa_public_key"), exports);
+28
View File
@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.id_mgf1 = exports.id_md5 = exports.id_md2 = exports.id_sha512_256 = exports.id_sha512_224 = exports.id_sha512 = exports.id_sha384 = exports.id_sha256 = exports.id_sha224 = exports.id_sha1 = exports.id_sha512_256WithRSAEncryption = exports.id_sha512_224WithRSAEncryption = exports.id_sha512WithRSAEncryption = exports.id_sha384WithRSAEncryption = exports.id_sha256WithRSAEncryption = exports.id_ssha224WithRSAEncryption = exports.id_sha224WithRSAEncryption = exports.id_sha1WithRSAEncryption = exports.id_md5WithRSAEncryption = exports.id_md2WithRSAEncryption = exports.id_RSASSA_PSS = exports.id_pSpecified = exports.id_RSAES_OAEP = exports.id_rsaEncryption = exports.id_pkcs_1 = void 0;
exports.id_pkcs_1 = "1.2.840.113549.1.1";
exports.id_rsaEncryption = `${exports.id_pkcs_1}.1`;
exports.id_RSAES_OAEP = `${exports.id_pkcs_1}.7`;
exports.id_pSpecified = `${exports.id_pkcs_1}.9`;
exports.id_RSASSA_PSS = `${exports.id_pkcs_1}.10`;
exports.id_md2WithRSAEncryption = `${exports.id_pkcs_1}.2`;
exports.id_md5WithRSAEncryption = `${exports.id_pkcs_1}.4`;
exports.id_sha1WithRSAEncryption = `${exports.id_pkcs_1}.5`;
exports.id_sha224WithRSAEncryption = `${exports.id_pkcs_1}.14`;
exports.id_ssha224WithRSAEncryption = exports.id_sha224WithRSAEncryption;
exports.id_sha256WithRSAEncryption = `${exports.id_pkcs_1}.11`;
exports.id_sha384WithRSAEncryption = `${exports.id_pkcs_1}.12`;
exports.id_sha512WithRSAEncryption = `${exports.id_pkcs_1}.13`;
exports.id_sha512_224WithRSAEncryption = `${exports.id_pkcs_1}.15`;
exports.id_sha512_256WithRSAEncryption = `${exports.id_pkcs_1}.16`;
exports.id_sha1 = "1.3.14.3.2.26";
exports.id_sha224 = "2.16.840.1.101.3.4.2.4";
exports.id_sha256 = "2.16.840.1.101.3.4.2.1";
exports.id_sha384 = "2.16.840.1.101.3.4.2.2";
exports.id_sha512 = "2.16.840.1.101.3.4.2.3";
exports.id_sha512_224 = "2.16.840.1.101.3.4.2.5";
exports.id_sha512_256 = "2.16.840.1.101.3.4.2.6";
exports.id_md2 = "1.2.840.113549.2.2";
exports.id_md5 = "1.2.840.113549.2.5";
exports.id_mgf1 = `${exports.id_pkcs_1}.8`;
+34
View File
@@ -0,0 +1,34 @@
"use strict";
var OtherPrimeInfos_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OtherPrimeInfos = exports.OtherPrimeInfo = void 0;
const tslib_1 = require("tslib");
const asn1_schema_1 = require("@peculiar/asn1-schema");
class OtherPrimeInfo {
constructor(params = {}) {
this.prime = new ArrayBuffer(0);
this.exponent = new ArrayBuffer(0);
this.coefficient = new ArrayBuffer(0);
Object.assign(this, params);
}
}
exports.OtherPrimeInfo = OtherPrimeInfo;
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter })
], OtherPrimeInfo.prototype, "prime", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter })
], OtherPrimeInfo.prototype, "exponent", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter })
], OtherPrimeInfo.prototype, "coefficient", void 0);
let OtherPrimeInfos = OtherPrimeInfos_1 = class OtherPrimeInfos extends asn1_schema_1.AsnArray {
constructor(items) {
super(items);
Object.setPrototypeOf(this, OtherPrimeInfos_1.prototype);
}
};
exports.OtherPrimeInfos = OtherPrimeInfos;
exports.OtherPrimeInfos = OtherPrimeInfos = OtherPrimeInfos_1 = tslib_1.__decorate([
(0, asn1_schema_1.AsnType)({ type: asn1_schema_1.AsnTypeTypes.Sequence, itemType: OtherPrimeInfo })
], OtherPrimeInfos);
+6
View File
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./rsaes_oaep"), exports);
tslib_1.__exportStar(require("./rsassa_pss"), exports);
tslib_1.__exportStar(require("./rsassa_pkcs1_v1_5"), exports);
+33
View File
@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RSAES_OAEP = exports.RsaEsOaepParams = void 0;
const tslib_1 = require("tslib");
const asn1_schema_1 = require("@peculiar/asn1-schema");
const asn1_x509_1 = require("@peculiar/asn1-x509");
const object_identifiers_1 = require("../object_identifiers");
const algorithms_1 = require("../algorithms");
class RsaEsOaepParams {
constructor(params = {}) {
this.hashAlgorithm = new asn1_x509_1.AlgorithmIdentifier(algorithms_1.sha1);
this.maskGenAlgorithm = new asn1_x509_1.AlgorithmIdentifier({
algorithm: object_identifiers_1.id_mgf1,
parameters: asn1_schema_1.AsnConvert.serialize(algorithms_1.sha1),
});
this.pSourceAlgorithm = new asn1_x509_1.AlgorithmIdentifier(algorithms_1.pSpecifiedEmpty);
Object.assign(this, params);
}
}
exports.RsaEsOaepParams = RsaEsOaepParams;
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.AlgorithmIdentifier, context: 0, defaultValue: algorithms_1.sha1 })
], RsaEsOaepParams.prototype, "hashAlgorithm", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.AlgorithmIdentifier, context: 1, defaultValue: algorithms_1.mgf1SHA1 })
], RsaEsOaepParams.prototype, "maskGenAlgorithm", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.AlgorithmIdentifier, context: 2, defaultValue: algorithms_1.pSpecifiedEmpty })
], RsaEsOaepParams.prototype, "pSourceAlgorithm", void 0);
exports.RSAES_OAEP = new asn1_x509_1.AlgorithmIdentifier({
algorithm: object_identifiers_1.id_RSAES_OAEP,
parameters: asn1_schema_1.AsnConvert.serialize(new RsaEsOaepParams()),
});
@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DigestInfo = void 0;
const tslib_1 = require("tslib");
const asn1_x509_1 = require("@peculiar/asn1-x509");
const asn1_schema_1 = require("@peculiar/asn1-schema");
class DigestInfo {
constructor(params = {}) {
this.digestAlgorithm = new asn1_x509_1.AlgorithmIdentifier();
this.digest = new asn1_schema_1.OctetString();
Object.assign(this, params);
}
}
exports.DigestInfo = DigestInfo;
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.AlgorithmIdentifier })
], DigestInfo.prototype, "digestAlgorithm", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.OctetString })
], DigestInfo.prototype, "digest", void 0);
+37
View File
@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RSASSA_PSS = exports.RsaSaPssParams = void 0;
const tslib_1 = require("tslib");
const asn1_schema_1 = require("@peculiar/asn1-schema");
const asn1_x509_1 = require("@peculiar/asn1-x509");
const object_identifiers_1 = require("../object_identifiers");
const algorithms_1 = require("../algorithms");
class RsaSaPssParams {
constructor(params = {}) {
this.hashAlgorithm = new asn1_x509_1.AlgorithmIdentifier(algorithms_1.sha1);
this.maskGenAlgorithm = new asn1_x509_1.AlgorithmIdentifier({
algorithm: object_identifiers_1.id_mgf1,
parameters: asn1_schema_1.AsnConvert.serialize(algorithms_1.sha1),
});
this.saltLength = 20;
this.trailerField = 1;
Object.assign(this, params);
}
}
exports.RsaSaPssParams = RsaSaPssParams;
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.AlgorithmIdentifier, context: 0, defaultValue: algorithms_1.sha1 })
], RsaSaPssParams.prototype, "hashAlgorithm", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_x509_1.AlgorithmIdentifier, context: 1, defaultValue: algorithms_1.mgf1SHA1 })
], RsaSaPssParams.prototype, "maskGenAlgorithm", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer, context: 2, defaultValue: 20 })
], RsaSaPssParams.prototype, "saltLength", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer, context: 3, defaultValue: 1 })
], RsaSaPssParams.prototype, "trailerField", void 0);
exports.RSASSA_PSS = new asn1_x509_1.AlgorithmIdentifier({
algorithm: object_identifiers_1.id_RSASSA_PSS,
parameters: asn1_schema_1.AsnConvert.serialize(new RsaSaPssParams()),
});
+51
View File
@@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RSAPrivateKey = void 0;
const tslib_1 = require("tslib");
const asn1_schema_1 = require("@peculiar/asn1-schema");
const other_prime_info_1 = require("./other_prime_info");
class RSAPrivateKey {
constructor(params = {}) {
this.version = 0;
this.modulus = new ArrayBuffer(0);
this.publicExponent = new ArrayBuffer(0);
this.privateExponent = new ArrayBuffer(0);
this.prime1 = new ArrayBuffer(0);
this.prime2 = new ArrayBuffer(0);
this.exponent1 = new ArrayBuffer(0);
this.exponent2 = new ArrayBuffer(0);
this.coefficient = new ArrayBuffer(0);
Object.assign(this, params);
}
}
exports.RSAPrivateKey = RSAPrivateKey;
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer })
], RSAPrivateKey.prototype, "version", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter })
], RSAPrivateKey.prototype, "modulus", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter })
], RSAPrivateKey.prototype, "publicExponent", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter })
], RSAPrivateKey.prototype, "privateExponent", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter })
], RSAPrivateKey.prototype, "prime1", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter })
], RSAPrivateKey.prototype, "prime2", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter })
], RSAPrivateKey.prototype, "exponent1", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter })
], RSAPrivateKey.prototype, "exponent2", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter })
], RSAPrivateKey.prototype, "coefficient", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: other_prime_info_1.OtherPrimeInfos, optional: true })
], RSAPrivateKey.prototype, "otherPrimeInfos", void 0);
+19
View File
@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RSAPublicKey = void 0;
const tslib_1 = require("tslib");
const asn1_schema_1 = require("@peculiar/asn1-schema");
class RSAPublicKey {
constructor(params = {}) {
this.modulus = new ArrayBuffer(0);
this.publicExponent = new ArrayBuffer(0);
Object.assign(this, params);
}
}
exports.RSAPublicKey = RSAPublicKey;
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter })
], RSAPublicKey.prototype, "modulus", void 0);
tslib_1.__decorate([
(0, asn1_schema_1.AsnProp)({ type: asn1_schema_1.AsnPropTypes.Integer, converter: asn1_schema_1.AsnIntegerArrayBufferConverter })
], RSAPublicKey.prototype, "publicExponent", void 0);
+36
View File
@@ -0,0 +1,36 @@
import { AsnConvert, AsnOctetStringConverter } from "@peculiar/asn1-schema";
import { AlgorithmIdentifier } from "@peculiar/asn1-x509";
import * as oid from "./object_identifiers";
function create(algorithm) {
return new AlgorithmIdentifier({ algorithm, parameters: null });
}
export const md2 = create(oid.id_md2);
export const md4 = create(oid.id_md5);
export const sha1 = create(oid.id_sha1);
export const sha224 = create(oid.id_sha224);
export const sha256 = create(oid.id_sha256);
export const sha384 = create(oid.id_sha384);
export const sha512 = create(oid.id_sha512);
export const sha512_224 = create(oid.id_sha512_224);
export const sha512_256 = create(oid.id_sha512_256);
export const mgf1SHA1 = new AlgorithmIdentifier({
algorithm: oid.id_mgf1,
parameters: AsnConvert.serialize(sha1),
});
export const pSpecifiedEmpty = new AlgorithmIdentifier({
algorithm: oid.id_pSpecified,
parameters: AsnConvert.serialize(AsnOctetStringConverter.toASN(new Uint8Array([
0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18,
0x90, 0xaf, 0xd8, 0x07, 0x09,
]).buffer)),
});
export const rsaEncryption = create(oid.id_rsaEncryption);
export const md2WithRSAEncryption = create(oid.id_md2WithRSAEncryption);
export const md5WithRSAEncryption = create(oid.id_md5WithRSAEncryption);
export const sha1WithRSAEncryption = create(oid.id_sha1WithRSAEncryption);
export const sha224WithRSAEncryption = create(oid.id_sha512_224WithRSAEncryption);
export const sha256WithRSAEncryption = create(oid.id_sha512_256WithRSAEncryption);
export const sha384WithRSAEncryption = create(oid.id_sha384WithRSAEncryption);
export const sha512WithRSAEncryption = create(oid.id_sha512WithRSAEncryption);
export const sha512_224WithRSAEncryption = create(oid.id_sha512_224WithRSAEncryption);
export const sha512_256WithRSAEncryption = create(oid.id_sha512_256WithRSAEncryption);
+6
View File
@@ -0,0 +1,6 @@
export * from "./parameters";
export * from "./algorithms";
export * from "./object_identifiers";
export * from "./other_prime_info";
export * from "./rsa_private_key";
export * from "./rsa_public_key";
+25
View File
@@ -0,0 +1,25 @@
export const id_pkcs_1 = "1.2.840.113549.1.1";
export const id_rsaEncryption = `${id_pkcs_1}.1`;
export const id_RSAES_OAEP = `${id_pkcs_1}.7`;
export const id_pSpecified = `${id_pkcs_1}.9`;
export const id_RSASSA_PSS = `${id_pkcs_1}.10`;
export const id_md2WithRSAEncryption = `${id_pkcs_1}.2`;
export const id_md5WithRSAEncryption = `${id_pkcs_1}.4`;
export const id_sha1WithRSAEncryption = `${id_pkcs_1}.5`;
export const id_sha224WithRSAEncryption = `${id_pkcs_1}.14`;
export const id_ssha224WithRSAEncryption = id_sha224WithRSAEncryption;
export const id_sha256WithRSAEncryption = `${id_pkcs_1}.11`;
export const id_sha384WithRSAEncryption = `${id_pkcs_1}.12`;
export const id_sha512WithRSAEncryption = `${id_pkcs_1}.13`;
export const id_sha512_224WithRSAEncryption = `${id_pkcs_1}.15`;
export const id_sha512_256WithRSAEncryption = `${id_pkcs_1}.16`;
export const id_sha1 = "1.3.14.3.2.26";
export const id_sha224 = "2.16.840.1.101.3.4.2.4";
export const id_sha256 = "2.16.840.1.101.3.4.2.1";
export const id_sha384 = "2.16.840.1.101.3.4.2.2";
export const id_sha512 = "2.16.840.1.101.3.4.2.3";
export const id_sha512_224 = "2.16.840.1.101.3.4.2.5";
export const id_sha512_256 = "2.16.840.1.101.3.4.2.6";
export const id_md2 = "1.2.840.113549.2.2";
export const id_md5 = "1.2.840.113549.2.5";
export const id_mgf1 = `${id_pkcs_1}.8`;
+30
View File
@@ -0,0 +1,30 @@
var OtherPrimeInfos_1;
import { __decorate } from "tslib";
import { AsnProp, AsnPropTypes, AsnIntegerArrayBufferConverter, AsnArray, AsnType, AsnTypeTypes, } from "@peculiar/asn1-schema";
export class OtherPrimeInfo {
constructor(params = {}) {
this.prime = new ArrayBuffer(0);
this.exponent = new ArrayBuffer(0);
this.coefficient = new ArrayBuffer(0);
Object.assign(this, params);
}
}
__decorate([
AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
], OtherPrimeInfo.prototype, "prime", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
], OtherPrimeInfo.prototype, "exponent", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
], OtherPrimeInfo.prototype, "coefficient", void 0);
let OtherPrimeInfos = OtherPrimeInfos_1 = class OtherPrimeInfos extends AsnArray {
constructor(items) {
super(items);
Object.setPrototypeOf(this, OtherPrimeInfos_1.prototype);
}
};
OtherPrimeInfos = OtherPrimeInfos_1 = __decorate([
AsnType({ type: AsnTypeTypes.Sequence, itemType: OtherPrimeInfo })
], OtherPrimeInfos);
export { OtherPrimeInfos };
+3
View File
@@ -0,0 +1,3 @@
export * from "./rsaes_oaep";
export * from "./rsassa_pss";
export * from "./rsassa_pkcs1_v1_5";
+29
View File
@@ -0,0 +1,29 @@
import { __decorate } from "tslib";
import { AsnProp, AsnConvert } from "@peculiar/asn1-schema";
import { AlgorithmIdentifier } from "@peculiar/asn1-x509";
import { id_mgf1, id_RSAES_OAEP } from "../object_identifiers";
import { sha1, mgf1SHA1, pSpecifiedEmpty } from "../algorithms";
export class RsaEsOaepParams {
constructor(params = {}) {
this.hashAlgorithm = new AlgorithmIdentifier(sha1);
this.maskGenAlgorithm = new AlgorithmIdentifier({
algorithm: id_mgf1,
parameters: AsnConvert.serialize(sha1),
});
this.pSourceAlgorithm = new AlgorithmIdentifier(pSpecifiedEmpty);
Object.assign(this, params);
}
}
__decorate([
AsnProp({ type: AlgorithmIdentifier, context: 0, defaultValue: sha1 })
], RsaEsOaepParams.prototype, "hashAlgorithm", void 0);
__decorate([
AsnProp({ type: AlgorithmIdentifier, context: 1, defaultValue: mgf1SHA1 })
], RsaEsOaepParams.prototype, "maskGenAlgorithm", void 0);
__decorate([
AsnProp({ type: AlgorithmIdentifier, context: 2, defaultValue: pSpecifiedEmpty })
], RsaEsOaepParams.prototype, "pSourceAlgorithm", void 0);
export const RSAES_OAEP = new AlgorithmIdentifier({
algorithm: id_RSAES_OAEP,
parameters: AsnConvert.serialize(new RsaEsOaepParams()),
});
@@ -0,0 +1,16 @@
import { __decorate } from "tslib";
import { AlgorithmIdentifier } from "@peculiar/asn1-x509";
import { AsnProp, OctetString } from "@peculiar/asn1-schema";
export class DigestInfo {
constructor(params = {}) {
this.digestAlgorithm = new AlgorithmIdentifier();
this.digest = new OctetString();
Object.assign(this, params);
}
}
__decorate([
AsnProp({ type: AlgorithmIdentifier })
], DigestInfo.prototype, "digestAlgorithm", void 0);
__decorate([
AsnProp({ type: OctetString })
], DigestInfo.prototype, "digest", void 0);
+33
View File
@@ -0,0 +1,33 @@
import { __decorate } from "tslib";
import { AsnProp, AsnConvert, AsnPropTypes } from "@peculiar/asn1-schema";
import { AlgorithmIdentifier } from "@peculiar/asn1-x509";
import { id_mgf1, id_RSASSA_PSS } from "../object_identifiers";
import { sha1, mgf1SHA1 } from "../algorithms";
export class RsaSaPssParams {
constructor(params = {}) {
this.hashAlgorithm = new AlgorithmIdentifier(sha1);
this.maskGenAlgorithm = new AlgorithmIdentifier({
algorithm: id_mgf1,
parameters: AsnConvert.serialize(sha1),
});
this.saltLength = 20;
this.trailerField = 1;
Object.assign(this, params);
}
}
__decorate([
AsnProp({ type: AlgorithmIdentifier, context: 0, defaultValue: sha1 })
], RsaSaPssParams.prototype, "hashAlgorithm", void 0);
__decorate([
AsnProp({ type: AlgorithmIdentifier, context: 1, defaultValue: mgf1SHA1 })
], RsaSaPssParams.prototype, "maskGenAlgorithm", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer, context: 2, defaultValue: 20 })
], RsaSaPssParams.prototype, "saltLength", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer, context: 3, defaultValue: 1 })
], RsaSaPssParams.prototype, "trailerField", void 0);
export const RSASSA_PSS = new AlgorithmIdentifier({
algorithm: id_RSASSA_PSS,
parameters: AsnConvert.serialize(new RsaSaPssParams()),
});
+47
View File
@@ -0,0 +1,47 @@
import { __decorate } from "tslib";
import { AsnProp, AsnPropTypes, AsnIntegerArrayBufferConverter } from "@peculiar/asn1-schema";
import { OtherPrimeInfos } from "./other_prime_info";
export class RSAPrivateKey {
constructor(params = {}) {
this.version = 0;
this.modulus = new ArrayBuffer(0);
this.publicExponent = new ArrayBuffer(0);
this.privateExponent = new ArrayBuffer(0);
this.prime1 = new ArrayBuffer(0);
this.prime2 = new ArrayBuffer(0);
this.exponent1 = new ArrayBuffer(0);
this.exponent2 = new ArrayBuffer(0);
this.coefficient = new ArrayBuffer(0);
Object.assign(this, params);
}
}
__decorate([
AsnProp({ type: AsnPropTypes.Integer })
], RSAPrivateKey.prototype, "version", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
], RSAPrivateKey.prototype, "modulus", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
], RSAPrivateKey.prototype, "publicExponent", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
], RSAPrivateKey.prototype, "privateExponent", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
], RSAPrivateKey.prototype, "prime1", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
], RSAPrivateKey.prototype, "prime2", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
], RSAPrivateKey.prototype, "exponent1", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
], RSAPrivateKey.prototype, "exponent2", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
], RSAPrivateKey.prototype, "coefficient", void 0);
__decorate([
AsnProp({ type: OtherPrimeInfos, optional: true })
], RSAPrivateKey.prototype, "otherPrimeInfos", void 0);
+15
View File
@@ -0,0 +1,15 @@
import { __decorate } from "tslib";
import { AsnProp, AsnPropTypes, AsnIntegerArrayBufferConverter } from "@peculiar/asn1-schema";
export class RSAPublicKey {
constructor(params = {}) {
this.modulus = new ArrayBuffer(0);
this.publicExponent = new ArrayBuffer(0);
Object.assign(this, params);
}
}
__decorate([
AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
], RSAPublicKey.prototype, "modulus", void 0);
__decorate([
AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter })
], RSAPublicKey.prototype, "publicExponent", void 0);
+22
View File
@@ -0,0 +1,22 @@
import { AlgorithmIdentifier } from "@peculiar/asn1-x509";
export declare const md2: AlgorithmIdentifier;
export declare const md4: AlgorithmIdentifier;
export declare const sha1: AlgorithmIdentifier;
export declare const sha224: AlgorithmIdentifier;
export declare const sha256: AlgorithmIdentifier;
export declare const sha384: AlgorithmIdentifier;
export declare const sha512: AlgorithmIdentifier;
export declare const sha512_224: AlgorithmIdentifier;
export declare const sha512_256: AlgorithmIdentifier;
export declare const mgf1SHA1: AlgorithmIdentifier;
export declare const pSpecifiedEmpty: AlgorithmIdentifier;
export declare const rsaEncryption: AlgorithmIdentifier;
export declare const md2WithRSAEncryption: AlgorithmIdentifier;
export declare const md5WithRSAEncryption: AlgorithmIdentifier;
export declare const sha1WithRSAEncryption: AlgorithmIdentifier;
export declare const sha224WithRSAEncryption: AlgorithmIdentifier;
export declare const sha256WithRSAEncryption: AlgorithmIdentifier;
export declare const sha384WithRSAEncryption: AlgorithmIdentifier;
export declare const sha512WithRSAEncryption: AlgorithmIdentifier;
export declare const sha512_224WithRSAEncryption: AlgorithmIdentifier;
export declare const sha512_256WithRSAEncryption: AlgorithmIdentifier;
+6
View File
@@ -0,0 +1,6 @@
export * from "./parameters";
export * from "./algorithms";
export * from "./object_identifiers";
export * from "./other_prime_info";
export * from "./rsa_private_key";
export * from "./rsa_public_key";
+176
View File
@@ -0,0 +1,176 @@
/**
* ```asn1
* pkcs-1 OBJECT IDENTIFIER ::= {
iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 1
* ```
*/
export declare const id_pkcs_1 = "1.2.840.113549.1.1";
/**
* ```asn1
* rsaEncryption OBJECT IDENTIFIER ::= { pkcs-1 1 }
* ```
*/
export declare const id_rsaEncryption = "1.2.840.113549.1.1.1";
/**
* ```asn1
* id-RSAES-OAEP OBJECT IDENTIFIER ::= { pkcs-1 7 }
* ```
*/
export declare const id_RSAES_OAEP = "1.2.840.113549.1.1.7";
/**
* ```asn1
* id-pSpecified OBJECT IDENTIFIER ::= { pkcs-1 9 }
* ```
*/
export declare const id_pSpecified = "1.2.840.113549.1.1.9";
/**
* ```asn1
* id-RSASSA-PSS OBJECT IDENTIFIER ::= { pkcs-1 10 }
* ```
*/
export declare const id_RSASSA_PSS = "1.2.840.113549.1.1.10";
/**
* ```asn1
* md2WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 2 }
* ```
*/
export declare const id_md2WithRSAEncryption = "1.2.840.113549.1.1.2";
/**
* ```asn1
* md5WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 4 }
* ```
*/
export declare const id_md5WithRSAEncryption = "1.2.840.113549.1.1.4";
/**
* ```asn1
* sha1WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 5 }
* ```
*/
export declare const id_sha1WithRSAEncryption = "1.2.840.113549.1.1.5";
/**
* ```asn1
* sha224WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 14 }
* ```
*/
export declare const id_sha224WithRSAEncryption = "1.2.840.113549.1.1.14";
/**
* ```asn1
* sha224WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 14 }
* ```
* @deprecated Should be removed later
*/
export declare const id_ssha224WithRSAEncryption = "1.2.840.113549.1.1.14";
/**
* ```asn1
* sha256WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 11 }
* ```
*/
export declare const id_sha256WithRSAEncryption = "1.2.840.113549.1.1.11";
/**
* ```asn1
* sha384WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 12 }
* ```
*/
export declare const id_sha384WithRSAEncryption = "1.2.840.113549.1.1.12";
/**
* ```asn1
* sha512WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 13 }
* ```
*/
export declare const id_sha512WithRSAEncryption = "1.2.840.113549.1.1.13";
/**
* ```asn1
* sha512-224WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 15 }
* ```
*/
export declare const id_sha512_224WithRSAEncryption = "1.2.840.113549.1.1.15";
/**
* ```asn1
* sha512-256WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 16 }
* ```
*/
export declare const id_sha512_256WithRSAEncryption = "1.2.840.113549.1.1.16";
/**
* ```asn1
* id-sha1 OBJECT IDENTIFIER ::= {
* iso(1) identified-organization(3) oiw(14) secsig(3) algorithms(2)
* 26
* ```
*/
export declare const id_sha1 = "1.3.14.3.2.26";
/**
* ```asn1
* id-sha224 OBJECT IDENTIFIER ::= {
* joint-iso-itu-t (2) country (16) us (840) organization (1)
* gov (101) csor (3) nistalgorithm (4) hashalgs (2) 4
* }
* ```
*/
export declare const id_sha224 = "2.16.840.1.101.3.4.2.4";
/**
* ```asn1
* id-sha256 OBJECT IDENTIFIER ::= {
* joint-iso-itu-t (2) country (16) us (840) organization (1)
* gov (101) csor (3) nistalgorithm (4) hashalgs (2) 1
* }
* ```
*/
export declare const id_sha256 = "2.16.840.1.101.3.4.2.1";
/**
* ```asn1
* id-sha384 OBJECT IDENTIFIER ::= {
* joint-iso-itu-t (2) country (16) us (840) organization (1)
* gov (101) csor (3) nistalgorithm (4) hashalgs (2) 2
* }
* ```
*/
export declare const id_sha384 = "2.16.840.1.101.3.4.2.2";
/**
* ```asn1
* id-sha512 OBJECT IDENTIFIER ::= {
* joint-iso-itu-t (2) country (16) us (840) organization (1)
* gov (101) csor (3) nistalgorithm (4) hashalgs (2) 3
* }
* ```
*/
export declare const id_sha512 = "2.16.840.1.101.3.4.2.3";
/**
* ```asn1
* id-sha512-224 OBJECT IDENTIFIER ::= {
* joint-iso-itu-t (2) country (16) us (840) organization (1)
* gov (101) csor (3) nistalgorithm (4) hashalgs (2) 5
* }
* ```
*/
export declare const id_sha512_224 = "2.16.840.1.101.3.4.2.5";
/**
* ```asn1
* id-sha512-256 OBJECT IDENTIFIER ::= {
* joint-iso-itu-t (2) country (16) us (840) organization (1)
* gov (101) csor (3) nistalgorithm (4) hashalgs (2) 6
* }
* ```
*/
export declare const id_sha512_256 = "2.16.840.1.101.3.4.2.6";
/**
* ```asn1
* id-md2 OBJECT IDENTIFIER ::= {
* iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 2
* }
* ```
*/
export declare const id_md2 = "1.2.840.113549.2.2";
/**
* ```asn1
* id-md5 OBJECT IDENTIFIER ::= {
* iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 5
* }
* ```
*/
export declare const id_md5 = "1.2.840.113549.2.5";
/**
* ```asn1
* id-mgf1 OBJECT IDENTIFIER ::= { pkcs-1 8 }
* ```
*/
export declare const id_mgf1 = "1.2.840.113549.1.1.8";
+24
View File
@@ -0,0 +1,24 @@
import { AsnArray } from "@peculiar/asn1-schema";
/**
* ```asn1
* OtherPrimeInfo ::= SEQUENCE {
* prime INTEGER, -- ri
* exponent INTEGER, -- di
* coefficient INTEGER -- ti
* }
* ```
*/
export declare class OtherPrimeInfo {
prime: ArrayBuffer;
exponent: ArrayBuffer;
coefficient: ArrayBuffer;
constructor(params?: Partial<OtherPrimeInfo>);
}
/**
* ```asn1
* OtherPrimeInfos ::= SEQUENCE SIZE(1..MAX) OF OtherPrimeInfo
* ```
*/
export declare class OtherPrimeInfos extends AsnArray<OtherPrimeInfo> {
constructor(items?: OtherPrimeInfo[]);
}
+3
View File
@@ -0,0 +1,3 @@
export * from "./rsaes_oaep";
export * from "./rsassa_pss";
export * from "./rsassa_pkcs1_v1_5";
+22
View File
@@ -0,0 +1,22 @@
import { AlgorithmIdentifier } from "@peculiar/asn1-x509";
/**
* ```asn1
* RSAES-OAEP-params ::= SEQUENCE {
* hashAlgorithm [0] HashAlgorithm DEFAULT sha1,
* maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT mgf1SHA1,
* pSourceAlgorithm [2] PSourceAlgorithm DEFAULT pSpecifiedEmpty
* }
* ```
*/
export declare class RsaEsOaepParams {
hashAlgorithm: AlgorithmIdentifier;
maskGenAlgorithm: AlgorithmIdentifier;
pSourceAlgorithm: AlgorithmIdentifier;
constructor(params?: Partial<RsaEsOaepParams>);
}
/**
* ```asn1
* { OID id-RSAES-OAEP PARAMETERS RSAES-OAEP-params } |
* ```
*/
export declare const RSAES_OAEP: AlgorithmIdentifier;
@@ -0,0 +1,15 @@
import { AlgorithmIdentifier } from "@peculiar/asn1-x509";
import { OctetString } from "@peculiar/asn1-schema";
/**
* ```asn1
* DigestInfo ::= SEQUENCE {
* digestAlgorithm DigestAlgorithm,
* digest OCTET STRING
* }
* ```
*/
export declare class DigestInfo {
digestAlgorithm: AlgorithmIdentifier;
digest: OctetString;
constructor(params?: Partial<DigestInfo>);
}
+30
View File
@@ -0,0 +1,30 @@
import { AlgorithmIdentifier } from "@peculiar/asn1-x509";
/**
* ```asn1
* TrailerField ::= INTEGER { trailerFieldBC(1) }
* ```
*/
export type TrailerField = number;
/**
* ```asn1
* RSASSA-PSS-params ::= SEQUENCE {
* hashAlgorithm [0] HashAlgorithm DEFAULT sha1,
* maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT mgf1SHA1,
* saltLength [2] INTEGER DEFAULT 20,
* trailerField [3] TrailerField DEFAULT trailerFieldBC
* }
* ```
*/
export declare class RsaSaPssParams {
hashAlgorithm: AlgorithmIdentifier;
maskGenAlgorithm: AlgorithmIdentifier;
saltLength: number;
trailerField: TrailerField;
constructor(params?: Partial<RsaSaPssParams>);
}
/**
* ```asn1
* { OID id-RSASSA-PSS PARAMETERS RSASSA-PSS-params }
* ```
*/
export declare const RSASSA_PSS: AlgorithmIdentifier;
+39
View File
@@ -0,0 +1,39 @@
import { OtherPrimeInfos } from "./other_prime_info";
/**
* ```asn1
* Version ::= INTEGER { two-prime(0), multi(1) }
* (CONSTRAINED BY
* {-- version MUST
* be multi if otherPrimeInfos present --})
* ```
*/
export type Version = number;
/**
* ```asn1
* RSAPrivateKey ::= SEQUENCE {
* version Version,
* modulus INTEGER, -- n
* publicExponent INTEGER, -- e
* privateExponent INTEGER, -- d
* prime1 INTEGER, -- p
* prime2 INTEGER, -- q
* exponent1 INTEGER, -- d mod (p-1)
* exponent2 INTEGER, -- d mod (q-1)
* coefficient INTEGER, -- (inverse of q) mod p
* otherPrimeInfos OtherPrimeInfos OPTIONAL
* }
* ```
*/
export declare class RSAPrivateKey {
version: Version;
modulus: ArrayBuffer;
publicExponent: ArrayBuffer;
privateExponent: ArrayBuffer;
prime1: ArrayBuffer;
prime2: ArrayBuffer;
exponent1: ArrayBuffer;
exponent2: ArrayBuffer;
coefficient: ArrayBuffer;
otherPrimeInfos?: OtherPrimeInfos;
constructor(params?: Partial<RSAPrivateKey>);
}
+13
View File
@@ -0,0 +1,13 @@
/**
* ```asn1
* RSAPublicKey ::= SEQUENCE {
* modulus INTEGER, -- n
* publicExponent INTEGER -- e
* }
* ```
*/
export declare class RSAPublicKey {
modulus: ArrayBuffer;
publicExponent: ArrayBuffer;
constructor(params?: Partial<RSAPublicKey>);
}
+42
View File
@@ -0,0 +1,42 @@
{
"name": "@peculiar/asn1-rsa",
"version": "2.6.1",
"description": "ASN.1 schema of `RSA Cryptography Specifications Version 2.2` (RFC8017)",
"files": [
"build/**/*.{js,d.ts}",
"LICENSE",
"README.md"
],
"bugs": {
"url": "https://github.com/PeculiarVentures/asn1-schema/issues"
},
"homepage": "https://github.com/PeculiarVentures/asn1-schema/tree/master/packages/rsa#readme",
"keywords": [
"asn"
],
"author": "PeculiarVentures, LLC",
"license": "MIT",
"main": "build/cjs/index.js",
"module": "build/es2015/index.js",
"types": "build/types/index.d.ts",
"publishConfig": {
"access": "public"
},
"scripts": {
"clear": "rimraf build",
"build": "npm run build:module && npm run build:types",
"build:module": "npm run build:cjs && npm run build:es2015",
"build:cjs": "tsc -p tsconfig.compile.json --removeComments --module commonjs --outDir build/cjs",
"build:es2015": "tsc -p tsconfig.compile.json --removeComments --module ES2015 --outDir build/es2015",
"prebuild:types": "rimraf build/types",
"build:types": "tsc -p tsconfig.compile.json --outDir build/types --declaration --emitDeclarationOnly",
"rebuild": "npm run clear && npm run build"
},
"dependencies": {
"@peculiar/asn1-schema": "^2.6.0",
"@peculiar/asn1-x509": "^2.6.1",
"asn1js": "^3.0.6",
"tslib": "^2.8.1"
},
"gitHead": "e533eba96fe14ca21b9a1b3f47cb58aaaa78c0ad"
}