UNPKG

@wildboar/pc

Version:

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

299 lines 19.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_ComponentIdentifier = exports._decode_ComponentIdentifier = exports._extension_additions_list_spec_for_ComponentIdentifier = exports._root_component_type_list_2_spec_for_ComponentIdentifier = exports._root_component_type_list_1_spec_for_ComponentIdentifier = exports.ComponentIdentifier = exports._encode_AttributeStatus = exports._decode_AttributeStatus = exports.removed = exports.AttributeStatus_removed = exports.modified = exports.AttributeStatus_modified = exports.added = exports.AttributeStatus_added = exports._enum_for_AttributeStatus = exports.AttributeStatus = exports._encode_URIReference = exports._decode_URIReference = exports.URIReference = exports._encode_CertificateIdentifier = exports._decode_CertificateIdentifier = exports.CertificateIdentifier = exports._encode_ComponentAddress = exports._decode_ComponentAddress = exports.ComponentAddress = exports._encode_PrivateEnterpriseNumber = exports._decode_PrivateEnterpriseNumber = exports._encode_ComponentClass = exports._decode_ComponentClass = exports.ComponentClass = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const ComponentClass_ta_1 = require("../PlatformCertificateProfile/ComponentClass.ta"); var ComponentClass_ta_2 = require("../PlatformCertificateProfile/ComponentClass.ta"); Object.defineProperty(exports, "ComponentClass", { enumerable: true, get: function () { return ComponentClass_ta_2.ComponentClass; } }); Object.defineProperty(exports, "_decode_ComponentClass", { enumerable: true, get: function () { return ComponentClass_ta_2._decode_ComponentClass; } }); Object.defineProperty(exports, "_encode_ComponentClass", { enumerable: true, get: function () { return ComponentClass_ta_2._encode_ComponentClass; } }); const PrivateEnterpriseNumber_ta_1 = require("../PlatformCertificateProfile/PrivateEnterpriseNumber.ta"); var PrivateEnterpriseNumber_ta_2 = require("../PlatformCertificateProfile/PrivateEnterpriseNumber.ta"); Object.defineProperty(exports, "_decode_PrivateEnterpriseNumber", { enumerable: true, get: function () { return PrivateEnterpriseNumber_ta_2._decode_PrivateEnterpriseNumber; } }); Object.defineProperty(exports, "_encode_PrivateEnterpriseNumber", { enumerable: true, get: function () { return PrivateEnterpriseNumber_ta_2._encode_PrivateEnterpriseNumber; } }); const ComponentAddress_ta_1 = require("../PlatformCertificateProfile/ComponentAddress.ta"); var ComponentAddress_ta_2 = require("../PlatformCertificateProfile/ComponentAddress.ta"); Object.defineProperty(exports, "ComponentAddress", { enumerable: true, get: function () { return ComponentAddress_ta_2.ComponentAddress; } }); Object.defineProperty(exports, "_decode_ComponentAddress", { enumerable: true, get: function () { return ComponentAddress_ta_2._decode_ComponentAddress; } }); Object.defineProperty(exports, "_encode_ComponentAddress", { enumerable: true, get: function () { return ComponentAddress_ta_2._encode_ComponentAddress; } }); const CertificateIdentifier_ta_1 = require("../PlatformCertificateProfile/CertificateIdentifier.ta"); var CertificateIdentifier_ta_2 = require("../PlatformCertificateProfile/CertificateIdentifier.ta"); Object.defineProperty(exports, "CertificateIdentifier", { enumerable: true, get: function () { return CertificateIdentifier_ta_2.CertificateIdentifier; } }); Object.defineProperty(exports, "_decode_CertificateIdentifier", { enumerable: true, get: function () { return CertificateIdentifier_ta_2._decode_CertificateIdentifier; } }); Object.defineProperty(exports, "_encode_CertificateIdentifier", { enumerable: true, get: function () { return CertificateIdentifier_ta_2._encode_CertificateIdentifier; } }); const URIReference_ta_1 = require("../PlatformCertificateProfile/URIReference.ta"); var URIReference_ta_2 = require("../PlatformCertificateProfile/URIReference.ta"); Object.defineProperty(exports, "URIReference", { enumerable: true, get: function () { return URIReference_ta_2.URIReference; } }); Object.defineProperty(exports, "_decode_URIReference", { enumerable: true, get: function () { return URIReference_ta_2._decode_URIReference; } }); Object.defineProperty(exports, "_encode_URIReference", { enumerable: true, get: function () { return URIReference_ta_2._encode_URIReference; } }); const AttributeStatus_ta_1 = require("../PlatformCertificateProfile/AttributeStatus.ta"); var AttributeStatus_ta_2 = require("../PlatformCertificateProfile/AttributeStatus.ta"); Object.defineProperty(exports, "AttributeStatus", { enumerable: true, get: function () { return AttributeStatus_ta_2.AttributeStatus; } }); Object.defineProperty(exports, "_enum_for_AttributeStatus", { enumerable: true, get: function () { return AttributeStatus_ta_2._enum_for_AttributeStatus; } }); Object.defineProperty(exports, "AttributeStatus_added", { enumerable: true, get: function () { return AttributeStatus_ta_2.AttributeStatus_added; } }); /* IMPORTED_LONG_ENUMERATION_ITEM */ Object.defineProperty(exports, "added", { enumerable: true, get: function () { return AttributeStatus_ta_2.added; } }); /* IMPORTED_SHORT_ENUMERATION_ITEM */ Object.defineProperty(exports, "AttributeStatus_modified", { enumerable: true, get: function () { return AttributeStatus_ta_2.AttributeStatus_modified; } }); /* IMPORTED_LONG_ENUMERATION_ITEM */ Object.defineProperty(exports, "modified", { enumerable: true, get: function () { return AttributeStatus_ta_2.modified; } }); /* IMPORTED_SHORT_ENUMERATION_ITEM */ Object.defineProperty(exports, "AttributeStatus_removed", { enumerable: true, get: function () { return AttributeStatus_ta_2.AttributeStatus_removed; } }); /* IMPORTED_LONG_ENUMERATION_ITEM */ Object.defineProperty(exports, "removed", { enumerable: true, get: function () { return AttributeStatus_ta_2.removed; } }); /* IMPORTED_SHORT_ENUMERATION_ITEM */ Object.defineProperty(exports, "_decode_AttributeStatus", { enumerable: true, get: function () { return AttributeStatus_ta_2._decode_AttributeStatus; } }); Object.defineProperty(exports, "_encode_AttributeStatus", { enumerable: true, get: function () { return AttributeStatus_ta_2._encode_AttributeStatus; } }); /* START_OF_SYMBOL_DEFINITION ComponentIdentifier */ /** * @summary ComponentIdentifier * @description * * ### ASN.1 Definition: * * ```asn1 * ComponentIdentifier ::= SEQUENCE { * componentClass ComponentClass, * componentManufacturer UTF8String (SIZE (1..strmax)), * componentModel UTF8String (SIZE (1..strmax)), * componentSerial [0] IMPLICIT UTF8String (SIZE (1..strmax)) OPTIONAL, * componentRevision [1] IMPLICIT UTF8String (SIZE (1..strmax)) OPTIONAL, * componentManufacturerId [2] IMPLICIT PrivateEnterpriseNumber OPTIONAL, * fieldReplaceable [3] IMPLICIT BOOLEAN OPTIONAL, * componentAddresses [4] IMPLICIT SEQUENCE (SIZE(1..MAX)) OF ComponentAddress OPTIONAL, * componentPlatformCert [5] IMPLICIT CertificateIdentifier OPTIONAL, * componentPlatformCertUri [6] IMPLICIT URIReference OPTIONAL, * status [7] IMPLICIT AttributeStatus OPTIONAL } * ``` * * @class */ class ComponentIdentifier { constructor( /** * @summary `componentClass`. * @public * @readonly */ componentClass, /** * @summary `componentManufacturer`. * @public * @readonly */ componentManufacturer, /** * @summary `componentModel`. * @public * @readonly */ componentModel, /** * @summary `componentSerial`. * @public * @readonly */ componentSerial, /** * @summary `componentRevision`. * @public * @readonly */ componentRevision, /** * @summary `componentManufacturerId`. * @public * @readonly */ componentManufacturerId, /** * @summary `fieldReplaceable`. * @public * @readonly */ fieldReplaceable, /** * @summary `componentAddresses`. * @public * @readonly */ componentAddresses, /** * @summary `componentPlatformCert`. * @public * @readonly */ componentPlatformCert, /** * @summary `componentPlatformCertUri`. * @public * @readonly */ componentPlatformCertUri, /** * @summary `status`. * @public * @readonly */ status) { this.componentClass = componentClass; this.componentManufacturer = componentManufacturer; this.componentModel = componentModel; this.componentSerial = componentSerial; this.componentRevision = componentRevision; this.componentManufacturerId = componentManufacturerId; this.fieldReplaceable = fieldReplaceable; this.componentAddresses = componentAddresses; this.componentPlatformCert = componentPlatformCert; this.componentPlatformCertUri = componentPlatformCertUri; this.status = status; } /** * @summary Restructures an object into a ComponentIdentifier * @description * * This takes an `object` and converts it to a `ComponentIdentifier`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `ComponentIdentifier`. * @returns {ComponentIdentifier} */ static _from_object(_o) { return new ComponentIdentifier(_o.componentClass, _o.componentManufacturer, _o.componentModel, _o.componentSerial, _o.componentRevision, _o.componentManufacturerId, _o.fieldReplaceable, _o.componentAddresses, _o.componentPlatformCert, _o.componentPlatformCertUri, _o.status); } } exports.ComponentIdentifier = ComponentIdentifier; /** * @summary The enum used as the type of the component `status` * @public * @static */ ComponentIdentifier._enum_for_status = AttributeStatus_ta_1._enum_for_AttributeStatus; /* END_OF_SYMBOL_DEFINITION ComponentIdentifier */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_ComponentIdentifier */ /** * @summary The Leading Root Component Types of ComponentIdentifier * @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_ComponentIdentifier = [ new $.ComponentSpec("componentClass", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("componentManufacturer", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 12), undefined, undefined), new $.ComponentSpec("componentModel", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 12), undefined, undefined), new $.ComponentSpec("componentSerial", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), new $.ComponentSpec("componentRevision", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined), new $.ComponentSpec("componentManufacturerId", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 2), undefined, undefined), new $.ComponentSpec("fieldReplaceable", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 3), undefined, undefined), new $.ComponentSpec("componentAddresses", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 4), undefined, undefined), new $.ComponentSpec("componentPlatformCert", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 5), undefined, undefined), new $.ComponentSpec("componentPlatformCertUri", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 6), undefined, undefined), new $.ComponentSpec("status", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 7), undefined, undefined) ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_ComponentIdentifier */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_ComponentIdentifier */ /** * @summary The Trailing Root Component Types of ComponentIdentifier * @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_ComponentIdentifier = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_ComponentIdentifier */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_ComponentIdentifier */ /** * @summary The Extension Addition Component Types of ComponentIdentifier * @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_ComponentIdentifier = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_ComponentIdentifier */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_ComponentIdentifier */ let _cached_decoder_for_ComponentIdentifier = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_ComponentIdentifier */ /* START_OF_SYMBOL_DEFINITION _decode_ComponentIdentifier */ /** * @summary Decodes an ASN.1 element into a(n) ComponentIdentifier * @function * @param {_Element} el The element being decoded. * @returns {ComponentIdentifier} The decoded data structure. */ function _decode_ComponentIdentifier(el) { if (!_cached_decoder_for_ComponentIdentifier) { _cached_decoder_for_ComponentIdentifier = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let componentClass; let componentManufacturer; let componentModel; let componentSerial; let componentRevision; let componentManufacturerId; let fieldReplaceable; let componentAddresses; let componentPlatformCert; let componentPlatformCertUri; let status; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { "componentClass": (_el) => { componentClass = ComponentClass_ta_1._decode_ComponentClass(_el); }, "componentManufacturer": (_el) => { componentManufacturer = $._decodeUTF8String(_el); }, "componentModel": (_el) => { componentModel = $._decodeUTF8String(_el); }, "componentSerial": (_el) => { componentSerial = $._decode_implicit(() => $._decodeUTF8String)(_el); }, "componentRevision": (_el) => { componentRevision = $._decode_implicit(() => $._decodeUTF8String)(_el); }, "componentManufacturerId": (_el) => { componentManufacturerId = $._decode_implicit(() => PrivateEnterpriseNumber_ta_1._decode_PrivateEnterpriseNumber)(_el); }, "fieldReplaceable": (_el) => { fieldReplaceable = $._decode_implicit(() => $._decodeBoolean)(_el); }, "componentAddresses": (_el) => { componentAddresses = $._decode_implicit(() => $._decodeSequenceOf(() => ComponentAddress_ta_1._decode_ComponentAddress))(_el); }, "componentPlatformCert": (_el) => { componentPlatformCert = $._decode_implicit(() => CertificateIdentifier_ta_1._decode_CertificateIdentifier)(_el); }, "componentPlatformCertUri": (_el) => { componentPlatformCertUri = $._decode_implicit(() => URIReference_ta_1._decode_URIReference)(_el); }, "status": (_el) => { status = $._decode_implicit(() => AttributeStatus_ta_1._decode_AttributeStatus)(_el); } }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_ComponentIdentifier, exports._extension_additions_list_spec_for_ComponentIdentifier, exports._root_component_type_list_2_spec_for_ComponentIdentifier, undefined); return new ComponentIdentifier(/* SEQUENCE_CONSTRUCTOR_CALL */ componentClass, componentManufacturer, componentModel, componentSerial, componentRevision, componentManufacturerId, fieldReplaceable, componentAddresses, componentPlatformCert, componentPlatformCertUri, status); }; } return _cached_decoder_for_ComponentIdentifier(el); } exports._decode_ComponentIdentifier = _decode_ComponentIdentifier; /* END_OF_SYMBOL_DEFINITION _decode_ComponentIdentifier */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_ComponentIdentifier */ let _cached_encoder_for_ComponentIdentifier = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_ComponentIdentifier */ /* START_OF_SYMBOL_DEFINITION _encode_ComponentIdentifier */ /** * @summary Encodes a(n) ComponentIdentifier 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 ComponentIdentifier, encoded as an ASN.1 Element. */ function _encode_ComponentIdentifier(value, elGetter) { if (!_cached_encoder_for_ComponentIdentifier) { _cached_encoder_for_ComponentIdentifier = function (value, elGetter) { return $._encodeSequence([].concat([ /* REQUIRED */ ComponentClass_ta_1._encode_ComponentClass(value.componentClass, $.BER), /* REQUIRED */ $._encodeUTF8String(value.componentManufacturer, $.BER), /* REQUIRED */ $._encodeUTF8String(value.componentModel, $.BER), /* IF_ABSENT */ ((value.componentSerial === undefined) ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => $._encodeUTF8String, $.BER)(value.componentSerial, $.BER)), /* IF_ABSENT */ ((value.componentRevision === undefined) ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => $._encodeUTF8String, $.BER)(value.componentRevision, $.BER)), /* IF_ABSENT */ ((value.componentManufacturerId === undefined) ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 2, () => PrivateEnterpriseNumber_ta_1._encode_PrivateEnterpriseNumber, $.BER)(value.componentManufacturerId, $.BER)), /* IF_ABSENT */ ((value.fieldReplaceable === undefined) ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 3, () => $._encodeBoolean, $.BER)(value.fieldReplaceable, $.BER)), /* IF_ABSENT */ ((value.componentAddresses === undefined) ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 4, () => $._encodeSequenceOf(() => ComponentAddress_ta_1._encode_ComponentAddress, $.BER), $.BER)(value.componentAddresses, $.BER)), /* IF_ABSENT */ ((value.componentPlatformCert === undefined) ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 5, () => CertificateIdentifier_ta_1._encode_CertificateIdentifier, $.BER)(value.componentPlatformCert, $.BER)), /* IF_ABSENT */ ((value.componentPlatformCertUri === undefined) ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 6, () => URIReference_ta_1._encode_URIReference, $.BER)(value.componentPlatformCertUri, $.BER)), /* IF_ABSENT */ ((value.status === undefined) ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 7, () => AttributeStatus_ta_1._encode_AttributeStatus, $.BER)(value.status, $.BER)) ]).filter((c) => (!!c)), $.BER); }; } return _cached_encoder_for_ComponentIdentifier(value, elGetter); } exports._encode_ComponentIdentifier = _encode_ComponentIdentifier; /* END_OF_SYMBOL_DEFINITION _encode_ComponentIdentifier */ /* eslint-enable */ //# sourceMappingURL=ComponentIdentifier.ta.js.map