UNPKG

@wildboar/pc

Version:

Trusted Computing Group Platform Certificate ASN.1 data structures in TypeScript

153 lines 7.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_AttributeCertificateIdentifier = exports._decode_AttributeCertificateIdentifier = exports._extension_additions_list_spec_for_AttributeCertificateIdentifier = exports._root_component_type_list_2_spec_for_AttributeCertificateIdentifier = exports._root_component_type_list_1_spec_for_AttributeCertificateIdentifier = exports.AttributeCertificateIdentifier = 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("@wildboar/x500/src/lib/modules/AuthenticationFramework/AlgorithmIdentifier.ta"); var AlgorithmIdentifier_ta_2 = require("@wildboar/x500/src/lib/modules/AuthenticationFramework/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; } }); /* START_OF_SYMBOL_DEFINITION AttributeCertificateIdentifier */ /** * @summary AttributeCertificateIdentifier * @description * * ### ASN.1 Definition: * * ```asn1 * AttributeCertificateIdentifier ::= SEQUENCE { * hashAlgorithm AlgorithmIdentifier, * hashOverSignatureValue OCTET STRING } * ``` * * @class */ class AttributeCertificateIdentifier { constructor( /** * @summary `hashAlgorithm`. * @public * @readonly */ hashAlgorithm, /** * @summary `hashOverSignatureValue`. * @public * @readonly */ hashOverSignatureValue) { this.hashAlgorithm = hashAlgorithm; this.hashOverSignatureValue = hashOverSignatureValue; } /** * @summary Restructures an object into a AttributeCertificateIdentifier * @description * * This takes an `object` and converts it to a `AttributeCertificateIdentifier`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `AttributeCertificateIdentifier`. * @returns {AttributeCertificateIdentifier} */ static _from_object(_o) { return new AttributeCertificateIdentifier(_o.hashAlgorithm, _o.hashOverSignatureValue); } } exports.AttributeCertificateIdentifier = AttributeCertificateIdentifier; /* END_OF_SYMBOL_DEFINITION AttributeCertificateIdentifier */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_AttributeCertificateIdentifier */ /** * @summary The Leading Root Component Types of AttributeCertificateIdentifier * @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_AttributeCertificateIdentifier = [ new $.ComponentSpec("hashAlgorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("hashOverSignatureValue", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined) ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_AttributeCertificateIdentifier */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_AttributeCertificateIdentifier */ /** * @summary The Trailing Root Component Types of AttributeCertificateIdentifier * @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_AttributeCertificateIdentifier = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_AttributeCertificateIdentifier */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_AttributeCertificateIdentifier */ /** * @summary The Extension Addition Component Types of AttributeCertificateIdentifier * @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_AttributeCertificateIdentifier = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_AttributeCertificateIdentifier */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_AttributeCertificateIdentifier */ let _cached_decoder_for_AttributeCertificateIdentifier = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_AttributeCertificateIdentifier */ /* START_OF_SYMBOL_DEFINITION _decode_AttributeCertificateIdentifier */ /** * @summary Decodes an ASN.1 element into a(n) AttributeCertificateIdentifier * @function * @param {_Element} el The element being decoded. * @returns {AttributeCertificateIdentifier} The decoded data structure. */ function _decode_AttributeCertificateIdentifier(el) { if (!_cached_decoder_for_AttributeCertificateIdentifier) { _cached_decoder_for_AttributeCertificateIdentifier = function (el) { const sequence = el.sequence; if (sequence.length < 2) { throw new asn1_ts_1.ASN1ConstructionError("AttributeCertificateIdentifier contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "hashAlgorithm"; sequence[1].name = "hashOverSignatureValue"; let hashAlgorithm; let hashOverSignatureValue; hashAlgorithm = AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier(sequence[0]); hashOverSignatureValue = $._decodeOctetString(sequence[1]); return new AttributeCertificateIdentifier(hashAlgorithm, hashOverSignatureValue); }; } return _cached_decoder_for_AttributeCertificateIdentifier(el); } exports._decode_AttributeCertificateIdentifier = _decode_AttributeCertificateIdentifier; /* END_OF_SYMBOL_DEFINITION _decode_AttributeCertificateIdentifier */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_AttributeCertificateIdentifier */ let _cached_encoder_for_AttributeCertificateIdentifier = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_AttributeCertificateIdentifier */ /* START_OF_SYMBOL_DEFINITION _encode_AttributeCertificateIdentifier */ /** * @summary Encodes a(n) AttributeCertificateIdentifier 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 AttributeCertificateIdentifier, encoded as an ASN.1 Element. */ function _encode_AttributeCertificateIdentifier(value, elGetter) { if (!_cached_encoder_for_AttributeCertificateIdentifier) { _cached_encoder_for_AttributeCertificateIdentifier = function (value, elGetter) { return $._encodeSequence([].concat([ /* REQUIRED */ AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.hashAlgorithm, $.BER), /* REQUIRED */ $._encodeOctetString(value.hashOverSignatureValue, $.BER) ]).filter((c) => (!!c)), $.BER); }; } return _cached_encoder_for_AttributeCertificateIdentifier(value, elGetter); } exports._encode_AttributeCertificateIdentifier = _encode_AttributeCertificateIdentifier; /* END_OF_SYMBOL_DEFINITION _encode_AttributeCertificateIdentifier */ /* eslint-enable */ //# sourceMappingURL=AttributeCertificateIdentifier.ta.js.map