Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3296080
D11901.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11901.diff
View Options
diff --git a/native/profile/secondary-device-qr-code-scanner.react.js b/native/profile/secondary-device-qr-code-scanner.react.js
--- a/native/profile/secondary-device-qr-code-scanner.react.js
+++ b/native/profile/secondary-device-qr-code-scanner.react.js
@@ -33,6 +33,7 @@
import {
composeTunnelbrokerQRAuthMessage,
parseTunnelbrokerQRAuthMessage,
+ signDeviceListUpdate,
} from '../qr-code/qr-code-utils.js';
import { useStyles } from '../themes/colors.js';
import Alert from '../utils/alert.js';
@@ -121,9 +122,8 @@
devices: [...devices, newDeviceID],
timestamp: Date.now(),
};
- await updateDeviceList({
- rawDeviceList: JSON.stringify(newDeviceList),
- });
+ const signedDeviceList = await signDeviceListUpdate(newDeviceList);
+ await updateDeviceList(signedDeviceList);
},
[identityContext],
);
diff --git a/native/qr-code/qr-code-utils.js b/native/qr-code/qr-code-utils.js
--- a/native/qr-code/qr-code-utils.js
+++ b/native/qr-code/qr-code-utils.js
@@ -1,6 +1,10 @@
// @flow
import { hexToUintArray } from 'lib/media/data-utils.js';
+import type {
+ RawDeviceList,
+ SignedDeviceList,
+} from 'lib/types/identity-service-types.js';
import {
peerToPeerMessageTypes,
type QRCodeAuthMessage,
@@ -9,6 +13,8 @@
qrCodeAuthMessagePayloadValidator,
type QRCodeAuthMessagePayload,
} from 'lib/types/tunnelbroker/qr-code-auth-message-types.js';
+import { getConfig } from 'lib/utils/config.js';
+import { getContentSigningKey } from 'lib/utils/crypto-utils.js';
import {
convertBytesToObj,
@@ -52,4 +58,29 @@
return Promise.resolve(payload);
}
-export { composeTunnelbrokerQRAuthMessage, parseTunnelbrokerQRAuthMessage };
+async function signDeviceListUpdate(
+ deviceListPayload: RawDeviceList,
+): Promise<SignedDeviceList> {
+ const deviceID = await getContentSigningKey();
+ const rawDeviceList = JSON.stringify(deviceListPayload);
+
+ // don't sign device list if current device is not a primary one
+ if (deviceListPayload.devices[0] !== deviceID) {
+ return {
+ rawDeviceList,
+ };
+ }
+
+ const { olmAPI } = getConfig();
+ const curPrimarySignature = await olmAPI.signMessage(rawDeviceList);
+ return {
+ rawDeviceList,
+ curPrimarySignature,
+ };
+}
+
+export {
+ composeTunnelbrokerQRAuthMessage,
+ parseTunnelbrokerQRAuthMessage,
+ signDeviceListUpdate,
+};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 18, 12:41 AM (21 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2532481
Default Alt Text
D11901.diff (2 KB)
Attached To
Mode
D11901: [native] Sign device list during QR auth
Attached
Detach File
Event Timeline
Log In to Comment