aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2016-10-20 09:58:55 +0100
committerMark Haines <mjark@negativecurvature.net>2016-10-20 09:58:55 +0100
commit653790eacbf7dcf94cbf181657cdb0c30c890c3f (patch)
tree6cf8ca49bff13c01d18c15cd8e1a5e53c1cf9167 /src
parent6ea9fb450ec1ef10b32d65ceb00a6042b927a95c (diff)
Return the message index when decrypting group messages.
Applications can use the index to detect replays of the same message.
Diffstat (limited to 'src')
-rw-r--r--src/inbound_group_session.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/inbound_group_session.c b/src/inbound_group_session.c
index bf00008..ed313a0 100644
--- a/src/inbound_group_session.c
+++ b/src/inbound_group_session.c
@@ -263,7 +263,8 @@ size_t olm_group_decrypt_max_plaintext_length(
static size_t _decrypt(
OlmInboundGroupSession *session,
uint8_t * message, size_t message_length,
- uint8_t * plaintext, size_t max_plaintext_length
+ uint8_t * plaintext, size_t max_plaintext_length,
+ uint32_t * message_index
) {
struct _OlmDecodeGroupMessageResults decoded_results;
size_t max_length, r;
@@ -286,6 +287,8 @@ static size_t _decrypt(
return (size_t)-1;
}
+ *message_index = decoded_results.message_index;
+
/* verify the signature. We could do this before decoding the message, but
* we allow for the possibility of future protocol versions which use a
* different signing mechanism; we would rather throw "BAD_MESSAGE_VERSION"
@@ -349,7 +352,8 @@ static size_t _decrypt(
size_t olm_group_decrypt(
OlmInboundGroupSession *session,
uint8_t * message, size_t message_length,
- uint8_t * plaintext, size_t max_plaintext_length
+ uint8_t * plaintext, size_t max_plaintext_length,
+ uint32_t * message_index
) {
size_t raw_message_length;
@@ -361,7 +365,8 @@ size_t olm_group_decrypt(
return _decrypt(
session, message, raw_message_length,
- plaintext, max_plaintext_length
+ plaintext, max_plaintext_length,
+ message_index
);
}