mirror of
https://github.com/moparisthebest/mail
synced 2024-08-13 16:43:47 -04:00
[WO-510] fix toBigInteger bug
* Add tests to reconstruct the issue * Upgrade to OpenPGP.js v0.7.2
This commit is contained in:
parent
1e7255f8ce
commit
e072f118ca
@ -1510,7 +1510,7 @@ module.exports = {
|
|||||||
|
|
||||||
show_version: true,
|
show_version: true,
|
||||||
show_comment: true,
|
show_comment: true,
|
||||||
versionstring: "OpenPGP.js v0.7.1",
|
versionstring: "OpenPGP.js v0.7.2",
|
||||||
commentstring: "Whiteout Mail - https://whiteout.io",
|
commentstring: "Whiteout Mail - https://whiteout.io",
|
||||||
|
|
||||||
keyserver: "keyserver.linux.it", // "pgp.mit.edu:11371"
|
keyserver: "keyserver.linux.it", // "pgp.mit.edu:11371"
|
||||||
@ -11767,6 +11767,10 @@ function generate(options) {
|
|||||||
if (options.keyType !== enums.publicKey.rsa_encrypt_sign) {
|
if (options.keyType !== enums.publicKey.rsa_encrypt_sign) {
|
||||||
throw new Error('Only RSA Encrypt or Sign supported');
|
throw new Error('Only RSA Encrypt or Sign supported');
|
||||||
}
|
}
|
||||||
|
// Key without passphrase is unlocked by definition
|
||||||
|
if (!options.passphrase) {
|
||||||
|
options.unlocked = true;
|
||||||
|
}
|
||||||
|
|
||||||
var packetlist = new packet.List();
|
var packetlist = new packet.List();
|
||||||
|
|
||||||
@ -14657,6 +14661,9 @@ SecretKey.prototype.generate = function (bits) {
|
|||||||
* Clear private MPIs, return to initial state
|
* Clear private MPIs, return to initial state
|
||||||
*/
|
*/
|
||||||
SecretKey.prototype.clearPrivateMPIs = function () {
|
SecretKey.prototype.clearPrivateMPIs = function () {
|
||||||
|
if (!this.encrypted) {
|
||||||
|
throw new Error('If secret key is not encrypted, clearing private MPIs is irreversible.');
|
||||||
|
}
|
||||||
this.mpi = this.mpi.slice(0, crypto.getPublicMpiCount(this.algorithm));
|
this.mpi = this.mpi.slice(0, crypto.getPublicMpiCount(this.algorithm));
|
||||||
this.isDecrypted = false;
|
this.isDecrypted = false;
|
||||||
};
|
};
|
||||||
|
@ -14,7 +14,7 @@ define(function(require) {
|
|||||||
keySize = 512,
|
keySize = 512,
|
||||||
keyId = 'F6F60E9B42CDFF4C',
|
keyId = 'F6F60E9B42CDFF4C',
|
||||||
pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK-----\r\n' +
|
pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK-----\r\n' +
|
||||||
'Version: OpenPGP.js v0.7.1\r\n' +
|
'Version: OpenPGP.js v0.7.2\r\n' +
|
||||||
'Comment: Whiteout Mail - https://whiteout.io\r\n' +
|
'Comment: Whiteout Mail - https://whiteout.io\r\n' +
|
||||||
'\r\n' +
|
'\r\n' +
|
||||||
'xk0EUlhMvAEB/2MZtCUOAYvyLFjDp3OBMGn3Ev8FwjzyPbIF0JUw+L7y2XR5\r\n' +
|
'xk0EUlhMvAEB/2MZtCUOAYvyLFjDp3OBMGn3Ev8FwjzyPbIF0JUw+L7y2XR5\r\n' +
|
||||||
@ -25,7 +25,7 @@ define(function(require) {
|
|||||||
'=6XMW\r\n' +
|
'=6XMW\r\n' +
|
||||||
'-----END PGP PUBLIC KEY BLOCK-----\r\n\r\n',
|
'-----END PGP PUBLIC KEY BLOCK-----\r\n\r\n',
|
||||||
privkey = '-----BEGIN PGP PRIVATE KEY BLOCK-----\r\n' +
|
privkey = '-----BEGIN PGP PRIVATE KEY BLOCK-----\r\n' +
|
||||||
'Version: OpenPGP.js v0.7.1\r\n' +
|
'Version: OpenPGP.js v0.7.2\r\n' +
|
||||||
'Comment: Whiteout Mail - https://whiteout.io\r\n' +
|
'Comment: Whiteout Mail - https://whiteout.io\r\n' +
|
||||||
'\r\n' +
|
'\r\n' +
|
||||||
'xcBeBFJYTLwBAf9jGbQlDgGL8ixYw6dzgTBp9xL/BcI88j2yBdCVMPi+8tl0\r\n' +
|
'xcBeBFJYTLwBAf9jGbQlDgGL8ixYw6dzgTBp9xL/BcI88j2yBdCVMPi+8tl0\r\n' +
|
||||||
@ -80,9 +80,29 @@ define(function(require) {
|
|||||||
expect(keys.keyId).to.exist;
|
expect(keys.keyId).to.exist;
|
||||||
expect(keys.privateKeyArmored).to.exist;
|
expect(keys.privateKeyArmored).to.exist;
|
||||||
expect(keys.publicKeyArmored).to.exist;
|
expect(keys.publicKeyArmored).to.exist;
|
||||||
|
|
||||||
|
// test encrypt/decrypt
|
||||||
|
pgp.importKeys({
|
||||||
|
passphrase: passphrase,
|
||||||
|
privateKeyArmored: keys.privateKeyArmored,
|
||||||
|
publicKeyArmored: keys.publicKeyArmored
|
||||||
|
}, function(err) {
|
||||||
|
expect(err).to.not.exist;
|
||||||
|
|
||||||
|
pgp.encrypt('secret', [keys.publicKeyArmored], function(err, ct) {
|
||||||
|
expect(err).to.not.exist;
|
||||||
|
expect(ct).to.exist;
|
||||||
|
|
||||||
|
pgp.decrypt(ct, keys.publicKeyArmored, function(err, pt, signValid) {
|
||||||
|
expect(err).to.not.exist;
|
||||||
|
expect(pt).to.equal('secret');
|
||||||
|
expect(signValid).to.be.true;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
it('should work without passphrase', function(done) {
|
it('should work without passphrase', function(done) {
|
||||||
pgp.generateKeys({
|
pgp.generateKeys({
|
||||||
emailAddress: user,
|
emailAddress: user,
|
||||||
@ -93,10 +113,30 @@ define(function(require) {
|
|||||||
expect(keys.keyId).to.exist;
|
expect(keys.keyId).to.exist;
|
||||||
expect(keys.privateKeyArmored).to.exist;
|
expect(keys.privateKeyArmored).to.exist;
|
||||||
expect(keys.publicKeyArmored).to.exist;
|
expect(keys.publicKeyArmored).to.exist;
|
||||||
|
|
||||||
|
// test encrypt/decrypt
|
||||||
|
pgp.importKeys({
|
||||||
|
passphrase: undefined,
|
||||||
|
privateKeyArmored: keys.privateKeyArmored,
|
||||||
|
publicKeyArmored: keys.publicKeyArmored
|
||||||
|
}, function(err) {
|
||||||
|
expect(err).to.not.exist;
|
||||||
|
|
||||||
|
pgp.encrypt('secret', [keys.publicKeyArmored], function(err, ct) {
|
||||||
|
expect(err).to.not.exist;
|
||||||
|
expect(ct).to.exist;
|
||||||
|
|
||||||
|
pgp.decrypt(ct, keys.publicKeyArmored, function(err, pt, signValid) {
|
||||||
|
expect(err).to.not.exist;
|
||||||
|
expect(pt).to.equal('secret');
|
||||||
|
expect(signValid).to.be.true;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('Import/Export key pair', function() {
|
describe('Import/Export key pair', function() {
|
||||||
it('should fail', function(done) {
|
it('should fail', function(done) {
|
||||||
|
Loading…
Reference in New Issue
Block a user