UNPKG

@wildboar/pkcs

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