aboutsummaryrefslogtreecommitdiff
path: root/src/session.cpp
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2016-05-24 12:06:47 +0100
committerRichard van der Hoff <richard@matrix.org>2016-05-24 12:06:47 +0100
commit2fd28a66824bda7b86c08b065736009c39761987 (patch)
tree8bd7226ffd290b7eb2863733460e2ec0f2685306 /src/session.cpp
parentd4a3c8dbaa6730519d3b6b13004e7fd9ea288870 (diff)
Rewrite _olm_cipher_aes_sha_256 initialisation
Replace the init-static-var dance with some preprocessor macros
Diffstat (limited to 'src/session.cpp')
-rw-r--r--src/session.cpp15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/session.cpp b/src/session.cpp
index 19b9f21..c148c97 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -35,22 +35,13 @@ static const olm::KdfInfo OLM_KDF_INFO = {
RATCHET_KDF_INFO, sizeof(RATCHET_KDF_INFO) - 1
};
-const _olm_cipher *get_cipher() {
- static _olm_cipher *cipher;
- static _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 OLM_CIPHER =
+ OLM_CIPHER_INIT_AES_SHA_256(CIPHER_KDF_INFO);
} // namespace
olm::Session::Session(
-) : ratchet(OLM_KDF_INFO, get_cipher()),
+) : ratchet(OLM_KDF_INFO, OLM_CIPHER_BASE(&OLM_CIPHER)),
last_error(OlmErrorCode::OLM_SUCCESS),
received_message(false) {