From 2e7b5b46e30c3b6c6aa50983a7ea1b419b23b5b3 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 26 Oct 2014 03:41:11 -0700 Subject: [PATCH] Remove AES-CTR entirely --- js/test.js | 24 ------------------------ js/webcrypto.js | 26 -------------------------- 2 files changed, 50 deletions(-) diff --git a/js/test.js b/js/test.js index b5103fe22..031c84ed3 100644 --- a/js/test.js +++ b/js/test.js @@ -29,30 +29,6 @@ describe("ArrayBuffer->String conversion", function() { }); describe("Cryptographic primitives", function() { - describe("Encrypt AES-CTR", function() { - it('works', function(done) { - var key = hexToArrayBuffer('2b7e151628aed2a6abf7158809cf4f3c'); - var counter = hexToArrayBuffer('f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff'); - var plaintext = hexToArrayBuffer('6bc1bee22e409f96e93d7e117393172a'); - var ciphertext = hexToArrayBuffer('874d6191b620e3261bef6864990db6ce'); - return window.textsecure.subtle.encrypt({name: "AES-CTR", counter: counter}, key, plaintext).then(function(result) { - assert.strictEqual(getString(result) +"", getString(ciphertext)); - }).then(done).catch(done); - }); - }); - - describe("Decrypt AES-CTR", function() { - it('works', function(done) { - var key = hexToArrayBuffer('2b7e151628aed2a6abf7158809cf4f3c'); - var counter = hexToArrayBuffer('f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff'); - var plaintext = hexToArrayBuffer('6bc1bee22e409f96e93d7e117393172a'); - var ciphertext = hexToArrayBuffer('874d6191b620e3261bef6864990db6ce'); - return window.textsecure.subtle.decrypt({name: "AES-CTR", counter: counter}, key, ciphertext).then(function(result) { - assert.strictEqual(getString(result), getString(plaintext)); - }).then(done).catch(done); - }); - }); - describe("Encrypt AES-CBC", function() { it('works', function(done) { var key = hexToArrayBuffer('603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4'); diff --git a/js/webcrypto.js b/js/webcrypto.js index 33c2791f2..77b86d5c3 100644 --- a/js/webcrypto.js +++ b/js/webcrypto.js @@ -31,28 +31,6 @@ window.textsecure.subtle = (function() { ).toString(CryptoJS.enc.Latin1); }; - function encryptAESCTR(plaintext, key, counter) { - assertIsArrayBuffer(plaintext); - assertIsArrayBuffer(key); - assertIsArrayBuffer(counter); - return CryptoJS.AES.encrypt(CryptoJS.enc.Latin1.parse(getString(plaintext)), - CryptoJS.enc.Latin1.parse(getString(key)), - {mode: CryptoJS.mode.CTR, iv: CryptoJS.enc.Latin1.parse(getString(counter)), - padding: CryptoJS.pad.NoPadding}) - .ciphertext.toString(CryptoJS.enc.Latin1); - }; - - function decryptAESCTR(ciphertext, key, counter) { - assertIsArrayBuffer(ciphertext); - assertIsArrayBuffer(key); - assertIsArrayBuffer(counter); - return CryptoJS.AES.decrypt(btoa(getString(ciphertext)), - CryptoJS.enc.Latin1.parse(getString(key)), - {mode: CryptoJS.mode.CTR, iv: CryptoJS.enc.Latin1.parse(getString(counter)), - padding: CryptoJS.pad.NoPadding}) - .toString(CryptoJS.enc.Latin1); - }; - function encryptAESCBC(plaintext, key, iv) { assertIsArrayBuffer(plaintext); assertIsArrayBuffer(key); @@ -83,14 +61,10 @@ window.textsecure.subtle = (function() { // public interface functions function encrypt(algorithm, key, data) { - if (algorithm.name === "AES-CTR") - return promise(encryptAESCTR, data, key, algorithm.counter); if (algorithm.name === "AES-CBC") return promise(encryptAESCBC, data, key, algorithm.iv); }; function decrypt(algorithm, key, data) { - if (algorithm.name === "AES-CTR") - return promise(decryptAESCTR, data, key, algorithm.counter); if (algorithm.name === "AES-CBC") return promise(decryptAESCBC, data, key, algorithm.iv); };