@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
176 lines • 6.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_PFX = exports._decode_PFX = exports._extension_additions_list_spec_for_PFX = exports._root_component_type_list_2_spec_for_PFX = exports._root_component_type_list_1_spec_for_PFX = exports.PFX = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const MacData_ta_1 = require("../PKCS-12/MacData.ta");
const PFX_version_ta_1 = require("../PKCS-12/PFX-version.ta");
const ContentInfo_ta_1 = require("../PKCS7/ContentInfo.ta");
/* START_OF_SYMBOL_DEFINITION PFX */
/**
* @summary PFX
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* PFX ::= SEQUENCE {
* version INTEGER {v3(3)}(v3,...),
* authSafe ContentInfo,
* macData MacData OPTIONAL
* }
* ```
*
* @class
*/
class PFX {
constructor(
/**
* @summary `version`.
* @public
* @readonly
*/
version,
/**
* @summary `authSafe`.
* @public
* @readonly
*/
authSafe,
/**
* @summary `macData`.
* @public
* @readonly
*/
macData) {
this.version = version;
this.authSafe = authSafe;
this.macData = macData;
}
/**
* @summary Restructures an object into a PFX
* @description
*
* This takes an `object` and converts it to a `PFX`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `PFX`.
* @returns {PFX}
*/
static _from_object(_o) {
return new PFX(_o.version, _o.authSafe, _o.macData);
}
}
exports.PFX = PFX;
/* END_OF_SYMBOL_DEFINITION PFX */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PFX */
/**
* @summary The Leading Root Component Types of PFX
* @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_PFX = [
new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("authSafe", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("macData", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PFX */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PFX */
/**
* @summary The Trailing Root Component Types of PFX
* @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_PFX = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PFX */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PFX */
/**
* @summary The Extension Addition Component Types of PFX
* @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_PFX = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PFX */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_PFX */
let _cached_decoder_for_PFX = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_PFX */
/* START_OF_SYMBOL_DEFINITION _decode_PFX */
/**
* @summary Decodes an ASN.1 element into a(n) PFX
* @function
* @param {_Element} el The element being decoded.
* @returns {PFX} The decoded data structure.
*/
function _decode_PFX(el) {
if (!_cached_decoder_for_PFX) {
_cached_decoder_for_PFX = function (el) {
/* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */
let version;
let authSafe;
let macData;
/* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */
/* START_OF_CALLBACKS_MAP */
const callbacks = {
version: (_el) => {
version = PFX_version_ta_1._decode_PFX_version(_el);
},
authSafe: (_el) => {
authSafe = ContentInfo_ta_1._decode_ContentInfo(_el);
},
macData: (_el) => {
macData = MacData_ta_1._decode_MacData(_el);
},
};
/* END_OF_CALLBACKS_MAP */
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_PFX, exports._extension_additions_list_spec_for_PFX, exports._root_component_type_list_2_spec_for_PFX, undefined);
return new PFX(
/* SEQUENCE_CONSTRUCTOR_CALL */ version, authSafe, macData);
};
}
return _cached_decoder_for_PFX(el);
}
exports._decode_PFX = _decode_PFX;
/* END_OF_SYMBOL_DEFINITION _decode_PFX */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_PFX */
let _cached_encoder_for_PFX = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_PFX */
/* START_OF_SYMBOL_DEFINITION _encode_PFX */
/**
* @summary Encodes a(n) PFX 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 PFX, encoded as an ASN.1 Element.
*/
function _encode_PFX(value, elGetter) {
if (!_cached_encoder_for_PFX) {
_cached_encoder_for_PFX = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ PFX_version_ta_1._encode_PFX_version(value.version, $.BER),
/* REQUIRED */ ContentInfo_ta_1._encode_ContentInfo(value.authSafe, $.BER),
/* IF_ABSENT */ value.macData === undefined
? undefined
: MacData_ta_1._encode_MacData(value.macData, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_PFX(value, elGetter);
}
exports._encode_PFX = _encode_PFX;
/* END_OF_SYMBOL_DEFINITION _encode_PFX */
/* eslint-enable */
//# sourceMappingURL=PFX.ta.js.map