mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 16:23:38 +00:00
Rename InitializationParameters -> AxolotlParameters
This commit is contained in:
parent
3f299936bf
commit
e0d2398ca5
@ -26,7 +26,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static org.whispersystems.libaxolotl.ratchet.RatchetingSession.InitializationParameters;
|
||||
import static org.whispersystems.libaxolotl.ratchet.RatchetingSession.AxolotlParameters;
|
||||
|
||||
public class SessionCipherTest extends AndroidTestCase {
|
||||
|
||||
@ -138,8 +138,8 @@ public class SessionCipherTest extends AndroidTestCase {
|
||||
ECKeyPair bobBaseKey = Curve.generateKeyPair(true);
|
||||
ECKeyPair bobEphemeralKey = bobBaseKey;
|
||||
|
||||
InitializationParameters aliceParameters =
|
||||
InitializationParameters.newBuilder()
|
||||
AxolotlParameters aliceParameters =
|
||||
AxolotlParameters.newBuilder()
|
||||
.setOurIdentityKey(aliceIdentityKey)
|
||||
.setOurBaseKey(aliceBaseKey)
|
||||
.setOurEphemeralKey(aliceEphemeralKey)
|
||||
@ -150,8 +150,8 @@ public class SessionCipherTest extends AndroidTestCase {
|
||||
.setTheirPreKey(Optional.<ECPublicKey>absent())
|
||||
.create();
|
||||
|
||||
InitializationParameters bobParameters =
|
||||
InitializationParameters.newBuilder()
|
||||
AxolotlParameters bobParameters =
|
||||
RatchetingSession.AxolotlParameters.newBuilder()
|
||||
.setOurIdentityKey(bobIdentityKey)
|
||||
.setOurBaseKey(bobBaseKey)
|
||||
.setOurEphemeralKey(bobEphemeralKey)
|
||||
@ -186,8 +186,8 @@ public class SessionCipherTest extends AndroidTestCase {
|
||||
|
||||
ECKeyPair bobPreKey = Curve.generateKeyPair(true);
|
||||
|
||||
InitializationParameters aliceParameters =
|
||||
InitializationParameters.newBuilder()
|
||||
AxolotlParameters aliceParameters =
|
||||
AxolotlParameters.newBuilder()
|
||||
.setOurIdentityKey(aliceIdentityKey)
|
||||
.setOurBaseKey(aliceBaseKey)
|
||||
.setOurEphemeralKey(aliceEphemeralKey)
|
||||
@ -198,8 +198,8 @@ public class SessionCipherTest extends AndroidTestCase {
|
||||
.setTheirPreKey(Optional.of(bobPreKey.getPublicKey()))
|
||||
.create();
|
||||
|
||||
InitializationParameters bobParameters =
|
||||
InitializationParameters.newBuilder()
|
||||
AxolotlParameters bobParameters =
|
||||
AxolotlParameters.newBuilder()
|
||||
.setOurIdentityKey(bobIdentityKey)
|
||||
.setOurBaseKey(bobBaseKey)
|
||||
.setOurEphemeralKey(bobEphemeralKey)
|
||||
|
@ -15,7 +15,7 @@ import org.whispersystems.libaxolotl.util.guava.Optional;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.whispersystems.libaxolotl.ratchet.RatchetingSession.InitializationParameters;
|
||||
import static org.whispersystems.libaxolotl.ratchet.RatchetingSession.AxolotlParameters;
|
||||
|
||||
public class RatchetingSessionTest extends AndroidTestCase {
|
||||
|
||||
@ -108,7 +108,7 @@ public class RatchetingSessionTest extends AndroidTestCase {
|
||||
ECPublicKey aliceEphemeralPublicKey = Curve.decodePoint(aliceEphemeralPublic, 0);
|
||||
IdentityKey aliceIdentityPublicKey = new IdentityKey(aliceIdentityPublic, 0);
|
||||
|
||||
InitializationParameters parameters = InitializationParameters.newBuilder()
|
||||
AxolotlParameters parameters = AxolotlParameters.newBuilder()
|
||||
.setOurBaseKey(bobBaseKey)
|
||||
.setOurEphemeralKey(bobEphemeralKey)
|
||||
.setOurIdentityKey(bobIdentityKey)
|
||||
@ -217,7 +217,7 @@ public class RatchetingSessionTest extends AndroidTestCase {
|
||||
|
||||
SessionState session = new SessionState();
|
||||
|
||||
InitializationParameters parameters = InitializationParameters.newBuilder()
|
||||
AxolotlParameters parameters = AxolotlParameters.newBuilder()
|
||||
.setOurBaseKey(aliceBaseKey)
|
||||
.setOurEphemeralKey(aliceEphemeralKey)
|
||||
.setOurIdentityKey(aliceIdentityKey)
|
||||
|
@ -22,7 +22,7 @@ import org.whispersystems.libaxolotl.util.guava.Optional;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
import static org.whispersystems.libaxolotl.ratchet.RatchetingSession.InitializationParameters;
|
||||
import static org.whispersystems.libaxolotl.ratchet.RatchetingSession.AxolotlParameters;
|
||||
|
||||
/**
|
||||
* SessionBuilder is responsible for setting up encrypted sessions.
|
||||
@ -118,7 +118,7 @@ public class SessionBuilder {
|
||||
|
||||
boolean simultaneousInitiate = sessionRecord.getSessionState().hasPendingPreKey();
|
||||
|
||||
InitializationParameters.Builder parameters = InitializationParameters.newBuilder();
|
||||
AxolotlParameters.Builder parameters = AxolotlParameters.newBuilder();
|
||||
|
||||
parameters.setTheirBaseKey(message.getBaseKey());
|
||||
parameters.setTheirEphemeralKey(message.getWhisperMessage().getSenderEphemeral());
|
||||
@ -165,10 +165,9 @@ public class SessionBuilder {
|
||||
return;
|
||||
}
|
||||
|
||||
SessionRecord sessionRecord = sessionStore.loadSession(recipientId, deviceId);
|
||||
boolean simultaneousInitiate = sessionRecord.getSessionState().hasPendingPreKey();
|
||||
|
||||
InitializationParameters.Builder parameters = InitializationParameters.newBuilder();
|
||||
SessionRecord sessionRecord = sessionStore.loadSession(recipientId, deviceId);
|
||||
boolean simultaneousInitiate = sessionRecord.getSessionState().hasPendingPreKey();
|
||||
AxolotlParameters.Builder parameters = RatchetingSession.AxolotlParameters.newBuilder();
|
||||
|
||||
parameters.setTheirBaseKey(message.getBaseKey());
|
||||
parameters.setTheirEphemeralKey(message.getWhisperMessage().getSenderEphemeral());
|
||||
@ -226,9 +225,9 @@ public class SessionBuilder {
|
||||
throw new InvalidKeyException("Both signed and unsigned prekeys are absent!");
|
||||
}
|
||||
|
||||
SessionRecord sessionRecord = sessionStore.loadSession(recipientId, deviceId);
|
||||
InitializationParameters.Builder parameters = InitializationParameters.newBuilder();
|
||||
ECKeyPair ourBaseKey = Curve.generateKeyPair(true);
|
||||
SessionRecord sessionRecord = sessionStore.loadSession(recipientId, deviceId);
|
||||
AxolotlParameters.Builder parameters = AxolotlParameters.newBuilder();
|
||||
ECKeyPair ourBaseKey = Curve.generateKeyPair(true);
|
||||
|
||||
parameters.setOurIdentityKey(identityKeyStore.getIdentityKeyPair());
|
||||
parameters.setOurBaseKey(ourBaseKey);
|
||||
@ -281,9 +280,9 @@ public class SessionBuilder {
|
||||
}
|
||||
|
||||
private KeyExchangeMessage processInitiate(KeyExchangeMessage message) throws InvalidKeyException {
|
||||
InitializationParameters.Builder parameters = InitializationParameters.newBuilder();
|
||||
int flags = KeyExchangeMessage.RESPONSE_FLAG;
|
||||
SessionRecord sessionRecord = sessionStore.loadSession(recipientId, deviceId);
|
||||
AxolotlParameters.Builder parameters = AxolotlParameters.newBuilder();
|
||||
int flags = KeyExchangeMessage.RESPONSE_FLAG;
|
||||
SessionRecord sessionRecord = sessionStore.loadSession(recipientId, deviceId);
|
||||
|
||||
if (message.getVersion() >= 3 &&
|
||||
!Curve.verifySignature(message.getIdentityKey().getPublicKey(),
|
||||
@ -305,7 +304,7 @@ public class SessionBuilder {
|
||||
parameters.setOurEphemeralKey(sessionRecord.getSessionState().getPendingKeyExchangeEphemeralKey());
|
||||
parameters.setOurIdentityKey(sessionRecord.getSessionState().getPendingKeyExchangeIdentityKey());
|
||||
parameters.setOurPreKey(Optional.<ECKeyPair>absent());
|
||||
flags |= KeyExchangeMessage.SIMULTAENOUS_INITIATE_FLAG;
|
||||
flags |= KeyExchangeMessage.SIMULTAENOUS_INITIATE_FLAG;
|
||||
}
|
||||
|
||||
parameters.setTheirBaseKey(message.getBaseKey());
|
||||
@ -344,17 +343,17 @@ public class SessionBuilder {
|
||||
else return;
|
||||
}
|
||||
|
||||
InitializationParameters parameters =
|
||||
InitializationParameters.newBuilder()
|
||||
.setOurBaseKey(sessionRecord.getSessionState().getPendingKeyExchangeBaseKey())
|
||||
.setOurEphemeralKey(sessionRecord.getSessionState().getPendingKeyExchangeEphemeralKey())
|
||||
.setOurPreKey(Optional.<ECKeyPair>absent())
|
||||
.setOurIdentityKey(sessionRecord.getSessionState().getPendingKeyExchangeIdentityKey())
|
||||
.setTheirBaseKey(message.getBaseKey())
|
||||
.setTheirEphemeralKey(message.getEphemeralKey())
|
||||
.setTheirPreKey(Optional.<ECPublicKey>absent())
|
||||
.setTheirIdentityKey(message.getIdentityKey())
|
||||
.create();
|
||||
AxolotlParameters parameters =
|
||||
AxolotlParameters.newBuilder()
|
||||
.setOurBaseKey(sessionRecord.getSessionState().getPendingKeyExchangeBaseKey())
|
||||
.setOurEphemeralKey(sessionRecord.getSessionState().getPendingKeyExchangeEphemeralKey())
|
||||
.setOurPreKey(Optional.<ECKeyPair>absent())
|
||||
.setOurIdentityKey(sessionRecord.getSessionState().getPendingKeyExchangeIdentityKey())
|
||||
.setTheirBaseKey(message.getBaseKey())
|
||||
.setTheirEphemeralKey(message.getEphemeralKey())
|
||||
.setTheirPreKey(Optional.<ECPublicKey>absent())
|
||||
.setTheirIdentityKey(message.getIdentityKey())
|
||||
.create();
|
||||
|
||||
sessionRecord.reset();
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class RatchetingSession {
|
||||
|
||||
public static void initializeSession(SessionState sessionState,
|
||||
int sessionVersion,
|
||||
InitializationParameters parameters)
|
||||
AxolotlParameters parameters)
|
||||
throws InvalidKeyException
|
||||
{
|
||||
if (isAlice(parameters)) initializeSessionAsAlice(sessionState, sessionVersion, parameters);
|
||||
@ -48,7 +48,7 @@ public class RatchetingSession {
|
||||
|
||||
private static void initializeSessionAsAlice(SessionState sessionState,
|
||||
int sessionVersion,
|
||||
InitializationParameters parameters)
|
||||
AxolotlParameters parameters)
|
||||
throws InvalidKeyException
|
||||
{
|
||||
sessionState.setRemoteIdentityKey(parameters.getTheirIdentityKey());
|
||||
@ -70,7 +70,7 @@ public class RatchetingSession {
|
||||
|
||||
private static void initializeSessionAsBob(SessionState sessionState,
|
||||
int sessionVersion,
|
||||
InitializationParameters parameters)
|
||||
AxolotlParameters parameters)
|
||||
throws InvalidKeyException
|
||||
{
|
||||
sessionState.setRemoteIdentityKey(parameters.getTheirIdentityKey());
|
||||
@ -86,7 +86,7 @@ public class RatchetingSession {
|
||||
}
|
||||
}
|
||||
|
||||
private static DHEResult calculate4DHE(boolean isAlice, int sessionVersion, InitializationParameters parameters)
|
||||
private static DHEResult calculate4DHE(boolean isAlice, int sessionVersion, AxolotlParameters parameters)
|
||||
throws InvalidKeyException
|
||||
{
|
||||
try {
|
||||
@ -131,7 +131,7 @@ public class RatchetingSession {
|
||||
}
|
||||
|
||||
private static byte[] calculateVerificationTag(boolean isAlice, VerifyKey verifyKey,
|
||||
InitializationParameters parameters)
|
||||
AxolotlParameters parameters)
|
||||
{
|
||||
if (isAlice) {
|
||||
return verifyKey.generateVerification(parameters.getOurBaseKey().getPublicKey(),
|
||||
@ -150,7 +150,7 @@ public class RatchetingSession {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isAlice(InitializationParameters parameters)
|
||||
private static boolean isAlice(AxolotlParameters parameters)
|
||||
{
|
||||
if (parameters.getOurEphemeralKey().equals(parameters.getOurBaseKey())) {
|
||||
return false;
|
||||
@ -172,7 +172,7 @@ public class RatchetingSession {
|
||||
else return Optional.absent();
|
||||
}
|
||||
|
||||
public static class InitializationParameters {
|
||||
public static class AxolotlParameters {
|
||||
private final ECKeyPair ourBaseKey;
|
||||
private final ECKeyPair ourEphemeralKey;
|
||||
private final Optional<ECKeyPair> ourPreKey;
|
||||
@ -183,10 +183,10 @@ public class RatchetingSession {
|
||||
private final Optional<ECPublicKey> theirPreKey;
|
||||
private final IdentityKey theirIdentityKey;
|
||||
|
||||
public InitializationParameters(ECKeyPair ourBaseKey, ECKeyPair ourEphemeralKey,
|
||||
Optional<ECKeyPair> ourPreKey, IdentityKeyPair ourIdentityKey,
|
||||
ECPublicKey theirBaseKey, ECPublicKey theirEphemeralKey,
|
||||
Optional<ECPublicKey> theirPreKey, IdentityKey theirIdentityKey)
|
||||
public AxolotlParameters(ECKeyPair ourBaseKey, ECKeyPair ourEphemeralKey,
|
||||
Optional<ECKeyPair> ourPreKey, IdentityKeyPair ourIdentityKey,
|
||||
ECPublicKey theirBaseKey, ECPublicKey theirEphemeralKey,
|
||||
Optional<ECPublicKey> theirPreKey, IdentityKey theirIdentityKey)
|
||||
{
|
||||
this.ourBaseKey = ourBaseKey;
|
||||
this.ourEphemeralKey = ourEphemeralKey;
|
||||
@ -300,17 +300,15 @@ public class RatchetingSession {
|
||||
return this;
|
||||
}
|
||||
|
||||
public RatchetingSession.InitializationParameters create() {
|
||||
public AxolotlParameters create() {
|
||||
if (ourBaseKey == null || ourEphemeralKey == null || ourPreKey == null || ourIdentityKey == null ||
|
||||
theirBaseKey == null || theirEphemeralKey == null || theirPreKey == null || theirIdentityKey == null)
|
||||
{
|
||||
throw new IllegalArgumentException("All parameters not specified!");
|
||||
}
|
||||
|
||||
return new RatchetingSession.InitializationParameters(ourBaseKey, ourEphemeralKey,
|
||||
ourPreKey, ourIdentityKey,
|
||||
theirBaseKey, theirEphemeralKey,
|
||||
theirPreKey, theirIdentityKey);
|
||||
return new AxolotlParameters(ourBaseKey, ourEphemeralKey, ourPreKey, ourIdentityKey,
|
||||
theirBaseKey, theirEphemeralKey, theirPreKey, theirIdentityKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user