@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
117 lines (116 loc) • 6.62 kB
JavaScript
/* eslint-disable */
import { ASN1TagClass as _TagClass } from "@wildboar/asn1";
import * as $ from "@wildboar/asn1/functional";
import { _decode_GenericSecretKeyAttributes, _encode_GenericSecretKeyAttributes, } from "../PKCS-15/GenericSecretKeyAttributes.ta.mjs";
import { _decode_OtherKey, _encode_OtherKey, } from "../PKCS-15/OtherKey.ta.mjs";
import { _get_decoder_for_SecretKeyObject, _get_encoder_for_SecretKeyObject, } from "../PKCS-15/SecretKeyObject.ta.mjs";
let _cached_decoder_for_SecretKeyType = null;
/**
* @summary Decodes an ASN.1 element into a(n) SecretKeyType
* @function
* @param {_Element} el The element being decoded.
* @returns {SecretKeyType} The decoded data structure.
*/
export function _decode_SecretKeyType(el) {
if (!_cached_decoder_for_SecretKeyType) {
_cached_decoder_for_SecretKeyType = $._decode_extensible_choice({
"UNIVERSAL 16": [
"genericSecretKey",
_get_decoder_for_SecretKeyObject(_decode_GenericSecretKeyAttributes),
],
"CONTEXT 0": [
"rc2key",
$._decode_implicit(() => _get_decoder_for_SecretKeyObject(_decode_GenericSecretKeyAttributes)),
],
"CONTEXT 1": [
"rc4key",
$._decode_implicit(() => _get_decoder_for_SecretKeyObject(_decode_GenericSecretKeyAttributes)),
],
"CONTEXT 2": [
"desKey",
$._decode_implicit(() => _get_decoder_for_SecretKeyObject(_decode_GenericSecretKeyAttributes)),
],
"CONTEXT 3": [
"des2Key",
$._decode_implicit(() => _get_decoder_for_SecretKeyObject(_decode_GenericSecretKeyAttributes)),
],
"CONTEXT 4": [
"des3Key",
$._decode_implicit(() => _get_decoder_for_SecretKeyObject(_decode_GenericSecretKeyAttributes)),
],
"CONTEXT 5": [
"castKey",
$._decode_implicit(() => _get_decoder_for_SecretKeyObject(_decode_GenericSecretKeyAttributes)),
],
"CONTEXT 6": [
"cast3Key",
$._decode_implicit(() => _get_decoder_for_SecretKeyObject(_decode_GenericSecretKeyAttributes)),
],
"CONTEXT 7": [
"cast128Key",
$._decode_implicit(() => _get_decoder_for_SecretKeyObject(_decode_GenericSecretKeyAttributes)),
],
"CONTEXT 8": [
"rc5Key",
$._decode_implicit(() => _get_decoder_for_SecretKeyObject(_decode_GenericSecretKeyAttributes)),
],
"CONTEXT 9": [
"ideaKey",
$._decode_implicit(() => _get_decoder_for_SecretKeyObject(_decode_GenericSecretKeyAttributes)),
],
"CONTEXT 10": [
"skipjackKey",
$._decode_implicit(() => _get_decoder_for_SecretKeyObject(_decode_GenericSecretKeyAttributes)),
],
"CONTEXT 11": [
"batonKey",
$._decode_implicit(() => _get_decoder_for_SecretKeyObject(_decode_GenericSecretKeyAttributes)),
],
"CONTEXT 12": [
"juniperKey",
$._decode_implicit(() => _get_decoder_for_SecretKeyObject(_decode_GenericSecretKeyAttributes)),
],
"CONTEXT 13": [
"rc6Key",
$._decode_implicit(() => _get_decoder_for_SecretKeyObject(_decode_GenericSecretKeyAttributes)),
],
"CONTEXT 14": [
"otherKey",
$._decode_implicit(() => _decode_OtherKey),
],
});
}
return _cached_decoder_for_SecretKeyType(el);
}
let _cached_encoder_for_SecretKeyType = null;
/**
* @summary Encodes a(n) SecretKeyType 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 SecretKeyType, encoded as an ASN.1 Element.
*/
export function _encode_SecretKeyType(value, elGetter) {
if (!_cached_encoder_for_SecretKeyType) {
_cached_encoder_for_SecretKeyType = $._encode_choice({
genericSecretKey: _get_encoder_for_SecretKeyObject(_encode_GenericSecretKeyAttributes),
rc2key: $._encode_implicit(_TagClass.context, 0, () => _get_encoder_for_SecretKeyObject(_encode_GenericSecretKeyAttributes), $.BER),
rc4key: $._encode_implicit(_TagClass.context, 1, () => _get_encoder_for_SecretKeyObject(_encode_GenericSecretKeyAttributes), $.BER),
desKey: $._encode_implicit(_TagClass.context, 2, () => _get_encoder_for_SecretKeyObject(_encode_GenericSecretKeyAttributes), $.BER),
des2Key: $._encode_implicit(_TagClass.context, 3, () => _get_encoder_for_SecretKeyObject(_encode_GenericSecretKeyAttributes), $.BER),
des3Key: $._encode_implicit(_TagClass.context, 4, () => _get_encoder_for_SecretKeyObject(_encode_GenericSecretKeyAttributes), $.BER),
castKey: $._encode_implicit(_TagClass.context, 5, () => _get_encoder_for_SecretKeyObject(_encode_GenericSecretKeyAttributes), $.BER),
cast3Key: $._encode_implicit(_TagClass.context, 6, () => _get_encoder_for_SecretKeyObject(_encode_GenericSecretKeyAttributes), $.BER),
cast128Key: $._encode_implicit(_TagClass.context, 7, () => _get_encoder_for_SecretKeyObject(_encode_GenericSecretKeyAttributes), $.BER),
rc5Key: $._encode_implicit(_TagClass.context, 8, () => _get_encoder_for_SecretKeyObject(_encode_GenericSecretKeyAttributes), $.BER),
ideaKey: $._encode_implicit(_TagClass.context, 9, () => _get_encoder_for_SecretKeyObject(_encode_GenericSecretKeyAttributes), $.BER),
skipjackKey: $._encode_implicit(_TagClass.context, 10, () => _get_encoder_for_SecretKeyObject(_encode_GenericSecretKeyAttributes), $.BER),
batonKey: $._encode_implicit(_TagClass.context, 11, () => _get_encoder_for_SecretKeyObject(_encode_GenericSecretKeyAttributes), $.BER),
juniperKey: $._encode_implicit(_TagClass.context, 12, () => _get_encoder_for_SecretKeyObject(_encode_GenericSecretKeyAttributes), $.BER),
rc6Key: $._encode_implicit(_TagClass.context, 13, () => _get_encoder_for_SecretKeyObject(_encode_GenericSecretKeyAttributes), $.BER),
otherKey: $._encode_implicit(_TagClass.context, 14, () => _encode_OtherKey, $.BER),
}, $.BER);
}
return _cached_encoder_for_SecretKeyType(value, elGetter);
}
/* eslint-enable */