@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
231 lines • 14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_KeyAgreeRecipientInfo = exports._decode_KeyAgreeRecipientInfo = exports._extension_additions_list_spec_for_KeyAgreeRecipientInfo = exports._root_component_type_list_2_spec_for_KeyAgreeRecipientInfo = exports._root_component_type_list_1_spec_for_KeyAgreeRecipientInfo = exports.KeyAgreeRecipientInfo = exports._encode_UserKeyingMaterial = exports._decode_UserKeyingMaterial = exports._encode_RecipientEncryptedKeys = exports._decode_RecipientEncryptedKeys = exports._encode_OriginatorIdentifierOrKey = exports._decode_OriginatorIdentifierOrKey = exports._encode_KeyEncryptionAlgorithmIdentifier = exports._decode_KeyEncryptionAlgorithmIdentifier = exports._encode_CMSVersion = exports._decode_CMSVersion = exports.v4 = exports.v3 = exports.v2 = exports.v1 = exports.v0 = exports.CMSVersion_v4 = exports.CMSVersion_v3 = exports.CMSVersion_v2 = exports.CMSVersion_v1 = exports.CMSVersion_v0 = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const CMSVersion_ta_1 = require("../CryptographicMessageSyntax/CMSVersion.ta");
const KeyEncryptionAlgorithmIdentifier_ta_1 = require("../CryptographicMessageSyntax/KeyEncryptionAlgorithmIdentifier.ta");
const OriginatorIdentifierOrKey_ta_1 = require("../CryptographicMessageSyntax/OriginatorIdentifierOrKey.ta");
const RecipientEncryptedKeys_ta_1 = require("../CryptographicMessageSyntax/RecipientEncryptedKeys.ta");
const UserKeyingMaterial_ta_1 = require("../CryptographicMessageSyntax/UserKeyingMaterial.ta");
var CMSVersion_ta_2 = require("../CryptographicMessageSyntax/CMSVersion.ta");
Object.defineProperty(exports, "CMSVersion_v0", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v0; } }); /* IMPORTED_LONG_NAMED_INTEGER */
Object.defineProperty(exports, "CMSVersion_v1", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v1; } }); /* IMPORTED_LONG_NAMED_INTEGER */
Object.defineProperty(exports, "CMSVersion_v2", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v2; } }); /* IMPORTED_LONG_NAMED_INTEGER */
Object.defineProperty(exports, "CMSVersion_v3", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v3; } }); /* IMPORTED_LONG_NAMED_INTEGER */
Object.defineProperty(exports, "CMSVersion_v4", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v4; } }); /* IMPORTED_LONG_NAMED_INTEGER */
Object.defineProperty(exports, "v0", { enumerable: true, get: function () { return CMSVersion_ta_2.v0; } }); /* IMPORTED_SHORT_NAMED_INTEGER */
Object.defineProperty(exports, "v1", { enumerable: true, get: function () { return CMSVersion_ta_2.v1; } }); /* IMPORTED_SHORT_NAMED_INTEGER */
Object.defineProperty(exports, "v2", { enumerable: true, get: function () { return CMSVersion_ta_2.v2; } }); /* IMPORTED_SHORT_NAMED_INTEGER */
Object.defineProperty(exports, "v3", { enumerable: true, get: function () { return CMSVersion_ta_2.v3; } }); /* IMPORTED_SHORT_NAMED_INTEGER */
Object.defineProperty(exports, "v4", { enumerable: true, get: function () { return CMSVersion_ta_2.v4; } }); /* IMPORTED_SHORT_NAMED_INTEGER */
Object.defineProperty(exports, "_decode_CMSVersion", { enumerable: true, get: function () { return CMSVersion_ta_2._decode_CMSVersion; } });
Object.defineProperty(exports, "_encode_CMSVersion", { enumerable: true, get: function () { return CMSVersion_ta_2._encode_CMSVersion; } });
var KeyEncryptionAlgorithmIdentifier_ta_2 = require("../CryptographicMessageSyntax/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 OriginatorIdentifierOrKey_ta_2 = require("../CryptographicMessageSyntax/OriginatorIdentifierOrKey.ta");
Object.defineProperty(exports, "_decode_OriginatorIdentifierOrKey", { enumerable: true, get: function () { return OriginatorIdentifierOrKey_ta_2._decode_OriginatorIdentifierOrKey; } });
Object.defineProperty(exports, "_encode_OriginatorIdentifierOrKey", { enumerable: true, get: function () { return OriginatorIdentifierOrKey_ta_2._encode_OriginatorIdentifierOrKey; } });
var RecipientEncryptedKeys_ta_2 = require("../CryptographicMessageSyntax/RecipientEncryptedKeys.ta");
Object.defineProperty(exports, "_decode_RecipientEncryptedKeys", { enumerable: true, get: function () { return RecipientEncryptedKeys_ta_2._decode_RecipientEncryptedKeys; } });
Object.defineProperty(exports, "_encode_RecipientEncryptedKeys", { enumerable: true, get: function () { return RecipientEncryptedKeys_ta_2._encode_RecipientEncryptedKeys; } });
var UserKeyingMaterial_ta_2 = require("../CryptographicMessageSyntax/UserKeyingMaterial.ta");
Object.defineProperty(exports, "_decode_UserKeyingMaterial", { enumerable: true, get: function () { return UserKeyingMaterial_ta_2._decode_UserKeyingMaterial; } });
Object.defineProperty(exports, "_encode_UserKeyingMaterial", { enumerable: true, get: function () { return UserKeyingMaterial_ta_2._encode_UserKeyingMaterial; } });
/* START_OF_SYMBOL_DEFINITION KeyAgreeRecipientInfo */
/**
* @summary KeyAgreeRecipientInfo
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* KeyAgreeRecipientInfo ::= SEQUENCE {
* version CMSVersion, -- always set to 3
* originator [0] EXPLICIT OriginatorIdentifierOrKey,
* ukm [1] EXPLICIT UserKeyingMaterial OPTIONAL,
* keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier,
* recipientEncryptedKeys RecipientEncryptedKeys
* }
* ```
*
* @class
*/
class KeyAgreeRecipientInfo {
constructor(
/**
* @summary `version`.
* @public
* @readonly
*/
version,
/**
* @summary `originator`.
* @public
* @readonly
*/
originator,
/**
* @summary `ukm`.
* @public
* @readonly
*/
ukm,
/**
* @summary `keyEncryptionAlgorithm`.
* @public
* @readonly
*/
keyEncryptionAlgorithm,
/**
* @summary `recipientEncryptedKeys`.
* @public
* @readonly
*/
recipientEncryptedKeys) {
this.version = version;
this.originator = originator;
this.ukm = ukm;
this.keyEncryptionAlgorithm = keyEncryptionAlgorithm;
this.recipientEncryptedKeys = recipientEncryptedKeys;
}
/**
* @summary Restructures an object into a KeyAgreeRecipientInfo
* @description
*
* This takes an `object` and converts it to a `KeyAgreeRecipientInfo`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `KeyAgreeRecipientInfo`.
* @returns {KeyAgreeRecipientInfo}
*/
static _from_object(_o) {
return new KeyAgreeRecipientInfo(_o.version, _o.originator, _o.ukm, _o.keyEncryptionAlgorithm, _o.recipientEncryptedKeys);
}
}
exports.KeyAgreeRecipientInfo = KeyAgreeRecipientInfo;
/* END_OF_SYMBOL_DEFINITION KeyAgreeRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_KeyAgreeRecipientInfo */
/**
* @summary The Leading Root Component Types of KeyAgreeRecipientInfo
* @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_KeyAgreeRecipientInfo = [
new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("originator", false, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined),
new $.ComponentSpec("ukm", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined),
new $.ComponentSpec("keyEncryptionAlgorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("recipientEncryptedKeys", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_KeyAgreeRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_KeyAgreeRecipientInfo */
/**
* @summary The Trailing Root Component Types of KeyAgreeRecipientInfo
* @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_KeyAgreeRecipientInfo = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_KeyAgreeRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_KeyAgreeRecipientInfo */
/**
* @summary The Extension Addition Component Types of KeyAgreeRecipientInfo
* @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_KeyAgreeRecipientInfo = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_KeyAgreeRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_KeyAgreeRecipientInfo */
let _cached_decoder_for_KeyAgreeRecipientInfo = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_KeyAgreeRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _decode_KeyAgreeRecipientInfo */
/**
* @summary Decodes an ASN.1 element into a(n) KeyAgreeRecipientInfo
* @function
* @param {_Element} el The element being decoded.
* @returns {KeyAgreeRecipientInfo} The decoded data structure.
*/
function _decode_KeyAgreeRecipientInfo(el) {
if (!_cached_decoder_for_KeyAgreeRecipientInfo) {
_cached_decoder_for_KeyAgreeRecipientInfo = function (el) {
/* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */
let version;
let originator;
let ukm;
let keyEncryptionAlgorithm;
let recipientEncryptedKeys;
/* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */
/* START_OF_CALLBACKS_MAP */
const callbacks = {
version: (_el) => {
version = CMSVersion_ta_1._decode_CMSVersion(_el);
},
originator: (_el) => {
originator = $._decode_explicit(() => OriginatorIdentifierOrKey_ta_1._decode_OriginatorIdentifierOrKey)(_el);
},
ukm: (_el) => {
ukm = $._decode_explicit(() => UserKeyingMaterial_ta_1._decode_UserKeyingMaterial)(_el);
},
keyEncryptionAlgorithm: (_el) => {
keyEncryptionAlgorithm = KeyEncryptionAlgorithmIdentifier_ta_1._decode_KeyEncryptionAlgorithmIdentifier(_el);
},
recipientEncryptedKeys: (_el) => {
recipientEncryptedKeys = RecipientEncryptedKeys_ta_1._decode_RecipientEncryptedKeys(_el);
},
};
/* END_OF_CALLBACKS_MAP */
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_KeyAgreeRecipientInfo, exports._extension_additions_list_spec_for_KeyAgreeRecipientInfo, exports._root_component_type_list_2_spec_for_KeyAgreeRecipientInfo, undefined);
return new KeyAgreeRecipientInfo(
/* SEQUENCE_CONSTRUCTOR_CALL */ version, originator, ukm, keyEncryptionAlgorithm, recipientEncryptedKeys);
};
}
return _cached_decoder_for_KeyAgreeRecipientInfo(el);
}
exports._decode_KeyAgreeRecipientInfo = _decode_KeyAgreeRecipientInfo;
/* END_OF_SYMBOL_DEFINITION _decode_KeyAgreeRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_KeyAgreeRecipientInfo */
let _cached_encoder_for_KeyAgreeRecipientInfo = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_KeyAgreeRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _encode_KeyAgreeRecipientInfo */
/**
* @summary Encodes a(n) KeyAgreeRecipientInfo 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 KeyAgreeRecipientInfo, encoded as an ASN.1 Element.
*/
function _encode_KeyAgreeRecipientInfo(value, elGetter) {
if (!_cached_encoder_for_KeyAgreeRecipientInfo) {
_cached_encoder_for_KeyAgreeRecipientInfo = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ CMSVersion_ta_1._encode_CMSVersion(value.version, $.BER),
/* REQUIRED */ $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 0, () => OriginatorIdentifierOrKey_ta_1._encode_OriginatorIdentifierOrKey, $.BER)(value.originator, $.BER),
/* IF_ABSENT */ value.ukm === undefined
? undefined
: $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 1, () => UserKeyingMaterial_ta_1._encode_UserKeyingMaterial, $.BER)(value.ukm, $.BER),
/* REQUIRED */ KeyEncryptionAlgorithmIdentifier_ta_1._encode_KeyEncryptionAlgorithmIdentifier(value.keyEncryptionAlgorithm, $.BER),
/* REQUIRED */ RecipientEncryptedKeys_ta_1._encode_RecipientEncryptedKeys(value.recipientEncryptedKeys, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_KeyAgreeRecipientInfo(value, elGetter);
}
exports._encode_KeyAgreeRecipientInfo = _encode_KeyAgreeRecipientInfo;
/* END_OF_SYMBOL_DEFINITION _encode_KeyAgreeRecipientInfo */
/* eslint-enable */
//# sourceMappingURL=KeyAgreeRecipientInfo.ta.js.map