|
|
|
|
@ -205,7 +205,7 @@ public class SessionBuilder {
|
|
|
|
|
* trusted.
|
|
|
|
|
*/
|
|
|
|
|
public void process(PreKeyBundle preKey) throws InvalidKeyException, UntrustedIdentityException {
|
|
|
|
|
|
|
|
|
|
synchronized (SessionCipher.SESSION_LOCK) {
|
|
|
|
|
if (!identityKeyStore.isTrustedIdentity(recipientId, preKey.getIdentityKey())) {
|
|
|
|
|
throw new UntrustedIdentityException();
|
|
|
|
|
}
|
|
|
|
|
@ -252,6 +252,7 @@ public class SessionBuilder {
|
|
|
|
|
sessionStore.storeSession(recipientId, deviceId, sessionRecord);
|
|
|
|
|
identityKeyStore.saveIdentity(recipientId, preKey.getIdentityKey());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Build a new session from a {@link org.whispersystems.libaxolotl.protocol.KeyExchangeMessage}
|
|
|
|
|
@ -264,7 +265,7 @@ public class SessionBuilder {
|
|
|
|
|
public KeyExchangeMessage process(KeyExchangeMessage message)
|
|
|
|
|
throws InvalidKeyException, UntrustedIdentityException, StaleKeyExchangeException
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
synchronized (SessionCipher.SESSION_LOCK) {
|
|
|
|
|
if (!identityKeyStore.isTrustedIdentity(recipientId, message.getIdentityKey())) {
|
|
|
|
|
throw new UntrustedIdentityException();
|
|
|
|
|
}
|
|
|
|
|
@ -276,6 +277,7 @@ public class SessionBuilder {
|
|
|
|
|
|
|
|
|
|
return responseMessage;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private KeyExchangeMessage processInitiate(KeyExchangeMessage message) throws InvalidKeyException {
|
|
|
|
|
int flags = KeyExchangeMessage.RESPONSE_FLAG;
|
|
|
|
|
@ -375,6 +377,7 @@ public class SessionBuilder {
|
|
|
|
|
* @return the KeyExchangeMessage to deliver.
|
|
|
|
|
*/
|
|
|
|
|
public KeyExchangeMessage process() {
|
|
|
|
|
synchronized (SessionCipher.SESSION_LOCK) {
|
|
|
|
|
try {
|
|
|
|
|
int sequence = KeyHelper.getRandomSequence(65534) + 1;
|
|
|
|
|
int flags = KeyExchangeMessage.INITIATE_FLAG;
|
|
|
|
|
@ -393,6 +396,7 @@ public class SessionBuilder {
|
|
|
|
|
throw new AssertionError(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|