UNPKG

@wildboar/pkcs

Version:
65 lines (64 loc) 3.48 kB
/* eslint-disable */ import { ASN1TagClass as _TagClass } from "@wildboar/asn1"; import * as $ from "@wildboar/asn1/functional"; import { _decode_PublicDHKeyAttributes, _encode_PublicDHKeyAttributes, } from "../PKCS-15/PublicDHKeyAttributes.ta.mjs"; import { _decode_PublicDSAKeyAttributes, _encode_PublicDSAKeyAttributes, } from "../PKCS-15/PublicDSAKeyAttributes.ta.mjs"; import { _decode_PublicECKeyAttributes, _encode_PublicECKeyAttributes, } from "../PKCS-15/PublicECKeyAttributes.ta.mjs"; import { _decode_PublicKEAKeyAttributes, _encode_PublicKEAKeyAttributes, } from "../PKCS-15/PublicKEAKeyAttributes.ta.mjs"; import { _get_decoder_for_PublicKeyObject, _get_encoder_for_PublicKeyObject, } from "../PKCS-15/PublicKeyObject.ta.mjs"; import { _decode_PublicRSAKeyAttributes, _encode_PublicRSAKeyAttributes, } from "../PKCS-15/PublicRSAKeyAttributes.ta.mjs"; let _cached_decoder_for_PublicKeyType = null; /** * @summary Decodes an ASN.1 element into a(n) PublicKeyType * @function * @param {_Element} el The element being decoded. * @returns {PublicKeyType} The decoded data structure. */ export function _decode_PublicKeyType(el) { if (!_cached_decoder_for_PublicKeyType) { _cached_decoder_for_PublicKeyType = $._decode_extensible_choice({ "UNIVERSAL 16": [ "publicRSAKey", _get_decoder_for_PublicKeyObject(_decode_PublicRSAKeyAttributes), ], "CONTEXT 0": [ "publicECKey", $._decode_implicit(() => _get_decoder_for_PublicKeyObject(_decode_PublicECKeyAttributes)), ], "CONTEXT 1": [ "publicDHKey", $._decode_implicit(() => _get_decoder_for_PublicKeyObject(_decode_PublicDHKeyAttributes)), ], "CONTEXT 2": [ "publicDSAKey", $._decode_implicit(() => _get_decoder_for_PublicKeyObject(_decode_PublicDSAKeyAttributes)), ], "CONTEXT 3": [ "publicKEAKey", $._decode_implicit(() => _get_decoder_for_PublicKeyObject(_decode_PublicKEAKeyAttributes)), ], }); } return _cached_decoder_for_PublicKeyType(el); } let _cached_encoder_for_PublicKeyType = null; /** * @summary Encodes a(n) PublicKeyType 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 PublicKeyType, encoded as an ASN.1 Element. */ export function _encode_PublicKeyType(value, elGetter) { if (!_cached_encoder_for_PublicKeyType) { _cached_encoder_for_PublicKeyType = $._encode_choice({ publicRSAKey: _get_encoder_for_PublicKeyObject(_encode_PublicRSAKeyAttributes), publicECKey: $._encode_implicit(_TagClass.context, 0, () => _get_encoder_for_PublicKeyObject(_encode_PublicECKeyAttributes), $.BER), publicDHKey: $._encode_implicit(_TagClass.context, 1, () => _get_encoder_for_PublicKeyObject(_encode_PublicDHKeyAttributes), $.BER), publicDSAKey: $._encode_implicit(_TagClass.context, 2, () => _get_encoder_for_PublicKeyObject(_encode_PublicDSAKeyAttributes), $.BER), publicKEAKey: $._encode_implicit(_TagClass.context, 3, () => _get_encoder_for_PublicKeyObject(_encode_PublicKEAKeyAttributes), $.BER), }, $.BER); } return _cached_encoder_for_PublicKeyType(value, elGetter); } /* eslint-enable */