X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/88d81c7a634938ca58d003861f6272f5bf56ee9b..c72aeed8bba4d5ca873b36b4edb2b8eda9c24ec7:/src/main/java/org/asamk/signal/manager/util/KeyUtils.java diff --git a/src/main/java/org/asamk/signal/manager/util/KeyUtils.java b/src/main/java/org/asamk/signal/manager/util/KeyUtils.java deleted file mode 100644 index d8861b1b..00000000 --- a/src/main/java/org/asamk/signal/manager/util/KeyUtils.java +++ /dev/null @@ -1,61 +0,0 @@ -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 { - - 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); - } - - public static ProfileKey createProfileKey() { - try { - return new ProfileKey(getSecretBytes(32)); - } catch (InvalidInputException e) { - throw new AssertionError("Profile key is guaranteed to be 32 bytes here"); - } - } - - public static String createPassword() { - return getSecret(18); - } - - public static byte[] createStickerUploadKey() { - 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); - } - - public static byte[] getSecretBytes(int size) { - byte[] secret = new byte[size]; - RandomUtils.getSecureRandom().nextBytes(secret); - return secret; - } -}