mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2026-03-19 14:48:59 +00:00
Addresses various review comments by @sanjanarajan
* Various FIXME tags are removed * In curve.js: - webCrypto/nodeCrypto fallback bug is fixed - Curve25519 has keyType ecdsa (won't be used for signing, but technically can be) - webGenKeyPair is simplifed * In base64.js: - documentation added and arguments simplified * In ecdsa.js and eddsa.js: - hash_algo is now at least as strong as the default curve hash - simplified the code by moving webSign/nodeSign and webVerify/nodeVerify to live in key.js (ht @ismaelbej) * In message.js: - in decryptSessionKey, loops break once a key packet is decrypted * In key.js: - getPreferredHashAlgorithm returns the best hash algorithm - enums are used for curve selection
This commit is contained in:
committed by
Sanjana Rajan
parent
3129e7c4e3
commit
5cb89f4f25
@@ -175,22 +175,22 @@ describe('Elliptic Curve Cryptography', function () {
|
||||
it('Signature verification', function (done) {
|
||||
var curve = elliptic_curves.get('p256');
|
||||
var key = curve.keyFromPublic(signature_data.pub);
|
||||
expect(key.verify(signature_data.message, signature_data.signature, 8)).to.be.true;
|
||||
expect(key.verify(signature_data.message, signature_data.signature, 8)).to.eventually.be.true;
|
||||
done();
|
||||
});
|
||||
it('Invalid signature', function (done) {
|
||||
var curve = elliptic_curves.get('p256');
|
||||
var key = curve.keyFromPublic(key_data.p256.pub);
|
||||
expect(key.verify(signature_data.message, signature_data.signature, 8)).to.be.false;
|
||||
expect(key.verify(signature_data.message, signature_data.signature, 8)).to.eventually.be.false;
|
||||
done();
|
||||
});
|
||||
it('Signature generation', function (done) {
|
||||
it('Signature generation', function () {
|
||||
var curve = elliptic_curves.get('p256');
|
||||
var key = curve.keyFromPrivate(key_data.p256.priv);
|
||||
var signature = key.sign(signature_data.message, 8);
|
||||
key = curve.keyFromPublic(key_data.p256.pub);
|
||||
expect(key.verify(signature_data.message, signature, 8)).to.be.true;
|
||||
done();
|
||||
return key.sign(signature_data.message, 8).then(signature => {
|
||||
key = curve.keyFromPublic(key_data.p256.pub);
|
||||
expect(key.verify(signature_data.message, signature, 8)).to.eventually.be.true;
|
||||
});
|
||||
});
|
||||
it('Shared secret generation', function (done) {
|
||||
var curve = elliptic_curves.get('p256');
|
||||
|
||||
@@ -200,7 +200,7 @@ describe('Elliptic Curve Cryptography', function () {
|
||||
var romeo = load_priv_key('romeo');
|
||||
var juliet = load_pub_key('juliet');
|
||||
expect(romeo.decrypt(data['romeo'].pass)).to.be.true;
|
||||
openpgp.encrypt(
|
||||
return openpgp.encrypt(
|
||||
{publicKeys: [juliet], privateKeys: [romeo], data: data.romeo.message + "\n"}
|
||||
).then(function (encrypted) {
|
||||
var message = openpgp.message.readArmored(encrypted.data);
|
||||
|
||||
Reference in New Issue
Block a user