Skip to content

Commit

Permalink
Allow for external OTPK handling, fix requirements in setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Henkes committed Jun 10, 2018
1 parent d85bedd commit 3913054
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 19 deletions.
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

setup(
name = "X3DH",
version = "0.1.0",
version = "0.2.0",
description = "A python implementation of the Extended Triple Diffie-Hellman key agreement protocol.",
author = "Tim Henkes",
url = "https://github.com/Syndace/python-x3dh",
packages = ["x3dh", "x3dh.exceptions", "x3dh.implementations"],
requires = ["scci", "pynacl", "hkdf"],
packages = ["x3dh", "x3dh.exceptions"],
requires = ["scci", "xeddsa", "hkdf"],
provides = ["x3dh"]
)
1 change: 0 additions & 1 deletion x3dh/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import absolute_import

from . import exceptions
from . import implementations

from .config import Config
from .publicbundle import PublicBundle
Expand Down
4 changes: 0 additions & 4 deletions x3dh/implementations/__init__.py

This file was deleted.

9 changes: 0 additions & 9 deletions x3dh/implementations/curvetypeencryptionkeyencoder.py

This file was deleted.

12 changes: 10 additions & 2 deletions x3dh/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,15 @@ def initSessionActive(self, other_public_bundle, allow_zero_otpks = False):
"sk": sk
}

def initSessionPassive(self, session_init_data, allow_no_otpk = False):
def initSessionPassive(self, session_init_data, allow_no_otpk = False, keep_otpk = False):
"""
The specification of X3DH dictates to delete the one time pre keys as soon as they are used.
This behaviour provides security but may lead to considerable usability downsides in some environments.
For that reason the keep_otpk flag exists. If set to True, the one time pre key is not automatically deleted.
USE WITH CARE, THIS MAY INTRODUCE SECURITY LEAKS IF USED INCORRECTLY.
If you decide set the flag and to keep the otpks, you have to manage deleting them yourself, e.g. by subclassing this class and overriding this method.
"""

other_ik = self.__KeyQuad(encryption_key = session_init_data["ik"])
other_ek = self.__KeyQuad(encryption_key = session_init_data["ek"])

Expand Down Expand Up @@ -210,7 +218,7 @@ def initSessionPassive(self, session_init_data, allow_no_otpk = False):

ad = other_ik_enc_serialized + ik_enc_serialized

if my_otpk:
if my_otpk and not keep_otpk:
self.__otpks.remove(my_otpk)
self._changed = True
self.__refillOTPKs()
Expand Down

0 comments on commit 3913054

Please sign in to comment.