mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
improve guards on loading keypair
This commit is contained in:
parent
926a245bf6
commit
dbff390035
1 changed files with 24 additions and 0 deletions
|
@ -48,6 +48,12 @@
|
|||
// Should we use ephemeral key pairs here rather than long term keys on each side?
|
||||
async encrypt(plaintext) {
|
||||
const myKeyPair = await textsecure.storage.protocol.getIdentityKeyPair();
|
||||
if (!myKeyPair) {
|
||||
window.log.warn("encrypt, Can't load myKeyPair from storage");
|
||||
// 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 symmetricKey = libsignal.Curve.calculateAgreement(
|
||||
this.pubKey,
|
||||
|
@ -63,6 +69,12 @@
|
|||
|
||||
async decrypt(ivAndCiphertext) {
|
||||
const myKeyPair = await textsecure.storage.protocol.getIdentityKeyPair();
|
||||
if (!myKeyPair) {
|
||||
window.log.warn("decrypt, Can't load myKeyPair from storage");
|
||||
// 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 symmetricKey = libsignal.Curve.calculateAgreement(
|
||||
this.pubKey,
|
||||
|
@ -169,6 +181,12 @@
|
|||
data[len] = type;
|
||||
|
||||
const myKeyPair = await textsecure.storage.protocol.getIdentityKeyPair();
|
||||
if (!myKeyPair) {
|
||||
window.log.warn("generateSignatureForPairing Can't load myKeyPair from storage");
|
||||
// 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(
|
||||
myKeyPair.privKey,
|
||||
data.buffer
|
||||
|
@ -292,6 +310,12 @@
|
|||
dcodeIO.ByteBuffer.fromBase64(serverPubKey64).toArrayBuffer()
|
||||
);
|
||||
const { privKey } = await textsecure.storage.protocol.getIdentityKeyPair();
|
||||
if (!myKeyPair) {
|
||||
window.log.warn("decryptToken, Can't load myKeyPair from storage");
|
||||
// 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(
|
||||
serverPubKey,
|
||||
privKey
|
||||
|
|
Loading…
Reference in a new issue