copying key when received

oxigraph-main
Niko PLP 1 year ago
parent 85d59d7c73
commit 2776c764d0
  1. 4
      plugin/openssl/openssl_provider.cc
  2. 5
      plugin/openssl/openssl_provider.h

@ -256,13 +256,13 @@ Status OpensslProvider::AddCipher(const std::string& /*descriptor*/,
return Status::InvalidArgument("Multiple encryption keys not supported.");
}
key_ = reinterpret_cast<const unsigned char *>(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();

@ -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;

Loading…
Cancel
Save