aboutsummaryrefslogtreecommitdiff
path: root/olm.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-07-09 18:35:54 +0100
committerMark Haines <mark.haines@matrix.org>2015-07-09 18:35:54 +0100
commit373acefde7be92f86b8294b325519ad916b1e054 (patch)
tree9d80437d0b059808eb3cd960d4517fdc59ab4731 /olm.py
parent5634be05074168e33b77246bbc9b60bd683759d8 (diff)
Add c bindings for the methods for managing one time keys
Diffstat (limited to 'olm.py')
-rwxr-xr-xolm.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/olm.py b/olm.py
index 81f9e25..eb36c5f 100755
--- a/olm.py
+++ b/olm.py
@@ -59,6 +59,18 @@ account_function(
)
account_function(lib.olm_account_one_time_keys_length)
account_function(lib.olm_account_one_time_keys, c_void_p, c_size_t)
+account_function(lib.olm_account_mark_keys_as_published)
+account_function(lib.olm_account_max_number_of_one_time_keys)
+account_function(
+ lib.olm_account_generate_one_time_keys_random_length,
+ c_size_t
+)
+account_function(
+ lib.olm_account_generate_one_time_keys
+ c_size_t,
+ c_void_p, c_size_t
+)
+
def read_random(n):
with open("/dev/urandom", "rb") as f:
@@ -113,6 +125,23 @@ class Account(object):
lib.olm_account_one_time_keys(self.ptr, out_buffer, out_length)
return json.loads(out_buffer.raw)
+ def mark_keys_as_published(self):
+ lib.olm_account_mark_keys_as_published(self.ptr)
+
+
+ def max_number_of_one_time_keys(self):
+ return lib.olm_account_max_number_of_one_time_keys(self.ptr)
+
+ def generate_one_time_keys(self, count):
+ random_length = lib.olm_account_generate_one_time_keys_random_length(
+ self.ptr
+ )
+ random = read_random(random_length)
+ random_buffer = create_string_buffer(random)
+ lib.olm_account_generate_one_time_keys(
+ self.ptr, random_buffer, random_length
+ )
+
def clear(self):
pass