Accept masterKey in ProvisionMessage

This commit is contained in:
Fedor Indutny 2023-10-30 21:31:39 +01:00 committed by GitHub
parent 79f7d64fb7
commit f1e8ffe720
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 5 deletions

View file

@ -198,7 +198,7 @@
"@electron/fuses": "1.5.0",
"@formatjs/intl": "2.6.7",
"@mixer/parallel-prettier": "2.0.3",
"@signalapp/mock-server": "4.2.0",
"@signalapp/mock-server": "4.3.0",
"@storybook/addon-a11y": "7.4.5",
"@storybook/addon-actions": "7.4.5",
"@storybook/addon-controls": "7.4.5",

View file

@ -26,6 +26,7 @@ message ProvisionMessage {
optional bytes profileKey = 6;
optional bool readReceipts = 7;
optional uint32 ProvisioningVersion = 9;
optional bytes masterKey = 13;
}
enum ProvisioningVersion {

View file

@ -67,6 +67,7 @@ const DAY = 24 * 60 * 60 * 1000;
const STARTING_KEY_ID = 1;
const PROFILE_KEY_LENGTH = 32;
const MASTER_KEY_LENGTH = 32;
const KEY_TOO_OLD_THRESHOLD = 14 * DAY;
export const KYBER_KEY_ID_KEY: StorageKeyByServiceIdKind = {
@ -120,6 +121,7 @@ type CreateAccountSharedOptionsType = Readonly<{
aciKeyPair: KeyPairType;
pniKeyPair: KeyPairType;
profileKey: Uint8Array;
masterKey: Uint8Array | undefined;
}>;
type CreatePrimaryDeviceOptionsType = Readonly<{
@ -302,6 +304,7 @@ export default class AccountManager extends EventTarget {
const pniKeyPair = generateKeyPair();
const profileKey = getRandomBytes(PROFILE_KEY_LENGTH);
const accessKey = deriveAccessKey(profileKey);
const masterKey = getRandomBytes(MASTER_KEY_LENGTH);
const registrationBaton = this.server.startRegistration();
try {
@ -314,6 +317,7 @@ export default class AccountManager extends EventTarget {
pniKeyPair,
profileKey,
accessKey,
masterKey,
readReceipts: true,
});
} finally {
@ -428,6 +432,7 @@ export default class AccountManager extends EventTarget {
ourAci,
ourPni,
readReceipts: Boolean(provisionMessage.readReceipts),
masterKey: provisionMessage.masterKey,
});
} finally {
this.server.finishRegistration(registrationBaton);
@ -968,6 +973,7 @@ export default class AccountManager extends EventTarget {
aciKeyPair,
pniKeyPair,
profileKey,
masterKey,
readReceipts,
userAgent,
} = options;
@ -1202,6 +1208,9 @@ export default class AccountManager extends EventTarget {
if (userAgent) {
await storage.put('userAgent', userAgent);
}
if (masterKey) {
await storage.put('masterKey', Bytes.toBase64(masterKey));
}
await storage.put('read-receipt-setting', Boolean(readReceipts));

View file

@ -24,6 +24,7 @@ type ProvisionDecryptResult = {
userAgent?: string;
readReceipts?: boolean;
profileKey?: Uint8Array;
masterKey?: Uint8Array;
};
class ProvisioningCipherInner {
@ -87,6 +88,9 @@ class ProvisioningCipherInner {
if (provisionMessage.profileKey) {
ret.profileKey = provisionMessage.profileKey;
}
if (provisionMessage.masterKey) {
ret.masterKey = provisionMessage.masterKey;
}
return ret;
}

View file

@ -3901,10 +3901,10 @@
node-gyp-build "^4.2.3"
uuid "^8.3.0"
"@signalapp/mock-server@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@signalapp/mock-server/-/mock-server-4.2.0.tgz#836bf1d8cb38b9f66a6f719205e5000cdc7d184b"
integrity sha512-pungaAf3Pel34yIK00nRtHWQHA9VCRjOH11ZBgrEjiMpdA+LPETCU94Do28Q9Un7T8GmNOJ0+cKAhCKuyo1Fow==
"@signalapp/mock-server@4.3.0":
version "4.3.0"
resolved "https://registry.yarnpkg.com/@signalapp/mock-server/-/mock-server-4.3.0.tgz#501d1e0bc9f9fe811189690e7b053dfe9bac7c88"
integrity sha512-zE8+EhuKsQ0byXG1Prkw5hoH0pMySwf+AJNf2sdOTsIJSKLx8/GOP4uG3m/vSOW3m4BoAmVnpNzJryRIjpfAbw==
dependencies:
"@signalapp/libsignal-client" "^0.30.2"
debug "^4.3.2"