UNPKG

@wildboar/pkcs

Version:
176 lines 8.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_CertificationRequest = exports._decode_CertificationRequest = exports._extension_additions_list_spec_for_CertificationRequest = exports._root_component_type_list_2_spec_for_CertificationRequest = exports._root_component_type_list_1_spec_for_CertificationRequest = exports.CertificationRequest = exports._encode_CertificationRequestInfo = exports._decode_CertificationRequestInfo = exports.CertificationRequestInfo = exports._encode_AlgorithmIdentifier = exports._decode_AlgorithmIdentifier = exports.AlgorithmIdentifier = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const AlgorithmIdentifier_ta_1 = require("../PKCS-10/AlgorithmIdentifier.ta"); const CertificationRequestInfo_ta_1 = require("../PKCS-10/CertificationRequestInfo.ta"); var AlgorithmIdentifier_ta_2 = require("../PKCS-10/AlgorithmIdentifier.ta"); Object.defineProperty(exports, "AlgorithmIdentifier", { enumerable: true, get: function () { return AlgorithmIdentifier_ta_2.AlgorithmIdentifier; } }); Object.defineProperty(exports, "_decode_AlgorithmIdentifier", { enumerable: true, get: function () { return AlgorithmIdentifier_ta_2._decode_AlgorithmIdentifier; } }); Object.defineProperty(exports, "_encode_AlgorithmIdentifier", { enumerable: true, get: function () { return AlgorithmIdentifier_ta_2._encode_AlgorithmIdentifier; } }); var CertificationRequestInfo_ta_2 = require("../PKCS-10/CertificationRequestInfo.ta"); Object.defineProperty(exports, "CertificationRequestInfo", { enumerable: true, get: function () { return CertificationRequestInfo_ta_2.CertificationRequestInfo; } }); Object.defineProperty(exports, "_decode_CertificationRequestInfo", { enumerable: true, get: function () { return CertificationRequestInfo_ta_2._decode_CertificationRequestInfo; } }); Object.defineProperty(exports, "_encode_CertificationRequestInfo", { enumerable: true, get: function () { return CertificationRequestInfo_ta_2._encode_CertificationRequestInfo; } }); /* START_OF_SYMBOL_DEFINITION CertificationRequest */ /** * @summary CertificationRequest * @description * * ### ASN.1 Definition: * * ```asn1 * CertificationRequest ::= SEQUENCE { * certificationRequestInfo CertificationRequestInfo, * signatureAlgorithm AlgorithmIdentifier{{ SignatureAlgorithms }}, * signature BIT STRING * } * ``` * * @class */ class CertificationRequest { constructor( /** * @summary `certificationRequestInfo`. * @public * @readonly */ certificationRequestInfo, /** * @summary `signatureAlgorithm`. * @public * @readonly */ signatureAlgorithm, /** * @summary `signature`. * @public * @readonly */ signature) { this.certificationRequestInfo = certificationRequestInfo; this.signatureAlgorithm = signatureAlgorithm; this.signature = signature; } /** * @summary Restructures an object into a CertificationRequest * @description * * This takes an `object` and converts it to a `CertificationRequest`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `CertificationRequest`. * @returns {CertificationRequest} */ static _from_object(_o) { return new CertificationRequest(_o.certificationRequestInfo, _o.signatureAlgorithm, _o.signature); } } exports.CertificationRequest = CertificationRequest; /* END_OF_SYMBOL_DEFINITION CertificationRequest */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_CertificationRequest */ /** * @summary The Leading Root Component Types of CertificationRequest * @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_CertificationRequest = [ new $.ComponentSpec("certificationRequestInfo", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("signatureAlgorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("signature", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 3), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_CertificationRequest */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_CertificationRequest */ /** * @summary The Trailing Root Component Types of CertificationRequest * @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_CertificationRequest = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_CertificationRequest */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_CertificationRequest */ /** * @summary The Extension Addition Component Types of CertificationRequest * @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_CertificationRequest = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_CertificationRequest */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_CertificationRequest */ let _cached_decoder_for_CertificationRequest = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_CertificationRequest */ /* START_OF_SYMBOL_DEFINITION _decode_CertificationRequest */ /** * @summary Decodes an ASN.1 element into a(n) CertificationRequest * @function * @param {_Element} el The element being decoded. * @returns {CertificationRequest} The decoded data structure. */ function _decode_CertificationRequest(el) { if (!_cached_decoder_for_CertificationRequest) { _cached_decoder_for_CertificationRequest = function (el) { const sequence = el.sequence; if (sequence.length < 3) { throw new asn1_ts_1.ASN1ConstructionError("CertificationRequest contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "certificationRequestInfo"; sequence[1].name = "signatureAlgorithm"; sequence[2].name = "signature"; let certificationRequestInfo; let signatureAlgorithm; let signature; certificationRequestInfo = CertificationRequestInfo_ta_1._decode_CertificationRequestInfo(sequence[0]); signatureAlgorithm = AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier(sequence[1]); signature = $._decodeBitString(sequence[2]); return new CertificationRequest(certificationRequestInfo, signatureAlgorithm, signature); }; } return _cached_decoder_for_CertificationRequest(el); } exports._decode_CertificationRequest = _decode_CertificationRequest; /* END_OF_SYMBOL_DEFINITION _decode_CertificationRequest */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_CertificationRequest */ let _cached_encoder_for_CertificationRequest = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_CertificationRequest */ /* START_OF_SYMBOL_DEFINITION _encode_CertificationRequest */ /** * @summary Encodes a(n) CertificationRequest 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 CertificationRequest, encoded as an ASN.1 Element. */ function _encode_CertificationRequest(value, elGetter) { if (!_cached_encoder_for_CertificationRequest) { _cached_encoder_for_CertificationRequest = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ CertificationRequestInfo_ta_1._encode_CertificationRequestInfo(value.certificationRequestInfo, $.BER), /* REQUIRED */ AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.signatureAlgorithm, $.BER), /* REQUIRED */ $._encodeBitString(value.signature, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_CertificationRequest(value, elGetter); } exports._encode_CertificationRequest = _encode_CertificationRequest; /* END_OF_SYMBOL_DEFINITION _encode_CertificationRequest */ /* eslint-enable */ //# sourceMappingURL=CertificationRequest.ta.js.map