|
|
@ -204,25 +204,25 @@
|
|
|
|
// Throws for invalid signature
|
|
|
|
// Throws for invalid signature
|
|
|
|
await libsignal.Curve.async.verifySignature(issuer, data.buffer, signature);
|
|
|
|
await libsignal.Curve.async.verifySignature(issuer, data.buffer, signature);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
async function decryptToken({ cipherText64, serverPubKey64 }) {
|
|
|
|
async function decryptToken({ cipherText64, serverPubKey64 }) {
|
|
|
|
const ivAndCiphertext = new Uint8Array(
|
|
|
|
const ivAndCiphertext = new Uint8Array(
|
|
|
|
dcodeIO.ByteBuffer.fromBase64(cipherText64).toArrayBuffer()
|
|
|
|
dcodeIO.ByteBuffer.fromBase64(cipherText64).toArrayBuffer()
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const serverPubKey = new Uint8Array(
|
|
|
|
const serverPubKey = new Uint8Array(
|
|
|
|
dcodeIO.ByteBuffer.fromBase64(serverPubKey64).toArrayBuffer()
|
|
|
|
dcodeIO.ByteBuffer.fromBase64(serverPubKey64).toArrayBuffer()
|
|
|
|
);
|
|
|
|
);
|
|
|
|
const { privKey } = await textsecure.storage.protocol.getIdentityKeyPair();
|
|
|
|
const { privKey } = await textsecure.storage.protocol.getIdentityKeyPair();
|
|
|
|
const symmetricKey = libsignal.Curve.calculateAgreement(
|
|
|
|
const symmetricKey = libsignal.Curve.calculateAgreement(
|
|
|
|
serverPubKey,
|
|
|
|
serverPubKey,
|
|
|
|
privKey
|
|
|
|
privKey
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const token = await DHDecrypt(symmetricKey, ivAndCiphertext);
|
|
|
|
const token = await DHDecrypt(symmetricKey, ivAndCiphertext);
|
|
|
|
|
|
|
|
|
|
|
|
const tokenString = dcodeIO.ByteBuffer.wrap(token).toString('utf8');
|
|
|
|
const tokenString = dcodeIO.ByteBuffer.wrap(token).toString('utf8');
|
|
|
|
return tokenString;
|
|
|
|
return tokenString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const snodeCipher = new LokiSnodeChannel();
|
|
|
|
const snodeCipher = new LokiSnodeChannel();
|
|
|
|
|
|
|
|
|
|
|
|
window.libloki.crypto = {
|
|
|
|
window.libloki.crypto = {
|
|
|
@ -231,7 +231,7 @@
|
|
|
|
FallBackSessionCipher,
|
|
|
|
FallBackSessionCipher,
|
|
|
|
FallBackDecryptionError,
|
|
|
|
FallBackDecryptionError,
|
|
|
|
snodeCipher,
|
|
|
|
snodeCipher,
|
|
|
|
decryptToken,
|
|
|
|
decryptToken,
|
|
|
|
generateSignatureForPairing,
|
|
|
|
generateSignatureForPairing,
|
|
|
|
verifyPairingAuthorisation,
|
|
|
|
verifyPairingAuthorisation,
|
|
|
|
// for testing
|
|
|
|
// for testing
|
|
|
|