-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix and test dummy key conversion (#1172)
Keys converted using makeDummy() were not serialised correctly as they were treated as unencrypted keys.
- Loading branch information
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2817,6 +2817,24 @@ describe('Key', function() { | |
await expect(key.validate()).to.be.rejectedWith('Key is invalid'); | ||
}); | ||
|
||
it('makeDummy() - the converted key can be parsed', async function() { | ||
const { key: key } = await openpgp.generateKey({ userIds: 'dummy <[email protected]>' }); | ||
key.primaryKey.makeDummy(); | ||
const parsedKeys = (await openpgp.key.readArmored(key.armor())).keys; | ||
expect(parsedKeys).to.not.be.empty; | ||
}); | ||
|
||
it('makeDummy() - the converted key can be encrypted and decrypted', async function() { | ||
const { key: key } = await openpgp.generateKey({ userIds: 'dummy <[email protected]>' }); | ||
const passphrase = 'passphrase'; | ||
key.primaryKey.makeDummy(); | ||
expect(key.isDecrypted()).to.be.true; | ||
await key.encrypt(passphrase); | ||
expect(key.isDecrypted()).to.be.false; | ||
await key.decrypt(passphrase); | ||
expect(key.isDecrypted()).to.be.true; | ||
}); | ||
|
||
it('makeDummy() - the converted key is valid but can no longer sign', async function() { | ||
const { keys: [key] } = await openpgp.key.readArmored(priv_key_rsa); | ||
await key.decrypt('hello world'); | ||
|