@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
161 lines • 7.68 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_RecipientEncryptedKey = exports._decode_RecipientEncryptedKey = exports._extension_additions_list_spec_for_RecipientEncryptedKey = exports._root_component_type_list_2_spec_for_RecipientEncryptedKey = exports._root_component_type_list_1_spec_for_RecipientEncryptedKey = exports.RecipientEncryptedKey = exports._encode_KeyAgreementRecipientIdentifier = exports._decode_KeyAgreementRecipientIdentifier = 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 KeyAgreementRecipientIdentifier_ta_1 = require("../PKCS7/KeyAgreementRecipientIdentifier.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 KeyAgreementRecipientIdentifier_ta_2 = require("../PKCS7/KeyAgreementRecipientIdentifier.ta");
Object.defineProperty(exports, "_decode_KeyAgreementRecipientIdentifier", { enumerable: true, get: function () { return KeyAgreementRecipientIdentifier_ta_2._decode_KeyAgreementRecipientIdentifier; } });
Object.defineProperty(exports, "_encode_KeyAgreementRecipientIdentifier", { enumerable: true, get: function () { return KeyAgreementRecipientIdentifier_ta_2._encode_KeyAgreementRecipientIdentifier; } });
/* START_OF_SYMBOL_DEFINITION RecipientEncryptedKey */
/**
* @summary RecipientEncryptedKey
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* RecipientEncryptedKey ::= SEQUENCE {
* recipientIdentifier KeyAgreementRecipientIdentifier,
* encryptedKey EncryptedKey
* }
* ```
*
* @class
*/
class RecipientEncryptedKey {
constructor(
/**
* @summary `recipientIdentifier`.
* @public
* @readonly
*/
recipientIdentifier,
/**
* @summary `encryptedKey`.
* @public
* @readonly
*/
encryptedKey) {
this.recipientIdentifier = recipientIdentifier;
this.encryptedKey = encryptedKey;
}
/**
* @summary Restructures an object into a RecipientEncryptedKey
* @description
*
* This takes an `object` and converts it to a `RecipientEncryptedKey`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `RecipientEncryptedKey`.
* @returns {RecipientEncryptedKey}
*/
static _from_object(_o) {
return new RecipientEncryptedKey(_o.recipientIdentifier, _o.encryptedKey);
}
}
exports.RecipientEncryptedKey = RecipientEncryptedKey;
/* END_OF_SYMBOL_DEFINITION RecipientEncryptedKey */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_RecipientEncryptedKey */
/**
* @summary The Leading Root Component Types of RecipientEncryptedKey
* @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_RecipientEncryptedKey = [
new $.ComponentSpec("recipientIdentifier", false, $.hasAnyTag, 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_RecipientEncryptedKey */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_RecipientEncryptedKey */
/**
* @summary The Trailing Root Component Types of RecipientEncryptedKey
* @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_RecipientEncryptedKey = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_RecipientEncryptedKey */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_RecipientEncryptedKey */
/**
* @summary The Extension Addition Component Types of RecipientEncryptedKey
* @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_RecipientEncryptedKey = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_RecipientEncryptedKey */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_RecipientEncryptedKey */
let _cached_decoder_for_RecipientEncryptedKey = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_RecipientEncryptedKey */
/* START_OF_SYMBOL_DEFINITION _decode_RecipientEncryptedKey */
/**
* @summary Decodes an ASN.1 element into a(n) RecipientEncryptedKey
* @function
* @param {_Element} el The element being decoded.
* @returns {RecipientEncryptedKey} The decoded data structure.
*/
function _decode_RecipientEncryptedKey(el) {
if (!_cached_decoder_for_RecipientEncryptedKey) {
_cached_decoder_for_RecipientEncryptedKey = function (el) {
const sequence = el.sequence;
if (sequence.length < 2) {
throw new asn1_ts_1.ASN1ConstructionError("RecipientEncryptedKey contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "recipientIdentifier";
sequence[1].name = "encryptedKey";
let recipientIdentifier;
let encryptedKey;
recipientIdentifier = KeyAgreementRecipientIdentifier_ta_1._decode_KeyAgreementRecipientIdentifier(sequence[0]);
encryptedKey = EncryptedKey_ta_1._decode_EncryptedKey(sequence[1]);
return new RecipientEncryptedKey(recipientIdentifier, encryptedKey);
};
}
return _cached_decoder_for_RecipientEncryptedKey(el);
}
exports._decode_RecipientEncryptedKey = _decode_RecipientEncryptedKey;
/* END_OF_SYMBOL_DEFINITION _decode_RecipientEncryptedKey */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_RecipientEncryptedKey */
let _cached_encoder_for_RecipientEncryptedKey = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_RecipientEncryptedKey */
/* START_OF_SYMBOL_DEFINITION _encode_RecipientEncryptedKey */
/**
* @summary Encodes a(n) RecipientEncryptedKey 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 RecipientEncryptedKey, encoded as an ASN.1 Element.
*/
function _encode_RecipientEncryptedKey(value, elGetter) {
if (!_cached_encoder_for_RecipientEncryptedKey) {
_cached_encoder_for_RecipientEncryptedKey = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ KeyAgreementRecipientIdentifier_ta_1._encode_KeyAgreementRecipientIdentifier(value.recipientIdentifier, $.BER),
/* REQUIRED */ EncryptedKey_ta_1._encode_EncryptedKey(value.encryptedKey, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_RecipientEncryptedKey(value, elGetter);
}
exports._encode_RecipientEncryptedKey = _encode_RecipientEncryptedKey;
/* END_OF_SYMBOL_DEFINITION _encode_RecipientEncryptedKey */
/* eslint-enable */
//# sourceMappingURL=RecipientEncryptedKey.ta.js.map