mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 12:19:41 +00:00
Fix attachments
This commit is contained in:
17
js/crypto.js
17
js/crypto.js
@@ -283,6 +283,19 @@ window.crypto = (function() {
|
||||
});
|
||||
}
|
||||
|
||||
var calculateMAC = function(data, key) {
|
||||
return HmacSHA256(key, data);
|
||||
}
|
||||
|
||||
var verifyMAC = function(data, key, mac) {
|
||||
return calculateMAC(data, key).then(function(calculated_mac) {
|
||||
var macString = getString(mac);//TODO: Move away from strings for comparison?
|
||||
|
||||
if (getString(calculated_mac).substring(0, macString.length) != macString)
|
||||
throw new Error("Bad MAC");
|
||||
});
|
||||
}
|
||||
|
||||
/******************************
|
||||
*** Ratchet implementation ***
|
||||
******************************/
|
||||
@@ -547,8 +560,8 @@ window.crypto = (function() {
|
||||
};
|
||||
|
||||
crypto.decryptAttachment = function(encryptedBin, keys) {
|
||||
var aes_key = key.slice(0, 32);
|
||||
var mac_key = key.slice(32, 64);
|
||||
var aes_key = keys.slice(0, 32);
|
||||
var mac_key = keys.slice(32, 64);
|
||||
|
||||
var iv = encryptedBin.slice(0, 32);
|
||||
var ciphertext = encryptedBin.slice(32, encryptedBin.byteLength - 32);
|
||||
|
||||
Reference in New Issue
Block a user