@wildboar/pc
Version:
Trusted Computing Group Platform Certificate ASN.1 data structures in TypeScript
161 lines • 6.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_TCGSpecificationVersion = exports._decode_TCGSpecificationVersion = exports._extension_additions_list_spec_for_TCGSpecificationVersion = exports._root_component_type_list_2_spec_for_TCGSpecificationVersion = exports._root_component_type_list_1_spec_for_TCGSpecificationVersion = exports.TCGSpecificationVersion = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
/* START_OF_SYMBOL_DEFINITION TCGSpecificationVersion */
/**
* @summary TCGSpecificationVersion
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* TCGSpecificationVersion ::= SEQUENCE {
* majorVersion INTEGER,
* minorVersion INTEGER,
* revision INTEGER }
* ```
*
* @class
*/
class TCGSpecificationVersion {
constructor(
/**
* @summary `majorVersion`.
* @public
* @readonly
*/
majorVersion,
/**
* @summary `minorVersion`.
* @public
* @readonly
*/
minorVersion,
/**
* @summary `revision`.
* @public
* @readonly
*/
revision) {
this.majorVersion = majorVersion;
this.minorVersion = minorVersion;
this.revision = revision;
}
/**
* @summary Restructures an object into a TCGSpecificationVersion
* @description
*
* This takes an `object` and converts it to a `TCGSpecificationVersion`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `TCGSpecificationVersion`.
* @returns {TCGSpecificationVersion}
*/
static _from_object(_o) {
return new TCGSpecificationVersion(_o.majorVersion, _o.minorVersion, _o.revision);
}
}
exports.TCGSpecificationVersion = TCGSpecificationVersion;
/* END_OF_SYMBOL_DEFINITION TCGSpecificationVersion */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_TCGSpecificationVersion */
/**
* @summary The Leading Root Component Types of TCGSpecificationVersion
* @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_TCGSpecificationVersion = [
new $.ComponentSpec("majorVersion", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("minorVersion", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("revision", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined)
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_TCGSpecificationVersion */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_TCGSpecificationVersion */
/**
* @summary The Trailing Root Component Types of TCGSpecificationVersion
* @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_TCGSpecificationVersion = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_TCGSpecificationVersion */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_TCGSpecificationVersion */
/**
* @summary The Extension Addition Component Types of TCGSpecificationVersion
* @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_TCGSpecificationVersion = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_TCGSpecificationVersion */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_TCGSpecificationVersion */
let _cached_decoder_for_TCGSpecificationVersion = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_TCGSpecificationVersion */
/* START_OF_SYMBOL_DEFINITION _decode_TCGSpecificationVersion */
/**
* @summary Decodes an ASN.1 element into a(n) TCGSpecificationVersion
* @function
* @param {_Element} el The element being decoded.
* @returns {TCGSpecificationVersion} The decoded data structure.
*/
function _decode_TCGSpecificationVersion(el) {
if (!_cached_decoder_for_TCGSpecificationVersion) {
_cached_decoder_for_TCGSpecificationVersion = function (el) {
const sequence = el.sequence;
if (sequence.length < 3) {
throw new asn1_ts_1.ASN1ConstructionError("TCGSpecificationVersion contained only " + sequence.length.toString() + " elements.");
}
sequence[0].name = "majorVersion";
sequence[1].name = "minorVersion";
sequence[2].name = "revision";
let majorVersion;
let minorVersion;
let revision;
majorVersion = $._decodeInteger(sequence[0]);
minorVersion = $._decodeInteger(sequence[1]);
revision = $._decodeInteger(sequence[2]);
return new TCGSpecificationVersion(majorVersion, minorVersion, revision);
};
}
return _cached_decoder_for_TCGSpecificationVersion(el);
}
exports._decode_TCGSpecificationVersion = _decode_TCGSpecificationVersion;
/* END_OF_SYMBOL_DEFINITION _decode_TCGSpecificationVersion */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_TCGSpecificationVersion */
let _cached_encoder_for_TCGSpecificationVersion = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_TCGSpecificationVersion */
/* START_OF_SYMBOL_DEFINITION _encode_TCGSpecificationVersion */
/**
* @summary Encodes a(n) TCGSpecificationVersion 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 TCGSpecificationVersion, encoded as an ASN.1 Element.
*/
function _encode_TCGSpecificationVersion(value, elGetter) {
if (!_cached_encoder_for_TCGSpecificationVersion) {
_cached_encoder_for_TCGSpecificationVersion = function (value, elGetter) {
return $._encodeSequence([].concat([
/* REQUIRED */ $._encodeInteger(value.majorVersion, $.BER),
/* REQUIRED */ $._encodeInteger(value.minorVersion, $.BER),
/* REQUIRED */ $._encodeInteger(value.revision, $.BER)
]).filter((c) => (!!c)), $.BER);
};
}
return _cached_encoder_for_TCGSpecificationVersion(value, elGetter);
}
exports._encode_TCGSpecificationVersion = _encode_TCGSpecificationVersion;
/* END_OF_SYMBOL_DEFINITION _encode_TCGSpecificationVersion */
/* eslint-enable */
//# sourceMappingURL=TCGSpecificationVersion.ta.js.map