@wildboar/pc
Version:
Trusted Computing Group Platform Certificate ASN.1 data structures in TypeScript
153 lines (152 loc) • 7 kB
JavaScript
/* eslint-disable */
import { ASN1TagClass as _TagClass, } from "@wildboar/asn1";
import * as $ from "@wildboar/asn1/functional";
import { _decode_ComponentIdentifier, _encode_ComponentIdentifier } from "../PlatformCertificateProfile/ComponentIdentifier.ta.mjs";
import { _decode_URIReference, _encode_URIReference } from "../PlatformCertificateProfile/URIReference.ta.mjs";
import { _decode_Properties, _encode_Properties } from "../PlatformCertificateProfile/Properties.ta.mjs";
/**
* @summary PlatformConfiguration
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* PlatformConfiguration ::= SEQUENCE {
* componentIdentifiers [0] IMPLICIT SEQUENCE (SIZE(1..MAX)) OF ComponentIdentifier OPTIONAL,
* componentIdentifiersUri [1] IMPLICIT URIReference OPTIONAL,
* platformProperties [2] IMPLICIT SEQUENCE (SIZE(1..MAX)) OF Properties OPTIONAL,
* platformPropertiesUri [3] IMPLICIT URIReference OPTIONAL }
* ```
*
*/
export class PlatformConfiguration {
componentIdentifiers;
componentIdentifiersUri;
platformProperties;
platformPropertiesUri;
constructor(
/**
* @summary `componentIdentifiers`.
* @public
* @readonly
*/
componentIdentifiers,
/**
* @summary `componentIdentifiersUri`.
* @public
* @readonly
*/
componentIdentifiersUri,
/**
* @summary `platformProperties`.
* @public
* @readonly
*/
platformProperties,
/**
* @summary `platformPropertiesUri`.
* @public
* @readonly
*/
platformPropertiesUri) {
this.componentIdentifiers = componentIdentifiers;
this.componentIdentifiersUri = componentIdentifiersUri;
this.platformProperties = platformProperties;
this.platformPropertiesUri = platformPropertiesUri;
}
/**
* @summary Restructures an object into a PlatformConfiguration
* @description
*
* This takes an `object` and converts it to a `PlatformConfiguration`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `PlatformConfiguration`.
* @returns {PlatformConfiguration}
*/
static _from_object(_o) {
return new PlatformConfiguration(_o.componentIdentifiers, _o.componentIdentifiersUri, _o.platformProperties, _o.platformPropertiesUri);
}
}
/**
* @summary The Leading Root Component Types of PlatformConfiguration
* @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_PlatformConfiguration = [
new $.ComponentSpec("componentIdentifiers", true, $.hasTag(_TagClass.context, 0)),
new $.ComponentSpec("componentIdentifiersUri", true, $.hasTag(_TagClass.context, 1)),
new $.ComponentSpec("platformProperties", true, $.hasTag(_TagClass.context, 2)),
new $.ComponentSpec("platformPropertiesUri", true, $.hasTag(_TagClass.context, 3))
];
/**
* @summary The Trailing Root Component Types of PlatformConfiguration
* @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_PlatformConfiguration = [];
/**
* @summary The Extension Addition Component Types of PlatformConfiguration
* @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_PlatformConfiguration = [];
let _cached_decoder_for_PlatformConfiguration = null;
/**
* @summary Decodes an ASN.1 element into a(n) PlatformConfiguration
* @function
* @param {_Element} el The element being decoded.
* @returns {PlatformConfiguration} The decoded data structure.
*/
export function _decode_PlatformConfiguration(el) {
if (!_cached_decoder_for_PlatformConfiguration) {
_cached_decoder_for_PlatformConfiguration = function (el) {
let componentIdentifiers;
let componentIdentifiersUri;
let platformProperties;
let platformPropertiesUri;
const callbacks = {
"componentIdentifiers": (_el) => { componentIdentifiers = $._decode_implicit(() => $._decodeSequenceOf(() => _decode_ComponentIdentifier))(_el); },
"componentIdentifiersUri": (_el) => { componentIdentifiersUri = $._decode_implicit(() => _decode_URIReference)(_el); },
"platformProperties": (_el) => { platformProperties = $._decode_implicit(() => $._decodeSequenceOf(() => _decode_Properties))(_el); },
"platformPropertiesUri": (_el) => { platformPropertiesUri = $._decode_implicit(() => _decode_URIReference)(_el); }
};
$._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_PlatformConfiguration, _extension_additions_list_spec_for_PlatformConfiguration, _root_component_type_list_2_spec_for_PlatformConfiguration, undefined);
return new PlatformConfiguration(componentIdentifiers, componentIdentifiersUri, platformProperties, platformPropertiesUri);
};
}
return _cached_decoder_for_PlatformConfiguration(el);
}
let _cached_encoder_for_PlatformConfiguration = null;
/**
* @summary Encodes a(n) PlatformConfiguration 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 PlatformConfiguration, encoded as an ASN.1 Element.
*/
export function _encode_PlatformConfiguration(value, elGetter) {
if (!_cached_encoder_for_PlatformConfiguration) {
_cached_encoder_for_PlatformConfiguration = function (value) {
return $._encodeSequence([].concat([
/* IF_ABSENT */ ((value.componentIdentifiers === undefined) ? undefined : $._encode_implicit(_TagClass.context, 0, () => $._encodeSequenceOf(() => _encode_ComponentIdentifier, $.DER), $.DER)(value.componentIdentifiers, $.DER)),
/* IF_ABSENT */ ((value.componentIdentifiersUri === undefined) ? undefined : $._encode_implicit(_TagClass.context, 1, () => _encode_URIReference, $.DER)(value.componentIdentifiersUri, $.DER)),
/* IF_ABSENT */ ((value.platformProperties === undefined) ? undefined : $._encode_implicit(_TagClass.context, 2, () => $._encodeSequenceOf(() => _encode_Properties, $.DER), $.DER)(value.platformProperties, $.DER)),
/* IF_ABSENT */ ((value.platformPropertiesUri === undefined) ? undefined : $._encode_implicit(_TagClass.context, 3, () => _encode_URIReference, $.DER)(value.platformPropertiesUri, $.DER))
]).filter((c) => (!!c)), $.DER);
};
}
return _cached_encoder_for_PlatformConfiguration(value, elGetter);
}
/* eslint-enable */