@wildboar/pc
Version:
Trusted Computing Group Platform Certificate ASN.1 data structures in TypeScript
238 lines (237 loc) • 10.1 kB
JavaScript
/* eslint-disable */
import { ASN1TagClass as _TagClass, } from "@wildboar/asn1";
import * as $ from "@wildboar/asn1/functional";
import { _enum_for_EvaluationAssuranceLevel, _decode_EvaluationAssuranceLevel, _encode_EvaluationAssuranceLevel } from "../PlatformCertificateProfile/EvaluationAssuranceLevel.ta.mjs";
import { _enum_for_StrengthOfFunction, _decode_StrengthOfFunction, _encode_StrengthOfFunction } from "../PlatformCertificateProfile/StrengthOfFunction.ta.mjs";
import { _decode_URIReference, _encode_URIReference } from "../PlatformCertificateProfile/URIReference.ta.mjs";
import { _decode_EvaluationStatus, _encode_EvaluationStatus, } from "./EvaluationStatus.ta.mjs";
/**
* @summary CommonCriteriaMeasures
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* CommonCriteriaMeasures ::= SEQUENCE {
* version IA5String (SIZE (1..strmax)), -- “2.2” or “3.1”; future syntax defined by CC
* assurancelevel EvaluationAssuranceLevel,
* evaluationStatus EvalutionStatus,
* plus BOOLEAN DEFAULT FALSE,
* strengthOfFunction [0] IMPLICIT StrengthOfFunction OPTIONAL,
* profileOid [1] IMPLICIT OBJECT IDENTIFIER OPTIONAL,
* profileUri [2] IMPLICIT URIReference OPTIONAL,
* targetOid [3] IMPLICIT OBJECT IDENTIFIER OPTIONAL,
* targetUri [4] IMPLICIT URIReference OPTIONAL }
* ```
*
*/
export class CommonCriteriaMeasures {
version;
assurancelevel;
evaluationStatus;
plus;
strengthOfFunction;
profileOid;
profileUri;
targetOid;
targetUri;
constructor(
/**
* @summary `version`.
* @public
* @readonly
*/
version,
/**
* @summary `assurancelevel`.
* @public
* @readonly
*/
assurancelevel,
/**
* @summary `evaluationStatus`.
* @public
* @readonly
*/
evaluationStatus,
/**
* @summary `plus`.
* @public
* @readonly
*/
plus,
/**
* @summary `strengthOfFunction`.
* @public
* @readonly
*/
strengthOfFunction,
/**
* @summary `profileOid`.
* @public
* @readonly
*/
profileOid,
/**
* @summary `profileUri`.
* @public
* @readonly
*/
profileUri,
/**
* @summary `targetOid`.
* @public
* @readonly
*/
targetOid,
/**
* @summary `targetUri`.
* @public
* @readonly
*/
targetUri) {
this.version = version;
this.assurancelevel = assurancelevel;
this.evaluationStatus = evaluationStatus;
this.plus = plus;
this.strengthOfFunction = strengthOfFunction;
this.profileOid = profileOid;
this.profileUri = profileUri;
this.targetOid = targetOid;
this.targetUri = targetUri;
}
/**
* @summary Restructures an object into a CommonCriteriaMeasures
* @description
*
* This takes an `object` and converts it to a `CommonCriteriaMeasures`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `CommonCriteriaMeasures`.
* @returns {CommonCriteriaMeasures}
*/
static _from_object(_o) {
return new CommonCriteriaMeasures(_o.version, _o.assurancelevel, _o.evaluationStatus, _o.plus, _o.strengthOfFunction, _o.profileOid, _o.profileUri, _o.targetOid, _o.targetUri);
}
/**
* @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 `assurancelevel`
* @public
* @static
*/
static _enum_for_assurancelevel = _enum_for_EvaluationAssuranceLevel;
/**
* @summary The enum used as the type of the component `strengthOfFunction`
* @public
* @static
*/
static _enum_for_strengthOfFunction = _enum_for_StrengthOfFunction;
}
/**
* @summary The Leading Root Component Types of CommonCriteriaMeasures
* @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_CommonCriteriaMeasures = [
new $.ComponentSpec("version", false, $.hasTag(_TagClass.universal, 22)),
new $.ComponentSpec("assurancelevel", false, $.hasTag(_TagClass.universal, 10)),
new $.ComponentSpec("evaluationStatus", false, $.hasTag(_TagClass.universal, 10)),
new $.ComponentSpec("plus", true, $.hasTag(_TagClass.universal, 1)),
new $.ComponentSpec("strengthOfFunction", true, $.hasTag(_TagClass.context, 0)),
new $.ComponentSpec("profileOid", true, $.hasTag(_TagClass.context, 1)),
new $.ComponentSpec("profileUri", true, $.hasTag(_TagClass.context, 2)),
new $.ComponentSpec("targetOid", true, $.hasTag(_TagClass.context, 3)),
new $.ComponentSpec("targetUri", true, $.hasTag(_TagClass.context, 4))
];
/**
* @summary The Trailing Root Component Types of CommonCriteriaMeasures
* @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_CommonCriteriaMeasures = [];
/**
* @summary The Extension Addition Component Types of CommonCriteriaMeasures
* @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_CommonCriteriaMeasures = [];
let _cached_decoder_for_CommonCriteriaMeasures = null;
/**
* @summary Decodes an ASN.1 element into a(n) CommonCriteriaMeasures
* @function
* @param {_Element} el The element being decoded.
* @returns {CommonCriteriaMeasures} The decoded data structure.
*/
export function _decode_CommonCriteriaMeasures(el) {
if (!_cached_decoder_for_CommonCriteriaMeasures) {
_cached_decoder_for_CommonCriteriaMeasures = function (el) {
let version;
let assurancelevel;
let evaluationStatus;
let plus = CommonCriteriaMeasures._default_value_for_plus;
let strengthOfFunction;
let profileOid;
let profileUri;
let targetOid;
let targetUri;
const callbacks = {
"version": (_el) => { version = $._decodeIA5String(_el); },
"assurancelevel": (_el) => { assurancelevel = _decode_EvaluationAssuranceLevel(_el); },
"evaluationStatus": (_el) => { evaluationStatus = _decode_EvaluationStatus(_el); },
"plus": (_el) => { plus = $._decodeBoolean(_el); },
"strengthOfFunction": (_el) => { strengthOfFunction = $._decode_implicit(() => _decode_StrengthOfFunction)(_el); },
"profileOid": (_el) => { profileOid = $._decode_implicit(() => $._decodeObjectIdentifier)(_el); },
"profileUri": (_el) => { profileUri = $._decode_implicit(() => _decode_URIReference)(_el); },
"targetOid": (_el) => { targetOid = $._decode_implicit(() => $._decodeObjectIdentifier)(_el); },
"targetUri": (_el) => { targetUri = $._decode_implicit(() => _decode_URIReference)(_el); }
};
$._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_CommonCriteriaMeasures, _extension_additions_list_spec_for_CommonCriteriaMeasures, _root_component_type_list_2_spec_for_CommonCriteriaMeasures, undefined);
return new CommonCriteriaMeasures(version, assurancelevel, evaluationStatus, plus, strengthOfFunction, profileOid, profileUri, targetOid, targetUri);
};
}
return _cached_decoder_for_CommonCriteriaMeasures(el);
}
let _cached_encoder_for_CommonCriteriaMeasures = null;
/**
* @summary Encodes a(n) CommonCriteriaMeasures 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 CommonCriteriaMeasures, encoded as an ASN.1 Element.
*/
export function _encode_CommonCriteriaMeasures(value, elGetter) {
if (!_cached_encoder_for_CommonCriteriaMeasures) {
_cached_encoder_for_CommonCriteriaMeasures = function (value) {
return $._encodeSequence([].concat([
/* REQUIRED */ $._encodeIA5String(value.version, $.DER),
/* REQUIRED */ _encode_EvaluationAssuranceLevel(value.assurancelevel, $.DER),
/* REQUIRED */ _encode_EvaluationStatus(value.evaluationStatus, $.DER),
/* IF_DEFAULT */ (value.plus === undefined || $.deepEq(value.plus, CommonCriteriaMeasures._default_value_for_plus) ? undefined : $._encodeBoolean(value.plus, $.DER)),
/* IF_ABSENT */ ((value.strengthOfFunction === undefined) ? undefined : $._encode_implicit(_TagClass.context, 0, () => _encode_StrengthOfFunction, $.DER)(value.strengthOfFunction, $.DER)),
/* IF_ABSENT */ ((value.profileOid === undefined) ? undefined : $._encode_implicit(_TagClass.context, 1, () => $._encodeObjectIdentifier, $.DER)(value.profileOid, $.DER)),
/* IF_ABSENT */ ((value.profileUri === undefined) ? undefined : $._encode_implicit(_TagClass.context, 2, () => _encode_URIReference, $.DER)(value.profileUri, $.DER)),
/* IF_ABSENT */ ((value.targetOid === undefined) ? undefined : $._encode_implicit(_TagClass.context, 3, () => $._encodeObjectIdentifier, $.DER)(value.targetOid, $.DER)),
/* IF_ABSENT */ ((value.targetUri === undefined) ? undefined : $._encode_implicit(_TagClass.context, 4, () => _encode_URIReference, $.DER)(value.targetUri, $.DER))
]).filter((c) => (!!c)), $.DER);
};
}
return _cached_encoder_for_CommonCriteriaMeasures(value, elGetter);
}
/* eslint-enable */