aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/prov/openssl/openssl_mode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/prov/openssl/openssl_mode.cpp')
-rw-r--r--src/lib/prov/openssl/openssl_mode.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/lib/prov/openssl/openssl_mode.cpp b/src/lib/prov/openssl/openssl_mode.cpp
index d1983949d..81f8413a2 100644
--- a/src/lib/prov/openssl/openssl_mode.cpp
+++ b/src/lib/prov/openssl/openssl_mode.cpp
@@ -65,14 +65,14 @@ OpenSSL_Cipher_Mode::OpenSSL_Cipher_Mode(const std::string& name,
m_cipher = EVP_CIPHER_CTX_new();
if (m_cipher == nullptr)
- throw OpenSSL_Error("Can't allocate new context");
+ throw OpenSSL_Error("Can't allocate new context", ERR_get_error());
EVP_CIPHER_CTX_init(m_cipher);
if(!EVP_CipherInit_ex(m_cipher, algo, nullptr, nullptr, nullptr,
m_direction == ENCRYPTION ? 1 : 0))
- throw OpenSSL_Error("EVP_CipherInit_ex");
+ throw OpenSSL_Error("EVP_CipherInit_ex", ERR_get_error());
if(!EVP_CIPHER_CTX_set_padding(m_cipher, 0))
- throw OpenSSL_Error("EVP_CIPHER_CTX_set_padding");
+ throw OpenSSL_Error("EVP_CIPHER_CTX_set_padding", ERR_get_error());
}
OpenSSL_Cipher_Mode::~OpenSSL_Cipher_Mode()
@@ -90,13 +90,13 @@ void OpenSSL_Cipher_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
if(nonce_len)
{
if(!EVP_CipherInit_ex(m_cipher, nullptr, nullptr, nullptr, nonce, -1))
- throw OpenSSL_Error("EVP_CipherInit_ex nonce");
+ throw OpenSSL_Error("EVP_CipherInit_ex nonce", ERR_get_error());
}
else if(m_nonce_set == false)
{
const std::vector<uint8_t> zeros(m_block_size);
if(!EVP_CipherInit_ex(m_cipher, nullptr, nullptr, nullptr, zeros.data(), -1))
- throw OpenSSL_Error("EVP_CipherInit_ex nonce");
+ throw OpenSSL_Error("EVP_CipherInit_ex nonce", ERR_get_error());
}
// otherwise existing CBC state left unchanged
@@ -116,7 +116,7 @@ size_t OpenSSL_Cipher_Mode::process(uint8_t msg[], size_t msg_len)
secure_vector<uint8_t> out(outl);
if(!EVP_CipherUpdate(m_cipher, out.data(), &outl, msg, msg_len))
- throw OpenSSL_Error("EVP_CipherUpdate");
+ throw OpenSSL_Error("EVP_CipherUpdate", ERR_get_error());
copy_mem(msg, out.data(), outl);
return outl;
}
@@ -136,7 +136,7 @@ void OpenSSL_Cipher_Mode::finish(secure_vector<uint8_t>& buffer,
secure_vector<uint8_t> out(outl);
if(!EVP_CipherFinal_ex(m_cipher, out.data(), &outl))
- throw OpenSSL_Error("EVP_CipherFinal_ex");
+ throw OpenSSL_Error("EVP_CipherFinal_ex", ERR_get_error());
copy_mem(buf + written, out.data(), outl);
written += outl;
buffer.resize(offset + written);
@@ -178,19 +178,19 @@ void OpenSSL_Cipher_Mode::clear()
const EVP_CIPHER* algo = EVP_CIPHER_CTX_cipher(m_cipher);
if(!EVP_CIPHER_CTX_cleanup(m_cipher))
- throw OpenSSL_Error("EVP_CIPHER_CTX_cleanup");
+ throw OpenSSL_Error("EVP_CIPHER_CTX_cleanup", ERR_get_error());
EVP_CIPHER_CTX_init(m_cipher);
if(!EVP_CipherInit_ex(m_cipher, algo, nullptr, nullptr, nullptr,
m_direction == ENCRYPTION ? 1 : 0))
- throw OpenSSL_Error("EVP_CipherInit_ex clear");
+ throw OpenSSL_Error("EVP_CipherInit_ex clear", ERR_get_error());
if(!EVP_CIPHER_CTX_set_padding(m_cipher, 0))
- throw OpenSSL_Error("EVP_CIPHER_CTX_set_padding clear");
+ throw OpenSSL_Error("EVP_CIPHER_CTX_set_padding clear", ERR_get_error());
}
void OpenSSL_Cipher_Mode::reset()
{
if(!EVP_CipherInit_ex(m_cipher, nullptr, nullptr, nullptr, nullptr, -1))
- throw OpenSSL_Error("EVP_CipherInit_ex clear");
+ throw OpenSSL_Error("EVP_CipherInit_ex clear", ERR_get_error());
m_nonce_set = false;
}
@@ -202,9 +202,9 @@ Key_Length_Specification OpenSSL_Cipher_Mode::key_spec() const
void OpenSSL_Cipher_Mode::key_schedule(const uint8_t key[], size_t length)
{
if(!EVP_CIPHER_CTX_set_key_length(m_cipher, length))
- throw OpenSSL_Error("EVP_CIPHER_CTX_set_key_length");
+ throw OpenSSL_Error("EVP_CIPHER_CTX_set_key_length", ERR_get_error());
if(!EVP_CipherInit_ex(m_cipher, nullptr, nullptr, key, nullptr, -1))
- throw OpenSSL_Error("EVP_CipherInit_ex key");
+ throw OpenSSL_Error("EVP_CipherInit_ex key", ERR_get_error());
m_key_set = true;
m_nonce_set = false;
}