aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2017-01-09 20:20:02 +0100
committerDaniel Gultsch <daniel@gultsch.de>2017-01-09 20:20:02 +0100
commita1cb855739b96c29d91225d125d3018a5f665468 (patch)
tree97c1e72a9d7cd072004656a6eb8290ca60762112 /src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java
parentef4ed908111d32734deee45c424d31074da015a9 (diff)
adding prekey='true' to omemo messages if applicable
Diffstat (limited to '')
-rw-r--r--src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java
index 725757a3..773b6857 100644
--- a/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java
+++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java
@@ -82,13 +82,13 @@ public class XmppAxolotlSession implements Comparable<XmppAxolotlSession> {
}
@Nullable
- public byte[] processReceiving(byte[] encryptedKey) {
+ public byte[] processReceiving(AxolotlKey encryptedKey) {
byte[] plaintext = null;
FingerprintStatus status = getTrust();
if (!status.isCompromised()) {
try {
try {
- PreKeyWhisperMessage message = new PreKeyWhisperMessage(encryptedKey);
+ PreKeyWhisperMessage message = new PreKeyWhisperMessage(encryptedKey.key);
if (!message.getPreKeyId().isPresent()) {
Log.w(Config.LOGTAG, AxolotlService.getLogprefix(account) + "PreKeyWhisperMessage did not contain a PreKeyId");
return null;
@@ -104,7 +104,7 @@ public class XmppAxolotlSession implements Comparable<XmppAxolotlSession> {
}
} catch (InvalidMessageException | InvalidVersionException e) {
Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account) + "WhisperMessage received");
- WhisperMessage message = new WhisperMessage(encryptedKey);
+ WhisperMessage message = new WhisperMessage(encryptedKey.key);
plaintext = cipher.decrypt(message);
} catch (InvalidKeyException | InvalidKeyIdException | UntrustedIdentityException e) {
Log.w(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Error decrypting axolotl header, " + e.getClass().getName() + ": " + e.getMessage());
@@ -123,11 +123,11 @@ public class XmppAxolotlSession implements Comparable<XmppAxolotlSession> {
}
@Nullable
- public byte[] processSending(@NonNull byte[] outgoingMessage) {
+ public AxolotlKey processSending(@NonNull byte[] outgoingMessage) {
FingerprintStatus status = getTrust();
if (status.isTrustedAndActive()) {
CiphertextMessage ciphertextMessage = cipher.encrypt(outgoingMessage);
- return ciphertextMessage.serialize();
+ return new AxolotlKey(ciphertextMessage.serialize(),ciphertextMessage.getType() == CiphertextMessage.PREKEY_TYPE);
} else {
return null;
}
@@ -141,4 +141,16 @@ public class XmppAxolotlSession implements Comparable<XmppAxolotlSession> {
public int compareTo(XmppAxolotlSession o) {
return getTrust().compareTo(o.getTrust());
}
+
+ public static class AxolotlKey {
+
+
+ public final byte[] key;
+ public final boolean prekey;
+
+ public AxolotlKey(byte[] key, boolean prekey) {
+ this.key = key;
+ this.prekey = prekey;
+ }
+ }
}