UNPKG

@wildboar/pkcs

Version:
180 lines 7.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_OOBCertHash = exports._decode_OOBCertHash = exports._extension_additions_list_spec_for_OOBCertHash = exports._root_component_type_list_2_spec_for_OOBCertHash = exports._root_component_type_list_1_spec_for_OOBCertHash = exports.OOBCertHash = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const AlgorithmIdentifier_ta_1 = require("@wildboar/x500/src/lib/modules/AuthenticationFramework/AlgorithmIdentifier.ta"); const CertId_ta_1 = require("../PKIXCRMF-2009/CertId.ta"); /* START_OF_SYMBOL_DEFINITION OOBCertHash */ /** * @summary OOBCertHash * @description * * ### ASN.1 Definition: * * ```asn1 * OOBCertHash ::= SEQUENCE { * hashAlg [0] AlgorithmIdentifier{DIGEST-ALGORITHM, {...}} * OPTIONAL, * certId [1] CertId OPTIONAL, * hashVal BIT STRING * -- hashVal is calculated over the DER encoding of the * -- self-signed certificate with the identifier certID. * } * ``` * * @class */ class OOBCertHash { constructor( /** * @summary `hashAlg`. * @public * @readonly */ hashAlg, /** * @summary `certId`. * @public * @readonly */ certId, /** * @summary `hashVal`. * @public * @readonly */ hashVal) { this.hashAlg = hashAlg; this.certId = certId; this.hashVal = hashVal; } /** * @summary Restructures an object into a OOBCertHash * @description * * This takes an `object` and converts it to a `OOBCertHash`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `OOBCertHash`. * @returns {OOBCertHash} */ static _from_object(_o) { return new OOBCertHash(_o.hashAlg, _o.certId, _o.hashVal); } } exports.OOBCertHash = OOBCertHash; /* END_OF_SYMBOL_DEFINITION OOBCertHash */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_OOBCertHash */ /** * @summary The Leading Root Component Types of OOBCertHash * @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_OOBCertHash = [ new $.ComponentSpec("hashAlg", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), new $.ComponentSpec("certId", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("hashVal", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 3), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_OOBCertHash */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_OOBCertHash */ /** * @summary The Trailing Root Component Types of OOBCertHash * @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_OOBCertHash = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_OOBCertHash */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_OOBCertHash */ /** * @summary The Extension Addition Component Types of OOBCertHash * @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_OOBCertHash = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_OOBCertHash */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_OOBCertHash */ let _cached_decoder_for_OOBCertHash = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_OOBCertHash */ /* START_OF_SYMBOL_DEFINITION _decode_OOBCertHash */ /** * @summary Decodes an ASN.1 element into a(n) OOBCertHash * @function * @param {_Element} el The element being decoded. * @returns {OOBCertHash} The decoded data structure. */ function _decode_OOBCertHash(el) { if (!_cached_decoder_for_OOBCertHash) { _cached_decoder_for_OOBCertHash = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let hashAlg; let certId; let hashVal; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { hashAlg: (_el) => { hashAlg = $._decode_explicit(() => AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier)(_el); }, certId: (_el) => { certId = $._decode_explicit(() => CertId_ta_1._decode_CertId)(_el); }, hashVal: (_el) => { hashVal = $._decodeBitString(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_OOBCertHash, exports._extension_additions_list_spec_for_OOBCertHash, exports._root_component_type_list_2_spec_for_OOBCertHash, undefined); return new OOBCertHash( /* SEQUENCE_CONSTRUCTOR_CALL */ hashAlg, certId, hashVal); }; } return _cached_decoder_for_OOBCertHash(el); } exports._decode_OOBCertHash = _decode_OOBCertHash; /* END_OF_SYMBOL_DEFINITION _decode_OOBCertHash */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_OOBCertHash */ let _cached_encoder_for_OOBCertHash = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_OOBCertHash */ /* START_OF_SYMBOL_DEFINITION _encode_OOBCertHash */ /** * @summary Encodes a(n) OOBCertHash 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 OOBCertHash, encoded as an ASN.1 Element. */ function _encode_OOBCertHash(value, elGetter) { if (!_cached_encoder_for_OOBCertHash) { _cached_encoder_for_OOBCertHash = function (value, elGetter) { return $._encodeSequence([] .concat([ /* IF_ABSENT */ value.hashAlg === undefined ? undefined : $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 0, () => AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier, $.BER)(value.hashAlg, $.BER), /* IF_ABSENT */ value.certId === undefined ? undefined : $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 1, () => CertId_ta_1._encode_CertId, $.BER)(value.certId, $.BER), /* REQUIRED */ $._encodeBitString(value.hashVal, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_OOBCertHash(value, elGetter); } exports._encode_OOBCertHash = _encode_OOBCertHash; /* END_OF_SYMBOL_DEFINITION _encode_OOBCertHash */ /* eslint-enable */ //# sourceMappingURL=OOBCertHash.ta.js.map