aboutsummaryrefslogtreecommitdiff
path: root/src/session.cpp
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-07-16 11:45:20 +0100
committerMark Haines <mark.haines@matrix.org>2015-07-16 11:45:20 +0100
commit3468886e27c54690cc484662ea656f021997a9c7 (patch)
tree0e0c059c7963505520304c8c1fd7cc851f1ee6ca /src/session.cpp
parent89d9b972a6d629648d18f4227a08596c65c3894d (diff)
Add method getting a session id. Update the python and javascript bindings
Diffstat (limited to 'src/session.cpp')
-rw-r--r--src/session.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/session.cpp b/src/session.cpp
index 0249e6c..b17a059 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -189,6 +189,27 @@ std::size_t olm::Session::new_inbound_session(
}
+std::size_t olm::Session::session_id_length() {
+ return 32;
+}
+
+
+std::size_t olm::Session::session_id(
+ std::uint8_t * id, std::size_t id_length
+) {
+ if (id_length < session_id_length()) {
+ last_error = olm::ErrorCode::OUTPUT_BUFFER_TOO_SMALL;
+ return std::size_t(-1);
+ }
+ std::uint8_t tmp[96];
+ std::memcpy(tmp, alice_identity_key.public_key, 32);
+ std::memcpy(tmp + 32, alice_base_key.public_key, 32);
+ std::memcpy(tmp + 64, bob_one_time_key.public_key, 32);
+ olm::sha256(tmp, sizeof(tmp), id);
+ return session_id_length();
+}
+
+
bool olm::Session::matches_inbound_session(
olm::Curve25519PublicKey const * their_identity_key,
std::uint8_t const * one_time_key_message, std::size_t message_length