aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/olm/account.hh60
-rw-r--r--include/olm/olm.hh18
-rw-r--r--include/olm/pickle.hh33
3 files changed, 101 insertions, 10 deletions
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<LocalKey, MAX_ONE_TIME_KEYS> one_time_keys;
+ IdentityKeys identity_keys;
+ List<OneTimeKey, MAX_ONE_TIME_KEYS> 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\":\""
+ * ? <device identifier>
+ * 22 "\",\"keys\":{\"curve25519:"
+ * 4 <base64 characters>
+ * 3 "\":\""
+ * 43 <base64 characters>
+ * 11 "\",\"ed25519:"
+ * 4 <base64 characters>
+ * 3 "\":\""
+ * 43 <base64 characters>
+ * 14 "\"},\"user_id\":\""
+ * ? <user identifier>
+ * 19 "\",\"valid_after_ts\":"
+ * ? <digits>
+ * 18 ",\"valid_until_ts\":"
+ * ? <digits>
+ * 16 ",\"signatures\":{\""
+ * ? <user identifier>
+ * 1 "/"
+ * ? <device identifier>
+ * 12 "\":{\"ed25519:"
+ * 4 <base64 characters>
+ * 3 "\":\""
+ * 86 <base64 characters>
+ * 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
);
diff --git a/include/olm/olm.hh b/include/olm/olm.hh
index fca35c4..ab71689 100644
--- a/include/olm/olm.hh
+++ b/include/olm/olm.hh
@@ -16,6 +16,7 @@
#define OLM_HH_
#include <stddef.h>
+#include <stdint.h>
#ifdef __cplusplus
extern "C" {
@@ -131,18 +132,23 @@ size_t olm_create_account(
/** The size of the output buffer needed to hold the identity keys */
size_t olm_account_identity_keys_length(
- OlmAccount * account
+ OlmAccount * account,
+ size_t user_id_length,
+ size_t device_id_length,
+ uint64_t valid_after_ts,
+ uint64_t valid_until_ts
);
/** Writes the public parts of the identity keys for the account into the
- * identity_keys output buffer. The output is formatted as though it was
- * created with sprintf(output, "[[%10d,\"%43s\"]\n]", key_id, key_base64).
- * The output can either be parsed as fixed width using the above format or by
- * a JSON parser. Returns olm_error() on failure. If the identity_keys
- * buffer was too small then olm_account_last_error() will be
+ * identity_keys output buffer. Returns olm_error() on failure. If the
+ * identity_keys buffer was too small then olm_account_last_error() will be
* "OUTPUT_BUFFER_TOO_SMALL". */
size_t olm_account_identity_keys(
OlmAccount * account,
+ void const * user_id, size_t user_id_length,
+ void const * device_id, size_t device_id_length,
+ uint64_t valid_after_ts,
+ uint64_t valid_until_ts,
void * identity_keys, size_t identity_key_length
);
diff --git a/include/olm/pickle.hh b/include/olm/pickle.hh
index 1676e23..7a2bd1b 100644
--- a/include/olm/pickle.hh
+++ b/include/olm/pickle.hh
@@ -170,6 +170,39 @@ std::uint8_t const * unpickle(
);
+std::size_t pickle_length(
+ const Ed25519PublicKey & value
+);
+
+
+std::uint8_t * pickle(
+ std::uint8_t * pos,
+ const Ed25519PublicKey & value
+);
+
+
+std::uint8_t const * unpickle(
+ std::uint8_t const * pos, std::uint8_t const * end,
+ Ed25519PublicKey & value
+);
+
+
+std::size_t pickle_length(
+ const Ed25519KeyPair & value
+);
+
+
+std::uint8_t * pickle(
+ std::uint8_t * pos,
+ const Ed25519KeyPair & value
+);
+
+
+std::uint8_t const * unpickle(
+ std::uint8_t const * pos, std::uint8_t const * end,
+ Ed25519KeyPair & value
+);
+
} // namespace olm