Commit broken attachment loader (S3 403s I can't figure out...)
This commit is contained in:
parent
ea1bd535dc
commit
3103eaa192
3 changed files with 72 additions and 8 deletions
18
js/crypto.js
18
js/crypto.js
|
@ -538,10 +538,24 @@ window.crypto = (function() {
|
|||
|
||||
var iv = decodedMessage.slice(1, 1 + 16);
|
||||
var ciphertext = decodedMessage.slice(1 + 16, decodedMessage.byteLength - 10);
|
||||
var ivAndCipherText = decodedMessage.slice(1, decodedMessage.byteLength - 10);
|
||||
var ivAndCiphertext = decodedMessage.slice(1, decodedMessage.byteLength - 10);
|
||||
var mac = decodedMessage.slice(decodedMessage.byteLength - 10, decodedMessage.byteLength);
|
||||
|
||||
return verifyMACWithVersionByte(ivAndCipherText, mac_key, mac).then(function() {
|
||||
return verifyMACWithVersionByte(ivAndCiphertext, mac_key, mac).then(function() {
|
||||
return window.crypto.subtle.decrypt({name: "AES-CBC", iv: iv}, aes_key, ciphertext);
|
||||
});
|
||||
};
|
||||
|
||||
crypto.decryptAttachment = function(encryptedBin, keys) {
|
||||
var aes_key = key.slice(0, 32);
|
||||
var mac_key = key.slice(32, 64);
|
||||
|
||||
var iv = encryptedBin.slice(0, 32);
|
||||
var ciphertext = encryptedBin.slice(32, encryptedBin.byteLength - 32);
|
||||
var ivAndCiphertext = encryptedBin.slice(0, encryptedBin.byteLength - 32);
|
||||
var mac = encryptedBin.slice(encryptedBin.byteLength - 32, encryptedBin.byteLength);
|
||||
|
||||
return verifyMAC(ivAndCiphertext, mac_key, mac).then(function() {
|
||||
return window.crypto.subtle.decrypt({name: "AES-CBC", iv: iv}, aes_key, ciphertext);
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue