From 0be795293cebf46af5b03ac007864921a2f1dc5e Mon Sep 17 00:00:00 2001 From: Neil Cook Date: Tue, 25 Jul 2023 08:38:27 +0100 Subject: [PATCH] Make context a static variable so that it doesn't get created everytime --- common/sodcrypto.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/sodcrypto.cc b/common/sodcrypto.cc index 685be5b2..573e499a 100644 --- a/common/sodcrypto.cc +++ b/common/sodcrypto.cc @@ -84,7 +84,7 @@ std::string sodEncryptSym(const std::string& msg, const std::string& key, Sodium int len; int ciphertext_len; // Each thread gets its own cipher context - thread_local auto ctx = std::unique_ptr(nullptr, EVP_CIPHER_CTX_free);; + static thread_local auto ctx = std::unique_ptr(nullptr, EVP_CIPHER_CTX_free); if (key.length() != CHACHA20_POLY1305_KEY_SIZE) { ostringstream err; @@ -126,7 +126,7 @@ std::string sodDecryptSym(const std::string& msg, const std::string& key, Sodium int len; int plaintext_len; // Each thread gets its own cipher context - thread_local auto ctx = std::unique_ptr(nullptr, EVP_CIPHER_CTX_free);; + static thread_local auto ctx = std::unique_ptr(nullptr, EVP_CIPHER_CTX_free); if (key.length() != CHACHA20_POLY1305_KEY_SIZE) { ostringstream err;