From 3b8cea67a2d72aba0d29bdf1e138689c7feb6728 Mon Sep 17 00:00:00 2001 From: Sanjana Rajan Date: Mon, 24 Jul 2017 18:36:18 +0200 Subject: [PATCH] some style fixes, update tests --- src/crypto/{rfc3394.js => aes_kw.js} | 0 src/crypto/crypto.js | 20 ++++++++++---------- src/crypto/index.js | 6 +++--- test/crypto/{rfc3394.js => aes_kw.js} | 4 ++-- test/crypto/index.js | 2 +- test/general/key.js | 12 ++---------- test/general/openpgp.js | 6 ++++-- 7 files changed, 22 insertions(+), 28 deletions(-) rename src/crypto/{rfc3394.js => aes_kw.js} (100%) rename test/crypto/{rfc3394.js => aes_kw.js} (90%) diff --git a/src/crypto/rfc3394.js b/src/crypto/aes_kw.js similarity index 100% rename from src/crypto/rfc3394.js rename to src/crypto/aes_kw.js diff --git a/src/crypto/crypto.js b/src/crypto/crypto.js index 784ae0f6..7eaedcc1 100644 --- a/src/crypto/crypto.js +++ b/src/crypto/crypto.js @@ -228,7 +228,7 @@ export default { } }, - generateMpi: function(algo, bits, curve, material) { + generateMpi: function(algo, bits, curve) { switch (algo) { case 'rsa_encrypt': case 'rsa_encrypt_sign': @@ -247,21 +247,21 @@ export default { }); case 'ecdsa': - return publicKey.elliptic.generate(curve, material).then(function (key) { + return publicKey.elliptic.generate(curve).then(function (keyObject) { return [ - new type_oid(key.oid), - BigInteger2mpi(key.R), - BigInteger2mpi(key.r) + new type_oid(keyObject.oid), + BigInteger2mpi(keyObject.R), + BigInteger2mpi(keyObject.r) ]; }); case 'ecdh': - return publicKey.elliptic.generate(curve, material).then(function (key) { + return publicKey.elliptic.generate(curve).then(function (keyObject) { return [ - new type_oid(key.oid), - BigInteger2mpi(key.R), - new type_kdf_params(key.hash, key.cipher), - BigInteger2mpi(key.r) + new type_oid(keyObject.oid), + BigInteger2mpi(keyObject.R), + new type_kdf_params(keyObject.hash, keyObject.cipher), + BigInteger2mpi(keyObject.r) ]; }); diff --git a/src/crypto/index.js b/src/crypto/index.js index b82d8b7b..036cee76 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -15,7 +15,7 @@ import random from './random'; import pkcs1 from './pkcs1'; import pkcs5 from './pkcs5.js'; import crypto from './crypto.js'; -import rfc3394 from './rfc3394.js'; +import aes_kw from './aes_kw.js'; const mod = { /** @see module:crypto/cipher */ @@ -36,8 +36,8 @@ const mod = { pkcs1: pkcs1, /** @see module:crypto/pkcs5 */ pkcs5: pkcs5, - /** @see module:crypto/rfc3394 */ - rfc3394: rfc3394, + /** @see module:crypto/aes_kw */ + aes_kw: aes_kw, }; for (var i in crypto) { diff --git a/test/crypto/rfc3394.js b/test/crypto/aes_kw.js similarity index 90% rename from test/crypto/rfc3394.js rename to test/crypto/aes_kw.js index 6887db79..f7e602ba 100644 --- a/test/crypto/rfc3394.js +++ b/test/crypto/aes_kw.js @@ -51,8 +51,8 @@ describe('AES Key Wrap and Unwrap', function () { var input_bin = openpgp.util.hex2bin(input); var output = test[3].replace(/\s/g, ""); var output_bin = openpgp.util.hex2bin(output); - expect(openpgp.util.hexidump(openpgp.crypto.rfc3394.wrap(kek, input_bin)).toUpperCase()).to.equal(output); - expect(openpgp.util.hexidump(openpgp.crypto.rfc3394.unwrap(kek, output_bin)).toUpperCase()).to.equal(input); + expect(openpgp.util.hexidump(openpgp.crypto.aes_kw.wrap(kek, input_bin)).toUpperCase()).to.equal(output); + expect(openpgp.util.hexidump(openpgp.crypto.aes_kw.unwrap(kek, output_bin)).toUpperCase()).to.equal(input); done(); }); }); diff --git a/test/crypto/index.js b/test/crypto/index.js index a61e6f6f..7ab5c758 100644 --- a/test/crypto/index.js +++ b/test/crypto/index.js @@ -5,5 +5,5 @@ describe('Crypto', function () { require('./crypto.js'); require('./elliptic.js'); require('./pkcs5.js'); - require('./rfc3394.js'); + require('./aes_kw.js'); }); diff --git a/test/general/key.js b/test/general/key.js index 10a8dde3..8a790a5f 100644 --- a/test/general/key.js +++ b/test/general/key.js @@ -527,6 +527,7 @@ describe('Key', function() { '=Q/kB', '-----END PGP PUBLIC KEY BLOCK-----'].join('\n'); +<<<<<<< HEAD var valid_binding_sig_among_many_expired_sigs_pub = [ '-----BEGIN PGP PUBLIC KEY BLOCK-----', '', @@ -582,7 +583,7 @@ describe('Key', function() { '=yzZh', '-----END PGP PUBLIC KEY BLOCK-----'].join('\n'); - it('Parsing armored text with RSA key and ECC subkey in tolerant mode', function(done) { + it('Parsing armored text with RSA key and ECC subkey', function(done) { openpgp.config.tolerant = true; var pubKeys = openpgp.key.readArmored(rsa_ecc_pub); expect(pubKeys).to.exist; @@ -592,15 +593,6 @@ describe('Key', function() { done(); }); - it('Parsing armored text with RSA key and ECC subkey in non-tolerant mode', function(done) { - openpgp.config.tolerant = false; - var pubKeys = openpgp.key.readArmored(rsa_ecc_pub); - expect(pubKeys).to.exist; - expect(pubKeys.err).to.exist; - done(); - }); - - var multi_uid_key = ['-----BEGIN PGP PUBLIC KEY BLOCK-----', 'Version: GnuPG v1', diff --git a/test/general/openpgp.js b/test/general/openpgp.js index c7d0b904..b3e4e92e 100644 --- a/test/general/openpgp.js +++ b/test/general/openpgp.js @@ -304,7 +304,8 @@ describe('OpenPGP.js public api tests', function() { passphrase: 'secret', numBits: 2048, unlocked: true, - keyExpirationTime: 0 + keyExpirationTime: 0, + curve: "" }).calledOnce).to.be.true; expect(newKey.key).to.exist; expect(newKey.privateKeyArmored).to.exist; @@ -319,7 +320,8 @@ describe('OpenPGP.js public api tests', function() { passphrase: undefined, numBits: 2048, unlocked: false, - keyExpirationTime: 0 + keyExpirationTime: 0, + curve: "" }).calledOnce).to.be.true; expect(newKey.key).to.exist; });