UNPKG

@wildboar/pkcs

Version:
52 lines (51 loc) 2.42 kB
/* eslint-disable */ import { ASN1TagClass as _TagClass } from "@wildboar/asn1"; import * as $ from "@wildboar/asn1/functional"; import { _decode_KeyAgreementRecipientInfo, _encode_KeyAgreementRecipientInfo, } from "../PKCS7/KeyAgreementRecipientInfo.ta.mjs"; import { _decode_KeyEncryptionKeyRecipientInfo, _encode_KeyEncryptionKeyRecipientInfo, } from "../PKCS7/KeyEncryptionKeyRecipientInfo.ta.mjs"; import { _decode_KeyTransportRecipientInfo, _encode_KeyTransportRecipientInfo, } from "../PKCS7/KeyTransportRecipientInfo.ta.mjs"; let _cached_decoder_for_RecipientInfo = null; /** * @summary Decodes an ASN.1 element into a(n) RecipientInfo * @function * @param {_Element} el The element being decoded. * @returns {RecipientInfo} The decoded data structure. */ export function _decode_RecipientInfo(el) { if (!_cached_decoder_for_RecipientInfo) { _cached_decoder_for_RecipientInfo = $._decode_inextensible_choice({ "UNIVERSAL 16": [ "keyTransportRecipientInfo", _decode_KeyTransportRecipientInfo, ], "CONTEXT 1": [ "keyAgreementRecipientInfo", $._decode_implicit(() => _decode_KeyAgreementRecipientInfo), ], "CONTEXT 2": [ "keyEncryptionKeyRecipientInfo", $._decode_implicit(() => _decode_KeyEncryptionKeyRecipientInfo), ], }); } return _cached_decoder_for_RecipientInfo(el); } let _cached_encoder_for_RecipientInfo = null; /** * @summary Encodes a(n) RecipientInfo 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 RecipientInfo, encoded as an ASN.1 Element. */ export function _encode_RecipientInfo(value, elGetter) { if (!_cached_encoder_for_RecipientInfo) { _cached_encoder_for_RecipientInfo = $._encode_choice({ keyTransportRecipientInfo: _encode_KeyTransportRecipientInfo, keyAgreementRecipientInfo: $._encode_implicit(_TagClass.context, 1, () => _encode_KeyAgreementRecipientInfo, $.BER), keyEncryptionKeyRecipientInfo: $._encode_implicit(_TagClass.context, 2, () => _encode_KeyEncryptionKeyRecipientInfo, $.BER), }, $.BER); } return _cached_encoder_for_RecipientInfo(value, elGetter); } /* eslint-enable */