Bug 1665281 - Follow-up, always check subkeys, even if primary key is usable. r=PatrickBrunschwig DONTBUILD

Differential Revision: https://phabricator.services.mozilla.com/D91581

--HG--
extra : amend_source : b28e0151f7117d1d02f2a031172c5897f26206af
This commit is contained in:
Kai Engert 2020-09-28 14:49:13 +02:00
Родитель b128976e8b
Коммит d45101f665
1 изменённых файлов: 12 добавлений и 14 удалений

Просмотреть файл

@ -1963,16 +1963,13 @@ var RNP = {
},
addSuitableEncryptKey(key, op) {
let use_sub = null;
// Prefer usable subkeys, because they are always newer
// (or same age) as primary key.
// looks like this will be unnecessary ???
if (!this.isKeyUsableFor(key, str_encrypt)) {
use_sub = this.getSuitableSubkey(key, str_encrypt);
if (!use_sub) {
let use_sub = this.getSuitableSubkey(key, str_encrypt);
if (!use_sub && !this.isKeyUsableFor(key, str_encrypt)) {
throw new Error("no suitable subkey found for " + str_encrypt);
}
}
if (
RNPLib.rnp_op_encrypt_add_recipient(op, use_sub != null ? use_sub : key)
@ -2101,13 +2098,14 @@ var RNP = {
this.addSuitableEncryptKey(senderKey, op);
}
if (args.sign) {
let use_sub = null;
if (!this.isKeyUsableFor(senderKey, str_sign)) {
use_sub = this.getSuitableSubkey(senderKey, str_sign);
if (!use_sub) {
// Prefer usable subkeys, because they are always newer
// (or same age) as primary key.
let use_sub = this.getSuitableSubkey(senderKey, str_sign);
if (!use_sub && !this.isKeyUsableFor(senderKey, str_sign)) {
throw new Error("no suitable subkey found for " + str_sign);
}
}
if (args.encrypt) {
if (
RNPLib.rnp_op_encrypt_add_signature(