You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by sc...@apache.org on 2016/12/16 23:08:08 UTC
svn commit: r1774683 - in
/santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL: OpenSSLCryptoHash.cpp
OpenSSLCryptoHash.hpp
Author: scantor
Date: Fri Dec 16 23:08:08 2016
New Revision: 1774683
URL: http://svn.apache.org/viewvc?rev=1774683&view=rev
Log:
OpenSSL 1.1 compatibility - Make EVP_MD_CTX opaque
Modified:
santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoHash.cpp
santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoHash.hpp
Modified: santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoHash.cpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoHash.cpp?rev=1774683&r1=1774682&r2=1774683&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoHash.cpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoHash.cpp Fri Dec 16 23:08:08 2016
@@ -38,7 +38,17 @@
// Constructors/Destructors
-OpenSSLCryptoHash::OpenSSLCryptoHash(HashType alg) {
+OpenSSLCryptoHash::OpenSSLCryptoHash(HashType alg) :
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+ mp_mdctx(&m_mdctx_store)
+#else
+ mp_mdctx(EVP_MD_CTX_new())
+#endif
+ , m_mdLen(0)
+ {
+ if (!mp_mdctx)
+ throw XSECCryptoException(XSECCryptoException::ECError, "OpenSSL:CryptoCryptoHash - cannot allocate contexts");
+
switch (alg) {
@@ -104,15 +114,18 @@ OpenSSLCryptoHash::OpenSSLCryptoHash(Has
"OpenSSL:Hash - Error loading Message Digest");
}
- EVP_DigestInit(&m_mdctx, mp_md);
+ EVP_DigestInit(mp_mdctx, mp_md);
m_hashType = alg;
}
OpenSSLCryptoHash::~OpenSSLCryptoHash() {
-
- EVP_MD_CTX_cleanup(&m_mdctx);
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+ EVP_MD_CTX_cleanup(mp_mdctx);
+#else
+ EVP_MD_CTX_free(mp_mdctx);
+#endif
}
@@ -121,16 +134,17 @@ OpenSSLCryptoHash::~OpenSSLCryptoHash()
// Hashing Activities
void OpenSSLCryptoHash::reset(void) {
- EVP_MD_CTX_cleanup(&m_mdctx);
-
- EVP_DigestInit(&m_mdctx, mp_md);
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+ EVP_MD_CTX_cleanup(mp_mdctx);
+#endif
+ EVP_DigestInit(mp_mdctx, mp_md);
}
void OpenSSLCryptoHash::hash(unsigned char * data,
unsigned int length) {
- EVP_DigestUpdate(&m_mdctx, data, length);
+ EVP_DigestUpdate(mp_mdctx, data, length);
}
unsigned int OpenSSLCryptoHash::finish(unsigned char * hash,
@@ -140,7 +154,7 @@ unsigned int OpenSSLCryptoHash::finish(u
// Finish up and copy out hash, returning the length
- EVP_DigestFinal(&m_mdctx, m_mdValue, &m_mdLen);
+ EVP_DigestFinal(mp_mdctx, m_mdValue, &m_mdLen);
// Copy to output buffer
Modified: santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoHash.hpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoHash.hpp?rev=1774683&r1=1774682&r2=1774683&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoHash.hpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoHash.hpp Fri Dec 16 23:08:08 2016
@@ -138,7 +138,7 @@ public :
* \brief Get OpenSSL hash context structure
*/
- EVP_MD_CTX * getOpenSSLEVP_MD_CTX(void) {return &m_mdctx;}
+ EVP_MD_CTX * getOpenSSLEVP_MD_CTX(void) {return mp_mdctx;}
//@}
@@ -148,7 +148,10 @@ private:
// Not implemented constructors
OpenSSLCryptoHash();
- EVP_MD_CTX m_mdctx; // Context for digest
+ EVP_MD_CTX * mp_mdctx; // Context for digest - storage
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+ EVP_MD_CTX m_mdctx_store; // Context for digest - storage
+#endif
const EVP_MD * mp_md; // Digest instance
unsigned char m_mdValue[EVP_MAX_MD_SIZE]; // Final output
unsigned int m_mdLen; // Length of digest