1 package org
.asamk
.signal
.manager
.util
;
3 import org
.asamk
.signal
.manager
.storage
.profiles
.SignalProfile
;
4 import org
.signal
.zkgroup
.profiles
.ProfileKey
;
5 import org
.whispersystems
.signalservice
.api
.crypto
.InvalidCiphertextException
;
6 import org
.whispersystems
.signalservice
.api
.crypto
.ProfileCipher
;
7 import org
.whispersystems
.signalservice
.api
.profiles
.SignalServiceProfile
;
9 import java
.util
.Base64
;
11 public class ProfileUtils
{
13 public static SignalProfile
decryptProfile(
14 final ProfileKey profileKey
, final SignalServiceProfile encryptedProfile
16 ProfileCipher profileCipher
= new ProfileCipher(profileKey
);
20 name
= encryptedProfile
.getName() == null
22 : new String(profileCipher
.decryptName(Base64
.getDecoder().decode(encryptedProfile
.getName())));
23 } catch (IllegalArgumentException e
) {
26 String unidentifiedAccess
;
28 unidentifiedAccess
= encryptedProfile
.getUnidentifiedAccess() == null
29 || !profileCipher
.verifyUnidentifiedAccess(Base64
.getDecoder()
30 .decode(encryptedProfile
.getUnidentifiedAccess()))
32 : encryptedProfile
.getUnidentifiedAccess();
33 } catch (IllegalArgumentException e
) {
34 unidentifiedAccess
= null;
36 return new SignalProfile(encryptedProfile
.getIdentityKey(),
39 encryptedProfile
.isUnrestrictedUnidentifiedAccess(),
40 encryptedProfile
.getCapabilities());
41 } catch (InvalidCiphertextException e
) {