Fix parsing of ECDH with unknown KDFParam version
Keys with such subkeys should still be usable, as long as they have a supported primary key.
This commit is contained in:
parent
f5b5b73f07
commit
32caf41929
|
@ -15,6 +15,8 @@
|
|||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
import { UnsupportedError } from '../packet/packet';
|
||||
|
||||
/**
|
||||
* Implementation of type KDF parameters
|
||||
*
|
||||
|
@ -50,7 +52,7 @@ class KDFParams {
|
|||
*/
|
||||
read(input) {
|
||||
if (input.length < 4 || input[0] !== 3 || input[1] !== 1) {
|
||||
throw new Error('Cannot read KDFParams');
|
||||
throw new UnsupportedError('Cannot read KDFParams');
|
||||
}
|
||||
this.hash = input[2];
|
||||
this.cipher = input[3];
|
||||
|
|
|
@ -2972,6 +2972,46 @@ module.exports = () => describe('Key', function() {
|
|||
expect(key).to.exist;
|
||||
});
|
||||
|
||||
it('Parsing ECDH key with unknown kdf param version', async function() {
|
||||
// subkey with unknown kdfParam version 255. Parsing should not fail, the subkey should simply dropped
|
||||
const key = await openpgp.readKey({ armoredKey: `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
||||
|
||||
xVgEZAdtGBYJKwYBBAHaRw8BAQdAcNgHyRGEaqGmzEqEwCobfUkyrJnY8faBvsf9
|
||||
R2c5ZzYAAP9bFL4nPBdo04ei0C2IAh5RXOpmuejGC3GAIn/UmL5cYQ+XzRtjaGFy
|
||||
bGVzIDxjaGFybGVzQHByb3Rvbi5tZT7CigQTFggAPAUCZAdtGAmQFXJtmBzDhdcW
|
||||
IQRl2gNflypl1XjRUV8Vcm2YHMOF1wIbAwIeAQIZAQILBwIVCAIWAAIiAQAAJKYA
|
||||
/2qY16Ozyo5erNz51UrKViEoWbEpwY3XaFVNzrw+b54YAQC7zXkf/t5ieylvjmA/
|
||||
LJz3/qgH5GxZRYAH9NTpWyW1AsdxBGQHbRgSCisGAQQBl1UBBQEBB0CxmxoJsHTW
|
||||
TiETWh47ot+kwNA1hCk1IYB9WwKxkXYyIBf/CgmKXzV1ODP/mRmtiBYVV+VQk5MF
|
||||
EAAA/1NW8D8nMc2ky140sPhQrwkeR7rVLKP2fe5n4BEtAnVQEB3CeAQYFggAKgUC
|
||||
ZAdtGAmQFXJtmBzDhdcWIQRl2gNflypl1XjRUV8Vcm2YHMOF1wIbUAAAl/8A/iIS
|
||||
zWBsBR8VnoOVfEE+VQk6YAi7cTSjcMjfsIez9FYtAQDKo9aCMhUohYyqvhZjn8aS
|
||||
3t9mIZPc+zRJtCHzQYmhDg==
|
||||
=lESj
|
||||
-----END PGP PRIVATE KEY BLOCK-----` });
|
||||
|
||||
expect(key.subkeys).to.have.length(0);
|
||||
|
||||
await expect(openpgp.readKey({
|
||||
armoredKey: `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
||||
|
||||
xVgEZAdtGBYJKwYBBAHaRw8BAQdAcNgHyRGEaqGmzEqEwCobfUkyrJnY8faBvsf9
|
||||
R2c5ZzYAAP9bFL4nPBdo04ei0C2IAh5RXOpmuejGC3GAIn/UmL5cYQ+XzRtjaGFy
|
||||
bGVzIDxjaGFybGVzQHByb3Rvbi5tZT7CigQTFggAPAUCZAdtGAmQFXJtmBzDhdcW
|
||||
IQRl2gNflypl1XjRUV8Vcm2YHMOF1wIbAwIeAQIZAQILBwIVCAIWAAIiAQAAJKYA
|
||||
/2qY16Ozyo5erNz51UrKViEoWbEpwY3XaFVNzrw+b54YAQC7zXkf/t5ieylvjmA/
|
||||
LJz3/qgH5GxZRYAH9NTpWyW1AsdxBGQHbRgSCisGAQQBl1UBBQEBB0CxmxoJsHTW
|
||||
TiETWh47ot+kwNA1hCk1IYB9WwKxkXYyIBf/CgmKXzV1ODP/mRmtiBYVV+VQk5MF
|
||||
EAAA/1NW8D8nMc2ky140sPhQrwkeR7rVLKP2fe5n4BEtAnVQEB3CeAQYFggAKgUC
|
||||
ZAdtGAmQFXJtmBzDhdcWIQRl2gNflypl1XjRUV8Vcm2YHMOF1wIbUAAAl/8A/iIS
|
||||
zWBsBR8VnoOVfEE+VQk6YAi7cTSjcMjfsIez9FYtAQDKo9aCMhUohYyqvhZjn8aS
|
||||
3t9mIZPc+zRJtCHzQYmhDg==
|
||||
=lESj
|
||||
-----END PGP PRIVATE KEY BLOCK-----`,
|
||||
config: { ignoreUnsupportedPackets: false }
|
||||
})).to.be.rejectedWith(/Cannot read KDFParams/);
|
||||
});
|
||||
|
||||
it('Testing key ID and fingerprint for V4 keys', async function() {
|
||||
const pubKeysV4 = await openpgp.readKeys({ armoredKeys: twoKeys });
|
||||
expect(pubKeysV4).to.exist;
|
||||
|
|
Loading…
Reference in New Issue
Block a user