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
;
8 import org
.whispersystems
.util
.Base64
;
10 import java
.io
.IOException
;
12 public class ProfileUtils
{
14 public static SignalProfile
decryptProfile(
15 final ProfileKey profileKey
, final SignalServiceProfile encryptedProfile
17 ProfileCipher profileCipher
= new ProfileCipher(profileKey
);
21 name
= encryptedProfile
.getName() == null
23 : new String(profileCipher
.decryptName(Base64
.decode(encryptedProfile
.getName())));
24 } catch (IOException e
) {
27 String unidentifiedAccess
;
29 unidentifiedAccess
= encryptedProfile
.getUnidentifiedAccess() == null
30 || !profileCipher
.verifyUnidentifiedAccess(Base64
.decode(encryptedProfile
.getUnidentifiedAccess()))
32 : encryptedProfile
.getUnidentifiedAccess();
33 } catch (IOException e
) {
34 unidentifiedAccess
= null;
36 return new SignalProfile(encryptedProfile
.getIdentityKey(),
39 encryptedProfile
.isUnrestrictedUnidentifiedAccess(),
40 encryptedProfile
.getCapabilities());
41 } catch (InvalidCiphertextException e
) {