@wildboar/pc
Version:
Trusted Computing Group Platform Certificate ASN.1 data structures in TypeScript
187 lines • 9.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_FIPSLevel = exports._decode_FIPSLevel = exports._extension_additions_list_spec_for_FIPSLevel = exports._root_component_type_list_2_spec_for_FIPSLevel = exports._root_component_type_list_1_spec_for_FIPSLevel = exports.FIPSLevel = exports._encode_SecurityLevel = exports._decode_SecurityLevel = exports.level4 = exports.SecurityLevel_level4 = exports.level3 = exports.SecurityLevel_level3 = exports.level2 = exports.SecurityLevel_level2 = exports.level1 = exports.SecurityLevel_level1 = exports._enum_for_SecurityLevel = exports.SecurityLevel = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const SecurityLevel_ta_1 = require("../PlatformCertificateProfile/SecurityLevel.ta");
var SecurityLevel_ta_2 = require("../PlatformCertificateProfile/SecurityLevel.ta");
Object.defineProperty(exports, "SecurityLevel", { enumerable: true, get: function () { return SecurityLevel_ta_2.SecurityLevel; } });
Object.defineProperty(exports, "_enum_for_SecurityLevel", { enumerable: true, get: function () { return SecurityLevel_ta_2._enum_for_SecurityLevel; } });
Object.defineProperty(exports, "SecurityLevel_level1", { enumerable: true, get: function () { return SecurityLevel_ta_2.SecurityLevel_level1; } }); /* IMPORTED_LONG_ENUMERATION_ITEM */
Object.defineProperty(exports, "level1", { enumerable: true, get: function () { return SecurityLevel_ta_2.level1; } }); /* IMPORTED_SHORT_ENUMERATION_ITEM */
Object.defineProperty(exports, "SecurityLevel_level2", { enumerable: true, get: function () { return SecurityLevel_ta_2.SecurityLevel_level2; } }); /* IMPORTED_LONG_ENUMERATION_ITEM */
Object.defineProperty(exports, "level2", { enumerable: true, get: function () { return SecurityLevel_ta_2.level2; } }); /* IMPORTED_SHORT_ENUMERATION_ITEM */
Object.defineProperty(exports, "SecurityLevel_level3", { enumerable: true, get: function () { return SecurityLevel_ta_2.SecurityLevel_level3; } }); /* IMPORTED_LONG_ENUMERATION_ITEM */
Object.defineProperty(exports, "level3", { enumerable: true, get: function () { return SecurityLevel_ta_2.level3; } }); /* IMPORTED_SHORT_ENUMERATION_ITEM */
Object.defineProperty(exports, "SecurityLevel_level4", { enumerable: true, get: function () { return SecurityLevel_ta_2.SecurityLevel_level4; } }); /* IMPORTED_LONG_ENUMERATION_ITEM */
Object.defineProperty(exports, "level4", { enumerable: true, get: function () { return SecurityLevel_ta_2.level4; } }); /* IMPORTED_SHORT_ENUMERATION_ITEM */
Object.defineProperty(exports, "_decode_SecurityLevel", { enumerable: true, get: function () { return SecurityLevel_ta_2._decode_SecurityLevel; } });
Object.defineProperty(exports, "_encode_SecurityLevel", { enumerable: true, get: function () { return SecurityLevel_ta_2._encode_SecurityLevel; } });
/* START_OF_SYMBOL_DEFINITION FIPSLevel */
/**
* @summary FIPSLevel
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* FIPSLevel ::= SEQUENCE {
* version IA5String (SIZE (1..strmax)), -- “140-1”, “140-2”, or “140-3”
* level SecurityLevel,
* plus BOOLEAN DEFAULT FALSE }
* ```
*
* @class
*/
class FIPSLevel {
constructor(
/**
* @summary `version`.
* @public
* @readonly
*/
version,
/**
* @summary `level`.
* @public
* @readonly
*/
level,
/**
* @summary `plus`.
* @public
* @readonly
*/
plus) {
this.version = version;
this.level = level;
this.plus = plus;
}
/**
* @summary Restructures an object into a FIPSLevel
* @description
*
* This takes an `object` and converts it to a `FIPSLevel`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `FIPSLevel`.
* @returns {FIPSLevel}
*/
static _from_object(_o) {
return new FIPSLevel(_o.version, _o.level, _o.plus);
}
/**
* @summary Getter that returns the default value for `plus`.
* @public
* @static
* @method
*/
static get _default_value_for_plus() { return false; } /**
* @summary The enum used as the type of the component `level`
* @public
* @static
*/
}
exports.FIPSLevel = FIPSLevel;
FIPSLevel._enum_for_level = SecurityLevel_ta_1._enum_for_SecurityLevel;
/* END_OF_SYMBOL_DEFINITION FIPSLevel */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_FIPSLevel */
/**
* @summary The Leading Root Component Types of FIPSLevel
* @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_FIPSLevel = [
new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 22), undefined, undefined),
new $.ComponentSpec("level", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 10), undefined, undefined),
new $.ComponentSpec("plus", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 1), undefined, undefined)
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_FIPSLevel */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_FIPSLevel */
/**
* @summary The Trailing Root Component Types of FIPSLevel
* @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_FIPSLevel = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_FIPSLevel */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_FIPSLevel */
/**
* @summary The Extension Addition Component Types of FIPSLevel
* @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_FIPSLevel = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_FIPSLevel */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_FIPSLevel */
let _cached_decoder_for_FIPSLevel = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_FIPSLevel */
/* START_OF_SYMBOL_DEFINITION _decode_FIPSLevel */
/**
* @summary Decodes an ASN.1 element into a(n) FIPSLevel
* @function
* @param {_Element} el The element being decoded.
* @returns {FIPSLevel} The decoded data structure.
*/
function _decode_FIPSLevel(el) {
if (!_cached_decoder_for_FIPSLevel) {
_cached_decoder_for_FIPSLevel = function (el) {
/* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */
let version;
let level;
let plus = FIPSLevel._default_value_for_plus;
/* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */
/* START_OF_CALLBACKS_MAP */
const callbacks = {
"version": (_el) => { version = $._decodeIA5String(_el); },
"level": (_el) => { level = SecurityLevel_ta_1._decode_SecurityLevel(_el); },
"plus": (_el) => { plus = $._decodeBoolean(_el); }
};
/* END_OF_CALLBACKS_MAP */
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_FIPSLevel, exports._extension_additions_list_spec_for_FIPSLevel, exports._root_component_type_list_2_spec_for_FIPSLevel, undefined);
return new FIPSLevel(/* SEQUENCE_CONSTRUCTOR_CALL */ version, level, plus);
};
}
return _cached_decoder_for_FIPSLevel(el);
}
exports._decode_FIPSLevel = _decode_FIPSLevel;
/* END_OF_SYMBOL_DEFINITION _decode_FIPSLevel */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_FIPSLevel */
let _cached_encoder_for_FIPSLevel = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_FIPSLevel */
/* START_OF_SYMBOL_DEFINITION _encode_FIPSLevel */
/**
* @summary Encodes a(n) FIPSLevel 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 FIPSLevel, encoded as an ASN.1 Element.
*/
function _encode_FIPSLevel(value, elGetter) {
if (!_cached_encoder_for_FIPSLevel) {
_cached_encoder_for_FIPSLevel = function (value, elGetter) {
return $._encodeSequence([].concat([
/* REQUIRED */ $._encodeIA5String(value.version, $.BER),
/* REQUIRED */ SecurityLevel_ta_1._encode_SecurityLevel(value.level, $.BER),
/* IF_DEFAULT */ (value.plus === undefined || $.deepEq(value.plus, FIPSLevel._default_value_for_plus) ? undefined : $._encodeBoolean(value.plus, $.BER))
]).filter((c) => (!!c)), $.BER);
};
}
return _cached_encoder_for_FIPSLevel(value, elGetter);
}
exports._encode_FIPSLevel = _encode_FIPSLevel;
/* END_OF_SYMBOL_DEFINITION _encode_FIPSLevel */
/* eslint-enable */
//# sourceMappingURL=FIPSLevel.ta.js.map