UNPKG

@wildboar/pkcs

Version:
346 lines 20 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_PinAttributes = exports._decode_PinAttributes = exports._extension_additions_list_spec_for_PinAttributes = exports._root_component_type_list_2_spec_for_PinAttributes = exports._root_component_type_list_1_spec_for_PinAttributes = exports.PinAttributes = exports._encode_Reference = exports._decode_Reference = exports._enum_for_PinType = exports._encode_PinType = exports._decode_PinType = exports.utf8 = exports.PinType_utf8 = exports.PinType_iso9564_1 = exports.PinType_half_nibble_bcd = exports.PinType_bcd = exports.PinType_ascii_numeric = exports.iso9564_1 = exports.half_nibble_bcd = exports.bcd = exports.ascii_numeric = exports._encode_PinFlags = exports._decode_PinFlags = exports.unblock_disabled = exports.unblockingPin = exports.soPin = exports.PinFlags_unblock_disabled = exports.PinFlags_unblockingPin = exports.PinFlags_soPin = exports.PinFlags_needs_padding = exports.PinFlags_local = exports.PinFlags_integrity_protected = exports.PinFlags_initialized = exports.PinFlags_exchangeRefData = exports.PinFlags_disable_allowed = exports.PinFlags_confidentiality_protected = exports.PinFlags_change_disabled = exports.PinFlags_case_sensitive = exports.needs_padding = exports.local = exports.integrity_protected = exports.initialized = exports.exchangeRefData = exports.disable_allowed = exports.confidentiality_protected = exports.change_disabled = exports.case_sensitive = exports._encode_Path = exports._decode_Path = exports.Path = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const Path_ta_1 = require("../PKCS-15/Path.ta"); const PinFlags_ta_1 = require("../PKCS-15/PinFlags.ta"); const PinType_ta_1 = require("../PKCS-15/PinType.ta"); const Reference_ta_1 = require("../PKCS-15/Reference.ta"); var Path_ta_2 = require("../PKCS-15/Path.ta"); Object.defineProperty(exports, "Path", { enumerable: true, get: function () { return Path_ta_2.Path; } }); Object.defineProperty(exports, "_decode_Path", { enumerable: true, get: function () { return Path_ta_2._decode_Path; } }); Object.defineProperty(exports, "_encode_Path", { enumerable: true, get: function () { return Path_ta_2._encode_Path; } }); var PinFlags_ta_2 = require("../PKCS-15/PinFlags.ta"); Object.defineProperty(exports, "case_sensitive", { enumerable: true, get: function () { return PinFlags_ta_2.case_sensitive; } }); /* IMPORTED_SHORT_NAMED_BIT */ Object.defineProperty(exports, "change_disabled", { enumerable: true, get: function () { return PinFlags_ta_2.change_disabled; } }); /* IMPORTED_SHORT_NAMED_BIT */ Object.defineProperty(exports, "confidentiality_protected", { enumerable: true, get: function () { return PinFlags_ta_2.confidentiality_protected; } }); /* IMPORTED_SHORT_NAMED_BIT */ Object.defineProperty(exports, "disable_allowed", { enumerable: true, get: function () { return PinFlags_ta_2.disable_allowed; } }); /* IMPORTED_SHORT_NAMED_BIT */ Object.defineProperty(exports, "exchangeRefData", { enumerable: true, get: function () { return PinFlags_ta_2.exchangeRefData; } }); /* IMPORTED_SHORT_NAMED_BIT */ Object.defineProperty(exports, "initialized", { enumerable: true, get: function () { return PinFlags_ta_2.initialized; } }); /* IMPORTED_SHORT_NAMED_BIT */ Object.defineProperty(exports, "integrity_protected", { enumerable: true, get: function () { return PinFlags_ta_2.integrity_protected; } }); /* IMPORTED_SHORT_NAMED_BIT */ Object.defineProperty(exports, "local", { enumerable: true, get: function () { return PinFlags_ta_2.local; } }); /* IMPORTED_SHORT_NAMED_BIT */ Object.defineProperty(exports, "needs_padding", { enumerable: true, get: function () { return PinFlags_ta_2.needs_padding; } }); /* IMPORTED_SHORT_NAMED_BIT */ Object.defineProperty(exports, "PinFlags_case_sensitive", { enumerable: true, get: function () { return PinFlags_ta_2.PinFlags_case_sensitive; } }); /* IMPORTED_LONG_NAMED_BIT */ Object.defineProperty(exports, "PinFlags_change_disabled", { enumerable: true, get: function () { return PinFlags_ta_2.PinFlags_change_disabled; } }); /* IMPORTED_LONG_NAMED_BIT */ Object.defineProperty(exports, "PinFlags_confidentiality_protected", { enumerable: true, get: function () { return PinFlags_ta_2.PinFlags_confidentiality_protected; } }); /* IMPORTED_LONG_NAMED_BIT */ Object.defineProperty(exports, "PinFlags_disable_allowed", { enumerable: true, get: function () { return PinFlags_ta_2.PinFlags_disable_allowed; } }); /* IMPORTED_LONG_NAMED_BIT */ Object.defineProperty(exports, "PinFlags_exchangeRefData", { enumerable: true, get: function () { return PinFlags_ta_2.PinFlags_exchangeRefData; } }); /* IMPORTED_LONG_NAMED_BIT */ Object.defineProperty(exports, "PinFlags_initialized", { enumerable: true, get: function () { return PinFlags_ta_2.PinFlags_initialized; } }); /* IMPORTED_LONG_NAMED_BIT */ Object.defineProperty(exports, "PinFlags_integrity_protected", { enumerable: true, get: function () { return PinFlags_ta_2.PinFlags_integrity_protected; } }); /* IMPORTED_LONG_NAMED_BIT */ Object.defineProperty(exports, "PinFlags_local", { enumerable: true, get: function () { return PinFlags_ta_2.PinFlags_local; } }); /* IMPORTED_LONG_NAMED_BIT */ Object.defineProperty(exports, "PinFlags_needs_padding", { enumerable: true, get: function () { return PinFlags_ta_2.PinFlags_needs_padding; } }); /* IMPORTED_LONG_NAMED_BIT */ Object.defineProperty(exports, "PinFlags_soPin", { enumerable: true, get: function () { return PinFlags_ta_2.PinFlags_soPin; } }); /* IMPORTED_LONG_NAMED_BIT */ Object.defineProperty(exports, "PinFlags_unblockingPin", { enumerable: true, get: function () { return PinFlags_ta_2.PinFlags_unblockingPin; } }); /* IMPORTED_LONG_NAMED_BIT */ Object.defineProperty(exports, "PinFlags_unblock_disabled", { enumerable: true, get: function () { return PinFlags_ta_2.PinFlags_unblock_disabled; } }); /* IMPORTED_LONG_NAMED_BIT */ Object.defineProperty(exports, "soPin", { enumerable: true, get: function () { return PinFlags_ta_2.soPin; } }); /* IMPORTED_SHORT_NAMED_BIT */ Object.defineProperty(exports, "unblockingPin", { enumerable: true, get: function () { return PinFlags_ta_2.unblockingPin; } }); /* IMPORTED_SHORT_NAMED_BIT */ Object.defineProperty(exports, "unblock_disabled", { enumerable: true, get: function () { return PinFlags_ta_2.unblock_disabled; } }); /* IMPORTED_SHORT_NAMED_BIT */ Object.defineProperty(exports, "_decode_PinFlags", { enumerable: true, get: function () { return PinFlags_ta_2._decode_PinFlags; } }); Object.defineProperty(exports, "_encode_PinFlags", { enumerable: true, get: function () { return PinFlags_ta_2._encode_PinFlags; } }); var PinType_ta_2 = require("../PKCS-15/PinType.ta"); Object.defineProperty(exports, "ascii_numeric", { enumerable: true, get: function () { return PinType_ta_2.ascii_numeric; } }); /* IMPORTED_SHORT_ENUMERATION_ITEM */ Object.defineProperty(exports, "bcd", { enumerable: true, get: function () { return PinType_ta_2.bcd; } }); /* IMPORTED_SHORT_ENUMERATION_ITEM */ Object.defineProperty(exports, "half_nibble_bcd", { enumerable: true, get: function () { return PinType_ta_2.half_nibble_bcd; } }); /* IMPORTED_SHORT_ENUMERATION_ITEM */ Object.defineProperty(exports, "iso9564_1", { enumerable: true, get: function () { return PinType_ta_2.iso9564_1; } }); /* IMPORTED_SHORT_ENUMERATION_ITEM */ Object.defineProperty(exports, "PinType_ascii_numeric", { enumerable: true, get: function () { return PinType_ta_2.PinType_ascii_numeric; } }); /* IMPORTED_LONG_ENUMERATION_ITEM */ Object.defineProperty(exports, "PinType_bcd", { enumerable: true, get: function () { return PinType_ta_2.PinType_bcd; } }); /* IMPORTED_LONG_ENUMERATION_ITEM */ Object.defineProperty(exports, "PinType_half_nibble_bcd", { enumerable: true, get: function () { return PinType_ta_2.PinType_half_nibble_bcd; } }); /* IMPORTED_LONG_ENUMERATION_ITEM */ Object.defineProperty(exports, "PinType_iso9564_1", { enumerable: true, get: function () { return PinType_ta_2.PinType_iso9564_1; } }); /* IMPORTED_LONG_ENUMERATION_ITEM */ Object.defineProperty(exports, "PinType_utf8", { enumerable: true, get: function () { return PinType_ta_2.PinType_utf8; } }); /* IMPORTED_LONG_ENUMERATION_ITEM */ Object.defineProperty(exports, "utf8", { enumerable: true, get: function () { return PinType_ta_2.utf8; } }); /* IMPORTED_SHORT_ENUMERATION_ITEM */ Object.defineProperty(exports, "_decode_PinType", { enumerable: true, get: function () { return PinType_ta_2._decode_PinType; } }); Object.defineProperty(exports, "_encode_PinType", { enumerable: true, get: function () { return PinType_ta_2._encode_PinType; } }); Object.defineProperty(exports, "_enum_for_PinType", { enumerable: true, get: function () { return PinType_ta_2._enum_for_PinType; } }); var Reference_ta_2 = require("../PKCS-15/Reference.ta"); Object.defineProperty(exports, "_decode_Reference", { enumerable: true, get: function () { return Reference_ta_2._decode_Reference; } }); Object.defineProperty(exports, "_encode_Reference", { enumerable: true, get: function () { return Reference_ta_2._encode_Reference; } }); /* START_OF_SYMBOL_DEFINITION PinAttributes */ /** * @summary PinAttributes * @description * * ### ASN.1 Definition: * * ```asn1 * PinAttributes ::= SEQUENCE { * pinFlags PinFlags, * pinType PinType, * minLength INTEGER (pkcs15-lb-minPinLength..pkcs15-ub-minPinLength), * storedLength INTEGER (0..pkcs15-ub-storedPinLength), * maxLength INTEGER OPTIONAL, * pinReference [0] Reference DEFAULT 0, * padChar OCTET STRING (SIZE(1)) OPTIONAL, * lastPinChange GeneralizedTime OPTIONAL, * path Path OPTIONAL, * ... -- For future extensions * } * ``` * * @class */ class PinAttributes { constructor( /** * @summary `pinFlags`. * @public * @readonly */ pinFlags, /** * @summary `pinType`. * @public * @readonly */ pinType, /** * @summary `minLength`. * @public * @readonly */ minLength, /** * @summary `storedLength`. * @public * @readonly */ storedLength, /** * @summary `maxLength`. * @public * @readonly */ maxLength, /** * @summary `pinReference`. * @public * @readonly */ pinReference, /** * @summary `padChar`. * @public * @readonly */ padChar, /** * @summary `lastPinChange`. * @public * @readonly */ lastPinChange, /** * @summary `path`. * @public * @readonly */ path, /** * @summary Extensions that are not recognized. * @public * @readonly */ _unrecognizedExtensionsList = []) { this.pinFlags = pinFlags; this.pinType = pinType; this.minLength = minLength; this.storedLength = storedLength; this.maxLength = maxLength; this.pinReference = pinReference; this.padChar = padChar; this.lastPinChange = lastPinChange; this.path = path; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; } /** * @summary Restructures an object into a PinAttributes * @description * * This takes an `object` and converts it to a `PinAttributes`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `PinAttributes`. * @returns {PinAttributes} */ static _from_object(_o) { return new PinAttributes(_o.pinFlags, _o.pinType, _o.minLength, _o.storedLength, _o.maxLength, _o.pinReference, _o.padChar, _o.lastPinChange, _o.path, _o._unrecognizedExtensionsList); } /** * @summary Getter that returns the default value for `pinReference`. * @public * @static * @method */ static get _default_value_for_pinReference() { return 0; } } exports.PinAttributes = PinAttributes; /** * @summary The enum used as the type of the component `pinType` * @public * @static */ PinAttributes._enum_for_pinType = PinType_ta_1._enum_for_PinType; /* END_OF_SYMBOL_DEFINITION PinAttributes */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PinAttributes */ /** * @summary The Leading Root Component Types of PinAttributes * @description * * This is an array of `ComponentSpec`s that define how to decode the leading root component type list of a SET or SEQUENCE. * * @constant */ exports._root_component_type_list_1_spec_for_PinAttributes = [ new $.ComponentSpec("pinFlags", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 3), undefined, undefined), new $.ComponentSpec("pinType", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 10), undefined, undefined), new $.ComponentSpec("minLength", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("storedLength", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("maxLength", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("pinReference", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), new $.ComponentSpec("padChar", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined), new $.ComponentSpec("lastPinChange", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 24), undefined, undefined), new $.ComponentSpec("path", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PinAttributes */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PinAttributes */ /** * @summary The Trailing Root Component Types of PinAttributes * @description * * This is an array of `ComponentSpec`s that define how to decode the trailing root component type list of a SET or SEQUENCE. * * @constant */ exports._root_component_type_list_2_spec_for_PinAttributes = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PinAttributes */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PinAttributes */ /** * @summary The Extension Addition Component Types of PinAttributes * @description * * This is an array of `ComponentSpec`s that define how to decode the extension addition component type list of a SET or SEQUENCE. * * @constant */ exports._extension_additions_list_spec_for_PinAttributes = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PinAttributes */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_PinAttributes */ let _cached_decoder_for_PinAttributes = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_PinAttributes */ /* START_OF_SYMBOL_DEFINITION _decode_PinAttributes */ /** * @summary Decodes an ASN.1 element into a(n) PinAttributes * @function * @param {_Element} el The element being decoded. * @returns {PinAttributes} The decoded data structure. */ function _decode_PinAttributes(el) { if (!_cached_decoder_for_PinAttributes) { _cached_decoder_for_PinAttributes = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let pinFlags; let pinType; let minLength; let storedLength; let maxLength; let pinReference = PinAttributes._default_value_for_pinReference; let padChar; let lastPinChange; let path; let _unrecognizedExtensionsList = []; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { pinFlags: (_el) => { pinFlags = PinFlags_ta_1._decode_PinFlags(_el); }, pinType: (_el) => { pinType = PinType_ta_1._decode_PinType(_el); }, minLength: (_el) => { minLength = $._decodeInteger(_el); }, storedLength: (_el) => { storedLength = $._decodeInteger(_el); }, maxLength: (_el) => { maxLength = $._decodeInteger(_el); }, pinReference: (_el) => { pinReference = $._decode_implicit(() => Reference_ta_1._decode_Reference)(_el); }, padChar: (_el) => { padChar = $._decodeOctetString(_el); }, lastPinChange: (_el) => { lastPinChange = $._decodeGeneralizedTime(_el); }, path: (_el) => { path = Path_ta_1._decode_Path(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_PinAttributes, exports._extension_additions_list_spec_for_PinAttributes, exports._root_component_type_list_2_spec_for_PinAttributes, (ext) => { _unrecognizedExtensionsList.push(ext); }); return new PinAttributes( /* SEQUENCE_CONSTRUCTOR_CALL */ pinFlags, pinType, minLength, storedLength, maxLength, pinReference, padChar, lastPinChange, path, _unrecognizedExtensionsList); }; } return _cached_decoder_for_PinAttributes(el); } exports._decode_PinAttributes = _decode_PinAttributes; /* END_OF_SYMBOL_DEFINITION _decode_PinAttributes */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_PinAttributes */ let _cached_encoder_for_PinAttributes = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_PinAttributes */ /* START_OF_SYMBOL_DEFINITION _encode_PinAttributes */ /** * @summary Encodes a(n) PinAttributes into an ASN.1 Element. * @function * @param {value} el The element being decoded. * @param elGetter A function that can be used to get new ASN.1 elements. * @returns {_Element} The PinAttributes, encoded as an ASN.1 Element. */ function _encode_PinAttributes(value, elGetter) { if (!_cached_encoder_for_PinAttributes) { _cached_encoder_for_PinAttributes = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ PinFlags_ta_1._encode_PinFlags(value.pinFlags, $.BER), /* REQUIRED */ PinType_ta_1._encode_PinType(value.pinType, $.BER), /* REQUIRED */ $._encodeInteger(value.minLength, $.BER), /* REQUIRED */ $._encodeInteger(value.storedLength, $.BER), /* IF_ABSENT */ value.maxLength === undefined ? undefined : $._encodeInteger(value.maxLength, $.BER), /* IF_DEFAULT */ value.pinReference === undefined || $.deepEq(value.pinReference, PinAttributes._default_value_for_pinReference) ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => Reference_ta_1._encode_Reference, $.BER)(value.pinReference, $.BER), /* IF_ABSENT */ value.padChar === undefined ? undefined : $._encodeOctetString(value.padChar, $.BER), /* IF_ABSENT */ value.lastPinChange === undefined ? undefined : $._encodeGeneralizedTime(value.lastPinChange, $.BER), /* IF_ABSENT */ value.path === undefined ? undefined : Path_ta_1._encode_Path(value.path, $.BER), ], value._unrecognizedExtensionsList ? value._unrecognizedExtensionsList : []) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_PinAttributes(value, elGetter); } exports._encode_PinAttributes = _encode_PinAttributes; /* END_OF_SYMBOL_DEFINITION _encode_PinAttributes */ /* eslint-enable */ //# sourceMappingURL=PinAttributes.ta.js.map