diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-07-09 18:35:54 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-07-09 18:35:54 +0100 |
commit | 373acefde7be92f86b8294b325519ad916b1e054 (patch) | |
tree | 9d80437d0b059808eb3cd960d4517fdc59ab4731 /olm.py | |
parent | 5634be05074168e33b77246bbc9b60bd683759d8 (diff) |
Add c bindings for the methods for managing one time keys
Diffstat (limited to 'olm.py')
-rwxr-xr-x | olm.py | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -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 |