Give up on webcrypto :(

pull/749/head
Matt Corallo 11 years ago
parent 21225b2074
commit 68a42a6ae7

@ -1,5 +1,4 @@
/* vim: ts=4:sw=4:expandtab
*
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@ -14,12 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* Web Crypto polyfill. TODO: replace with web crypto */
// All inputs/outputs are arraybuffers!
window.textsecure.subtle = (function() {
/* if (window.crypto.subtle !== undefined && window.crypto.subtle !== null) {
return window.crypto.subtle;
} else*/ {
var StaticArrayBufferProto = new ArrayBuffer().__proto__;
function assertIsArrayBuffer(thing) {
if (thing !== Object(thing) || thing.__proto__ != StaticArrayBufferProto)
@ -31,7 +26,7 @@ window.textsecure.subtle = (function() {
assertIsArrayBuffer(key);
assertIsArrayBuffer(input);
return CryptoJS.HmacSHA256(
CryptoJS.lib.WordArray.create(toArrayBuffer(input)),
CryptoJS.lib.WordArray.create(input),
CryptoJS.enc.Latin1.parse(getString(key))
).toString(CryptoJS.enc.Latin1);
};
@ -108,5 +103,4 @@ window.textsecure.subtle = (function() {
decrypt : decrypt,
sign : sign,
}
}
})();

Loading…
Cancel
Save