@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
252 lines • 14.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_SignedData = exports._decode_SignedData = exports._extension_additions_list_spec_for_SignedData = exports._root_component_type_list_2_spec_for_SignedData = exports._root_component_type_list_1_spec_for_SignedData = exports.SignedData = exports._encode_SignerInfos = exports._decode_SignerInfos = exports._encode_EncapsulatedContentInfo = exports._decode_EncapsulatedContentInfo = exports.EncapsulatedContentInfo = exports._encode_DigestAlgorithmIdentifiers = exports._decode_DigestAlgorithmIdentifiers = exports._encode_CMSVersion = exports._decode_CMSVersion = exports.v4 = exports.v3 = exports.v2 = exports.v1 = exports.v0 = exports.CMSVersion_v4 = exports.CMSVersion_v3 = exports.CMSVersion_v2 = exports.CMSVersion_v1 = exports.CMSVersion_v0 = exports._encode_CertificateSet = exports._decode_CertificateSet = exports._encode_CertificateRevocationLists = exports._decode_CertificateRevocationLists = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const CertificateRevocationLists_ta_1 = require("../CryptographicMessageSyntax/CertificateRevocationLists.ta");
const CertificateSet_ta_1 = require("../CryptographicMessageSyntax/CertificateSet.ta");
const CMSVersion_ta_1 = require("../CryptographicMessageSyntax/CMSVersion.ta");
const DigestAlgorithmIdentifiers_ta_1 = require("../CryptographicMessageSyntax/DigestAlgorithmIdentifiers.ta");
const EncapsulatedContentInfo_ta_1 = require("../CryptographicMessageSyntax/EncapsulatedContentInfo.ta");
const SignerInfos_ta_1 = require("../CryptographicMessageSyntax/SignerInfos.ta");
var CertificateRevocationLists_ta_2 = require("../CryptographicMessageSyntax/CertificateRevocationLists.ta");
Object.defineProperty(exports, "_decode_CertificateRevocationLists", { enumerable: true, get: function () { return CertificateRevocationLists_ta_2._decode_CertificateRevocationLists; } });
Object.defineProperty(exports, "_encode_CertificateRevocationLists", { enumerable: true, get: function () { return CertificateRevocationLists_ta_2._encode_CertificateRevocationLists; } });
var CertificateSet_ta_2 = require("../CryptographicMessageSyntax/CertificateSet.ta");
Object.defineProperty(exports, "_decode_CertificateSet", { enumerable: true, get: function () { return CertificateSet_ta_2._decode_CertificateSet; } });
Object.defineProperty(exports, "_encode_CertificateSet", { enumerable: true, get: function () { return CertificateSet_ta_2._encode_CertificateSet; } });
var CMSVersion_ta_2 = require("../CryptographicMessageSyntax/CMSVersion.ta");
Object.defineProperty(exports, "CMSVersion_v0", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v0; } }); /* IMPORTED_LONG_NAMED_INTEGER */
Object.defineProperty(exports, "CMSVersion_v1", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v1; } }); /* IMPORTED_LONG_NAMED_INTEGER */
Object.defineProperty(exports, "CMSVersion_v2", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v2; } }); /* IMPORTED_LONG_NAMED_INTEGER */
Object.defineProperty(exports, "CMSVersion_v3", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v3; } }); /* IMPORTED_LONG_NAMED_INTEGER */
Object.defineProperty(exports, "CMSVersion_v4", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v4; } }); /* IMPORTED_LONG_NAMED_INTEGER */
Object.defineProperty(exports, "v0", { enumerable: true, get: function () { return CMSVersion_ta_2.v0; } }); /* IMPORTED_SHORT_NAMED_INTEGER */
Object.defineProperty(exports, "v1", { enumerable: true, get: function () { return CMSVersion_ta_2.v1; } }); /* IMPORTED_SHORT_NAMED_INTEGER */
Object.defineProperty(exports, "v2", { enumerable: true, get: function () { return CMSVersion_ta_2.v2; } }); /* IMPORTED_SHORT_NAMED_INTEGER */
Object.defineProperty(exports, "v3", { enumerable: true, get: function () { return CMSVersion_ta_2.v3; } }); /* IMPORTED_SHORT_NAMED_INTEGER */
Object.defineProperty(exports, "v4", { enumerable: true, get: function () { return CMSVersion_ta_2.v4; } }); /* IMPORTED_SHORT_NAMED_INTEGER */
Object.defineProperty(exports, "_decode_CMSVersion", { enumerable: true, get: function () { return CMSVersion_ta_2._decode_CMSVersion; } });
Object.defineProperty(exports, "_encode_CMSVersion", { enumerable: true, get: function () { return CMSVersion_ta_2._encode_CMSVersion; } });
var DigestAlgorithmIdentifiers_ta_2 = require("../CryptographicMessageSyntax/DigestAlgorithmIdentifiers.ta");
Object.defineProperty(exports, "_decode_DigestAlgorithmIdentifiers", { enumerable: true, get: function () { return DigestAlgorithmIdentifiers_ta_2._decode_DigestAlgorithmIdentifiers; } });
Object.defineProperty(exports, "_encode_DigestAlgorithmIdentifiers", { enumerable: true, get: function () { return DigestAlgorithmIdentifiers_ta_2._encode_DigestAlgorithmIdentifiers; } });
var EncapsulatedContentInfo_ta_2 = require("../CryptographicMessageSyntax/EncapsulatedContentInfo.ta");
Object.defineProperty(exports, "EncapsulatedContentInfo", { enumerable: true, get: function () { return EncapsulatedContentInfo_ta_2.EncapsulatedContentInfo; } });
Object.defineProperty(exports, "_decode_EncapsulatedContentInfo", { enumerable: true, get: function () { return EncapsulatedContentInfo_ta_2._decode_EncapsulatedContentInfo; } });
Object.defineProperty(exports, "_encode_EncapsulatedContentInfo", { enumerable: true, get: function () { return EncapsulatedContentInfo_ta_2._encode_EncapsulatedContentInfo; } });
var SignerInfos_ta_2 = require("../CryptographicMessageSyntax/SignerInfos.ta");
Object.defineProperty(exports, "_decode_SignerInfos", { enumerable: true, get: function () { return SignerInfos_ta_2._decode_SignerInfos; } });
Object.defineProperty(exports, "_encode_SignerInfos", { enumerable: true, get: function () { return SignerInfos_ta_2._encode_SignerInfos; } });
/* START_OF_SYMBOL_DEFINITION SignedData */
/**
* @summary SignedData
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* SignedData ::= SEQUENCE {
* version CMSVersion,
* digestAlgorithms DigestAlgorithmIdentifiers,
* encapContentInfo EncapsulatedContentInfo,
* certificates [0] IMPLICIT CertificateSet OPTIONAL,
* crls [1] IMPLICIT CertificateRevocationLists OPTIONAL,
* signerInfos SignerInfos
* }
* ```
*
* @class
*/
class SignedData {
constructor(
/**
* @summary `version`.
* @public
* @readonly
*/
version,
/**
* @summary `digestAlgorithms`.
* @public
* @readonly
*/
digestAlgorithms,
/**
* @summary `encapContentInfo`.
* @public
* @readonly
*/
encapContentInfo,
/**
* @summary `certificates`.
* @public
* @readonly
*/
certificates,
/**
* @summary `crls`.
* @public
* @readonly
*/
crls,
/**
* @summary `signerInfos`.
* @public
* @readonly
*/
signerInfos) {
this.version = version;
this.digestAlgorithms = digestAlgorithms;
this.encapContentInfo = encapContentInfo;
this.certificates = certificates;
this.crls = crls;
this.signerInfos = signerInfos;
}
/**
* @summary Restructures an object into a SignedData
* @description
*
* This takes an `object` and converts it to a `SignedData`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `SignedData`.
* @returns {SignedData}
*/
static _from_object(_o) {
return new SignedData(_o.version, _o.digestAlgorithms, _o.encapContentInfo, _o.certificates, _o.crls, _o.signerInfos);
}
}
exports.SignedData = SignedData;
/* END_OF_SYMBOL_DEFINITION SignedData */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_SignedData */
/**
* @summary The Leading Root Component Types of SignedData
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the leading root component type list of a SET or SEQUENCE.
*
* @constant
*/
exports._root_component_type_list_1_spec_for_SignedData = [
new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("digestAlgorithms", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined),
new $.ComponentSpec("encapContentInfo", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("certificates", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined),
new $.ComponentSpec("crls", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined),
new $.ComponentSpec("signerInfos", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_SignedData */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_SignedData */
/**
* @summary The Trailing Root Component Types of SignedData
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the trailing root component type list of a SET or SEQUENCE.
*
* @constant
*/
exports._root_component_type_list_2_spec_for_SignedData = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_SignedData */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_SignedData */
/**
* @summary The Extension Addition Component Types of SignedData
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the extension addition component type list of a SET or SEQUENCE.
*
* @constant
*/
exports._extension_additions_list_spec_for_SignedData = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_SignedData */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_SignedData */
let _cached_decoder_for_SignedData = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_SignedData */
/* START_OF_SYMBOL_DEFINITION _decode_SignedData */
/**
* @summary Decodes an ASN.1 element into a(n) SignedData
* @function
* @param {_Element} el The element being decoded.
* @returns {SignedData} The decoded data structure.
*/
function _decode_SignedData(el) {
if (!_cached_decoder_for_SignedData) {
_cached_decoder_for_SignedData = function (el) {
/* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */
let version;
let digestAlgorithms;
let encapContentInfo;
let certificates;
let crls;
let signerInfos;
/* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */
/* START_OF_CALLBACKS_MAP */
const callbacks = {
version: (_el) => {
version = CMSVersion_ta_1._decode_CMSVersion(_el);
},
digestAlgorithms: (_el) => {
digestAlgorithms = DigestAlgorithmIdentifiers_ta_1._decode_DigestAlgorithmIdentifiers(_el);
},
encapContentInfo: (_el) => {
encapContentInfo = EncapsulatedContentInfo_ta_1._decode_EncapsulatedContentInfo(_el);
},
certificates: (_el) => {
certificates = $._decode_implicit(() => CertificateSet_ta_1._decode_CertificateSet)(_el);
},
crls: (_el) => {
crls = $._decode_implicit(() => CertificateRevocationLists_ta_1._decode_CertificateRevocationLists)(_el);
},
signerInfos: (_el) => {
signerInfos = SignerInfos_ta_1._decode_SignerInfos(_el);
},
};
/* END_OF_CALLBACKS_MAP */
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_SignedData, exports._extension_additions_list_spec_for_SignedData, exports._root_component_type_list_2_spec_for_SignedData, undefined);
return new SignedData(
/* SEQUENCE_CONSTRUCTOR_CALL */ version, digestAlgorithms, encapContentInfo, certificates, crls, signerInfos);
};
}
return _cached_decoder_for_SignedData(el);
}
exports._decode_SignedData = _decode_SignedData;
/* END_OF_SYMBOL_DEFINITION _decode_SignedData */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_SignedData */
let _cached_encoder_for_SignedData = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_SignedData */
/* START_OF_SYMBOL_DEFINITION _encode_SignedData */
/**
* @summary Encodes a(n) SignedData into an ASN.1 Element.
* @function
* @param {value} el The element being decoded.
* @param elGetter A function that can be used to get new ASN.1 elements.
* @returns {_Element} The SignedData, encoded as an ASN.1 Element.
*/
function _encode_SignedData(value, elGetter) {
if (!_cached_encoder_for_SignedData) {
_cached_encoder_for_SignedData = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ CMSVersion_ta_1._encode_CMSVersion(value.version, $.BER),
/* REQUIRED */ DigestAlgorithmIdentifiers_ta_1._encode_DigestAlgorithmIdentifiers(value.digestAlgorithms, $.BER),
/* REQUIRED */ EncapsulatedContentInfo_ta_1._encode_EncapsulatedContentInfo(value.encapContentInfo, $.BER),
/* IF_ABSENT */ value.certificates === undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => CertificateSet_ta_1._encode_CertificateSet, $.BER)(value.certificates, $.BER),
/* IF_ABSENT */ value.crls === undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => CertificateRevocationLists_ta_1._encode_CertificateRevocationLists, $.BER)(value.crls, $.BER),
/* REQUIRED */ SignerInfos_ta_1._encode_SignerInfos(value.signerInfos, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_SignedData(value, elGetter);
}
exports._encode_SignedData = _encode_SignedData;
/* END_OF_SYMBOL_DEFINITION _encode_SignedData */
/* eslint-enable */
//# sourceMappingURL=SignedData.ta.js.map