Remove axolotl.storage usage from libtextsecure

This commit is contained in:
Matt Corallo 2015-02-13 12:15:28 -08:00
parent b790f82849
commit e2e06b2d3c
3 changed files with 28 additions and 28 deletions

View file

@ -37679,7 +37679,7 @@ window.axolotl.sessions = {
window.textsecure.crypto = { window.textsecure.crypto = {
// Decrypts message into a raw string // Decrypts message into a raw string
decryptWebsocketMessage: function(message) { decryptWebsocketMessage: function(message) {
var signaling_key = axolotl.api.storage.get("signaling_key"); //TODO: in crypto_storage var signaling_key = textsecure.storage.getEncrypted("signaling_key"); //TODO: in crypto_storage
var aes_key = toArrayBuffer(signaling_key.substring(0, 32)); var aes_key = toArrayBuffer(signaling_key.substring(0, 32));
var mac_key = toArrayBuffer(signaling_key.substring(32, 32 + 20)); var mac_key = toArrayBuffer(signaling_key.substring(32, 32 + 20));
@ -38010,11 +38010,11 @@ window.axolotl.sessions = {
window.textsecure.storage.groups = { window.textsecure.storage.groups = {
createNewGroup: function(numbers, groupId) { createNewGroup: function(numbers, groupId) {
if (groupId !== undefined && axolotl.api.storage.get("group" + groupId) !== undefined) if (groupId !== undefined && textsecure.storage.getEncrypted("group" + groupId) !== undefined)
throw new Error("Tried to recreate group"); throw new Error("Tried to recreate group");
while (groupId === undefined || axolotl.api.storage.get("group" + groupId) !== undefined) while (groupId === undefined || textsecure.storage.getEncrypted("group" + groupId) !== undefined)
groupId = getString(axolotl.crypto.getRandomBytes(16)); groupId = getString(textsecure.crypto.getRandomBytes(16));
var me = textsecure.utils.unencodeNumber(textsecure.storage.getUnencrypted("number_id"))[0]; var me = textsecure.utils.unencodeNumber(textsecure.storage.getUnencrypted("number_id"))[0];
var haveMe = false; var haveMe = false;
@ -38036,13 +38036,13 @@ window.axolotl.sessions = {
for (var i in finalNumbers) for (var i in finalNumbers)
groupObject.numberRegistrationIds[finalNumbers[i]] = {}; groupObject.numberRegistrationIds[finalNumbers[i]] = {};
axolotl.api.storage.put("group" + groupId, groupObject); textsecure.storage.putEncrypted("group" + groupId, groupObject);
return {id: groupId, numbers: finalNumbers}; return {id: groupId, numbers: finalNumbers};
}, },
getNumbers: function(groupId) { getNumbers: function(groupId) {
var group = axolotl.api.storage.get("group" + groupId); var group = textsecure.storage.getEncrypted("group" + groupId);
if (group === undefined) if (group === undefined)
return undefined; return undefined;
@ -38050,7 +38050,7 @@ window.axolotl.sessions = {
}, },
removeNumber: function(groupId, number) { removeNumber: function(groupId, number) {
var group = axolotl.api.storage.get("group" + groupId); var group = textsecure.storage.getEncrypted("group" + groupId);
if (group === undefined) if (group === undefined)
return undefined; return undefined;
@ -38062,14 +38062,14 @@ window.axolotl.sessions = {
if (i > -1) { if (i > -1) {
group.numbers.slice(i, 1); group.numbers.slice(i, 1);
delete group.numberRegistrationIds[number]; delete group.numberRegistrationIds[number];
axolotl.api.storage.put("group" + groupId, group); textsecure.storage.putEncrypted("group" + groupId, group);
} }
return group.numbers; return group.numbers;
}, },
addNumbers: function(groupId, numbers) { addNumbers: function(groupId, numbers) {
var group = axolotl.api.storage.get("group" + groupId); var group = textsecure.storage.getEncrypted("group" + groupId);
if (group === undefined) if (group === undefined)
return undefined; return undefined;
@ -38083,16 +38083,16 @@ window.axolotl.sessions = {
} }
} }
axolotl.api.storage.put("group" + groupId, group); textsecure.storage.putEncrypted("group" + groupId, group);
return group.numbers; return group.numbers;
}, },
deleteGroup: function(groupId) { deleteGroup: function(groupId) {
axolotl.api.storage.remove("group" + groupId); textsecure.storage.removeEncrypted("group" + groupId);
}, },
getGroup: function(groupId) { getGroup: function(groupId) {
var group = axolotl.api.storage.get("group" + groupId); var group = textsecure.storage.getEncrypted("group" + groupId);
if (group === undefined) if (group === undefined)
return undefined; return undefined;
@ -38100,7 +38100,7 @@ window.axolotl.sessions = {
}, },
needUpdateByDeviceRegistrationId: function(groupId, number, encodedNumber, registrationId) { needUpdateByDeviceRegistrationId: function(groupId, number, encodedNumber, registrationId) {
var group = axolotl.api.storage.get("group" + groupId); var group = textsecure.storage.getEncrypted("group" + groupId);
if (group === undefined) if (group === undefined)
throw new Error("Unknown group for device registration id"); throw new Error("Unknown group for device registration id");
@ -38112,7 +38112,7 @@ window.axolotl.sessions = {
var needUpdate = group.numberRegistrationIds[number][encodedNumber] !== undefined; var needUpdate = group.numberRegistrationIds[number][encodedNumber] !== undefined;
group.numberRegistrationIds[number][encodedNumber] = registrationId; group.numberRegistrationIds[number][encodedNumber] = registrationId;
axolotl.api.storage.put("group" + groupId, group); textsecure.storage.putEncrypted("group" + groupId, group);
return needUpdate; return needUpdate;
}, },
}; };

View file

@ -48,7 +48,7 @@
window.textsecure.crypto = { window.textsecure.crypto = {
// Decrypts message into a raw string // Decrypts message into a raw string
decryptWebsocketMessage: function(message) { decryptWebsocketMessage: function(message) {
var signaling_key = axolotl.api.storage.get("signaling_key"); //TODO: in crypto_storage var signaling_key = textsecure.storage.getEncrypted("signaling_key"); //TODO: in crypto_storage
var aes_key = toArrayBuffer(signaling_key.substring(0, 32)); var aes_key = toArrayBuffer(signaling_key.substring(0, 32));
var mac_key = toArrayBuffer(signaling_key.substring(32, 32 + 20)); var mac_key = toArrayBuffer(signaling_key.substring(32, 32 + 20));

View file

@ -25,11 +25,11 @@
window.textsecure.storage.groups = { window.textsecure.storage.groups = {
createNewGroup: function(numbers, groupId) { createNewGroup: function(numbers, groupId) {
if (groupId !== undefined && axolotl.api.storage.get("group" + groupId) !== undefined) if (groupId !== undefined && textsecure.storage.getEncrypted("group" + groupId) !== undefined)
throw new Error("Tried to recreate group"); throw new Error("Tried to recreate group");
while (groupId === undefined || axolotl.api.storage.get("group" + groupId) !== undefined) while (groupId === undefined || textsecure.storage.getEncrypted("group" + groupId) !== undefined)
groupId = getString(axolotl.crypto.getRandomBytes(16)); groupId = getString(textsecure.crypto.getRandomBytes(16));
var me = textsecure.utils.unencodeNumber(textsecure.storage.getUnencrypted("number_id"))[0]; var me = textsecure.utils.unencodeNumber(textsecure.storage.getUnencrypted("number_id"))[0];
var haveMe = false; var haveMe = false;
@ -51,13 +51,13 @@
for (var i in finalNumbers) for (var i in finalNumbers)
groupObject.numberRegistrationIds[finalNumbers[i]] = {}; groupObject.numberRegistrationIds[finalNumbers[i]] = {};
axolotl.api.storage.put("group" + groupId, groupObject); textsecure.storage.putEncrypted("group" + groupId, groupObject);
return {id: groupId, numbers: finalNumbers}; return {id: groupId, numbers: finalNumbers};
}, },
getNumbers: function(groupId) { getNumbers: function(groupId) {
var group = axolotl.api.storage.get("group" + groupId); var group = textsecure.storage.getEncrypted("group" + groupId);
if (group === undefined) if (group === undefined)
return undefined; return undefined;
@ -65,7 +65,7 @@
}, },
removeNumber: function(groupId, number) { removeNumber: function(groupId, number) {
var group = axolotl.api.storage.get("group" + groupId); var group = textsecure.storage.getEncrypted("group" + groupId);
if (group === undefined) if (group === undefined)
return undefined; return undefined;
@ -77,14 +77,14 @@
if (i > -1) { if (i > -1) {
group.numbers.slice(i, 1); group.numbers.slice(i, 1);
delete group.numberRegistrationIds[number]; delete group.numberRegistrationIds[number];
axolotl.api.storage.put("group" + groupId, group); textsecure.storage.putEncrypted("group" + groupId, group);
} }
return group.numbers; return group.numbers;
}, },
addNumbers: function(groupId, numbers) { addNumbers: function(groupId, numbers) {
var group = axolotl.api.storage.get("group" + groupId); var group = textsecure.storage.getEncrypted("group" + groupId);
if (group === undefined) if (group === undefined)
return undefined; return undefined;
@ -98,16 +98,16 @@
} }
} }
axolotl.api.storage.put("group" + groupId, group); textsecure.storage.putEncrypted("group" + groupId, group);
return group.numbers; return group.numbers;
}, },
deleteGroup: function(groupId) { deleteGroup: function(groupId) {
axolotl.api.storage.remove("group" + groupId); textsecure.storage.removeEncrypted("group" + groupId);
}, },
getGroup: function(groupId) { getGroup: function(groupId) {
var group = axolotl.api.storage.get("group" + groupId); var group = textsecure.storage.getEncrypted("group" + groupId);
if (group === undefined) if (group === undefined)
return undefined; return undefined;
@ -115,7 +115,7 @@
}, },
needUpdateByDeviceRegistrationId: function(groupId, number, encodedNumber, registrationId) { needUpdateByDeviceRegistrationId: function(groupId, number, encodedNumber, registrationId) {
var group = axolotl.api.storage.get("group" + groupId); var group = textsecure.storage.getEncrypted("group" + groupId);
if (group === undefined) if (group === undefined)
throw new Error("Unknown group for device registration id"); throw new Error("Unknown group for device registration id");
@ -127,7 +127,7 @@
var needUpdate = group.numberRegistrationIds[number][encodedNumber] !== undefined; var needUpdate = group.numberRegistrationIds[number][encodedNumber] !== undefined;
group.numberRegistrationIds[number][encodedNumber] = registrationId; group.numberRegistrationIds[number][encodedNumber] = registrationId;
axolotl.api.storage.put("group" + groupId, group); textsecure.storage.putEncrypted("group" + groupId, group);
return needUpdate; return needUpdate;
}, },
}; };