convert logging to throws

pull/823/head
Ryan Tharp 5 years ago
parent 23fe8407ea
commit 0ac79b2275

@ -49,10 +49,7 @@
async encrypt(plaintext) { async encrypt(plaintext) {
const myKeyPair = await textsecure.storage.protocol.getIdentityKeyPair(); const myKeyPair = await textsecure.storage.protocol.getIdentityKeyPair();
if (!myKeyPair) { if (!myKeyPair) {
window.log.warn("encrypt, Can't load myKeyPair from storage"); throw new Error("Failed to get keypair for encryption");
// FIXME: not sure what I should give on failure
// just going to stick with the same type of value
return {};
} }
const myPrivateKey = myKeyPair.privKey; const myPrivateKey = myKeyPair.privKey;
const symmetricKey = libsignal.Curve.calculateAgreement( const symmetricKey = libsignal.Curve.calculateAgreement(
@ -70,10 +67,7 @@
async decrypt(ivAndCiphertext) { async decrypt(ivAndCiphertext) {
const myKeyPair = await textsecure.storage.protocol.getIdentityKeyPair(); const myKeyPair = await textsecure.storage.protocol.getIdentityKeyPair();
if (!myKeyPair) { if (!myKeyPair) {
window.log.warn("decrypt, Can't load myKeyPair from storage"); throw new Error("Failed to get keypair for decryption");
// FIXME: not sure what I should give on failure
// just going to stick with the same type of value
return {};
} }
const myPrivateKey = myKeyPair.privKey; const myPrivateKey = myKeyPair.privKey;
const symmetricKey = libsignal.Curve.calculateAgreement( const symmetricKey = libsignal.Curve.calculateAgreement(
@ -182,10 +176,7 @@
const myKeyPair = await textsecure.storage.protocol.getIdentityKeyPair(); const myKeyPair = await textsecure.storage.protocol.getIdentityKeyPair();
if (!myKeyPair) { if (!myKeyPair) {
window.log.warn("generateSignatureForPairing Can't load myKeyPair from storage"); throw new Error("Failed to get keypair for pairing signature generation");
// FIXME: not sure what I should give on failure
// just going to stick with the same type of value
return {};
} }
const signature = await libsignal.Curve.async.calculateSignature( const signature = await libsignal.Curve.async.calculateSignature(
myKeyPair.privKey, myKeyPair.privKey,
@ -311,10 +302,7 @@
); );
const { privKey } = await textsecure.storage.protocol.getIdentityKeyPair(); const { privKey } = await textsecure.storage.protocol.getIdentityKeyPair();
if (!privKey) { if (!privKey) {
window.log.warn("decryptToken, Can't load myKeyPair from storage"); throw new Error("Failed to get keypair for token decryption");
// FIXME: not sure what I should give on failure
// just going to stick with the same type of value
return {};
} }
const symmetricKey = libsignal.Curve.calculateAgreement( const symmetricKey = libsignal.Curve.calculateAgreement(
serverPubKey, serverPubKey,

Loading…
Cancel
Save