@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
217 lines • 11.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_KeyAgreementRecipientInfo = exports._decode_KeyAgreementRecipientInfo = exports._extension_additions_list_spec_for_KeyAgreementRecipientInfo = exports._root_component_type_list_2_spec_for_KeyAgreementRecipientInfo = exports._root_component_type_list_1_spec_for_KeyAgreementRecipientInfo = exports.KeyAgreementRecipientInfo = exports._encode_Version = exports._decode_Version = exports._encode_RecipientEncryptedKeys = exports._decode_RecipientEncryptedKeys = exports._encode_OriginatorIdentifierOrKey = exports._decode_OriginatorIdentifierOrKey = exports._encode_KeyEncryptionAlgorithmIdentifier = exports._decode_KeyEncryptionAlgorithmIdentifier = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const KeyEncryptionAlgorithmIdentifier_ta_1 = require("../PKCS7/KeyEncryptionAlgorithmIdentifier.ta");
const OriginatorIdentifierOrKey_ta_1 = require("../PKCS7/OriginatorIdentifierOrKey.ta");
const RecipientEncryptedKeys_ta_1 = require("../PKCS7/RecipientEncryptedKeys.ta");
const Version_ta_1 = require("../PKCS7/Version.ta");
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 OriginatorIdentifierOrKey_ta_2 = require("../PKCS7/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("../PKCS7/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 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 KeyAgreementRecipientInfo */
/**
* @summary KeyAgreementRecipientInfo
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* KeyAgreementRecipientInfo ::= SEQUENCE {
* version Version,
* originator [0] OriginatorIdentifierOrKey,
* userKeyingMaterial [1] EXPLICIT OCTET STRING OPTIONAL,
* keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier,
* recipientEncryptedKeys RecipientEncryptedKeys
* }
* ```
*
* @class
*/
class KeyAgreementRecipientInfo {
constructor(
/**
* @summary `version`.
* @public
* @readonly
*/
version,
/**
* @summary `originator`.
* @public
* @readonly
*/
originator,
/**
* @summary `userKeyingMaterial`.
* @public
* @readonly
*/
userKeyingMaterial,
/**
* @summary `keyEncryptionAlgorithm`.
* @public
* @readonly
*/
keyEncryptionAlgorithm,
/**
* @summary `recipientEncryptedKeys`.
* @public
* @readonly
*/
recipientEncryptedKeys) {
this.version = version;
this.originator = originator;
this.userKeyingMaterial = userKeyingMaterial;
this.keyEncryptionAlgorithm = keyEncryptionAlgorithm;
this.recipientEncryptedKeys = recipientEncryptedKeys;
}
/**
* @summary Restructures an object into a KeyAgreementRecipientInfo
* @description
*
* This takes an `object` and converts it to a `KeyAgreementRecipientInfo`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `KeyAgreementRecipientInfo`.
* @returns {KeyAgreementRecipientInfo}
*/
static _from_object(_o) {
return new KeyAgreementRecipientInfo(_o.version, _o.originator, _o.userKeyingMaterial, _o.keyEncryptionAlgorithm, _o.recipientEncryptedKeys);
}
}
exports.KeyAgreementRecipientInfo = KeyAgreementRecipientInfo;
/* END_OF_SYMBOL_DEFINITION KeyAgreementRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_KeyAgreementRecipientInfo */
/**
* @summary The Leading Root Component Types of KeyAgreementRecipientInfo
* @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_KeyAgreementRecipientInfo = [
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("userKeyingMaterial", 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_KeyAgreementRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_KeyAgreementRecipientInfo */
/**
* @summary The Trailing Root Component Types of KeyAgreementRecipientInfo
* @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_KeyAgreementRecipientInfo = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_KeyAgreementRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_KeyAgreementRecipientInfo */
/**
* @summary The Extension Addition Component Types of KeyAgreementRecipientInfo
* @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_KeyAgreementRecipientInfo = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_KeyAgreementRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_KeyAgreementRecipientInfo */
let _cached_decoder_for_KeyAgreementRecipientInfo = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_KeyAgreementRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _decode_KeyAgreementRecipientInfo */
/**
* @summary Decodes an ASN.1 element into a(n) KeyAgreementRecipientInfo
* @function
* @param {_Element} el The element being decoded.
* @returns {KeyAgreementRecipientInfo} The decoded data structure.
*/
function _decode_KeyAgreementRecipientInfo(el) {
if (!_cached_decoder_for_KeyAgreementRecipientInfo) {
_cached_decoder_for_KeyAgreementRecipientInfo = function (el) {
/* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */
let version;
let originator;
let userKeyingMaterial;
let keyEncryptionAlgorithm;
let recipientEncryptedKeys;
/* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */
/* START_OF_CALLBACKS_MAP */
const callbacks = {
version: (_el) => {
version = Version_ta_1._decode_Version(_el);
},
originator: (_el) => {
originator = $._decode_explicit(() => OriginatorIdentifierOrKey_ta_1._decode_OriginatorIdentifierOrKey)(_el);
},
userKeyingMaterial: (_el) => {
userKeyingMaterial = $._decode_explicit(() => $._decodeOctetString)(_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_KeyAgreementRecipientInfo, exports._extension_additions_list_spec_for_KeyAgreementRecipientInfo, exports._root_component_type_list_2_spec_for_KeyAgreementRecipientInfo, undefined);
return new KeyAgreementRecipientInfo(
/* SEQUENCE_CONSTRUCTOR_CALL */ version, originator, userKeyingMaterial, keyEncryptionAlgorithm, recipientEncryptedKeys);
};
}
return _cached_decoder_for_KeyAgreementRecipientInfo(el);
}
exports._decode_KeyAgreementRecipientInfo = _decode_KeyAgreementRecipientInfo;
/* END_OF_SYMBOL_DEFINITION _decode_KeyAgreementRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_KeyAgreementRecipientInfo */
let _cached_encoder_for_KeyAgreementRecipientInfo = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_KeyAgreementRecipientInfo */
/* START_OF_SYMBOL_DEFINITION _encode_KeyAgreementRecipientInfo */
/**
* @summary Encodes a(n) KeyAgreementRecipientInfo 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 KeyAgreementRecipientInfo, encoded as an ASN.1 Element.
*/
function _encode_KeyAgreementRecipientInfo(value, elGetter) {
if (!_cached_encoder_for_KeyAgreementRecipientInfo) {
_cached_encoder_for_KeyAgreementRecipientInfo = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ Version_ta_1._encode_Version(value.version, $.BER),
/* REQUIRED */ $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 0, () => OriginatorIdentifierOrKey_ta_1._encode_OriginatorIdentifierOrKey, $.BER)(value.originator, $.BER),
/* IF_ABSENT */ value.userKeyingMaterial === undefined
? undefined
: $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 1, () => $._encodeOctetString, $.BER)(value.userKeyingMaterial, $.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_KeyAgreementRecipientInfo(value, elGetter);
}
exports._encode_KeyAgreementRecipientInfo = _encode_KeyAgreementRecipientInfo;
/* END_OF_SYMBOL_DEFINITION _encode_KeyAgreementRecipientInfo */
/* eslint-enable */
//# sourceMappingURL=KeyAgreementRecipientInfo.ta.js.map