Give up on webcrypto :(
This commit is contained in:
parent
21225b2074
commit
68a42a6ae7
1 changed files with 82 additions and 88 deletions
|
@ -1,5 +1,4 @@
|
||||||
/* vim: ts=4:sw=4:expandtab
|
/*
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* 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
|
* 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/>.
|
* 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!
|
// All inputs/outputs are arraybuffers!
|
||||||
window.textsecure.subtle = (function() {
|
window.textsecure.subtle = (function() {
|
||||||
/* if (window.crypto.subtle !== undefined && window.crypto.subtle !== null) {
|
|
||||||
return window.crypto.subtle;
|
|
||||||
} else*/ {
|
|
||||||
var StaticArrayBufferProto = new ArrayBuffer().__proto__;
|
var StaticArrayBufferProto = new ArrayBuffer().__proto__;
|
||||||
function assertIsArrayBuffer(thing) {
|
function assertIsArrayBuffer(thing) {
|
||||||
if (thing !== Object(thing) || thing.__proto__ != StaticArrayBufferProto)
|
if (thing !== Object(thing) || thing.__proto__ != StaticArrayBufferProto)
|
||||||
|
@ -31,7 +26,7 @@ window.textsecure.subtle = (function() {
|
||||||
assertIsArrayBuffer(key);
|
assertIsArrayBuffer(key);
|
||||||
assertIsArrayBuffer(input);
|
assertIsArrayBuffer(input);
|
||||||
return CryptoJS.HmacSHA256(
|
return CryptoJS.HmacSHA256(
|
||||||
CryptoJS.lib.WordArray.create(toArrayBuffer(input)),
|
CryptoJS.lib.WordArray.create(input),
|
||||||
CryptoJS.enc.Latin1.parse(getString(key))
|
CryptoJS.enc.Latin1.parse(getString(key))
|
||||||
).toString(CryptoJS.enc.Latin1);
|
).toString(CryptoJS.enc.Latin1);
|
||||||
};
|
};
|
||||||
|
@ -108,5 +103,4 @@ window.textsecure.subtle = (function() {
|
||||||
decrypt : decrypt,
|
decrypt : decrypt,
|
||||||
sign : sign,
|
sign : sign,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in a new issue