aboutsummaryrefslogtreecommitdiff
path: root/src/inbound_group_session.c
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2016-09-13 17:54:07 +0100
committerGitHub <noreply@github.com>2016-09-13 17:54:07 +0100
commit1a50a4b3a0bd38326a7f2327df5513072763ba65 (patch)
treefdb86b76d1a1e4a0c92dc2875dd463aac3e75310 /src/inbound_group_session.c
parente0b51971b7bc4cf3bb56b080f5f54296b58b3f0c (diff)
parent71bcaa5d45f63fc9b217937010199030d410f305 (diff)
Merge pull request #22 from matrix-org/markjh/inbound_group_session_id
Add a olm_inbound_group_session_id method
Diffstat (limited to 'src/inbound_group_session.c')
-rw-r--r--src/inbound_group_session.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/inbound_group_session.c b/src/inbound_group_session.c
index 82ff66f..65c6018 100644
--- a/src/inbound_group_session.c
+++ b/src/inbound_group_session.c
@@ -29,6 +29,7 @@
#define OLM_PROTOCOL_VERSION 3
+#define GROUP_SESSION_ID_LENGTH ED25519_PUBLIC_KEY_LENGTH
#define PICKLE_VERSION 1
#define SESSION_KEY_VERSION 2
@@ -364,3 +365,23 @@ size_t olm_group_decrypt(
plaintext, max_plaintext_length
);
}
+
+size_t olm_inbound_group_session_id_length(
+ const OlmInboundGroupSession *session
+) {
+ return _olm_encode_base64_length(GROUP_SESSION_ID_LENGTH);
+}
+
+size_t olm_inbound_group_session_id(
+ OlmInboundGroupSession *session,
+ uint8_t * id, size_t id_length
+) {
+ if (id_length < olm_inbound_group_session_id_length(session)) {
+ session->last_error = OLM_OUTPUT_BUFFER_TOO_SMALL;
+ return (size_t)-1;
+ }
+
+ return _olm_encode_base64(
+ session->signing_key.public_key, GROUP_SESSION_ID_LENGTH, id
+ );
+}