aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/.gdb_history225
-rw-r--r--python/olm/__init__.py1
-rwxr-xr-xpython/olm/__main__.py12
-rw-r--r--python/olm/utility.py56
-rwxr-xr-xpython/test_olm.sh4
5 files changed, 298 insertions, 0 deletions
diff --git a/python/.gdb_history b/python/.gdb_history
new file mode 100644
index 0000000..747b80f
--- /dev/null
+++ b/python/.gdb_history
@@ -0,0 +1,225 @@
+b _olm_enc_input
+r
+l
+p key
+p key_lenght
+p key_length
+b _olm_enc_input
+r
+key[12]
+p key[12]
+p key[11]
+key[11]='\0'
+p key[11]='\0'
+p key[11]
+key_length=12
+p key_length=12
+n
+c
+b _olm_enc_input
+r
+r
+r
+b olm_decrypt
+r
+l
+b 677
+c
+s
+fin
+s
+s
+fin
+s
+s
+fin
+s
+l
+n
+l
+l
+s
+s
+n
+l
+n
+l
+p reader
+p *this
+n
+p chain
+p receiver_chains
+p receiver_chains.length()
+p receiver_chains.size()
+p reader
+p reader.ratchet_key
+r
+r
+b olm_account_one_time_keys
+r
+l
+s
+n
+p *this
+p one_time_keys
+p one_time_keys.length
+p one_time_keys.length()
+p one_time_keys.len()
+p one_time_keys.size()
+p one_time_keys.count()
+p one_time_keys.data
+p one_time_keys._data
+p &one_time_keys._data
+l
+n
+q
+r
+b olm_create_inbound_session
+r
+b olm_create_inbound_session_from
+r
+r
+r
+b olm_create_inbound_session_from
+r
+b olm_create_inbound_session
+b olm_create_inbound_session
+r
+l
+n
+l
+s
+b olm_create_inbound_session
+r
+l
+l
+n
+s
+f
+s
+fin
+s
+s
+fin
+s
+l
+n
+l
+l -
+l
+l
+l
+n
+p our_one_time_key
+p *our_one_time_key
+l
+n
+l
+n
+p bob_one_time_key
+p alice_identity_key
+p alice_base_key
+p bob_identity_key
+x alice_identity_key
+x &alice_identity_key
+x /32x &alice_identity_key
+x /32b &alice_identity_key
+l
+l
+l
+n
+b olm_decrypt
+c
+l
+l
+b 'olm::Session::decrypt'
+c
+l
+l
+n
+l
+n
+p reader
+p reader
+5*128
+p 5*128
+p 0xb0 - 0x80
+p 0xb0 - 0x80 + 640
+l
+n
+s
+l
+n
+p reader
+n
+l
+n
+p max_length
+p reader.ciphertext_length
+l
+n
+l
+p receiver_chains
+p &receiver_chains ._data
+p &receiver_chains ._data[1]
+n
+s
+s
+l
+n
+p new_chain.index
+p reader.counter
+n
+l
+l
+n
+s
+s
+n
+l
+x key
+x /16b key
+l
+l
+n
+p keys
+_olm_crypto_aes_decrypt_cbc&keys.aes_key, &keys.aes_iv, ciphertext, ciphertext_length, plaintext
+p _olm_crypto_aes_decrypt_cbc(&keys.aes_key, &keys.aes_iv, ciphertext, ciphertext_length, plaintext)
+p plaintext
+r
+b olm_account_identity_keys
+l
+r
+b olm_unpickle_account
+r
+l
+n
+p object.last_error
+l
+l -
+l
+b 268
+r
+c
+s
+l
+l
+p end-pos
+x /246b pos
+x /246x pos
+x /82x pos+164
+x /82x pos+132
+pos
+p pos
+x /246x pos
+r
+r
+b olm_create_outbound_session
+r
+n
+l
+p id_key_length
+p ot_key_length
+p olm::decode_base64_length(id_key_length)
+p olm::decode_base64_length(ot_key_length)
+p CURVE25519_KEY_LENGTH
diff --git a/python/olm/__init__.py b/python/olm/__init__.py
index 31b29b9..f74cbcb 100644
--- a/python/olm/__init__.py
+++ b/python/olm/__init__.py
@@ -2,3 +2,4 @@ from .account import Account
from .session import Session
from .outbound_group_session import OutboundGroupSession
from .inbound_group_session import InboundGroupSession
+from .utility import ed25519_verify
diff --git a/python/olm/__main__.py b/python/olm/__main__.py
index 71f018a..2a48b78 100755
--- a/python/olm/__main__.py
+++ b/python/olm/__main__.py
@@ -344,6 +344,9 @@ def build_arg_parser():
)
export_inbound_group.set_defaults(func=do_export_inbound_group)
+ ed25519_verify = commands.add_parser("ed25519_verify",
+ help="Verify an ed25519 signature")
+ ed25519_verify.set_defaults(func=do_verify_ed25519_signature)
return parser
@@ -430,6 +433,15 @@ def do_export_inbound_group(args):
args.export_file.write(session.export_session(index))
+def do_verify_ed25519_signature(args):
+ account = Account()
+ account.create()
+ message = "A Message".encode("ASCII")
+ ed25519_key = account.identity_keys()["ed25519"].encode("utf-8")
+ signature = account.sign(message)
+ ed25519_verify(ed25519_key, message, signature)
+
+
if __name__ == '__main__':
parser = build_arg_parser()
args = parser.parse_args()
diff --git a/python/olm/utility.py b/python/olm/utility.py
new file mode 100644
index 0000000..dac0225
--- /dev/null
+++ b/python/olm/utility.py
@@ -0,0 +1,56 @@
+from ._base import lib, c_void_p, c_size_t, c_char_p, \
+ create_string_buffer, ERR, OlmError
+
+lib.olm_utility_size.argtypes = []
+lib.olm_utility_size.restype = c_size_t
+
+lib.olm_utility.argtypes = [c_void_p]
+lib.olm_utility.restype = c_void_p
+
+lib.olm_utility_last_error.argtypes = [c_void_p]
+lib.olm_utility_last_error.restype = c_char_p
+
+
+def utility_errcheck(res, func, args):
+ if res == ERR:
+ raise OlmError("%s: %s" % (
+ func.__name__, lib.olm_utility_last_error(args[0])
+ ))
+ return res
+
+
+def utility_function(func, *types):
+ func.argtypes = (c_void_p,) + types
+ func.restypes = c_size_t
+ func.errcheck = utility_errcheck
+
+utility_function(
+ lib.olm_ed25519_verify,
+ c_void_p, c_size_t, # key, key_length
+ c_void_p, c_size_t, # message, message_length
+ c_void_p, c_size_t, # signature, signature_length
+)
+
+
+class Utility(object):
+ def __init__(self):
+ self.buf = create_string_buffer(lib.olm_utility_size())
+ self.ptr = lib.olm_utility(self.buf)
+
+_utility = None
+
+
+def ed25519_verify(key, message, signature):
+ """ Verify an ed25519 signature. Raises an OlmError if verification fails.
+ Args:
+ key(bytes): The ed25519 public key used for signing.
+ message(bytes): The signed message.
+ signature(bytes): The message signature.
+ """
+ global _utility
+ if not _utility:
+ _utility = Utility()
+ lib.olm_ed25519_verify(_utility.ptr,
+ key, len(key),
+ message, len(message),
+ signature, len(signature))
diff --git a/python/test_olm.sh b/python/test_olm.sh
index 7c90daf..6ba92b6 100755
--- a/python/test_olm.sh
+++ b/python/test_olm.sh
@@ -37,3 +37,7 @@ $OLM group_decrypt $BOB_GROUP_SESSION group_message
$OLM export_inbound_group $BOB_GROUP_SESSION | $OLM import_inbound_group $CHARLIE_GROUP_SESSION
$OLM group_decrypt $CHARLIE_GROUP_SESSION group_message
+
+### Utility
+
+$OLM ed25519_verify