diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2017-01-14 18:10:04 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2017-01-14 18:10:04 +0100 |
commit | 8f39a594ff38568376db3589a642d662a66e9316 (patch) | |
tree | ddca8f8996e2669c98b70fe52725dee8ad12cda7 /src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java | |
parent | aa7bfe9fe7979727df5ff4d6694194dcd134d0e1 (diff) |
partially improved logging for receiving omemo messages
Diffstat (limited to 'src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java | 17 |
1 files changed, 8 insertions, 9 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 938c19a4..4e03627f 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java @@ -82,7 +82,7 @@ public class XmppAxolotlSession implements Comparable<XmppAxolotlSession> { } @Nullable - public byte[] processReceiving(AxolotlKey encryptedKey) { + public byte[] processReceiving(AxolotlKey encryptedKey) throws CryptoFailedException { byte[] plaintext = null; FingerprintStatus status = getTrust(); if (!status.isCompromised()) { @@ -90,8 +90,7 @@ public class XmppAxolotlSession implements Comparable<XmppAxolotlSession> { try { 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; + throw new CryptoFailedException("PreKeyWhisperMessage did not contain a PreKeyId"); } Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account) + "PreKeyWhisperMessage received, new session ID:" + message.getSignedPreKeyId() + "/" + message.getPreKeyId()); IdentityKey msgIdentityKey = message.getIdentityKey(); @@ -107,19 +106,19 @@ public class XmppAxolotlSession implements Comparable<XmppAxolotlSession> { 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()); + throw new CryptoFailedException("Error decrypting axolotl header, \" + e.getClass().getName() + \": \" + e.getMessage()"); } } catch (LegacyMessageException | InvalidMessageException | DuplicateMessageException | NoSessionException e) { - Log.w(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Error decrypting axolotl header, " + e.getClass().getName() + ": " + e.getMessage()); + throw new CryptoFailedException("Error decrypting axolotl header, \" + e.getClass().getName() + \": \" + e.getMessage()"); + } + if (plaintext==null) { + throw new CryptoFailedException("plaintext unexpectedly null"); } - - if (plaintext != null) { if (!status.isActive()) { setTrust(status.toActive()); } - } } else { - Log.d(Config.LOGTAG,account.getJid().toBareJid()+" not encrypting omemo message from fingerprint "+getFingerprint()+" because it was marked as compromised"); + throw new CryptoFailedException("not encrypting omemo message from fingerprint "+getFingerprint()+" because it was marked as compromised"); } return plaintext; } |