UNPKG

@wildboar/pkcs

Version:
59 lines (58 loc) 3.09 kB
/* eslint-disable */ import { ASN1TagClass as _TagClass } from "@wildboar/asn1"; import * as $ from "@wildboar/asn1/functional"; import { _get_decoder_for_AuthenticationObject, _get_encoder_for_AuthenticationObject, } from "../PKCS-15/AuthenticationObject.ta.mjs"; import { _decode_AuthKeyAttributes, _encode_AuthKeyAttributes, } from "../PKCS-15/AuthKeyAttributes.ta.mjs"; import { _decode_BiometricAttributes, _encode_BiometricAttributes, } from "../PKCS-15/BiometricAttributes.ta.mjs"; import { _decode_ExternalAuthObjectAttributes, _encode_ExternalAuthObjectAttributes, } from "../PKCS-15/ExternalAuthObjectAttributes.ta.mjs"; import { _decode_PinAttributes, _encode_PinAttributes, } from "../PKCS-15/PinAttributes.ta.mjs"; let _cached_decoder_for_AuthenticationType = null; /** * @summary Decodes an ASN.1 element into a(n) AuthenticationType * @function * @param {_Element} el The element being decoded. * @returns {AuthenticationType} The decoded data structure. */ export function _decode_AuthenticationType(el) { if (!_cached_decoder_for_AuthenticationType) { _cached_decoder_for_AuthenticationType = $._decode_extensible_choice({ "UNIVERSAL 16": [ "pin", _get_decoder_for_AuthenticationObject(_decode_PinAttributes), ], "CONTEXT 0": [ "biometricTemplate", $._decode_implicit(() => _get_decoder_for_AuthenticationObject(_decode_BiometricAttributes)), ], "CONTEXT 1": [ "authKey", $._decode_implicit(() => _get_decoder_for_AuthenticationObject(_decode_AuthKeyAttributes)), ], "CONTEXT 2": [ "external", $._decode_implicit(() => _get_decoder_for_AuthenticationObject(_decode_ExternalAuthObjectAttributes)), ], }); } return _cached_decoder_for_AuthenticationType(el); } let _cached_encoder_for_AuthenticationType = null; /** * @summary Encodes a(n) AuthenticationType 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 AuthenticationType, encoded as an ASN.1 Element. */ export function _encode_AuthenticationType(value, elGetter) { if (!_cached_encoder_for_AuthenticationType) { _cached_encoder_for_AuthenticationType = $._encode_choice({ pin: _get_encoder_for_AuthenticationObject(_encode_PinAttributes), biometricTemplate: $._encode_implicit(_TagClass.context, 0, () => _get_encoder_for_AuthenticationObject(_encode_BiometricAttributes), $.BER), authKey: $._encode_implicit(_TagClass.context, 1, () => _get_encoder_for_AuthenticationObject(_encode_AuthKeyAttributes), $.BER), external: $._encode_implicit(_TagClass.context, 2, () => _get_encoder_for_AuthenticationObject(_encode_ExternalAuthObjectAttributes), $.BER), }, $.BER); } return _cached_encoder_for_AuthenticationType(value, elGetter); } /* eslint-enable */