Commit graph

822 commits

Author SHA1 Message Date
Andreas Straub a3991d59c9 Improve trust toggle responsiveness
Removed unnecessary UI refreshes, explicitly update UI where needed.
2015-07-29 02:59:41 +02:00
Andreas Straub efcefc2e63 Refactor out inner classes, cache trust store
Moves SQLiteAxolotlStore and XmppAxolotlSession into proper classes.

IdentityKeys trust statuses are now cached in an LruCache to prevent
hammering the database when rendering the UI.
2015-07-29 02:59:26 +02:00
Daniel Gultsch 17bc4fb6cd show http downloaded images in notification 2015-07-29 01:57:08 +02:00
Daniel Gultsch 8f14d2bfbd removed recursion in message.getMerged*() 2015-07-28 23:00:30 +02:00
Daniel Gultsch 8924c448d1 changed logging. (work around logcat null pointer 2015-07-28 22:26:29 +02:00
Daniel Gultsch 6b8e1ecb95 log reason for message failure 2015-07-28 14:44:11 +02:00
Daniel Gultsch ff0c114cd6 set time on resend to current time
fixes #1298
fixes #919
2015-07-28 12:54:54 +02:00
Daniel Gultsch 9c94c9ad8f rewrote dns fallback 2015-07-24 19:06:47 +02:00
Daniel Gultsch e5fae429fa call refreshUi directly 2015-07-24 14:43:13 +02:00
Daniel Gultsch c32162c280 switch/case can't deal with null pointers 2015-07-23 14:02:25 +02:00
Daniel Gultsch cd204d5931 show warning when trying to highlight users that have left the conference 2015-07-22 15:57:17 +02:00
Daniel Gultsch f7634a85be treat private, non-anonymous mucs like 1:1 chats notification wise 2015-07-22 15:31:00 +02:00
Andreas Straub db05d26433 Always build own device session automatically 2015-07-22 15:03:52 +02:00
Daniel Gultsch 9c1c86ed44 add no-store to chat states 2015-07-22 14:17:02 +02:00
Daniel Gultsch 63206e6d4a use type=chat more often to go along with new, simple carbon and mam rules
* change chat states to type=chat and chat markers to type=chat
* use same type as requesting stanza for delivery receipts (which should make them type=chat most of the time)
2015-07-22 14:15:00 +02:00
Daniel Gultsch a1e63944a2 use 'interactive mode' when starting downloads from the context menu 2015-07-22 12:15:09 +02:00
Andreas Straub c2813cea29 Hide regenerate keys button
Can re-enable it via Config.java setting
2015-07-22 01:00:20 +02:00
Andreas Straub 4c1c2892c7 Disable trust toggle completely for INACTIVE keys 2015-07-22 00:53:54 +02:00
Daniel Gultsch 456d4c8b23 made image file format configurable by Config.java 2015-07-21 23:49:35 +02:00
Daniel Gultsch d38228f482 fixed npe in error message handling 2015-07-21 19:45:41 +02:00
Daniel Gultsch f6281a182d fixed npe in error message handling 2015-07-21 19:44:25 +02:00
Andreas Straub 92b5081b5e Add INACTIVE state for removed keys
We introduce a new trust state: INACTIVE. This state is intended for
old keys that have been removed.

When a TRUSTED device is removed from the PEP devicelist, it's status
will be set to INACTIVE. INACTIVE keys are shown in the UI as greyed
out, non-interactible key rows. Messages are not encrypted for INACTIVE
devices.

When an INACTIVE device reappears in PEP, or a message is received from
an INACTIVE device, it is set back to trusted.
2015-07-21 14:24:59 +02:00
Andreas Straub 3c5c0c7d3b Fill own device sessions into SessionMap 2015-07-21 14:24:59 +02:00
Daniel Gultsch 1aeb5874b0 allow for private messages being started from muc details in anonymous mucs 2015-07-21 13:15:59 +02:00
Daniel Gultsch 32f90613a3 and now do that properly 2015-07-21 12:02:15 +02:00
Daniel Gultsch ffa588ba3e and now do that properly 2015-07-21 12:01:20 +02:00
Daniel Gultsch af76ad0144 end otr session when receiving failed otr message warnings 2015-07-21 12:00:01 +02:00
Daniel Gultsch 394486b300 bugfix: also add no-permanent-storage to message hints 2015-07-21 11:59:52 +02:00
Daniel Gultsch f1ee5cccf0 bugfix: changed condition of onOtrSessionEstablished being called
fixed #1263
fixed #1260
fixed #1293
2015-07-21 11:59:30 +02:00
Daniel Gultsch 5c2720efd0 bugfix: don't crash if aes key could not be set before jingle transfer 2015-07-21 11:55:48 +02:00
Daniel Gultsch 37cbdb8b4e bugfix: use sendIqPacket method in service instead of invoking XmppConnection directly 2015-07-21 11:55:33 +02:00
Daniel Gultsch 086653b649 bugfix: accept status code 201 on http upload 2015-07-21 11:55:18 +02:00
Daniel Gultsch 87bc9d3a31 end otr session when receiving failed otr message warnings 2015-07-21 11:52:49 +02:00
Daniel Gultsch a5027104fd bugfix: also add no-permanent-storage to message hints 2015-07-21 11:50:32 +02:00
Daniel Gultsch f74ee765a2 bugfix: changed condition of onOtrSessionEstablished being called
fixed #1263
fixed #1260
fixed #1293
2015-07-21 11:46:56 +02:00
Andreas Straub b7ff2c3461 Use properly fixed numeral values in Trust enum
Why, oh God, why?! #thanksjamesgosling
2015-07-21 01:52:22 +02:00
Andreas Straub 639ebd644b Remove unused import 2015-07-21 01:17:29 +02:00
Andreas Straub 122bc97ce2 Switch payload encryption to AES-GCM
This also ensures that the IV is generated with proper randomness.
2015-07-21 01:17:14 +02:00
Andreas Straub 971aa3a11e Also decrypt messages from UNTRUSTED sessions 2015-07-20 23:16:06 +02:00
Andreas Straub d2845e9ac1 Refactor axolotl send processing/caching flow 2015-07-20 23:13:28 +02:00
Andreas Straub 8be0e8a27d Start TrustKeysActivity if no keys are TRUSTED
If there are no UNDECIDED keys, but none of the contact's keys are
trusted, redirect the user to the TrustKeysActivity
2015-07-20 22:35:07 +02:00
Andreas Straub 4ee3f330f5 Do not display clear devices button if not online 2015-07-20 22:19:04 +02:00
Andreas Straub ab2d114bbc Add purge axolotl key option
Can now long-press a key to permanently purge it.
2015-07-20 22:18:24 +02:00
Andreas Straub 0ee64124fe Fix getNumTrustedKeys 2015-07-20 22:02:54 +02:00
Daniel Gultsch e79f82ca72 attempt to fix the delay problem 2015-07-20 18:11:33 +02:00
Raphael Pohl e6cb12dfe4 changed message bubble appearance 2015-07-20 16:02:17 +02:00
Daniel Gultsch 504ef0b72e rely on refreshUi/refreshUiReal and make sure it is being used everywhere 2015-07-20 15:48:58 +02:00
Andreas Straub aaa8fe8978 Merge branch 'CryptoNextBeta' into development
* CryptoNextBeta: (60 commits)
  Lock TrustKeys if no trusted keys are available
  Optimize imports
  Use MD style for key trust toggle switch
  Fix set/remove OnUpdateBlocklistListener
  Fix axolotl database migration
  Remove device list from EditAccount
  Add clear devices to overflow menu in EditAccount
  Ask for key trust when sending messages
  Encrypt files for HTTP upload in encrypted chats
  Refactor trust key ui and show in account details
  Send correct body for HTTP files
  Handle file transmission properly in axolotl
  Remove unneccessary code
  Fix trust status for outgoing messages
  Don't merge messages with different trust statuses
  Fix copying of axolotl keys to clipboard
  Add refresh icon to v21 theme
  Disable Axolotl option if not usable
  Show trust status of messages' originating session
  Add key trust toggle to ContactDetailsActivity
  ...
2015-07-20 15:13:14 +02:00
Andreas Straub 19a0ae42d6 Lock TrustKeys if no trusted keys are available 2015-07-20 14:56:41 +02:00
Andreas Straub 012f036840 Optimize imports 2015-07-20 14:26:29 +02:00
Daniel Gultsch 9c91b9036a don't show 'show contact details' context menu item when contact isn not in roster 2015-07-20 14:24:59 +02:00
Andreas Straub e9d7d7e12a Fix set/remove OnUpdateBlocklistListener 2015-07-20 14:12:24 +02:00
Daniel Gultsch 2d2da11bfa Merge pull request #1289 from kriztan/patch-2
show contact details in conference details ...
2015-07-20 13:16:19 +02:00
Andreas Straub dd964077b9 Fix axolotl database migration
Can't call getWritableDatabase in recreateAxolotlDb()
2015-07-20 13:15:49 +02:00
Andreas Straub 2240066bbe Remove device list from EditAccount 2015-07-19 23:38:09 +02:00
Andreas Straub 480b1cde81 Add clear devices to overflow menu in EditAccount 2015-07-19 23:35:03 +02:00
Andreas Straub 14010bf5a6 Ask for key trust when sending messages
If the contact (or the own account) has keys that have UNDECIDED trust,
we now drop the user into the new TrustKeysActivity, where they have to
decide for each new key whether it should be TRUSTED or UNTRUSTED.
2015-07-19 22:27:26 +02:00
Andreas Straub ec0aff4ed7 Encrypt files for HTTP upload in encrypted chats 2015-07-19 22:24:05 +02:00
Andreas Straub 6f67469bda Refactor trust key ui and show in account details
Refactored the trust key row UI element so it can be used in multiple
places. It now also uses a slider to toggle the trust state, and the
redundant trust state description was removed.

EditAccountActivity now shows the keys of other devices associated with
that account.
2015-07-19 22:24:03 +02:00
Andreas Straub 9c4d55f82c Send correct body for HTTP files
When using HTTP upload to send files, take care to transmit only the URL
rather than the entire body, which contains metadata.
2015-07-19 22:23:28 +02:00
Andreas Straub 2045a71262 Handle file transmission properly in axolotl 2015-07-19 22:23:28 +02:00
Andreas Straub 43703870e8 Remove unneccessary code 2015-07-19 22:23:28 +02:00
Andreas Straub 4038af2f47 Fix trust status for outgoing messages
Tag sent messages with own fingerprint, set own fingerprint as always
trusted, include own fingerprint in database trust search, explicitly
reset trust colorfilter
2015-07-19 22:23:28 +02:00
Andreas Straub e8ec2ee628 Don't merge messages with different trust statuses 2015-07-19 22:23:28 +02:00
Sam Whited fca0c36757 Fix copying of axolotl keys to clipboard 2015-07-19 22:23:28 +02:00
Sam Whited 3ab59c93a6 Add refresh icon to v21 theme 2015-07-19 22:23:27 +02:00
Andreas Straub 6c38e53128 Disable Axolotl option if not usable
In MUCs or if contact is not axolotl capable, disable axolotl menu
option
2015-07-19 22:23:27 +02:00
Andreas Straub 9e8d9a6401 Show trust status of messages' originating session
Shade lock icon red if message was received in a session that has not
been marked trusted by the user or fingerprint is unknown
2015-07-19 22:23:27 +02:00
Andreas Straub 3d33946088 Add key trust toggle to ContactDetailsActivity
Can now toggle IdentityKey trust
2015-07-19 22:23:27 +02:00
Andreas Straub 35714d3d08 Ensure that available sessions are always used
Any time a new session is established, call syncRosterToDisk() to ensure
that on subsequent restoreFromDatabase() calls, the roster is actually
available. This is important so that initAccountServices() can properly
initialize the SessionMap. This prevents a race condition where after
adding a new account and initiating sessions with it, if the app is
killed (e.g. by reinstall) before triggering a syncRosterToDisk(),
subsequent restores will not have the roster available, leading to
missing XmppAxolotlSessions in the SessionMap cache. As a result of
this, a new session was initiated when sending a new message, and
received messages could not be tagged with the originating session's
fingerprint.

As an added sanity check, go to the database to confirm no records are
present before creating fresh XmppAxolotlSession objects (both in the
sending and receiving case).
2015-07-19 22:23:27 +02:00
Andreas Straub 31d375c2c3 Fix setIdentityKeyTrust update statement 2015-07-19 22:23:27 +02:00
Andreas Straub 160e4017df Fix IdentityKey storage model
Added proper UNIQUE statement
2015-07-19 22:23:27 +02:00
Andreas Straub 461d0446f7 Fix and expand key regeneration function
Wipe session cache to prevent stale sessions being used. Wipe fetch
status cache to enable recreation of sessions. Regenerate deviceId, so
that foreign devices will talk to us again.
2015-07-19 22:23:27 +02:00
Andreas Straub 23a4e1e6fa Display trust status in ContactDetailsActivity 2015-07-19 22:23:25 +02:00
Andreas Straub d173913eba Overhauled Message tagging
Messages are now tagged with the IdentityKey fingerprint of the
originating session. IdentityKeys have one of three trust states:
undecided (default), trusted, and untrusted/not yet trusted.
2015-07-19 22:17:58 +02:00
Andreas Straub 7f918542c8 Postpone initAccountService until roster loaded
The AxolotlService depends on the roster being loaded when it is
initialized so that it can fill its in-memory SessionMap.
2015-07-19 22:17:57 +02:00
Andreas Straub 03614a0262 Fix getSubDeviceSessions SQL query 2015-07-19 22:17:57 +02:00
Andreas Straub 2628662a7f Display axolotl chat message hint 2015-07-19 22:17:57 +02:00
Andreas Straub f1d73b9d4e Use full int range for device IDs 2015-07-19 22:17:57 +02:00
Andreas Straub 540faeb54b Clean up unused constant 2015-07-19 22:17:57 +02:00
Andreas Straub bd29653a20 Make some fields final 2015-07-19 22:17:57 +02:00
Andreas Straub 3458f5bb91 Clean up logging
Add a fixed prefix to axolotl-related log messages, set log levels
sensibly.
2015-07-19 22:17:57 +02:00
Andreas Straub 7049904c32 Add basic PEP managemend UI to EditAccountActivity
EditAccountActivity now show own fingerprint, and gives an option to
regenerate local keying material (and wipe all sessions associated with
the old keys in the process).

It also now displays a list of other own devices, and gives an option to
remove all but the current device.
2015-07-19 22:17:55 +02:00
Christian S 37b214a8a8 show contact details in conference details ... 2015-07-19 22:11:51 +02:00
Andreas Straub 968410ae33 Fix devicelist update handling
No longer store own device ID (so that we don't encrypt messages for
ourselves), verify that own device ID is present in update list
(otherwise republish), reflect update in UI.
2015-07-19 21:32:27 +02:00
Andreas Straub 7a962e5180 Refactor axolotl database recreation 2015-07-19 21:32:27 +02:00
Andreas Straub 8fd46d40d6 Adapt prettifyFingerprint() to axolotl FP sizes 2015-07-19 21:32:27 +02:00
Andreas Straub 491f623708 Fix displaying Contact IdentityKeys
Migrate ContactDetailsActivity to use new SQL IdentityKeys storage,
remove dead code from Contact class.
2015-07-19 21:32:27 +02:00
Andreas Straub 0cf64857cf Only cache session if successfully established
When receiving a message, only remember the XmppAxolotlSession wrapper
if the prospective session was actually established. This prevents us
from erroneously adding empty sessions that are never established using
received PreKeyWhisperMessages, which would lead to errors if we try to
use them for sending.
2015-07-19 21:32:27 +02:00
Andreas Straub 6867b5c3ab Return empty set on invalid PEP devicelist 2015-07-19 21:32:27 +02:00
Andreas Straub 25450bf6d3 Trust all IdentityKeys
The trust-on-first-use policy leads to problems when receiving messages
from two different devices of a contact before sending a message to them
(as their IdentityKeys will not have been added yet). Since session
trust will be managed externally anyway, this change is not a security
problem, and will allow us to decrypt messages from yet-untrusted
sessions.
2015-07-19 21:32:27 +02:00
Andreas Straub bf4185ac08 Refresh PEP on session establish
We now track preKeys used to establish incoming sessions with us. On
each new established session, we remove the used prekey from PEP. We
have to do this because libaxolotl-java internally clears the used
preKey from its storage, so we will not be able to establish any future
sessions using that key.
2015-07-19 21:32:27 +02:00
Andreas Straub 69600502d2 Fix asynchronous axolotl message sending
XmppConnectionService.sendMessage() now dispatches messages to the
AxolotlService, where they only are prepared for sending and cached.
AxolotlService now triggers a XmppConnectionService.resendMessage(),
which then handles sending the cached message packet.

This transparently fixes, e.g., handling of messages sent while we are
offline.
2015-07-19 21:32:27 +02:00
Andreas Straub ec6870307e Properly track message sender
Previously, the sender was assumed to be the conversation counterpart.
This broke carboned own-device messages. We now track the sender
properly, and also set the status (sent by one of the own devices vs
received from the counterpart) accordingly.
2015-07-19 21:32:27 +02:00
Andreas Straub 18c1e15d00 Rework PEP content verification
Now checks which part(s) are out of sync w/ local storage, and updates
only those, rather than assuming the entire node corrupt and
overwriting it all (especially relevant for preKey list)
2015-07-19 21:32:27 +02:00
Andreas Straub 9a0232f7e7 Formatting fixes 2015-07-19 21:32:27 +02:00
Andreas Straub 992cf5652e When receiving, add mock session if none exists
We need a session object in order to build a session from a
PreKeyWhisperMessage, so add an empty one when none exists on receiving
a message.

Warning: this will break right now if the session can not be constructed
from the received message.There will be an invalid session which will
break if we try to send using it.
2015-07-19 21:32:26 +02:00
Andreas Straub 1b0596d574 Tag messages with originating session
This can be used later in order to display trust status of messages, as
well as for potential resending of messages in case of preKey conflicts.
2015-07-19 21:32:26 +02:00
Andreas Straub 3815d4efa3 Fetch bundles on-demand, encrypt in background
Bundles are now fetched on demand when a session needs to be
established. This should lessen the chance of changes to the bundles
occuring before they're used, as well as lessen the load of fetching
bundles.

Also, the message encryption is now done in a background thread, as this
can be somewhat costly if many sessions are present. This is probably
not going to be an issue in real use, but it's good practice anyway.
2015-07-19 21:32:26 +02:00
Andreas Straub cb7980c65e Use bareJid for own session retrieval 2015-07-19 21:32:26 +02:00