aboutsummaryrefslogtreecommitdiff
path: root/src/megolm.c
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2016-05-24 14:54:01 +0100
committerRichard van der Hoff <richard@matrix.org>2016-05-24 14:54:01 +0100
commita919a149fbb192e3fae7aba921ca28e02d9c0d10 (patch)
tree482f05d70d330d21934d296ec1d26e126b1a1732 /src/megolm.c
parentfa1e9446ac2b4d26dd592813ce0a372565df4c93 (diff)
Update megolm_cipher as a global struct
Initialise megolm_cipher via the preprocessor macro, instead of with a function.
Diffstat (limited to 'src/megolm.c')
-rw-r--r--src/megolm.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/megolm.c b/src/megolm.c
index 7567894..110f939 100644
--- a/src/megolm.c
+++ b/src/megolm.c
@@ -22,18 +22,9 @@
#include "olm/crypto.h"
#include "olm/pickle.h"
-const struct _olm_cipher *megolm_cipher() {
- static const uint8_t CIPHER_KDF_INFO[] = "MEGOLM_KEYS";
- static struct _olm_cipher *cipher;
- static struct _olm_cipher_aes_sha_256 OLM_CIPHER;
- if (!cipher) {
- cipher = _olm_cipher_aes_sha_256_init(
- &OLM_CIPHER,
- CIPHER_KDF_INFO, sizeof(CIPHER_KDF_INFO) - 1
- );
- }
- return cipher;
-}
+static const struct _olm_cipher_aes_sha_256 MEGOLM_CIPHER =
+ OLM_CIPHER_INIT_AES_SHA_256("MEGOLM_KEYS");
+const struct _olm_cipher *megolm_cipher = OLM_CIPHER_BASE(&MEGOLM_CIPHER);
/* the seeds used in the HMAC-SHA-256 functions for each part of the ratchet.
*/