mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Actually store preKeys
This commit is contained in:
parent
08f8d2b026
commit
dbebd38391
2 changed files with 10 additions and 1 deletions
|
@ -34,7 +34,7 @@ public class JsonSignedPreKeyStore implements SignedPreKeyStore {
|
||||||
public JSONArray getJson() {
|
public JSONArray getJson() {
|
||||||
JSONArray result = new JSONArray();
|
JSONArray result = new JSONArray();
|
||||||
for (Integer id : store.keySet()) {
|
for (Integer id : store.keySet()) {
|
||||||
result.put(new JSONObject().put("id", id.toString()).put("record", store.get(id)));
|
result.put(new JSONObject().put("id", id.toString()).put("record", Base64.encodeBytes(store.get(id))));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.whispersystems.libaxolotl.InvalidVersionException;
|
||||||
import org.whispersystems.libaxolotl.state.PreKeyRecord;
|
import org.whispersystems.libaxolotl.state.PreKeyRecord;
|
||||||
import org.whispersystems.libaxolotl.state.SignedPreKeyRecord;
|
import org.whispersystems.libaxolotl.state.SignedPreKeyRecord;
|
||||||
import org.whispersystems.libaxolotl.util.KeyHelper;
|
import org.whispersystems.libaxolotl.util.KeyHelper;
|
||||||
|
import org.whispersystems.libaxolotl.util.Medium;
|
||||||
import org.whispersystems.libaxolotl.util.guava.Optional;
|
import org.whispersystems.libaxolotl.util.guava.Optional;
|
||||||
import org.whispersystems.textsecure.api.TextSecureAccountManager;
|
import org.whispersystems.textsecure.api.TextSecureAccountManager;
|
||||||
import org.whispersystems.textsecure.api.TextSecureMessagePipe;
|
import org.whispersystems.textsecure.api.TextSecureMessagePipe;
|
||||||
|
@ -137,13 +138,21 @@ public class Manager {
|
||||||
|
|
||||||
//accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID)));
|
//accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID)));
|
||||||
registered = true;
|
registered = true;
|
||||||
|
|
||||||
int start = 0;
|
int start = 0;
|
||||||
List<PreKeyRecord> oneTimePreKeys = KeyHelper.generatePreKeys(start, 100);
|
List<PreKeyRecord> oneTimePreKeys = KeyHelper.generatePreKeys(start, 100);
|
||||||
|
for (int i = start; i < oneTimePreKeys.size(); i++) {
|
||||||
|
axolotlStore.storePreKey(i, oneTimePreKeys.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
PreKeyRecord lastResortKey = KeyHelper.generateLastResortPreKey();
|
PreKeyRecord lastResortKey = KeyHelper.generateLastResortPreKey();
|
||||||
|
axolotlStore.storePreKey(Medium.MAX_VALUE, lastResortKey);
|
||||||
|
|
||||||
int signedPreKeyId = 0;
|
int signedPreKeyId = 0;
|
||||||
SignedPreKeyRecord signedPreKeyRecord;
|
SignedPreKeyRecord signedPreKeyRecord;
|
||||||
try {
|
try {
|
||||||
signedPreKeyRecord = KeyHelper.generateSignedPreKey(axolotlStore.getIdentityKeyPair(), signedPreKeyId);
|
signedPreKeyRecord = KeyHelper.generateSignedPreKey(axolotlStore.getIdentityKeyPair(), signedPreKeyId);
|
||||||
|
axolotlStore.storeSignedPreKey(signedPreKeyId, signedPreKeyRecord);
|
||||||
} catch (InvalidKeyException e) {
|
} catch (InvalidKeyException e) {
|
||||||
// Should really not happen
|
// Should really not happen
|
||||||
System.out.println("invalid key");
|
System.out.println("invalid key");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue