X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/9d71313a0c2b2dc369a5974f4733204f22e89998..dbebd38391596cab7581841a8a3eeb34c511c9da:/src/main/java/cli/Manager.java diff --git a/src/main/java/cli/Manager.java b/src/main/java/cli/Manager.java index ff2178b4..b745988b 100644 --- a/src/main/java/cli/Manager.java +++ b/src/main/java/cli/Manager.java @@ -24,6 +24,7 @@ import org.whispersystems.libaxolotl.InvalidVersionException; import org.whispersystems.libaxolotl.state.PreKeyRecord; import org.whispersystems.libaxolotl.state.SignedPreKeyRecord; import org.whispersystems.libaxolotl.util.KeyHelper; +import org.whispersystems.libaxolotl.util.Medium; import org.whispersystems.libaxolotl.util.guava.Optional; import org.whispersystems.textsecure.api.TextSecureAccountManager; import org.whispersystems.textsecure.api.TextSecureMessagePipe; @@ -117,12 +118,16 @@ public class Manager { return registered; } - public void register() throws IOException { + public void register(boolean voiceVerication) throws IOException { password = Util.getSecret(18); accountManager = new TextSecureAccountManager(URL, TRUST_STORE, username, password); - accountManager.requestSmsVerificationCode(); + if (voiceVerication) + accountManager.requestVoiceVerificationCode(); + else + accountManager.requestSmsVerificationCode(); + registered = false; } @@ -133,13 +138,21 @@ public class Manager { //accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID))); registered = true; + int start = 0; List oneTimePreKeys = KeyHelper.generatePreKeys(start, 100); + for (int i = start; i < oneTimePreKeys.size(); i++) { + axolotlStore.storePreKey(i, oneTimePreKeys.get(i)); + } + PreKeyRecord lastResortKey = KeyHelper.generateLastResortPreKey(); + axolotlStore.storePreKey(Medium.MAX_VALUE, lastResortKey); + int signedPreKeyId = 0; SignedPreKeyRecord signedPreKeyRecord; try { signedPreKeyRecord = KeyHelper.generateSignedPreKey(axolotlStore.getIdentityKeyPair(), signedPreKeyId); + axolotlStore.storeSignedPreKey(signedPreKeyId, signedPreKeyRecord); } catch (InvalidKeyException e) { // Should really not happen System.out.println("invalid key");