UNPKG

@wildboar/pc

Version:

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

153 lines 7.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_TCGPlatformSpecification = exports._decode_TCGPlatformSpecification = exports._extension_additions_list_spec_for_TCGPlatformSpecification = exports._root_component_type_list_2_spec_for_TCGPlatformSpecification = exports._root_component_type_list_1_spec_for_TCGPlatformSpecification = exports.TCGPlatformSpecification = exports._encode_TCGSpecificationVersion = exports._decode_TCGSpecificationVersion = exports.TCGSpecificationVersion = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const TCGSpecificationVersion_ta_1 = require("../PlatformCertificateProfile/TCGSpecificationVersion.ta"); var TCGSpecificationVersion_ta_2 = require("../PlatformCertificateProfile/TCGSpecificationVersion.ta"); Object.defineProperty(exports, "TCGSpecificationVersion", { enumerable: true, get: function () { return TCGSpecificationVersion_ta_2.TCGSpecificationVersion; } }); Object.defineProperty(exports, "_decode_TCGSpecificationVersion", { enumerable: true, get: function () { return TCGSpecificationVersion_ta_2._decode_TCGSpecificationVersion; } }); Object.defineProperty(exports, "_encode_TCGSpecificationVersion", { enumerable: true, get: function () { return TCGSpecificationVersion_ta_2._encode_TCGSpecificationVersion; } }); /* START_OF_SYMBOL_DEFINITION TCGPlatformSpecification */ /** * @summary TCGPlatformSpecification * @description * * ### ASN.1 Definition: * * ```asn1 * TCGPlatformSpecification ::= SEQUENCE { * version TCGSpecificationVersion, * platformClass OCTET STRING (SIZE(4)) } * ``` * * @class */ class TCGPlatformSpecification { constructor( /** * @summary `version`. * @public * @readonly */ version, /** * @summary `platformClass`. * @public * @readonly */ platformClass) { this.version = version; this.platformClass = platformClass; } /** * @summary Restructures an object into a TCGPlatformSpecification * @description * * This takes an `object` and converts it to a `TCGPlatformSpecification`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `TCGPlatformSpecification`. * @returns {TCGPlatformSpecification} */ static _from_object(_o) { return new TCGPlatformSpecification(_o.version, _o.platformClass); } } exports.TCGPlatformSpecification = TCGPlatformSpecification; /* END_OF_SYMBOL_DEFINITION TCGPlatformSpecification */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_TCGPlatformSpecification */ /** * @summary The Leading Root Component Types of TCGPlatformSpecification * @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_TCGPlatformSpecification = [ new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("platformClass", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined) ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_TCGPlatformSpecification */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_TCGPlatformSpecification */ /** * @summary The Trailing Root Component Types of TCGPlatformSpecification * @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_TCGPlatformSpecification = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_TCGPlatformSpecification */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_TCGPlatformSpecification */ /** * @summary The Extension Addition Component Types of TCGPlatformSpecification * @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_TCGPlatformSpecification = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_TCGPlatformSpecification */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_TCGPlatformSpecification */ let _cached_decoder_for_TCGPlatformSpecification = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_TCGPlatformSpecification */ /* START_OF_SYMBOL_DEFINITION _decode_TCGPlatformSpecification */ /** * @summary Decodes an ASN.1 element into a(n) TCGPlatformSpecification * @function * @param {_Element} el The element being decoded. * @returns {TCGPlatformSpecification} The decoded data structure. */ function _decode_TCGPlatformSpecification(el) { if (!_cached_decoder_for_TCGPlatformSpecification) { _cached_decoder_for_TCGPlatformSpecification = function (el) { const sequence = el.sequence; if (sequence.length < 2) { throw new asn1_ts_1.ASN1ConstructionError("TCGPlatformSpecification contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "version"; sequence[1].name = "platformClass"; let version; let platformClass; version = TCGSpecificationVersion_ta_1._decode_TCGSpecificationVersion(sequence[0]); platformClass = $._decodeOctetString(sequence[1]); return new TCGPlatformSpecification(version, platformClass); }; } return _cached_decoder_for_TCGPlatformSpecification(el); } exports._decode_TCGPlatformSpecification = _decode_TCGPlatformSpecification; /* END_OF_SYMBOL_DEFINITION _decode_TCGPlatformSpecification */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_TCGPlatformSpecification */ let _cached_encoder_for_TCGPlatformSpecification = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_TCGPlatformSpecification */ /* START_OF_SYMBOL_DEFINITION _encode_TCGPlatformSpecification */ /** * @summary Encodes a(n) TCGPlatformSpecification 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 TCGPlatformSpecification, encoded as an ASN.1 Element. */ function _encode_TCGPlatformSpecification(value, elGetter) { if (!_cached_encoder_for_TCGPlatformSpecification) { _cached_encoder_for_TCGPlatformSpecification = function (value, elGetter) { return $._encodeSequence([].concat([ /* REQUIRED */ TCGSpecificationVersion_ta_1._encode_TCGSpecificationVersion(value.version, $.BER), /* REQUIRED */ $._encodeOctetString(value.platformClass, $.BER) ]).filter((c) => (!!c)), $.BER); }; } return _cached_encoder_for_TCGPlatformSpecification(value, elGetter); } exports._encode_TCGPlatformSpecification = _encode_TCGPlatformSpecification; /* END_OF_SYMBOL_DEFINITION _encode_TCGPlatformSpecification */ /* eslint-enable */ //# sourceMappingURL=TCGPlatformSpecification.ta.js.map