diff --git a/src/packet/secret_key.js b/src/packet/secret_key.js index c8de668a..8258c619 100644 --- a/src/packet/secret_key.js +++ b/src/packet/secret_key.js @@ -280,11 +280,14 @@ SecretKey.prototype.makeDummy = function () { throw new Error("Key is not decrypted"); } this.clearPrivateParams(); + this.keyMaterial = null; this.isEncrypted = false; this.s2k = new type_s2k(); this.s2k.algorithm = 0; this.s2k.c = 0; this.s2k.type = 'gnu-dummy'; + this.s2k_usage = 254; + this.symmetric = 'aes256'; }; /** diff --git a/test/general/key.js b/test/general/key.js index f0e96765..bc553b7e 100644 --- a/test/general/key.js +++ b/test/general/key.js @@ -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 ' }); + 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 ' }); + 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');