UNPKG

@wildboar/pkcs

Version:
180 lines 8.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_KeyEncryptionKeyIdentifier = exports._decode_KeyEncryptionKeyIdentifier = exports._extension_additions_list_spec_for_KeyEncryptionKeyIdentifier = exports._root_component_type_list_2_spec_for_KeyEncryptionKeyIdentifier = exports._root_component_type_list_1_spec_for_KeyEncryptionKeyIdentifier = exports.KeyEncryptionKeyIdentifier = exports._encode_OtherKeyAttribute = exports._decode_OtherKeyAttribute = exports.OtherKeyAttribute = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const OtherKeyAttribute_ta_1 = require("../PKCS7/OtherKeyAttribute.ta"); var OtherKeyAttribute_ta_2 = require("../PKCS7/OtherKeyAttribute.ta"); Object.defineProperty(exports, "OtherKeyAttribute", { enumerable: true, get: function () { return OtherKeyAttribute_ta_2.OtherKeyAttribute; } }); Object.defineProperty(exports, "_decode_OtherKeyAttribute", { enumerable: true, get: function () { return OtherKeyAttribute_ta_2._decode_OtherKeyAttribute; } }); Object.defineProperty(exports, "_encode_OtherKeyAttribute", { enumerable: true, get: function () { return OtherKeyAttribute_ta_2._encode_OtherKeyAttribute; } }); /* START_OF_SYMBOL_DEFINITION KeyEncryptionKeyIdentifier */ /** * @summary KeyEncryptionKeyIdentifier * @description * * ### ASN.1 Definition: * * ```asn1 * KeyEncryptionKeyIdentifier ::= SEQUENCE { * keyIdentifier OCTET STRING, * date GeneralizedTime OPTIONAL, * otherKeyAttribute OtherKeyAttribute OPTIONAL * } * ``` * * @class */ class KeyEncryptionKeyIdentifier { constructor( /** * @summary `keyIdentifier`. * @public * @readonly */ keyIdentifier, /** * @summary `date`. * @public * @readonly */ date, /** * @summary `otherKeyAttribute`. * @public * @readonly */ otherKeyAttribute) { this.keyIdentifier = keyIdentifier; this.date = date; this.otherKeyAttribute = otherKeyAttribute; } /** * @summary Restructures an object into a KeyEncryptionKeyIdentifier * @description * * This takes an `object` and converts it to a `KeyEncryptionKeyIdentifier`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `KeyEncryptionKeyIdentifier`. * @returns {KeyEncryptionKeyIdentifier} */ static _from_object(_o) { return new KeyEncryptionKeyIdentifier(_o.keyIdentifier, _o.date, _o.otherKeyAttribute); } } exports.KeyEncryptionKeyIdentifier = KeyEncryptionKeyIdentifier; /* END_OF_SYMBOL_DEFINITION KeyEncryptionKeyIdentifier */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_KeyEncryptionKeyIdentifier */ /** * @summary The Leading Root Component Types of KeyEncryptionKeyIdentifier * @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_KeyEncryptionKeyIdentifier = [ new $.ComponentSpec("keyIdentifier", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined), new $.ComponentSpec("date", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 24), undefined, undefined), new $.ComponentSpec("otherKeyAttribute", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_KeyEncryptionKeyIdentifier */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_KeyEncryptionKeyIdentifier */ /** * @summary The Trailing Root Component Types of KeyEncryptionKeyIdentifier * @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_KeyEncryptionKeyIdentifier = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_KeyEncryptionKeyIdentifier */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_KeyEncryptionKeyIdentifier */ /** * @summary The Extension Addition Component Types of KeyEncryptionKeyIdentifier * @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_KeyEncryptionKeyIdentifier = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_KeyEncryptionKeyIdentifier */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_KeyEncryptionKeyIdentifier */ let _cached_decoder_for_KeyEncryptionKeyIdentifier = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_KeyEncryptionKeyIdentifier */ /* START_OF_SYMBOL_DEFINITION _decode_KeyEncryptionKeyIdentifier */ /** * @summary Decodes an ASN.1 element into a(n) KeyEncryptionKeyIdentifier * @function * @param {_Element} el The element being decoded. * @returns {KeyEncryptionKeyIdentifier} The decoded data structure. */ function _decode_KeyEncryptionKeyIdentifier(el) { if (!_cached_decoder_for_KeyEncryptionKeyIdentifier) { _cached_decoder_for_KeyEncryptionKeyIdentifier = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let keyIdentifier; let date; let otherKeyAttribute; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { keyIdentifier: (_el) => { keyIdentifier = $._decodeOctetString(_el); }, date: (_el) => { date = $._decodeGeneralizedTime(_el); }, otherKeyAttribute: (_el) => { otherKeyAttribute = OtherKeyAttribute_ta_1._decode_OtherKeyAttribute(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_KeyEncryptionKeyIdentifier, exports._extension_additions_list_spec_for_KeyEncryptionKeyIdentifier, exports._root_component_type_list_2_spec_for_KeyEncryptionKeyIdentifier, undefined); return new KeyEncryptionKeyIdentifier( /* SEQUENCE_CONSTRUCTOR_CALL */ keyIdentifier, date, otherKeyAttribute); }; } return _cached_decoder_for_KeyEncryptionKeyIdentifier(el); } exports._decode_KeyEncryptionKeyIdentifier = _decode_KeyEncryptionKeyIdentifier; /* END_OF_SYMBOL_DEFINITION _decode_KeyEncryptionKeyIdentifier */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_KeyEncryptionKeyIdentifier */ let _cached_encoder_for_KeyEncryptionKeyIdentifier = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_KeyEncryptionKeyIdentifier */ /* START_OF_SYMBOL_DEFINITION _encode_KeyEncryptionKeyIdentifier */ /** * @summary Encodes a(n) KeyEncryptionKeyIdentifier 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 KeyEncryptionKeyIdentifier, encoded as an ASN.1 Element. */ function _encode_KeyEncryptionKeyIdentifier(value, elGetter) { if (!_cached_encoder_for_KeyEncryptionKeyIdentifier) { _cached_encoder_for_KeyEncryptionKeyIdentifier = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ $._encodeOctetString(value.keyIdentifier, $.BER), /* IF_ABSENT */ value.date === undefined ? undefined : $._encodeGeneralizedTime(value.date, $.BER), /* IF_ABSENT */ value.otherKeyAttribute === undefined ? undefined : OtherKeyAttribute_ta_1._encode_OtherKeyAttribute(value.otherKeyAttribute, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_KeyEncryptionKeyIdentifier(value, elGetter); } exports._encode_KeyEncryptionKeyIdentifier = _encode_KeyEncryptionKeyIdentifier; /* END_OF_SYMBOL_DEFINITION _encode_KeyEncryptionKeyIdentifier */ /* eslint-enable */ //# sourceMappingURL=KeyEncryptionKeyIdentifier.ta.js.map