Add "last resort" PreKey generation to KeyHelper.

This commit is contained in:
Moxie Marlinspike 2014-04-25 17:11:29 -07:00
parent e84a0948e9
commit 81ae9af2e4
2 changed files with 12 additions and 0 deletions

View File

@ -48,6 +48,7 @@ prekeys.
IdentityKeyPair identityKeyPair = KeyHelper.generateIdentityKeyPair();
int registrationId = KeyHelper.generateRegistrationId();
List<PreKeyRecord> preKeys = KeyHelper.generatePreKeys(startId, 100);
PreKeyRecord lastResortKey = KeyHelper.generateLastResortKey();
// Store identityKeyPair somewhere durable and safe.
// Store registrationId somewhere durable and safe.

View File

@ -74,4 +74,15 @@ public class KeyHelper {
return results;
}
/**
* Generate the last resort PreKey. Clients should do this only once, at install
* time, and durably store it for the length of the install.
*
* @return the generated last resort PreKeyRecord.
*/
public static PreKeyRecord generateLastResortPreKey() {
ECKeyPair keyPair = Curve.generateKeyPair(true);
return new PreKeyRecord(Medium.MAX_VALUE, keyPair);
}
}