From b05452a9c9dbf90b453d1ee72aae991f8e55be93 Mon Sep 17 00:00:00 2001 From: Benau Date: Thu, 25 Feb 2021 12:15:26 +0800 Subject: [PATCH] Fix possible crash for mbedtls --- src/network/crypto_mbedtls.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/crypto_mbedtls.hpp b/src/network/crypto_mbedtls.hpp index 2166282e0..774471190 100644 --- a/src/network/crypto_mbedtls.hpp +++ b/src/network/crypto_mbedtls.hpp @@ -114,6 +114,8 @@ public: assert(iv.size() == 12); std::copy_n(iv.begin(), 12, m_iv.begin()); m_packet_counter = 0; + mbedtls_gcm_init(&m_aes_encrypt_context); + mbedtls_gcm_init(&m_aes_decrypt_context); mbedtls_gcm_setkey(&m_aes_encrypt_context, MBEDTLS_CIPHER_ID_AES, key.data(), key.size() * 8); mbedtls_gcm_setkey(&m_aes_decrypt_context, MBEDTLS_CIPHER_ID_AES,