@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
196 lines • 10.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_KeyEncryptionKeyRecipientInfo = exports._decode_KeyEncryptionKeyRecipientInfo = exports._extension_additions_list_spec_for_KeyEncryptionKeyRecipientInfo = exports._root_component_type_list_2_spec_for_KeyEncryptionKeyRecipientInfo = exports._root_component_type_list_1_spec_for_KeyEncryptionKeyRecipientInfo = exports.KeyEncryptionKeyRecipientInfo = exports._encode_Version = exports._decode_Version = exports._encode_KeyEncryptionKeyIdentifier = exports._decode_KeyEncryptionKeyIdentifier = exports.KeyEncryptionKeyIdentifier = exports._encode_KeyEncryptionAlgorithmIdentifier = exports._decode_KeyEncryptionAlgorithmIdentifier = exports._encode_EncryptedKey = exports._decode_EncryptedKey = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const EncryptedKey_ta_1 = require("../PKCS7/EncryptedKey.ta");
const KeyEncryptionAlgorithmIdentifier_ta_1 = require("../PKCS7/KeyEncryptionAlgorithmIdentifier.ta");
const KeyEncryptionKeyIdentifier_ta_1 = require("../PKCS7/KeyEncryptionKeyIdentifier.ta");
const Version_ta_1 = require("../PKCS7/Version.ta");
var EncryptedKey_ta_2 = require("../PKCS7/EncryptedKey.ta");
Object.defineProperty(exports, "_decode_EncryptedKey", { enumerable: true, get: function () { return EncryptedKey_ta_2._decode_EncryptedKey; } });
Object.defineProperty(exports, "_encode_EncryptedKey", { enumerable: true, get: function () { return EncryptedKey_ta_2._encode_EncryptedKey; } });
var KeyEncryptionAlgorithmIdentifier_ta_2 = require("../PKCS7/KeyEncryptionAlgorithmIdentifier.ta");
Object.defineProperty(exports, "_decode_KeyEncryptionAlgorithmIdentifier", { enumerable: true, get: function () { return KeyEncryptionAlgorithmIdentifier_ta_2._decode_KeyEncryptionAlgorithmIdentifier; } });
Object.defineProperty(exports, "_encode_KeyEncryptionAlgorithmIdentifier", { enumerable: true, get: function () { return KeyEncryptionAlgorithmIdentifier_ta_2._encode_KeyEncryptionAlgorithmIdentifier; } });
var KeyEncryptionKeyIdentifier_ta_2 = require("../PKCS7/KeyEncryptionKeyIdentifier.ta");
Object.defineProperty(exports, "KeyEncryptionKeyIdentifier", { enumerable: true, get: function () { return KeyEncryptionKeyIdentifier_ta_2.KeyEncryptionKeyIdentifier; } });
Object.defineProperty(exports, "_decode_KeyEncryptionKeyIdentifier", { enumerable: true, get: function () { return KeyEncryptionKeyIdentifier_ta_2._decode_KeyEncryptionKeyIdentifier; } });
Object.defineProperty(exports, "_encode_KeyEncryptionKeyIdentifier", { enumerable: true, get: function () { return KeyEncryptionKeyIdentifier_ta_2._encode_KeyEncryptionKeyIdentifier; } });
var Version_ta_2 = require("../PKCS7/Version.ta");
Object.defineProperty(exports, "_decode_Version", { enumerable: true, get: function () { return Version_ta_2._decode_Version; } });
Object.defineProperty(exports, "_encode_Version", { enumerable: true, get: function () { return Version_ta_2._encode_Version; } });
/* START_OF_SYMBOL_DEFINITION KeyEncryptionKeyRecipientInfo */
/**
* @summary KeyEncryptionKeyRecipientInfo
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* KeyEncryptionKeyRecipientInfo ::= SEQUENCE {
* version Version,
* keyEncryptionKeyIdentifier KeyEncryptionKeyIdentifier,
* keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier,
* encryptedKey EncryptedKey
* }
* ```
*
* @class
*/
class KeyEncryptionKeyRecipientInfo {
constructor(
/**
* @summary `version`.
* @public
* @readonly
*/
version,
/**
* @summary `keyEncryptionKeyIdentifier`.
* @public
* @readonly
*/
keyEncryptionKeyIdentifier,
/**
* @summary `keyEncryptionAlgorithm`.
* @public
* @readonly
*/
keyEncryptionAlgorithm,
/**
* @summary `encryptedKey`.
* @public
* @readonly
*/
encryptedKey) {
this.version = version;
this.keyEncryptionKeyIdentifier = keyEncryptionKeyIdentifier;
this.keyEncryptionAlgorithm = keyEncryptionAlgorithm;
this.encryptedKey = encryptedKey;
}
/**
* @summary Restructures an object into a KeyEncryptionKeyRecipientInfo
* @description
*
* This takes an `object` and converts it to a `KeyEncryptionKeyRecipientInfo`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `KeyEncryptionKeyRecipientInfo`.
* @returns {KeyEncryptionKeyRecipientInfo}
*/
static _from_object(_o) {
return new KeyEncryptionKeyRecipientInfo(_o.version, _o.keyEncryptionKeyIdentifier, _o.keyEncryptionAlgorithm, _o.encryptedKey);
}
}
exports.KeyEncryptionKeyRecipientInfo = KeyEncryptionKeyRecipientInfo;
/* END_OF_SYMBOL_DEFINITION KeyEncryptionKeyRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_KeyEncryptionKeyRecipientInfo */
/**
* @summary The Leading Root Component Types of KeyEncryptionKeyRecipientInfo
* @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_KeyEncryptionKeyRecipientInfo = [
new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("keyEncryptionKeyIdentifier", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("keyEncryptionAlgorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("encryptedKey", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_KeyEncryptionKeyRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_KeyEncryptionKeyRecipientInfo */
/**
* @summary The Trailing Root Component Types of KeyEncryptionKeyRecipientInfo
* @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_KeyEncryptionKeyRecipientInfo = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_KeyEncryptionKeyRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_KeyEncryptionKeyRecipientInfo */
/**
* @summary The Extension Addition Component Types of KeyEncryptionKeyRecipientInfo
* @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_KeyEncryptionKeyRecipientInfo = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_KeyEncryptionKeyRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_KeyEncryptionKeyRecipientInfo */
let _cached_decoder_for_KeyEncryptionKeyRecipientInfo = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_KeyEncryptionKeyRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _decode_KeyEncryptionKeyRecipientInfo */
/**
* @summary Decodes an ASN.1 element into a(n) KeyEncryptionKeyRecipientInfo
* @function
* @param {_Element} el The element being decoded.
* @returns {KeyEncryptionKeyRecipientInfo} The decoded data structure.
*/
function _decode_KeyEncryptionKeyRecipientInfo(el) {
if (!_cached_decoder_for_KeyEncryptionKeyRecipientInfo) {
_cached_decoder_for_KeyEncryptionKeyRecipientInfo = function (el) {
const sequence = el.sequence;
if (sequence.length < 4) {
throw new asn1_ts_1.ASN1ConstructionError("KeyEncryptionKeyRecipientInfo contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "version";
sequence[1].name = "keyEncryptionKeyIdentifier";
sequence[2].name = "keyEncryptionAlgorithm";
sequence[3].name = "encryptedKey";
let version;
let keyEncryptionKeyIdentifier;
let keyEncryptionAlgorithm;
let encryptedKey;
version = Version_ta_1._decode_Version(sequence[0]);
keyEncryptionKeyIdentifier = KeyEncryptionKeyIdentifier_ta_1._decode_KeyEncryptionKeyIdentifier(sequence[1]);
keyEncryptionAlgorithm = KeyEncryptionAlgorithmIdentifier_ta_1._decode_KeyEncryptionAlgorithmIdentifier(sequence[2]);
encryptedKey = EncryptedKey_ta_1._decode_EncryptedKey(sequence[3]);
return new KeyEncryptionKeyRecipientInfo(version, keyEncryptionKeyIdentifier, keyEncryptionAlgorithm, encryptedKey);
};
}
return _cached_decoder_for_KeyEncryptionKeyRecipientInfo(el);
}
exports._decode_KeyEncryptionKeyRecipientInfo = _decode_KeyEncryptionKeyRecipientInfo;
/* END_OF_SYMBOL_DEFINITION _decode_KeyEncryptionKeyRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_KeyEncryptionKeyRecipientInfo */
let _cached_encoder_for_KeyEncryptionKeyRecipientInfo = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_KeyEncryptionKeyRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _encode_KeyEncryptionKeyRecipientInfo */
/**
* @summary Encodes a(n) KeyEncryptionKeyRecipientInfo 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 KeyEncryptionKeyRecipientInfo, encoded as an ASN.1 Element.
*/
function _encode_KeyEncryptionKeyRecipientInfo(value, elGetter) {
if (!_cached_encoder_for_KeyEncryptionKeyRecipientInfo) {
_cached_encoder_for_KeyEncryptionKeyRecipientInfo = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ Version_ta_1._encode_Version(value.version, $.BER),
/* REQUIRED */ KeyEncryptionKeyIdentifier_ta_1._encode_KeyEncryptionKeyIdentifier(value.keyEncryptionKeyIdentifier, $.BER),
/* REQUIRED */ KeyEncryptionAlgorithmIdentifier_ta_1._encode_KeyEncryptionAlgorithmIdentifier(value.keyEncryptionAlgorithm, $.BER),
/* REQUIRED */ EncryptedKey_ta_1._encode_EncryptedKey(value.encryptedKey, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_KeyEncryptionKeyRecipientInfo(value, elGetter);
}
exports._encode_KeyEncryptionKeyRecipientInfo = _encode_KeyEncryptionKeyRecipientInfo;
/* END_OF_SYMBOL_DEFINITION _encode_KeyEncryptionKeyRecipientInfo */
/* eslint-enable */
//# sourceMappingURL=KeyEncryptionKeyRecipientInfo.ta.js.map