aboutsummaryrefslogtreecommitdiff
path: root/src/inbound_group_session.c
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2016-09-13 16:45:54 +0100
committerMark Haines <mjark@negativecurvature.net>2016-09-13 16:45:54 +0100
commit5926a8fd29ecb997e6c4609e2195e68274d1f9df (patch)
tree0792dfed9ade4caee9f359a5455e3c8c1c8d5618 /src/inbound_group_session.c
parentd62e344db708672dee58238be330382b2c903b5b (diff)
Comment on the encoding of the message counter.
Diffstat (limited to 'src/inbound_group_session.c')
-rw-r--r--src/inbound_group_session.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/inbound_group_session.c b/src/inbound_group_session.c
index f2a310a..82ff66f 100644
--- a/src/inbound_group_session.c
+++ b/src/inbound_group_session.c
@@ -88,10 +88,10 @@ static size_t _init_group_session_keys(
}
uint32_t counter = 0;
- counter <<= 8; counter |= *ptr++;
- counter <<= 8; counter |= *ptr++;
- counter <<= 8; counter |= *ptr++;
- counter <<= 8; counter |= *ptr++;
+ // Decode counter as a big endian 32-bit number.
+ for (unsigned i = 0; i < 4; i++) {
+ counter <<= 8; counter |= *ptr++;
+ }
megolm_init(&session->initial_ratchet, ptr, counter);
megolm_init(&session->latest_ratchet, ptr, counter);