UNPKG

@wildboar/pki-stub

Version:
83 lines (82 loc) 3.74 kB
/* eslint-disable */ import { ASN1TagClass as _TagClass, } from "@wildboar/asn1"; import * as $ from "@wildboar/asn1/functional"; import { _decode_EDIPartyName, _encode_EDIPartyName, } from "../CertificateExtensions/EDIPartyName.ta.mjs"; import { _decode_Name, _encode_Name } from "./Name.ta.mjs"; import { _decode_ORAddress, _encode_ORAddress, } from "../PkiPmiExternalDataTypes/ORAddress.ta.mjs"; let _cached_decoder_for_GeneralName = null; /** * @summary Decodes an ASN.1 element into a(n) GeneralName * @function * @param {_Element} el The element being decoded. * @returns {GeneralName} The decoded data structure. */ export function _decode_GeneralName(el) { if (!_cached_decoder_for_GeneralName) { _cached_decoder_for_GeneralName = $._decode_extensible_choice({ "CONTEXT 0": [ "otherName", $._decode_implicit(() => $._decodeInstanceOf), ], "CONTEXT 1": [ "rfc822Name", $._decode_implicit(() => $._decodeIA5String), ], "CONTEXT 2": [ "dNSName", $._decode_implicit(() => $._decodeIA5String), ], "CONTEXT 3": [ "x400Address", $._decode_implicit(() => _decode_ORAddress), ], "CONTEXT 4": [ "directoryName", $._decode_explicit(() => _decode_Name), ], "CONTEXT 5": [ "ediPartyName", $._decode_implicit(() => _decode_EDIPartyName), ], "CONTEXT 6": [ "uniformResourceIdentifier", $._decode_implicit(() => $._decodeIA5String), ], "CONTEXT 7": [ "iPAddress", $._decode_implicit(() => $._decodeOctetString), ], "CONTEXT 8": [ "registeredID", $._decode_implicit(() => $._decodeObjectIdentifier), ], }); } return _cached_decoder_for_GeneralName(el); } let _cached_encoder_for_GeneralName = null; /** * @summary Encodes a(n) GeneralName 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 GeneralName, encoded as an ASN.1 Element. */ export function _encode_GeneralName(value, elGetter) { if (!_cached_encoder_for_GeneralName) { _cached_encoder_for_GeneralName = $._encode_choice({ otherName: $._encode_implicit(_TagClass.context, 0, () => $._encodeInstanceOf, $.BER), rfc822Name: $._encode_implicit(_TagClass.context, 1, () => $._encodeIA5String, $.BER), dNSName: $._encode_implicit(_TagClass.context, 2, () => $._encodeIA5String, $.BER), x400Address: $._encode_implicit(_TagClass.context, 3, () => _encode_ORAddress, $.BER), directoryName: $._encode_explicit(_TagClass.context, 4, () => _encode_Name, $.BER), ediPartyName: $._encode_implicit(_TagClass.context, 5, () => _encode_EDIPartyName, $.BER), uniformResourceIdentifier: $._encode_implicit(_TagClass.context, 6, () => $._encodeIA5String, $.BER), iPAddress: $._encode_implicit(_TagClass.context, 7, () => $._encodeOctetString, $.BER), registeredID: $._encode_implicit(_TagClass.context, 8, () => $._encodeObjectIdentifier, $.BER), }, $.BER); } return _cached_encoder_for_GeneralName(value, elGetter); } /* eslint-enable */