diff --git a/plugin/openssl/openssl_provider.cc b/plugin/openssl/openssl_provider.cc index 3adfd9de6..aeb22a928 100644 --- a/plugin/openssl/openssl_provider.cc +++ b/plugin/openssl/openssl_provider.cc @@ -256,13 +256,13 @@ Status OpensslProvider::AddCipher(const std::string& /*descriptor*/, return Status::InvalidArgument("Multiple encryption keys not supported."); } - key_ = reinterpret_cast(cipher); - if (len == 16) { aes_cipher_ = EVP_aes_128_ctr(); } else if (len == 24) { aes_cipher_ = EVP_aes_192_ctr(); } else if (len == 32) { aes_cipher_ = EVP_aes_256_ctr(); } else return Status::InvalidArgument("Invalid key size in provider."); + memcpy(key_,cipher,len); + //if( 1 != EVP_CIPHER_up_ref(aes_cipher_)) return handleErrors("Failed to create provider."); return Status::OK(); diff --git a/plugin/openssl/openssl_provider.h b/plugin/openssl/openssl_provider.h index fa3439a61..2fc968eb6 100644 --- a/plugin/openssl/openssl_provider.h +++ b/plugin/openssl/openssl_provider.h @@ -48,10 +48,11 @@ class OpensslProvider : public EncryptionProvider { private: const EVP_CIPHER *aes_cipher_; - const unsigned char *key_; + //const unsigned char *key_; + unsigned char key_[32]; size_t key_len_; OpensslProvider() - : aes_cipher_(nullptr), key_(nullptr), key_len_(0) {} + : aes_cipher_(nullptr), key_len_(0) {} OpensslProvider(const OpensslProvider&) = delete; OpensslProvider& operator=(const OpensslProvider&) = delete; Status handleErrors (const char * str) const;