From 3a382aec59937b086c37f039f1b011f253e80e97 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Tue, 7 Jul 2015 16:42:03 +0100 Subject: Encode the account keys as a signed JSON object --- include/olm/account.hh | 60 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 4 deletions(-) (limited to 'include/olm/account.hh') diff --git a/include/olm/account.hh b/include/olm/account.hh index d3bde0d..1a4778b 100644 --- a/include/olm/account.hh +++ b/include/olm/account.hh @@ -24,7 +24,12 @@ namespace olm { -struct LocalKey { +struct IdentityKeys { + Ed25519KeyPair ed25519_key; + Curve25519KeyPair curve25519_key; +}; + +struct OneTimeKey { std::uint32_t id; Curve25519KeyPair key; }; @@ -34,8 +39,8 @@ static std::size_t const MAX_ONE_TIME_KEYS = 100; struct Account { - LocalKey identity_key; - List one_time_keys; + IdentityKeys identity_keys; + List one_time_keys; ErrorCode last_error; /** Number of random bytes needed to create a new account */ @@ -47,7 +52,54 @@ struct Account { uint8_t const * random, std::size_t random_length ); - LocalKey const * lookup_key( + /** Number of bytes needed to output the identity keys for this account */ + std::size_t get_identity_json_length( + std::size_t user_id_length, + std::size_t device_id_length, + std::uint64_t valid_after_ts, + std::uint64_t valid_until_ts + ); + + /** Output the identity keys for this account as JSON in the following + * format. + * + * 14 "{\"algorithms\":" + * 30 "[\"m.olm.curve25519-aes-sha256\"" + * 15 "],\"device_id\":\"" + * ? + * 22 "\",\"keys\":{\"curve25519:" + * 4 + * 3 "\":\"" + * 43 + * 11 "\",\"ed25519:" + * 4 + * 3 "\":\"" + * 43 + * 14 "\"},\"user_id\":\"" + * ? + * 19 "\",\"valid_after_ts\":" + * ? + * 18 ",\"valid_until_ts\":" + * ? + * 16 ",\"signatures\":{\"" + * ? + * 1 "/" + * ? + * 12 "\":{\"ed25519:" + * 4 + * 3 "\":\"" + * 86 + * 4 "\"}}}" + */ + std::size_t get_identity_json( + std::uint8_t const * user_id, std::size_t user_id_length, + std::uint8_t const * device_id, std::size_t device_id_length, + std::uint64_t valid_after_ts, + std::uint64_t valid_until_ts, + std::uint8_t * identity_keys, std::size_t identity_keys_length + ); + + OneTimeKey const * lookup_key( std::uint32_t id ); -- cgit v1.2.3