diff options
Diffstat (limited to 'include/olm')
-rw-r--r-- | include/olm/account.hh | 52 | ||||
-rw-r--r-- | include/olm/olm.hh | 25 |
2 files changed, 36 insertions, 41 deletions
diff --git a/include/olm/account.hh b/include/olm/account.hh index da3ca35..209139a 100644 --- a/include/olm/account.hh +++ b/include/olm/account.hh @@ -56,57 +56,45 @@ struct Account { ); /** 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 - ); + std::size_t get_identity_json_length(); /** Output the identity keys for this account as JSON in the following * format: * - * {"algorithms": - * ["m.olm.curve25519-aes-sha256" - * ] - * ,"device_id":"<device identifier>" - * ,"keys": - * {"curve25519:<key id>":"<base64 characters>" - * ,"ed25519:<key id>":"<base64 characters>" - * } - * ,"user_id":"<user identifier>" - * ,"valid_after_ts":<digits> - * ,"valid_until_ts":<digits> - * ,"signatures": - * {"<user identifier>/<device identifier>": - * {"ed25519:<key id>":"<base64 characters>" - * } - * } + * {"curve25519":"<43 base64 characters>" + * ,"ed25519":"<43 base64 characters>" * } * - * The user_id and device_id must not contain 0x00-0x1F, '\"' or '\\'. - * The JSON up to but not including the "signatures" key will be signed - * using the account's ed25519 key. That signature is then included under - * the "signatures" key. * * 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_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_json, std::size_t identity_json_length ); + /** + * The length of an ed25519 signature in bytes. + */ + std::size_t signature_length(); + + /** + * Signs a message with the ed25519 key for this account. + */ + std::size_t sign( + std::uint8_t const * message, std::size_t message_length, + std::uint8_t * signature, std::size_t signature_length + ); + /** Number of bytes needed to output the one time keys for this account */ std::size_t get_one_time_keys_json_length(); /** Output the one time keys that haven't been published yet as JSON: * - * {"curve25519:<key id>":"<base64 characters>" - * ,"curve25519:<key_id>":"<base64 characters>" + * {"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. diff --git a/include/olm/olm.hh b/include/olm/olm.hh index 46f7a68..2919767 100644 --- a/include/olm/olm.hh +++ b/include/olm/olm.hh @@ -132,11 +132,7 @@ 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, - size_t user_id_length, - size_t device_id_length, - uint64_t valid_after_ts, - uint64_t valid_until_ts + OlmAccount * account ); /** Writes the public parts of the identity keys for the account into the @@ -145,13 +141,24 @@ size_t olm_account_identity_keys_length( * "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 ); + +/** The length of an ed25519 signature encoded as base64. */ +size_t olm_account_signature_length( + OlmAccount * account +); + +/** Signs a message with the ed25519 key for this account. Returns olm_error() + * on failure. If the signature buffer was too small then + * olm_account_last_error() will be "OUTPUT_BUFFER_TOO_SMALL" */ +size_t olm_account_sign( + OlmAccount * account, + void const * message, size_t message_length, + void * signature, size_t signature_length +); + /** The size of the output buffer needed to hold the one time keys */ size_t olm_account_one_time_keys_length( OlmAccount * account |