UNPKG

@wildboar/pkcs

Version:
46 lines (45 loc) 2.12 kB
/* eslint-disable */ import { ASN1TagClass as _TagClass } from "@wildboar/asn1"; import * as $ from "@wildboar/asn1/functional"; import { _decode_IssuerAndSerialNumber, _encode_IssuerAndSerialNumber, } from "../CryptographicMessageSyntax/IssuerAndSerialNumber.ta.mjs"; import { _decode_RecipientKeyIdentifier, _encode_RecipientKeyIdentifier, } from "../CryptographicMessageSyntax/RecipientKeyIdentifier.ta.mjs"; let _cached_decoder_for_KeyAgreeRecipientIdentifier = null; /** * @summary Decodes an ASN.1 element into a(n) KeyAgreeRecipientIdentifier * @function * @param {_Element} el The element being decoded. * @returns {KeyAgreeRecipientIdentifier} The decoded data structure. */ export function _decode_KeyAgreeRecipientIdentifier(el) { if (!_cached_decoder_for_KeyAgreeRecipientIdentifier) { _cached_decoder_for_KeyAgreeRecipientIdentifier = $._decode_inextensible_choice({ "UNIVERSAL 16": [ "issuerAndSerialNumber", _decode_IssuerAndSerialNumber, ], "CONTEXT 0": [ "rKeyId", $._decode_implicit(() => _decode_RecipientKeyIdentifier), ], }); } return _cached_decoder_for_KeyAgreeRecipientIdentifier(el); } let _cached_encoder_for_KeyAgreeRecipientIdentifier = null; /** * @summary Encodes a(n) KeyAgreeRecipientIdentifier 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 KeyAgreeRecipientIdentifier, encoded as an ASN.1 Element. */ export function _encode_KeyAgreeRecipientIdentifier(value, elGetter) { if (!_cached_encoder_for_KeyAgreeRecipientIdentifier) { _cached_encoder_for_KeyAgreeRecipientIdentifier = $._encode_choice({ issuerAndSerialNumber: _encode_IssuerAndSerialNumber, rKeyId: $._encode_implicit(_TagClass.context, 0, () => _encode_RecipientKeyIdentifier, $.BER), }, $.BER); } return _cached_encoder_for_KeyAgreeRecipientIdentifier(value, elGetter); } /* eslint-enable */