|
|
@ -220,10 +220,7 @@
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
await verify(
|
|
|
|
await verify(requestSignature, PairingType.REQUEST);
|
|
|
|
requestSignature,
|
|
|
|
|
|
|
|
textsecure.protobuf.PairingAuthorisationMessage.Type.REQUEST
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
window.log.warn(
|
|
|
|
window.log.warn(
|
|
|
|
'Could not verify pairing request authorisation signature. Ignoring message.'
|
|
|
|
'Could not verify pairing request authorisation signature. Ignoring message.'
|
|
|
@ -233,10 +230,7 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isGrant) {
|
|
|
|
if (isGrant) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
await verify(
|
|
|
|
await verify(grantSignature, PairingType.GRANT);
|
|
|
|
grantSignature,
|
|
|
|
|
|
|
|
textsecure.protobuf.PairingAuthorisationMessage.Type.GRANT
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
window.log.warn(
|
|
|
|
window.log.warn(
|
|
|
|
'Could not verify pairing grant authorisation signature. Ignoring message.'
|
|
|
|
'Could not verify pairing grant authorisation signature. Ignoring message.'
|
|
|
@ -265,12 +259,10 @@
|
|
|
|
// For REQUEST type message, the secondary device signs the primary device pubkey
|
|
|
|
// For REQUEST type message, the secondary device signs the primary device pubkey
|
|
|
|
// For GRANT type message, the primary device signs the secondary device pubkey
|
|
|
|
// For GRANT type message, the primary device signs the secondary device pubkey
|
|
|
|
let issuer;
|
|
|
|
let issuer;
|
|
|
|
if (type === textsecure.protobuf.PairingAuthorisationMessage.Type.GRANT) {
|
|
|
|
if (type === PairingType.GRANT) {
|
|
|
|
data.set(new Uint8Array(secondaryPubKeyArrayBuffer));
|
|
|
|
data.set(new Uint8Array(secondaryPubKeyArrayBuffer));
|
|
|
|
issuer = primaryDevicePubKeyArrayBuffer;
|
|
|
|
issuer = primaryDevicePubKeyArrayBuffer;
|
|
|
|
} else if (
|
|
|
|
} else if (type === PairingType.REQUEST) {
|
|
|
|
type === textsecure.protobuf.PairingAuthorisationMessage.Type.REQUEST
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
data.set(new Uint8Array(primaryDevicePubKeyArrayBuffer));
|
|
|
|
data.set(new Uint8Array(primaryDevicePubKeyArrayBuffer));
|
|
|
|
issuer = secondaryPubKeyArrayBuffer;
|
|
|
|
issuer = secondaryPubKeyArrayBuffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -301,6 +293,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
const sha512 = data => crypto.subtle.digest('SHA-512', data);
|
|
|
|
const sha512 = data => crypto.subtle.digest('SHA-512', data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const PairingType = Object.freeze({
|
|
|
|
|
|
|
|
REQUEST: 0,
|
|
|
|
|
|
|
|
GRANT: 1,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
window.libloki.crypto = {
|
|
|
|
window.libloki.crypto = {
|
|
|
|
DHEncrypt,
|
|
|
|
DHEncrypt,
|
|
|
|
DHDecrypt,
|
|
|
|
DHDecrypt,
|
|
|
@ -311,6 +308,7 @@
|
|
|
|
generateSignatureForPairing,
|
|
|
|
generateSignatureForPairing,
|
|
|
|
verifyPairingSignature,
|
|
|
|
verifyPairingSignature,
|
|
|
|
validateAuthorisation,
|
|
|
|
validateAuthorisation,
|
|
|
|
|
|
|
|
PairingType,
|
|
|
|
// for testing
|
|
|
|
// for testing
|
|
|
|
_LokiSnodeChannel: LokiSnodeChannel,
|
|
|
|
_LokiSnodeChannel: LokiSnodeChannel,
|
|
|
|
_decodeSnodeAddressToPubKey: decodeSnodeAddressToPubKey,
|
|
|
|
_decodeSnodeAddressToPubKey: decodeSnodeAddressToPubKey,
|
|
|
|