]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/manager/util/KeyUtils.java
Check for null query when decoding device link uri
[signal-cli] / src / main / java / org / asamk / signal / manager / util / KeyUtils.java
index 2b4bc3716192c267abec1369e465cf3d454f3c2c..d8861b1be7cd164b4ee6bcf5baa5c78e0ddfad7a 100644 (file)
@@ -3,6 +3,12 @@ package org.asamk.signal.manager.util;
 import org.asamk.signal.util.RandomUtils;
 import org.signal.zkgroup.InvalidInputException;
 import org.signal.zkgroup.profiles.ProfileKey;
+import org.whispersystems.libsignal.IdentityKey;
+import org.whispersystems.libsignal.IdentityKeyPair;
+import org.whispersystems.libsignal.ecc.Curve;
+import org.whispersystems.libsignal.ecc.ECKeyPair;
+import org.whispersystems.libsignal.ecc.ECPrivateKey;
+import org.whispersystems.signalservice.api.kbs.MasterKey;
 import org.whispersystems.util.Base64;
 
 public class KeyUtils {
@@ -10,6 +16,14 @@ public class KeyUtils {
     private KeyUtils() {
     }
 
+    public static IdentityKeyPair generateIdentityKeyPair() {
+        ECKeyPair djbKeyPair = Curve.generateKeyPair();
+        IdentityKey djbIdentityKey = new IdentityKey(djbKeyPair.getPublicKey());
+        ECPrivateKey djbPrivateKey = djbKeyPair.getPrivateKey();
+
+        return new IdentityKeyPair(djbIdentityKey, djbPrivateKey);
+    }
+
     public static String createSignalingKey() {
         return getSecret(52);
     }
@@ -30,6 +44,10 @@ public class KeyUtils {
         return getSecretBytes(32);
     }
 
+    public static MasterKey createMasterKey() {
+        return MasterKey.createNew(RandomUtils.getSecureRandom());
+    }
+
     private static String getSecret(int size) {
         byte[] secret = getSecretBytes(size);
         return Base64.encodeBytes(secret);