Skip to content

Commit

Permalink
Add test case for unknown binary notations (#1140)
Browse files Browse the repository at this point in the history
  • Loading branch information
wiktor-k authored Aug 18, 2020
1 parent 0712e8a commit 2e26509
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/general/signature.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,32 @@ hUhMKMuiM3pRwdIyDOItkUWQmjEEw7/XmhgInkXsCw==
expect(notation.humanReadable).to.equal(false);
});

it('Checks for critical bit in non-human-readable notations', async function() {
try {
openpgp.config.tolerant = false;
await openpgp.message.readArmored(`-----BEGIN PGP SIGNATURE-----
wsEfBAABCABJBYJfKDH0K5QAAAAAAB0ABXVua25vd25AdGVzdHMuc2VxdW9pYS1w
Z3Aub3JndmFsdWUWIQTRpm4aI7GCyZgPeIz7/MgqAV5zMAAKCRD7/MgqAV5zMLBK
C/9Vdte8yq8QFp7Bo3mWWXiUDJ2vOdEpJs9PB12hN97wewjFKWvKcWRHofBrK+0v
P4/sixMjqSXB75iz/lzCbPjkmgmaGKN6Smq6Pj5kIdpWIdtfjNoa+OEn1emrxpY1
dT0Pe7r8w3Y/JmfK1ZoFfiq5YBP+rsjmAXf6BQ9RH+kMUsOgOVCjqzI5vPibTD91
Aefm7XS35Wlj/O/zFXR9tiZyE/dKIujohB3bsV6sAmYzPxZVuZCYaj+6afRlAuWg
IYs+aFmldMg4p1t1Ab/bRHbBxIlzhtbNE6IyOfc17mgOcjQzVJBc/EaxD7S3KjU2
4aFmOaLyWDrvAJu1Ror2b+zekEiq90CnCtAUiAq6/qbWlGCGX4zFKWyHousDJcEB
1n0xDkFUhndisMZanaU3S1hwzawMnpHi1RHI2a/etPPk0Ryrzo2rFi8ZdAHLWY6o
4ymAWpppg47NhCwuYh/EG5G1P4ccxksRj1GX2r5HxH8ZeAQWWdviINErgrUONWHy
bwM=
=0x2S
-----END PGP SIGNATURE-----`);
throw new Error('openpgp.message.readArmored should throw but it did not.');
} catch (e) {
expect(e.message).to.equal('Unknown critical notation: [email protected]');
} finally {
openpgp.config.tolerant = true;
}
});

it('Verify V4 signature. Hash: SHA1. PK: RSA. Signature Type: 0x00 (binary document)', async function() {
const { reject_message_hash_algorithms } = openpgp.config;
Object.assign(openpgp.config, { reject_message_hash_algorithms: new Set([openpgp.enums.hash.md5, openpgp.enums.hash.ripemd]) });
Expand Down

0 comments on commit 2e26509

Please sign in to comment.