Move IdentityKeyPair generation to KeyUtils

in preparation for rust libsignal which doesn't provide the method
This commit is contained in:
AsamK 2020-12-21 10:25:36 +01:00
parent 00339b1abe
commit 88d81c7a63
3 changed files with 15 additions and 2 deletions

View file

@ -317,7 +317,7 @@ public class Manager implements Closeable {
PathConfig pathConfig = PathConfig.createDefault(settingsPath);
if (!SignalAccount.userExists(pathConfig.getDataPath(), username)) {
IdentityKeyPair identityKey = KeyHelper.generateIdentityKeyPair();
IdentityKeyPair identityKey = KeyUtils.generateIdentityKeyPair();
int registrationId = KeyHelper.generateRegistrationId(false);
ProfileKey profileKey = KeyUtils.createProfileKey();

View file

@ -52,7 +52,7 @@ public class ProvisioningManager {
this.serviceConfiguration = serviceConfiguration;
this.userAgent = userAgent;
identityKey = KeyHelper.generateIdentityKeyPair();
identityKey = KeyUtils.generateIdentityKeyPair();
registrationId = KeyHelper.generateRegistrationId(false);
password = KeyUtils.createPassword();
final SleepTimer timer = new UptimeSleepTimer();

View file

@ -3,6 +3,11 @@ 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;
@ -11,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);
}