UNPKG

@wildboar/pc

Version:

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

200 lines (199 loc) 8.25 kB
/* eslint-disable */ import { ASN1TagClass as _TagClass, ASN1UniversalType as _UniversalType, } from "@wildboar/asn1"; import * as $ from "@wildboar/asn1/functional"; import { _decode_CommonCriteriaMeasures, _encode_CommonCriteriaMeasures } from "../PlatformCertificateProfile/CommonCriteriaMeasures.ta.mjs"; import { _decode_FIPSLevel, _encode_FIPSLevel } from "../PlatformCertificateProfile/FIPSLevel.ta.mjs"; import { _enum_for_MeasurementRootType, _decode_MeasurementRootType, _encode_MeasurementRootType } from "../PlatformCertificateProfile/MeasurementRootType.ta.mjs"; import { _decode_Version, _encode_Version, v1, } from "./Version.ta.mjs"; /** * @summary TBBSecurityAssertions * @description * * ### ASN.1 Definition: * * ```asn1 * TBBSecurityAssertions ::= SEQUENCE { * version Version DEFAULT v1, * ccInfo [0] IMPLICIT CommonCriteriaMeasures OPTIONAL, * fipsLevel [1] IMPLICIT FIPSLevel OPTIONAL, * rtmType [2] IMPLICIT MeasurementRootType OPTIONAL, * iso9000Certified BOOLEAN DEFAULT FALSE, * iso9000Uri IA5String (SIZE (1..urimax)) OPTIONAL } * ``` * */ export class TBBSecurityAssertions { version; ccInfo; fipsLevel; rtmType; iso9000Certified; iso9000Uri; constructor( /** * @summary `version`. * @public * @readonly */ version, /** * @summary `ccInfo`. * @public * @readonly */ ccInfo, /** * @summary `fipsLevel`. * @public * @readonly */ fipsLevel, /** * @summary `rtmType`. * @public * @readonly */ rtmType, /** * @summary `iso9000Certified`. * @public * @readonly */ iso9000Certified, /** * @summary `iso9000Uri`. * @public * @readonly */ iso9000Uri) { this.version = version; this.ccInfo = ccInfo; this.fipsLevel = fipsLevel; this.rtmType = rtmType; this.iso9000Certified = iso9000Certified; this.iso9000Uri = iso9000Uri; } /** * @summary Restructures an object into a TBBSecurityAssertions * @description * * This takes an `object` and converts it to a `TBBSecurityAssertions`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `TBBSecurityAssertions`. * @returns {TBBSecurityAssertions} */ static _from_object(_o) { return new TBBSecurityAssertions(_o.version, _o.ccInfo, _o.fipsLevel, _o.rtmType, _o.iso9000Certified, _o.iso9000Uri); } /** * @summary Getter that returns the default value for `version`. * @public * @static * @method */ static get _default_value_for_version() { return v1; } /** * @summary Getter that returns the default value for `iso9000Certified`. * @public * @static * @method */ static get _default_value_for_iso9000Certified() { return false; } /** * @summary The enum used as the type of the component `rtmType` * @public * @static */ static _enum_for_rtmType = _enum_for_MeasurementRootType; } /** * @summary The Leading Root Component Types of TBBSecurityAssertions * @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 */ export const _root_component_type_list_1_spec_for_TBBSecurityAssertions = [ new $.ComponentSpec("version", true, $.hasTag(_TagClass.universal, _UniversalType.integer)), new $.ComponentSpec("ccInfo", true, $.hasTag(_TagClass.context, 0)), new $.ComponentSpec("fipsLevel", true, $.hasTag(_TagClass.context, 1)), new $.ComponentSpec("rtmType", true, $.hasTag(_TagClass.context, 2)), new $.ComponentSpec("iso9000Certified", true, $.hasTag(_TagClass.universal, 1)), new $.ComponentSpec("iso9000Uri", true, $.hasTag(_TagClass.universal, 22)) ]; /** * @summary The Trailing Root Component Types of TBBSecurityAssertions * @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 */ export const _root_component_type_list_2_spec_for_TBBSecurityAssertions = []; /** * @summary The Extension Addition Component Types of TBBSecurityAssertions * @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 */ export const _extension_additions_list_spec_for_TBBSecurityAssertions = []; let _cached_decoder_for_TBBSecurityAssertions = null; /** * @summary Decodes an ASN.1 element into a(n) TBBSecurityAssertions * @function * @param {_Element} el The element being decoded. * @returns {TBBSecurityAssertions} The decoded data structure. */ export function _decode_TBBSecurityAssertions(el) { if (!_cached_decoder_for_TBBSecurityAssertions) { _cached_decoder_for_TBBSecurityAssertions = function (el) { let version = TBBSecurityAssertions._default_value_for_version; let ccInfo; let fipsLevel; let rtmType; let iso9000Certified = TBBSecurityAssertions._default_value_for_iso9000Certified; let iso9000Uri; const callbacks = { "version": (_el) => { version = _decode_Version(_el); }, "ccInfo": (_el) => { ccInfo = $._decode_implicit(() => _decode_CommonCriteriaMeasures)(_el); }, "fipsLevel": (_el) => { fipsLevel = $._decode_implicit(() => _decode_FIPSLevel)(_el); }, "rtmType": (_el) => { rtmType = $._decode_implicit(() => _decode_MeasurementRootType)(_el); }, "iso9000Certified": (_el) => { iso9000Certified = $._decodeBoolean(_el); }, "iso9000Uri": (_el) => { iso9000Uri = $._decodeIA5String(_el); } }; $._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_TBBSecurityAssertions, _extension_additions_list_spec_for_TBBSecurityAssertions, _root_component_type_list_2_spec_for_TBBSecurityAssertions, undefined); return new TBBSecurityAssertions(version, ccInfo, fipsLevel, rtmType, iso9000Certified, iso9000Uri); }; } return _cached_decoder_for_TBBSecurityAssertions(el); } let _cached_encoder_for_TBBSecurityAssertions = null; /** * @summary Encodes a(n) TBBSecurityAssertions into an ASN.1 Element. * @function * @param value The element being encoded. * @param elGetter A function that can be used to get new ASN.1 elements. * @returns {_Element} The TBBSecurityAssertions, encoded as an ASN.1 Element. */ export function _encode_TBBSecurityAssertions(value, elGetter) { if (!_cached_encoder_for_TBBSecurityAssertions) { _cached_encoder_for_TBBSecurityAssertions = function (value) { return $._encodeSequence([].concat([ /* IF_DEFAULT */ (value.version === undefined || $.deepEq(value.version, TBBSecurityAssertions._default_value_for_version) ? undefined : _encode_Version(value.version, $.DER)), /* IF_ABSENT */ ((value.ccInfo === undefined) ? undefined : $._encode_implicit(_TagClass.context, 0, () => _encode_CommonCriteriaMeasures, $.DER)(value.ccInfo, $.DER)), /* IF_ABSENT */ ((value.fipsLevel === undefined) ? undefined : $._encode_implicit(_TagClass.context, 1, () => _encode_FIPSLevel, $.DER)(value.fipsLevel, $.DER)), /* IF_ABSENT */ ((value.rtmType === undefined) ? undefined : $._encode_implicit(_TagClass.context, 2, () => _encode_MeasurementRootType, $.DER)(value.rtmType, $.DER)), /* IF_DEFAULT */ (value.iso9000Certified === undefined || $.deepEq(value.iso9000Certified, TBBSecurityAssertions._default_value_for_iso9000Certified) ? undefined : $._encodeBoolean(value.iso9000Certified, $.DER)), /* IF_ABSENT */ ((value.iso9000Uri === undefined) ? undefined : $._encodeIA5String(value.iso9000Uri, $.DER)) ]).filter((c) => (!!c)), $.DER); }; } return _cached_encoder_for_TBBSecurityAssertions(value, elGetter); } /* eslint-enable */