@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
161 lines • 7.5 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_KeyAgreeRecipientIdentifier = exports._decode_KeyAgreeRecipientIdentifier = 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("../CryptographicMessageSyntax/EncryptedKey.ta");
const KeyAgreeRecipientIdentifier_ta_1 = require("../CryptographicMessageSyntax/KeyAgreeRecipientIdentifier.ta");
var EncryptedKey_ta_2 = require("../CryptographicMessageSyntax/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 KeyAgreeRecipientIdentifier_ta_2 = require("../CryptographicMessageSyntax/KeyAgreeRecipientIdentifier.ta");
Object.defineProperty(exports, "_decode_KeyAgreeRecipientIdentifier", { enumerable: true, get: function () { return KeyAgreeRecipientIdentifier_ta_2._decode_KeyAgreeRecipientIdentifier; } });
Object.defineProperty(exports, "_encode_KeyAgreeRecipientIdentifier", { enumerable: true, get: function () { return KeyAgreeRecipientIdentifier_ta_2._encode_KeyAgreeRecipientIdentifier; } });
/* START_OF_SYMBOL_DEFINITION RecipientEncryptedKey */
/**
* @summary RecipientEncryptedKey
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* RecipientEncryptedKey ::= SEQUENCE {
* rid KeyAgreeRecipientIdentifier,
* encryptedKey EncryptedKey
* }
* ```
*
* @class
*/
class RecipientEncryptedKey {
constructor(
/**
* @summary `rid`.
* @public
* @readonly
*/
rid,
/**
* @summary `encryptedKey`.
* @public
* @readonly
*/
encryptedKey) {
this.rid = rid;
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.rid, _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("rid", 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 = "rid";
sequence[1].name = "encryptedKey";
let rid;
let encryptedKey;
rid = KeyAgreeRecipientIdentifier_ta_1._decode_KeyAgreeRecipientIdentifier(sequence[0]);
encryptedKey = EncryptedKey_ta_1._decode_EncryptedKey(sequence[1]);
return new RecipientEncryptedKey(rid, 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 */ KeyAgreeRecipientIdentifier_ta_1._encode_KeyAgreeRecipientIdentifier(value.rid, $.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