UNPKG

@wildboar/pkcs

Version:
137 lines (136 loc) 4.71 kB
/* eslint-disable */ import { ASN1TagClass as _TagClass, } from "@wildboar/asn1"; import * as $ from "@wildboar/asn1/functional"; import { _decode_CertificateRevocationLists, _encode_CertificateRevocationLists, } from "../CryptographicMessageSyntax/CertificateRevocationLists.ta.mjs"; import { _decode_CertificateSet, _encode_CertificateSet, } from "../CryptographicMessageSyntax/CertificateSet.ta.mjs"; /** * @summary OriginatorInfo * @description * * ### ASN.1 Definition: * * ```asn1 * OriginatorInfo ::= SEQUENCE { * certs [0] IMPLICIT CertificateSet OPTIONAL, * crls [1] IMPLICIT CertificateRevocationLists OPTIONAL * } * ``` * */ export class OriginatorInfo { certs; crls; constructor( /** * @summary `certs`. * @public * @readonly */ certs, /** * @summary `crls`. * @public * @readonly */ crls) { this.certs = certs; this.crls = crls; } /** * @summary Restructures an object into a OriginatorInfo * @description * * This takes an `object` and converts it to a `OriginatorInfo`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `OriginatorInfo`. * @returns {OriginatorInfo} */ static _from_object(_o) { return new OriginatorInfo(_o.certs, _o.crls); } } /** * @summary The Leading Root Component Types of OriginatorInfo * @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_OriginatorInfo = [ new $.ComponentSpec("certs", true, $.hasTag(_TagClass.context, 0)), new $.ComponentSpec("crls", true, $.hasTag(_TagClass.context, 1)), ]; /** * @summary The Trailing Root Component Types of OriginatorInfo * @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_OriginatorInfo = []; /** * @summary The Extension Addition Component Types of OriginatorInfo * @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_OriginatorInfo = []; let _cached_decoder_for_OriginatorInfo = null; /** * @summary Decodes an ASN.1 element into a(n) OriginatorInfo * @function * @param {_Element} el The element being decoded. * @returns {OriginatorInfo} The decoded data structure. */ export function _decode_OriginatorInfo(el) { if (!_cached_decoder_for_OriginatorInfo) { _cached_decoder_for_OriginatorInfo = function (el) { let certs; let crls; const callbacks = { certs: (_el) => { certs = $._decode_implicit(() => _decode_CertificateSet)(_el); }, crls: (_el) => { crls = $._decode_implicit(() => _decode_CertificateRevocationLists)(_el); }, }; $._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_OriginatorInfo, _extension_additions_list_spec_for_OriginatorInfo, _root_component_type_list_2_spec_for_OriginatorInfo, undefined); return new OriginatorInfo(certs, crls); }; } return _cached_decoder_for_OriginatorInfo(el); } let _cached_encoder_for_OriginatorInfo = null; /** * @summary Encodes a(n) OriginatorInfo 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 OriginatorInfo, encoded as an ASN.1 Element. */ export function _encode_OriginatorInfo(value, elGetter) { if (!_cached_encoder_for_OriginatorInfo) { _cached_encoder_for_OriginatorInfo = function (value) { return $._encodeSequence([] .concat([ /* IF_ABSENT */ value.certs === undefined ? undefined : $._encode_implicit(_TagClass.context, 0, () => _encode_CertificateSet, $.BER)(value.certs, $.BER), /* IF_ABSENT */ value.crls === undefined ? undefined : $._encode_implicit(_TagClass.context, 1, () => _encode_CertificateRevocationLists, $.BER)(value.crls, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_OriginatorInfo(value, elGetter); } /* eslint-enable */