UNPKG

@wildboar/pkcs

Version:
162 lines 7.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_OtherKey = exports._decode_OtherKey = exports._extension_additions_list_spec_for_OtherKey = exports._root_component_type_list_2_spec_for_OtherKey = exports._root_component_type_list_1_spec_for_OtherKey = exports.OtherKey = exports._get_encoder_for_SecretKeyObject = exports._get_decoder_for_SecretKeyObject = exports._encode_GenericSecretKeyAttributes = exports._decode_GenericSecretKeyAttributes = exports.GenericSecretKeyAttributes = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const GenericSecretKeyAttributes_ta_1 = require("../PKCS-15/GenericSecretKeyAttributes.ta"); const SecretKeyObject_ta_1 = require("../PKCS-15/SecretKeyObject.ta"); var GenericSecretKeyAttributes_ta_2 = require("../PKCS-15/GenericSecretKeyAttributes.ta"); Object.defineProperty(exports, "GenericSecretKeyAttributes", { enumerable: true, get: function () { return GenericSecretKeyAttributes_ta_2.GenericSecretKeyAttributes; } }); Object.defineProperty(exports, "_decode_GenericSecretKeyAttributes", { enumerable: true, get: function () { return GenericSecretKeyAttributes_ta_2._decode_GenericSecretKeyAttributes; } }); Object.defineProperty(exports, "_encode_GenericSecretKeyAttributes", { enumerable: true, get: function () { return GenericSecretKeyAttributes_ta_2._encode_GenericSecretKeyAttributes; } }); var SecretKeyObject_ta_2 = require("../PKCS-15/SecretKeyObject.ta"); Object.defineProperty(exports, "_get_decoder_for_SecretKeyObject", { enumerable: true, get: function () { return SecretKeyObject_ta_2._get_decoder_for_SecretKeyObject; } }); Object.defineProperty(exports, "_get_encoder_for_SecretKeyObject", { enumerable: true, get: function () { return SecretKeyObject_ta_2._get_encoder_for_SecretKeyObject; } }); /* START_OF_SYMBOL_DEFINITION OtherKey */ /** * @summary OtherKey * @description * * ### ASN.1 Definition: * * ```asn1 * OtherKey ::= SEQUENCE { * keyType OBJECT IDENTIFIER, * keyAttr SecretKeyObject {GenericSecretKeyAttributes} * } * ``` * * @class */ class OtherKey { constructor( /** * @summary `keyType`. * @public * @readonly */ keyType, /** * @summary `keyAttr`. * @public * @readonly */ keyAttr) { this.keyType = keyType; this.keyAttr = keyAttr; } /** * @summary Restructures an object into a OtherKey * @description * * This takes an `object` and converts it to a `OtherKey`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `OtherKey`. * @returns {OtherKey} */ static _from_object(_o) { return new OtherKey(_o.keyType, _o.keyAttr); } } exports.OtherKey = OtherKey; /* END_OF_SYMBOL_DEFINITION OtherKey */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_OtherKey */ /** * @summary The Leading Root Component Types of OtherKey * @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_OtherKey = [ new $.ComponentSpec("keyType", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined), new $.ComponentSpec("keyAttr", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_OtherKey */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_OtherKey */ /** * @summary The Trailing Root Component Types of OtherKey * @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_OtherKey = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_OtherKey */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_OtherKey */ /** * @summary The Extension Addition Component Types of OtherKey * @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_OtherKey = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_OtherKey */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_OtherKey */ let _cached_decoder_for_OtherKey = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_OtherKey */ /* START_OF_SYMBOL_DEFINITION _decode_OtherKey */ /** * @summary Decodes an ASN.1 element into a(n) OtherKey * @function * @param {_Element} el The element being decoded. * @returns {OtherKey} The decoded data structure. */ function _decode_OtherKey(el) { if (!_cached_decoder_for_OtherKey) { _cached_decoder_for_OtherKey = function (el) { const sequence = el.sequence; if (sequence.length < 2) { throw new asn1_ts_1.ASN1ConstructionError("OtherKey contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "keyType"; sequence[1].name = "keyAttr"; let keyType; let keyAttr; keyType = $._decodeObjectIdentifier(sequence[0]); keyAttr = SecretKeyObject_ta_1._get_decoder_for_SecretKeyObject(GenericSecretKeyAttributes_ta_1._decode_GenericSecretKeyAttributes)(sequence[1]); return new OtherKey(keyType, keyAttr); }; } return _cached_decoder_for_OtherKey(el); } exports._decode_OtherKey = _decode_OtherKey; /* END_OF_SYMBOL_DEFINITION _decode_OtherKey */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_OtherKey */ let _cached_encoder_for_OtherKey = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_OtherKey */ /* START_OF_SYMBOL_DEFINITION _encode_OtherKey */ /** * @summary Encodes a(n) OtherKey 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 OtherKey, encoded as an ASN.1 Element. */ function _encode_OtherKey(value, elGetter) { if (!_cached_encoder_for_OtherKey) { _cached_encoder_for_OtherKey = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ $._encodeObjectIdentifier(value.keyType, $.BER), /* REQUIRED */ SecretKeyObject_ta_1._get_encoder_for_SecretKeyObject(GenericSecretKeyAttributes_ta_1._encode_GenericSecretKeyAttributes)(value.keyAttr, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_OtherKey(value, elGetter); } exports._encode_OtherKey = _encode_OtherKey; /* END_OF_SYMBOL_DEFINITION _encode_OtherKey */ /* eslint-enable */ //# sourceMappingURL=OtherKey.ta.js.map