]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/manager/KeyUtils.java
Refactor to use GroupId class to wrap the byte array
[signal-cli] / src / main / java / org / asamk / signal / manager / KeyUtils.java
index 617893fc727b7205f2eb86ff8135176a90d4bb61..21f6037fe240fa8d960f66191f551e3d91b03736 100644 (file)
@@ -1,7 +1,9 @@
 package org.asamk.signal.manager;
 
 import org.asamk.signal.util.RandomUtils;
-import org.whispersystems.signalservice.internal.util.Base64;
+import org.signal.zkgroup.InvalidInputException;
+import org.signal.zkgroup.profiles.ProfileKey;
+import org.whispersystems.util.Base64;
 
 class KeyUtils {
 
@@ -12,16 +14,20 @@ class KeyUtils {
         return getSecret(52);
     }
 
-    static byte[] createProfileKey() {
-        return getSecretBytes(32);
+    static ProfileKey createProfileKey() {
+        try {
+            return new ProfileKey(getSecretBytes(32));
+        } catch (InvalidInputException e) {
+            throw new AssertionError("Profile key is guaranteed to be 32 bytes here");
+        }
     }
 
     static String createPassword() {
         return getSecret(18);
     }
 
-    static byte[] createGroupId() {
-        return getSecretBytes(16);
+    static byte[] createStickerUploadKey() {
+        return getSecretBytes(32);
     }
 
     private static String getSecret(int size) {
@@ -29,7 +35,7 @@ class KeyUtils {
         return Base64.encodeBytes(secret);
     }
 
-    private static byte[] getSecretBytes(int size) {
+    static byte[] getSecretBytes(int size) {
         byte[] secret = new byte[size];
         RandomUtils.getSecureRandom().nextBytes(secret);
         return secret;