diff options
author | Richard van der Hoff <richard@matrix.org> | 2016-05-24 14:54:01 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2016-05-24 14:54:01 +0100 |
commit | a919a149fbb192e3fae7aba921ca28e02d9c0d10 (patch) | |
tree | 482f05d70d330d21934d296ec1d26e126b1a1732 /src/outbound_group_session.c | |
parent | fa1e9446ac2b4d26dd592813ce0a372565df4c93 (diff) |
Update megolm_cipher as a global struct
Initialise megolm_cipher via the preprocessor macro, instead of with a
function.
Diffstat (limited to 'src/outbound_group_session.c')
-rw-r--r-- | src/outbound_group_session.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/outbound_group_session.c b/src/outbound_group_session.c index cf7d32c..9f36ad8 100644 --- a/src/outbound_group_session.c +++ b/src/outbound_group_session.c @@ -179,13 +179,12 @@ static size_t raw_message_length( size_t plaintext_length) { size_t ciphertext_length, mac_length; - const struct _olm_cipher *cipher = megolm_cipher(); - ciphertext_length = cipher->ops->encrypt_ciphertext_length( - cipher, plaintext_length + ciphertext_length = megolm_cipher->ops->encrypt_ciphertext_length( + megolm_cipher, plaintext_length ); - mac_length = cipher->ops->mac_length(cipher); + mac_length = megolm_cipher->ops->mac_length(megolm_cipher); return _olm_encode_group_message_length( GROUP_SESSION_ID_LENGTH, session->ratchet.counter, @@ -210,7 +209,6 @@ size_t olm_group_encrypt( size_t rawmsglen; size_t result; uint8_t *ciphertext_ptr, *message_pos; - const struct _olm_cipher *cipher = megolm_cipher(); rawmsglen = raw_message_length(session, plaintext_length); @@ -219,8 +217,8 @@ size_t olm_group_encrypt( return (size_t)-1; } - ciphertext_length = cipher->ops->encrypt_ciphertext_length( - cipher, + ciphertext_length = megolm_cipher->ops->encrypt_ciphertext_length( + megolm_cipher, plaintext_length ); @@ -240,8 +238,8 @@ size_t olm_group_encrypt( message_pos, &ciphertext_ptr); - result = cipher->ops->encrypt( - cipher, + result = megolm_cipher->ops->encrypt( + megolm_cipher, megolm_get_data(&(session->ratchet)), MEGOLM_RATCHET_LENGTH, plaintext, plaintext_length, ciphertext_ptr, ciphertext_length, |