pkcs-ts
Version:
PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More
68 lines • 4.49 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;
const tslib_1 = require("tslib");
const asn1_ts_1 = require("asn1-ts");
const $ = tslib_1.__importStar(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; } });
class RecipientEncryptedKey {
constructor(recipientIdentifier, encryptedKey) {
this.recipientIdentifier = recipientIdentifier;
this.encryptedKey = encryptedKey;
}
static _from_object(_o) {
return new RecipientEncryptedKey(_o.recipientIdentifier, _o.encryptedKey);
}
}
exports.RecipientEncryptedKey = RecipientEncryptedKey;
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),
];
exports._root_component_type_list_2_spec_for_RecipientEncryptedKey = [];
exports._extension_additions_list_spec_for_RecipientEncryptedKey = [];
let _cached_decoder_for_RecipientEncryptedKey = null;
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;
let _cached_encoder_for_RecipientEncryptedKey = null;
function _encode_RecipientEncryptedKey(value, elGetter) {
if (!_cached_encoder_for_RecipientEncryptedKey) {
_cached_encoder_for_RecipientEncryptedKey = function (value, elGetter) {
return $._encodeSequence([]
.concat([
KeyAgreementRecipientIdentifier_ta_1._encode_KeyAgreementRecipientIdentifier(value.recipientIdentifier, $.BER),
EncryptedKey_ta_1._encode_EncryptedKey(value.encryptedKey, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_RecipientEncryptedKey(value, elGetter);
}
exports._encode_RecipientEncryptedKey = _encode_RecipientEncryptedKey;
//# sourceMappingURL=RecipientEncryptedKey.ta.js.map