From 96d42e24d2f4d92bce040d9110d1c5695a226e43 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Wed, 22 Apr 2020 09:59:03 +1000 Subject: [PATCH] Made calculateAgreement async --- js/modules/loki_app_dot_net_api.js | 2 +- js/modules/loki_rpc.js | 4 ++-- libloki/crypto.js | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/js/modules/loki_app_dot_net_api.js b/js/modules/loki_app_dot_net_api.js index 1cc177847..bddd36c73 100644 --- a/js/modules/loki_app_dot_net_api.js +++ b/js/modules/loki_app_dot_net_api.js @@ -101,7 +101,7 @@ const sendToProxy = async ( const ephemeralKey = await libsignal.Curve.async.generateKeyPair(); // mix server pub key with our priv key - const symKey = libsignal.Curve.calculateAgreement( + const symKey = await libsignal.Curve.async.calculateAgreement( srvPubKey, // server's pubkey ephemeralKey.privKey // our privkey ); diff --git a/js/modules/loki_rpc.js b/js/modules/loki_rpc.js index 85425385a..fcf99083e 100644 --- a/js/modules/loki_rpc.js +++ b/js/modules/loki_rpc.js @@ -22,7 +22,7 @@ const encryptForNode = async (node, payload) => { const snPubkey = StringView.hexToArrayBuffer(node.pubkey_x25519); - const ephemeralSecret = libsignal.Curve.calculateAgreement( + const ephemeralSecret = await libsignal.Curve.async.calculateAgreement( snPubkey, ephemeral.privKey ); @@ -237,7 +237,7 @@ const sendToProxy = async (options = {}, targetNode, retryNumber = 0) => { const myKeys = await window.libloki.crypto.generateEphemeralKeyPair(); - const symmetricKey = libsignal.Curve.calculateAgreement( + const symmetricKey = await libsignal.Curve.async.calculateAgreement( snPubkeyHex, myKeys.privKey ); diff --git a/libloki/crypto.js b/libloki/crypto.js index dabe9cb7b..3805336b5 100644 --- a/libloki/crypto.js +++ b/libloki/crypto.js @@ -99,7 +99,7 @@ throw new Error('Failed to get keypair for encryption'); } const myPrivateKey = myKeyPair.privKey; - const symmetricKey = libsignal.Curve.calculateAgreement( + const symmetricKey = await libsignal.Curve.async.calculateAgreement( this.pubKey, myPrivateKey ); @@ -117,7 +117,7 @@ throw new Error('Failed to get keypair for decryption'); } const myPrivateKey = myKeyPair.privKey; - const symmetricKey = libsignal.Curve.calculateAgreement( + const symmetricKey = await libsignal.Curve.async.calculateAgreement( this.pubKey, myPrivateKey ); @@ -290,7 +290,7 @@ throw new Error('Failed to get keypair for token decryption'); } const { privKey } = keyPair; - const symmetricKey = libsignal.Curve.calculateAgreement( + const symmetricKey = await libsignal.Curve.async.calculateAgreement( serverPubKey, privKey );