Remove AES-CTR entirely
This commit is contained in:
parent
da0c63fb1b
commit
2e7b5b46e3
2 changed files with 0 additions and 50 deletions
24
js/test.js
24
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');
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue