From 171044f3fca084bd1c5c1f8f4bfe146434b07f0b Mon Sep 17 00:00:00 2001 From: Hubert Chathi Date: Fri, 14 Aug 2020 17:29:25 -0400 Subject: add support for fallback keys --- include/olm/account.hh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'include/olm/account.hh') diff --git a/include/olm/account.hh b/include/olm/account.hh index 7e58ca3..82bba27 100644 --- a/include/olm/account.hh +++ b/include/olm/account.hh @@ -43,6 +43,8 @@ struct Account { Account(); IdentityKeys identity_keys; List one_time_keys; + OneTimeKey current_fallback_key; + OneTimeKey prev_fallback_key; std::uint32_t next_one_time_key_id; OlmErrorCode last_error; @@ -126,6 +128,36 @@ struct Account { std::uint8_t const * random, std::size_t random_length ); + /** The number of random bytes needed to generate a fallback key. */ + std::size_t generate_fallback_key_random_length( + ); + + /** Generates a new fallback key. Returns std::size_t(-1) on error. If the + * number of random bytes is too small then last_error will be + * NOT_ENOUGH_RANDOM */ + std::size_t generate_fallback_key( + std::uint8_t const * random, std::size_t random_length + ); + + /** Number of bytes needed to output the one time keys for this account */ + std::size_t get_fallback_key_json_length(); + + /** Output the fallback key as JSON: + * + * {"curve25519": + * ["<6 byte key id>":"<43 base64 characters>" + * ,"<6 byte key id>":"<43 base64 characters>" + * ... + * ] + * } + * + * Returns the size of the JSON written or std::size_t(-1) on error. + * If the buffer is too small last_error will be OUTPUT_BUFFER_TOO_SMALL. + */ + std::size_t get_fallback_key_json( + std::uint8_t * fallback_json, std::size_t fallback_json_length + ); + /** Lookup a one time key with the given public key */ OneTimeKey const * lookup_key( _olm_curve25519_public_key const & public_key -- cgit v1.2.3 From c47c6ca3992c74489700cda44443ec29c3cb3b13 Mon Sep 17 00:00:00 2001 From: Hubert Chathi Date: Wed, 16 Sep 2020 16:14:23 -0400 Subject: fix style --- include/olm/account.hh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include/olm/account.hh') diff --git a/include/olm/account.hh b/include/olm/account.hh index 82bba27..826b26d 100644 --- a/include/olm/account.hh +++ b/include/olm/account.hh @@ -129,8 +129,7 @@ struct Account { ); /** The number of random bytes needed to generate a fallback key. */ - std::size_t generate_fallback_key_random_length( - ); + std::size_t generate_fallback_key_random_length(); /** Generates a new fallback key. Returns std::size_t(-1) on error. If the * number of random bytes is too small then last_error will be -- cgit v1.2.3