Handle both given and family name in decrypted profile name

* Decrypt given and family names from profile name string
* Handle both given and family name from decrypted profile name
* Ensure we properly handle profiles with no family name
This commit is contained in:
Scott Nonnenberg 2020-01-13 14:28:28 -08:00 committed by Ken Powers
parent 4f50c0b093
commit 11266cb775
9 changed files with 326 additions and 39 deletions

View file

@ -1787,16 +1787,19 @@
const data = window.Signal.Crypto.base64ToArrayBuffer(encryptedName);
// decrypt
const decrypted = await textsecure.crypto.decryptProfileName(
const { given, family } = await textsecure.crypto.decryptProfileName(
data,
keyBuffer
);
// encode
const profileName = window.Signal.Crypto.stringFromBytes(decrypted);
const profileName = window.Signal.Crypto.stringFromBytes(given);
const profileFamilyName = family
? window.Signal.Crypto.stringFromBytes(family)
: null;
// set
this.set({ profileName });
this.set({ profileName, profileFamilyName });
},
async setProfileAvatar(avatarPath) {
if (!avatarPath) {
@ -1840,6 +1843,7 @@
profileKey,
accessKey: null,
profileName: null,
profileFamilyName: null,
profileAvatar: null,
sealedSender: SEALED_SENDER.UNKNOWN,
});
@ -1865,6 +1869,7 @@
profileAvatar: null,
profileKey: null,
profileName: null,
profileFamilyName: null,
accessKey: null,
sealedSender: SEALED_SENDER.UNKNOWN,
});
@ -1951,7 +1956,10 @@
getProfileName() {
if (this.isPrivate()) {
return this.get('profileName');
return Util.combineNames(
this.get('profileName'),
this.get('profileFamilyName')
);
}
return null;
},