From 0b37b4041764eb8db1f30b70c6b4eaca33ef3014 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Wed, 10 Apr 2013 19:14:48 +0200 Subject: [PATCH] nacl-crypto cleanup --- src/js/crypto/nacl-crypto.js | 8 ++++---- test/unit/nacl-crypto-test.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/js/crypto/nacl-crypto.js b/src/js/crypto/nacl-crypto.js index e03e7fc..6dce299 100644 --- a/src/js/crypto/nacl-crypto.js +++ b/src/js/crypto/nacl-crypto.js @@ -43,7 +43,7 @@ var NaclCrypto = function(nacl, util) { * @param senderBoxSk [String] The sender's base64 encoded private key * @return [Object] The base64 encoded ciphertext and nonce */ - this.asymmetricEncrypt = function(plaintext, nonce, recipientBoxPk, senderBoxSk) { + this.asymEncrypt = function(plaintext, nonce, recipientBoxPk, senderBoxSk) { // convert to Uint8Array var ptBuf = nacl.encode_utf8(plaintext); var recipientBoxPkBuf = nacl.encode_latin1(util.base642Str(recipientBoxPk)); @@ -65,7 +65,7 @@ var NaclCrypto = function(nacl, util) { * @param recipientBoxSk [String] The receiver's base64 encoded private key * @return [String] The decrypted plaintext in UTF8 */ - this.asymmetricDecrypt = function(ciphertext, nonce, senderBoxPk, recipientBoxSk) { + this.asymDecrypt = function(ciphertext, nonce, senderBoxPk, recipientBoxSk) { // convert to Uint8Array var ctBuf = nacl.encode_latin1(util.base642Str(ciphertext)); var nonceBuf = nacl.encode_latin1(util.base642Str(nonce)); @@ -86,7 +86,7 @@ var NaclCrypto = function(nacl, util) { * @param secretKey [String] The receiver's base64 encoded public key * @return [Object] The base64 encoded ciphertext and nonce */ - this.symmetricEncrypt = function(plaintext, nonce, secretKey) { + this.symEncrypt = function(plaintext, nonce, secretKey) { // convert to Uint8Array var ptBuf = nacl.encode_utf8(plaintext); var secretKeyBuf = nacl.encode_latin1(util.base642Str(secretKey)); @@ -106,7 +106,7 @@ var NaclCrypto = function(nacl, util) { * @param secretKey [String] The sender's base64 encoded public key * @return [String] The decrypted plaintext in UTF8 */ - this.symmetricDecrypt = function(ciphertext, nonce, secretKey) { + this.symDecrypt = function(ciphertext, nonce, secretKey) { // convert to Uint8Array var ctBuf = nacl.encode_latin1(util.base642Str(ciphertext)); var nonceBuf = nacl.encode_latin1(util.base642Str(nonce)); diff --git a/test/unit/nacl-crypto-test.js b/test/unit/nacl-crypto-test.js index 2bee843..2d89569 100644 --- a/test/unit/nacl-crypto-test.js +++ b/test/unit/nacl-crypto-test.js @@ -37,11 +37,11 @@ test("Asymmetric En/Decrypt", 3, function() { var nonce = nacl_test.crypto.generateNonce(); ok(nonce, 'Nonce: ' + nonce); // encrypt - var ct = nacl_test.crypto.asymmetricEncrypt(plaintext, nonce, nacl_test.recipientKeypair.boxPk, nacl_test.senderKeypair.boxSk); + var ct = nacl_test.crypto.asymEncrypt(plaintext, nonce, nacl_test.recipientKeypair.boxPk, nacl_test.senderKeypair.boxSk); ok(ct, 'Ciphertext length: ' + ct.length); // decrypt - var decrypted = nacl_test.crypto.asymmetricDecrypt(ct, nonce, nacl_test.senderKeypair.boxPk, nacl_test.recipientKeypair.boxSk); + var decrypted = nacl_test.crypto.asymDecrypt(ct, nonce, nacl_test.senderKeypair.boxPk, nacl_test.recipientKeypair.boxSk); equal(decrypted, plaintext, 'Decryption correct: ' + decrypted); }); @@ -51,11 +51,11 @@ test("Symmetric En/Decrypt", 3, function() { var nonce = nacl_test.crypto.generateNonce(); ok(nonce, 'Nonce: ' + nonce); // encrypt - var ct = nacl_test.crypto.symmetricEncrypt(plaintext, nonce, nacl_test.senderKeypair.boxSk); + var ct = nacl_test.crypto.symEncrypt(plaintext, nonce, nacl_test.senderKeypair.boxSk); ok(ct, 'Ciphertext length: ' + ct.length); // decrypt - var decrypted = nacl_test.crypto.symmetricDecrypt(ct, nonce, nacl_test.senderKeypair.boxSk); + var decrypted = nacl_test.crypto.symDecrypt(ct, nonce, nacl_test.senderKeypair.boxSk); equal(decrypted, plaintext, 'Decryption correct: ' + decrypted); });