From 89d9b972a6d629648d18f4227a08596c65c3894d Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Thu, 16 Jul 2015 10:45:10 +0100 Subject: Add versions of olm_session_create_inbound and olm_session_matches_inbound which take the curve25519 identity key of the remote device we think the message is from as an additional argument --- include/olm/olm.hh | 29 +++++++++++++++++++++++++++++ include/olm/session.hh | 2 ++ 2 files changed, 31 insertions(+) (limited to 'include/olm') diff --git a/include/olm/olm.hh b/include/olm/olm.hh index 64454e6..f08fb9f 100644 --- a/include/olm/olm.hh +++ b/include/olm/olm.hh @@ -242,6 +242,21 @@ size_t olm_create_inbound_session( void * one_time_key_message, size_t message_length ); +/** Create a new in-bound session for sending/receiving messages from an + * incoming PRE_KEY message. Returns olm_error() on failure. If the base64 + * couldn't be decoded then olm_session_last_error will be "INVALID_BASE64". + * If the message was for an unsupported protocol version then + * olm_session_last_error() will be "BAD_MESSAGE_VERSION". If the message + * couldn't be decoded then then olm_session_last_error() will be + * "BAD_MESSAGE_FORMAT". If the message refers to an unknown one time + * key then olm_session_last_error() will be "BAD_MESSAGE_KEY_ID". */ +size_t olm_create_inbound_session_from( + OlmSession * session, + OlmAccount * account, + void const * their_identity_key, size_t their_identity_key_length, + void * one_time_key_message, size_t message_length +); + /** Checks if the PRE_KEY message is for this in-bound session. This can happen * if multiple messages are sent to this account before this account sends a * message in reply. Returns olm_error() on failure. If the base64 @@ -255,6 +270,20 @@ size_t olm_matches_inbound_session( void * one_time_key_message, size_t message_length ); +/** Checks if the PRE_KEY message is for this in-bound session. This can happen + * if multiple messages are sent to this account before this account sends a + * message in reply. Returns olm_error() on failure. If the base64 + * couldn't be decoded then olm_session_last_error will be "INVALID_BASE64". + * If the message was for an unsupported protocol version then + * olm_session_last_error() will be "BAD_MESSAGE_VERSION". If the message + * couldn't be decoded then then olm_session_last_error() will be + * "BAD_MESSAGE_FORMAT". */ +size_t olm_matches_inbound_session_from( + OlmSession * session, + void const * their_identity_key, size_t their_identity_key_length, + void * one_time_key_message, size_t message_length +); + /** Removes the one time keys that the session used from the account. Returns * olm_error() on failure. If the account doesn't have any matching one time * keys then olm_account_last_error() will be "BAD_MESSAGE_KEY_ID". */ diff --git a/include/olm/session.hh b/include/olm/session.hh index 125df68..b70ce6a 100644 --- a/include/olm/session.hh +++ b/include/olm/session.hh @@ -50,10 +50,12 @@ struct Session { std::size_t new_inbound_session( Account & local_account, + Curve25519PublicKey const * their_identity_key, std::uint8_t const * one_time_key_message, std::size_t message_length ); bool matches_inbound_session( + Curve25519PublicKey const * their_identity_key, std::uint8_t const * one_time_key_message, std::size_t message_length ); -- cgit v1.2.3