Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First draft of OMEMO #1256

Draft
wants to merge 49 commits into
base: master
Choose a base branch
from
Draft

First draft of OMEMO #1256

wants to merge 49 commits into from

Conversation

daniele-athome
Copy link
Member

@daniele-athome daniele-athome commented Apr 24, 2019

A first very draft implementation of OMEMO, trying to fullfil #132.

The OMEMO model (in Smack) requires authentication to be handled tightly with encryption, so our current abstractions and separation between encryption and authentication struggles to work with smack-omemo.

I would rather not tighten Keyring with Coder, instead I would leave it to the higher functions (MessageCenter and UI stuff). Blind Trust Before Verification might be harder to do in a transparent way for the Coder interface, unless it's done in a separate manner (e.g. when receiving key bundles for users, through some listeners. Also PGP trust changes can be a trigger to trust or distrust OMEMO devices).


OMEMO doesn't support stanza encryption yet (only the body is encrypted), therefore group messages will leak group metadata to servers and to unauthorized parties. Same thing with non-body parts of the message (chat state, attachments). HTTP-uploaded attachments will still be encrypted with OpenPGP.


The current prototype uses Smack 4.3 which contains an alpha version of the OMEMO modules. The OMEMO API was rewritten in Smack 4.4 which is currently under development and raises Java minimum version to 1.8, which requires Android API 19. Sorry pre-KitKat users :-(

(Some notes on this decision to raise Java and Android versions here: https://discourse.igniterealtime.org/t/smack-android-api-requirements/85767)

Sending not implemented yet; Receiving works only if user subscription was granted.
The way the OMEMO API and our own application is designed, it's not easy to build
something abstracted following the Coder interface. But since Smack 4.4 will dismantle
the current OMEMO API...

Signed-off-by: Daniele Ricci <[email protected]>
Signed-off-by: Daniele Ricci <[email protected]>
Signed-off-by: Daniele Ricci <[email protected]>
Signed-off-by: Daniele Ricci <[email protected]>
Signed-off-by: Daniele Ricci <[email protected]>
Actually it's not just because of OMEMO, the aim here is to create
a more clear abstraction for encrypting/decrypting.

Signed-off-by: Daniele Ricci <[email protected]>
[skip ci]

Signed-off-by: Daniele Ricci <[email protected]>
Signed-off-by: Daniele Ricci <[email protected]>
Also update security flags of a message when falling back to basic encryption

Signed-off-by: Daniele Ricci <[email protected]>
@daniele-athome daniele-athome added the enhancement New feature or request label Apr 24, 2019
@daniele-athome daniele-athome self-assigned this Apr 24, 2019
@codecov
Copy link

codecov bot commented Apr 24, 2019

Codecov Report

Merging #1256 into master will decrease coverage by 0.01%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master   #1256      +/-   ##
===========================================
- Coverage      1.70%   1.68%   -0.02%     
  Complexity      113     113              
===========================================
  Files           359     357       -2     
  Lines         25143   25330     +187     
  Branches       3267    3297      +30     
===========================================
  Hits            428     428              
- Misses        24666   24853     +187     
  Partials         49      49              
Impacted Files Coverage Δ Complexity Δ
.../src/main/java/org/kontalk/MessagesController.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
.../java/org/kontalk/authenticator/Authenticator.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...ain/java/org/kontalk/client/KontalkConnection.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...main/java/org/kontalk/client/SmackInitializer.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
app/src/main/java/org/kontalk/crypto/Coder.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...p/src/main/java/org/kontalk/crypto/OmemoCoder.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
app/src/main/java/org/kontalk/crypto/PGPCoder.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...pp/src/main/java/org/kontalk/crypto/PGPUserID.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
.../src/main/java/org/kontalk/crypto/PersonalKey.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...n/java/org/kontalk/crypto/PersonalKeyExporter.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f7dd667...aa8c9b1. Read the comment docs.

Also move TRUST_* constants to Keyring

Signed-off-by: Daniele Ricci <[email protected]>
Signed-off-by: Daniele Ricci <[email protected]>
[skip ci]

Signed-off-by: Daniele Ricci <[email protected]>
Signed-off-by: Daniele Ricci <[email protected]>
Because of the way smack-omemo is designed, processing and decryption
can't be separated, so a few dirty tricks were put in place to make
this work.

Signed-off-by: Daniele Ricci <[email protected]>
Signed-off-by: Daniele Ricci <[email protected]>
Signed-off-by: Daniele Ricci <[email protected]>
And a few optimizations.

Signed-off-by: Daniele Ricci <[email protected]>
Signed-off-by: Daniele Ricci <[email protected]>
@daniele-athome daniele-athome added this to the 5.0.0 milestone Jun 16, 2019
Signed-off-by: Daniele Ricci <[email protected]>
# Conflicts:
#	app/src/main/java/org/kontalk/ui/GroupInfoFragment.java
# Conflicts:
#	app/src/main/java/org/kontalk/crypto/PGPCoder.java
#	app/src/main/java/org/kontalk/provider/Keyring.java
#	app/src/main/java/org/kontalk/service/msgcenter/DiscoverInfoListener.java
#	app/src/main/java/org/kontalk/service/msgcenter/DiscoverItemsListener.java
#	app/src/main/java/org/kontalk/service/msgcenter/MessageCenterService.java
#	app/src/main/java/org/kontalk/service/msgcenter/PushDiscoverItemsListener.java
#	app/src/main/java/org/kontalk/util/MessageUtils.java
# Conflicts:
#	app/src/androidTest/java/org/kontalk/provider/UsersProviderTest.java
#	app/src/main/java/org/kontalk/data/Contact.java
Signed-off-by: Daniele Ricci <[email protected]>
Sorry people, I missed this...

Signed-off-by: Daniele Ricci <[email protected]>
Signed-off-by: Daniele Ricci <[email protected]>
Signed-off-by: Daniele Ricci <[email protected]>
# Conflicts:
#	app/src/main/java/org/kontalk/data/Contact.java
#	app/src/main/java/org/kontalk/service/msgcenter/MessageCenterService.java
#	app/src/main/java/org/kontalk/service/msgcenter/MessageListener.java
#	app/src/main/java/org/kontalk/service/msgcenter/RegenerateKeyPairListener.java
#	app/src/main/java/org/kontalk/sync/Syncer.java
#	app/src/main/java/org/kontalk/util/MessageUtils.java
@daniele-athome daniele-athome marked this pull request as draft April 21, 2020 23:58
Brings Java to 1.8 and minimum API level to 19

Signed-off-by: Daniele Ricci <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant