From faa089e24934bb7287fd368e54c362f89cdffaf4 Mon Sep 17 00:00:00 2001 From: Alex Fabijanic Date: Fri, 22 Sep 2017 18:29:30 -0500 Subject: [PATCH] openssl 1.1 --- CppUnit/CppUnit_x64_vs150.vcxproj | 100 +++++++++++++-------------- Crypto/Crypto_vs140.vcxproj | 24 ++++--- Crypto/Crypto_vs150.vcxproj | 24 ++++--- Crypto/Crypto_x64_vs140.vcxproj | 24 ++++--- Crypto/Crypto_x64_vs150.vcxproj | 26 +++---- Crypto/include/Poco/Crypto/Crypto.h | 21 +----- Crypto/include/Poco/Crypto/EVPPKey.h | 13 +++- Crypto/src/EVPPKey.cpp | 45 ++++++------ Crypto/src/PKCS12Container.cpp | 2 +- openssl | 2 +- 10 files changed, 140 insertions(+), 141 deletions(-) diff --git a/CppUnit/CppUnit_x64_vs150.vcxproj b/CppUnit/CppUnit_x64_vs150.vcxproj index cda95d198..707633d53 100644 --- a/CppUnit/CppUnit_x64_vs150.vcxproj +++ b/CppUnit/CppUnit_x64_vs150.vcxproj @@ -1,4 +1,4 @@ - + @@ -32,7 +32,7 @@ CppUnit Win32Proj - + StaticLibrary MultiByte @@ -63,27 +63,27 @@ MultiByte v141 - - + + - + - + - + - + - + - + - + <_ProjectFileVersion>14.0.23107.0 PocoCppUnit64d @@ -132,7 +132,7 @@ true true true - + Level3 ProgramDatabase Default @@ -163,9 +163,9 @@ true true true - + Level3 - + Default @@ -184,7 +184,7 @@ Disabled .\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;POCO_STATIC;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true true EnableFastChecks @@ -193,7 +193,7 @@ true true true - + ..\lib64\PocoCppUnitmtd.pdb Level3 ProgramDatabase @@ -211,16 +211,16 @@ Speed true .\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;POCO_STATIC;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true MultiThreaded false true true true - + Level3 - + Default @@ -231,7 +231,7 @@ Disabled .\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;POCO_STATIC;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true true EnableFastChecks @@ -240,7 +240,7 @@ true true true - + ..\lib64\PocoCppUnitmdd.pdb Level3 ProgramDatabase @@ -258,16 +258,16 @@ Speed true .\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;POCO_STATIC;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true MultiThreadedDLL false true true true - + Level3 - + Default @@ -275,32 +275,32 @@ - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + + \ No newline at end of file diff --git a/Crypto/Crypto_vs140.vcxproj b/Crypto/Crypto_vs140.vcxproj index 3beff5c90..f6722211d 100644 --- a/Crypto/Crypto_vs140.vcxproj +++ b/Crypto/Crypto_vs140.vcxproj @@ -121,8 +121,9 @@ - xcopy /y ..\openssl\VS_120\win32\bin\debug\*32MDd.dll ..\bin\* 1>nul -xcopy /y ..\openssl\VS_120\win32\bin\debug\*32MDd.lib ..\lib\* 1>nul + xcopy /y ..\openssl\VS_120\win32\bin\debug\*.dll ..\bin\* 1>nul +xcopy /y ..\openssl\VS_120\win32\bin\debug\*.lib ..\lib\* 1>nul +xcopy /y ..\openssl\VS_120\win32\bin\debug\*.pdb ..\bin\* 1>nul exit 0 @@ -156,8 +157,8 @@ exit 0 - xcopy /y ..\openssl\VS_120\win32\bin\release\*32MD.dll ..\bin\* 1>nul -xcopy /y ..\openssl\VS_120\win32\bin\release\*32MD.lib ..\lib\* 1>nul + xcopy /y ..\openssl\VS_120\win32\bin\release\*.dll ..\bin\* 1>nul +xcopy /y ..\openssl\VS_120\win32\bin\release\*.lib ..\lib\* 1>nul exit 0 @@ -194,8 +195,8 @@ exit 0 - xcopy /y ..\openssl\VS_120\win32\lib\debug\*32MTd.lib ..\lib\* 1>nul -xcopy /y ..\openssl\VS_120\win32\lib\debug\*32MTd.pdb ..\lib\* 1>nul + xcopy /y ..\openssl\VS_120\win32\lib\debug\*.lib ..\lib\* 1>nul +xcopy /y ..\openssl\VS_120\win32\lib\debug\*.pdb ..\lib\* 1>nul exit 0 @@ -222,7 +223,7 @@ exit 0 - xcopy /y ..\openssl\VS_120\win32\lib\release\*32MT.lib ..\lib\* 1>nul + xcopy /y ..\openssl\VS_120\win32\lib\release\*.lib ..\lib\* 1>nul exit 0 @@ -250,8 +251,9 @@ exit 0 - xcopy /y ..\openssl\VS_120\win32\bin\debug\*32MDd.dll ..\bin\* 1>nul -xcopy /y ..\openssl\VS_120\win32\bin\debug\*32MDd.lib ..\lib\* 1>nul + xcopy /y ..\openssl\VS_120\win32\bin\debug\*.dll ..\bin\* 1>nul +xcopy /y ..\openssl\VS_120\win32\bin\debug\*.lib ..\lib\* 1>nul +xcopy /y ..\openssl\VS_120\win32\bin\debug\*.pdb ..\bin\* 1>nul exit 0 @@ -278,8 +280,8 @@ exit 0 - xcopy /y ..\openssl\VS_120\win32\bin\release\*32MD.dll ..\bin\* 1>nul -xcopy /y ..\openssl\VS_120\win32\bin\release\*32MD.lib ..\lib\* 1>nul + xcopy /y ..\openssl\VS_120\win32\bin\release\*.dll ..\bin\* 1>nul +xcopy /y ..\openssl\VS_120\win32\bin\release\*.lib ..\lib\* 1>nul exit 0 diff --git a/Crypto/Crypto_vs150.vcxproj b/Crypto/Crypto_vs150.vcxproj index 50f269ff3..82d368242 100644 --- a/Crypto/Crypto_vs150.vcxproj +++ b/Crypto/Crypto_vs150.vcxproj @@ -121,8 +121,9 @@ - xcopy /y ..\openssl\VS_120\win32\bin\debug\*32MDd.dll ..\bin\* 1>nul -xcopy /y ..\openssl\VS_120\win32\bin\debug\*32MDd.lib ..\lib\* 1>nul + xcopy /y ..\openssl\VS_120\win32\bin\debug\*.dll ..\bin\* 1>nul +xcopy /y ..\openssl\VS_120\win32\bin\debug\*.lib ..\lib\* 1>nul +xcopy /y ..\openssl\VS_120\win32\bin\debug\*.pdb ..\bin\* 1>nul exit 0 @@ -156,8 +157,8 @@ exit 0 - xcopy /y ..\openssl\VS_120\win32\bin\release\*32MD.dll ..\bin\* 1>nul -xcopy /y ..\openssl\VS_120\win32\bin\release\*32MD.lib ..\lib\* 1>nul + xcopy /y ..\openssl\VS_120\win32\bin\release\*.dll ..\bin\* 1>nul +xcopy /y ..\openssl\VS_120\win32\bin\release\*.lib ..\lib\* 1>nul exit 0 @@ -194,8 +195,8 @@ exit 0 - xcopy /y ..\openssl\VS_120\win32\lib\debug\*32MTd.lib ..\lib\* 1>nul -xcopy /y ..\openssl\VS_120\win32\lib\debug\*32MTd.pdb ..\lib\* 1>nul + xcopy /y ..\openssl\VS_120\win32\lib\debug\*.lib ..\lib\* 1>nul +xcopy /y ..\openssl\VS_120\win32\lib\debug\*.pdb ..\lib\* 1>nul exit 0 @@ -222,7 +223,7 @@ exit 0 - xcopy /y ..\openssl\VS_120\win32\lib\release\*32MT.lib ..\lib\* 1>nul + xcopy /y ..\openssl\VS_120\win32\lib\release\*.lib ..\lib\* 1>nul exit 0 @@ -250,8 +251,9 @@ exit 0 - xcopy /y ..\openssl\VS_120\win32\bin\debug\*32MDd.dll ..\bin\* 1>nul -xcopy /y ..\openssl\VS_120\win32\bin\debug\*32MDd.lib ..\lib\* 1>nul + xcopy /y ..\openssl\VS_120\win32\bin\debug\*.dll ..\bin\* 1>nul +xcopy /y ..\openssl\VS_120\win32\bin\debug\*.lib ..\lib\* 1>nul +xcopy /y ..\openssl\VS_120\win32\bin\debug\*.pdb ..\bin\* 1>nul exit 0 @@ -278,8 +280,8 @@ exit 0 - xcopy /y ..\openssl\VS_120\win32\bin\release\*32MD.dll ..\bin\* 1>nul -xcopy /y ..\openssl\VS_120\win32\bin\release\*32MD.lib ..\lib\* 1>nul + xcopy /y ..\openssl\VS_120\win32\bin\release\*.dll ..\bin\* 1>nul +xcopy /y ..\openssl\VS_120\win32\bin\release\*.lib ..\lib\* 1>nul exit 0 diff --git a/Crypto/Crypto_x64_vs140.vcxproj b/Crypto/Crypto_x64_vs140.vcxproj index 953d8cdc3..e9e9a48e5 100644 --- a/Crypto/Crypto_x64_vs140.vcxproj +++ b/Crypto/Crypto_x64_vs140.vcxproj @@ -121,8 +121,9 @@ - xcopy /y ..\openssl\VS_120\win64\bin\debug\*64MDd.dll ..\bin64\* 1>nul -xcopy /y ..\openssl\VS_120\win64\bin\debug\*64MDd.lib ..\lib64\* 1>nul + xcopy /y ..\openssl\VS_120\win64\bin\debug\*.dll ..\bin64\* 1>nul +xcopy /y ..\openssl\VS_120\win64\bin\debug\*.lib ..\lib64\* 1>nul +xcopy /y ..\openssl\VS_120\win64\bin\debug\*.pdb ..\bin64\* 1>nul exit 0 @@ -156,8 +157,8 @@ exit 0 - xcopy /y ..\openssl\VS_120\win64\bin\release\*64MD.dll ..\bin64\* 1>nul -xcopy /y ..\openssl\VS_120\win64\bin\release\*64MD.lib ..\lib64\* 1>nul + xcopy /y ..\openssl\VS_120\win64\bin\release\*.dll ..\bin64\* 1>nul +xcopy /y ..\openssl\VS_120\win64\bin\release\*.lib ..\lib64\* 1>nul exit 0 @@ -194,8 +195,8 @@ exit 0 - xcopy /y ..\openssl\VS_120\win64\lib\debug\*64MTd.lib ..\lib64\* 1>nul -xcopy /y ..\openssl\VS_120\win64\lib\debug\*64MTd.pdb ..\lib64\* 1>nul + xcopy /y ..\openssl\VS_120\win64\lib\debug\*.lib ..\lib64\* 1>nul +xcopy /y ..\openssl\VS_120\win64\lib\debug\*.pdb ..\lib64\* 1>nul exit 0 @@ -222,7 +223,7 @@ exit 0 - xcopy /y ..\openssl\VS_120\win64\lib\release\*64MT.lib ..\lib64\* 1>nul + xcopy /y ..\openssl\VS_120\win64\lib\release\*.lib ..\lib64\* 1>nul exit 0 @@ -250,8 +251,9 @@ exit 0 - xcopy /y ..\openssl\VS_120\win64\bin\debug\*64MDd.dll ..\bin64\* 1>nul -xcopy /y ..\openssl\VS_120\win64\bin\debug\*64MDd.lib ..\lib64\* 1>nul + xcopy /y ..\openssl\VS_120\win64\bin\debug\*.dll ..\bin64\* 1>nul +xcopy /y ..\openssl\VS_120\win64\bin\debug\*.lib ..\lib64\* 1>nul +xcopy /y ..\openssl\VS_120\win64\bin\debug\*.pdb ..\bin64\* 1>nul exit 0 @@ -278,8 +280,8 @@ exit 0 - xcopy /y ..\openssl\VS_120\win64\bin\release\*64MD.dll ..\bin64\* 1>nul -xcopy /y ..\openssl\VS_120\win64\bin\release\*64MD.lib ..\lib64\* 1>nul + xcopy /y ..\openssl\VS_120\win64\bin\release\*.dll ..\bin64\* 1>nul +xcopy /y ..\openssl\VS_120\win64\bin\release\*.lib ..\lib64\* 1>nul exit 0 diff --git a/Crypto/Crypto_x64_vs150.vcxproj b/Crypto/Crypto_x64_vs150.vcxproj index 26a699fca..06111c963 100644 --- a/Crypto/Crypto_x64_vs150.vcxproj +++ b/Crypto/Crypto_x64_vs150.vcxproj @@ -1,4 +1,4 @@ - + @@ -121,8 +121,9 @@ - xcopy /y ..\openssl\VS_120\win64\bin\debug\*64MDd.dll ..\bin64\* 1>nul -xcopy /y ..\openssl\VS_120\win64\bin\debug\*64MDd.lib ..\lib64\* 1>nul + xcopy /y ..\openssl\VS_120\win64\bin\debug\*.dll ..\bin64\* 1>nul +xcopy /y ..\openssl\VS_120\win64\bin\debug\*.lib ..\lib64\* 1>nul +xcopy /y ..\openssl\VS_120\win64\bin\debug\*.pdb ..\lib64\* 1>nul exit 0 @@ -156,8 +157,8 @@ exit 0 - xcopy /y ..\openssl\VS_120\win64\bin\release\*64MD.dll ..\bin64\* 1>nul -xcopy /y ..\openssl\VS_120\win64\bin\release\*64MD.lib ..\lib64\* 1>nul + xcopy /y ..\openssl\VS_120\win64\bin\release\*.dll ..\bin64\* 1>nul +xcopy /y ..\openssl\VS_120\win64\bin\release\*.lib ..\lib64\* 1>nul exit 0 @@ -194,8 +195,8 @@ exit 0 - xcopy /y ..\openssl\VS_120\win64\lib\debug\*64MTd.lib ..\lib64\* 1>nul -xcopy /y ..\openssl\VS_120\win64\lib\debug\*64MTd.pdb ..\lib64\* 1>nul + xcopy /y ..\openssl\VS_120\win64\lib\debug\*.lib ..\lib64\* 1>nul +xcopy /y ..\openssl\VS_120\win64\lib\debug\*.pdb ..\lib64\* 1>nul exit 0 @@ -222,7 +223,7 @@ exit 0 - xcopy /y ..\openssl\VS_120\win64\lib\release\*64MT.lib ..\lib64\* 1>nul + xcopy /y ..\openssl\VS_120\win64\lib\release\*.lib ..\lib64\* 1>nul exit 0 @@ -250,8 +251,9 @@ exit 0 - xcopy /y ..\openssl\VS_120\win64\bin\debug\*64MDd.dll ..\bin64\* 1>nul -xcopy /y ..\openssl\VS_120\win64\bin\debug\*64MDd.lib ..\lib64\* 1>nul + xcopy /y ..\openssl\VS_120\win64\bin\debug\*.dll ..\bin64\* 1>nul +xcopy /y ..\openssl\VS_120\win64\bin\debug\*.lib ..\lib64\* 1>nul +xcopy /y ..\openssl\VS_120\win64\bin\debug\*.pdb ..\lib64\* 1>nul exit 0 @@ -278,8 +280,8 @@ exit 0 - xcopy /y ..\openssl\VS_120\win64\bin\release\*64MD.dll ..\bin64\* 1>nul -xcopy /y ..\openssl\VS_120\win64\bin\release\*64MD.lib ..\lib64\* 1>nul + xcopy /y ..\openssl\VS_120\win64\bin\release\*.dll ..\bin64\* 1>nul +xcopy /y ..\openssl\VS_120\win64\bin\release\*.lib ..\lib64\* 1>nul exit 0 diff --git a/Crypto/include/Poco/Crypto/Crypto.h b/Crypto/include/Poco/Crypto/Crypto.h index aa9046465..f5c0a1a59 100644 --- a/Crypto/include/Poco/Crypto/Crypto.h +++ b/Crypto/include/Poco/Crypto/Crypto.h @@ -87,27 +87,10 @@ enum RSAPaddingMode // Automatically link Crypto and OpenSSL libraries. // #if defined(_MSC_VER) - #if defined(_WIN64) - #define POCO_PLATFORM_BITS "64" - #else - #define POCO_PLATFORM_BITS "32" - #endif - - #if defined (_DEBUG) - #define POCO_DEBUG_POSTFIX "d" - #else - #define POCO_DEBUG_POSTFIX "" - #endif - #if !defined(POCO_NO_AUTOMATIC_LIBS) #if !defined(POCO_EXTERNAL_OPENSSL) - #if defined (_DLL) - #pragma comment(lib, "libeay" POCO_PLATFORM_BITS "MD" POCO_DEBUG_POSTFIX ".lib") - #pragma comment(lib, "ssleay" POCO_PLATFORM_BITS "MD" POCO_DEBUG_POSTFIX ".lib") - #else - #pragma comment(lib, "libeay" POCO_PLATFORM_BITS "MT" POCO_DEBUG_POSTFIX ".lib") - #pragma comment(lib, "ssleay" POCO_PLATFORM_BITS "MT" POCO_DEBUG_POSTFIX ".lib") - #endif + #pragma comment(lib, "libcrypto.lib") + #pragma comment(lib, "libssl.lib") #endif // POCO_EXTERNAL_OPENSSL #if !defined(Crypto_EXPORTS) #pragma comment(lib, "PocoCrypto" POCO_LIB_SUFFIX) diff --git a/Crypto/include/Poco/Crypto/EVPPKey.h b/Crypto/include/Poco/Crypto/EVPPKey.h index 77f680281..6ad348fc8 100644 --- a/Crypto/include/Poco/Crypto/EVPPKey.h +++ b/Crypto/include/Poco/Crypto/EVPPKey.h @@ -120,6 +120,7 @@ public: /// Returns pointer to the OpenSSL EVP_PKEY structure. private: + static int type(EVP_PKEY* pEVPPKey); void newECKey(const char* group); void duplicate(EVP_PKEY* pEVPPKey); void setKey(ECKey* pKey); @@ -244,11 +245,17 @@ private: // inlines // +inline int EVPPKey::type(EVP_PKEY* pEVPPKey) +{ + if (!pEVPPKey) return NID_undef; + + return EVP_PKEY_type(EVP_PKEY_id(pEVPPKey)); +} + + inline int EVPPKey::type() const { - if (!_pEVPPKey) return NID_undef; - - return EVP_PKEY_type(_pEVPPKey->type); + return type(_pEVPPKey); } diff --git a/Crypto/src/EVPPKey.cpp b/Crypto/src/EVPPKey.cpp index 5cf1ebf4a..7095a5998 100644 --- a/Crypto/src/EVPPKey.cpp +++ b/Crypto/src/EVPPKey.cpp @@ -213,33 +213,34 @@ void EVPPKey::duplicate(EVP_PKEY* pEVPPKey) if (!_pEVPPKey) throw NullPointerException("EVPPKey::duplicate(): " "EVP_PKEY_new() returned null."); - switch (pEVPPKey->type) + int keyType = type(pEVPPKey); + switch (keyType) { - case EVP_PKEY_RSA: + case EVP_PKEY_RSA: + { + RSA* pRSA = EVP_PKEY_get1_RSA(pEVPPKey); + if (pRSA) { - RSA* pRSA = EVP_PKEY_get1_RSA(pEVPPKey); - if (pRSA) - { - EVP_PKEY_set1_RSA(_pEVPPKey, pRSA); - RSA_free(pRSA); - } - else throw OpenSSLException(); - break; + EVP_PKEY_set1_RSA(_pEVPPKey, pRSA); + RSA_free(pRSA); } - case EVP_PKEY_EC: + else throw OpenSSLException(); + break; + } + case EVP_PKEY_EC: + { + EC_KEY* pEC = EVP_PKEY_get1_EC_KEY(pEVPPKey); + if (pEC) { - EC_KEY* pEC = EVP_PKEY_get1_EC_KEY(pEVPPKey); - if (pEC) - { - EVP_PKEY_set1_EC_KEY(_pEVPPKey, pEC); - EC_KEY_free(pEC); - } - else throw OpenSSLException("EVPPKey:duplicate()"); - break; + EVP_PKEY_set1_EC_KEY(_pEVPPKey, pEC); + EC_KEY_free(pEC); } - default: - throw NotImplementedException("EVPPKey:duplicate(); Key type: " + - NumberFormatter::format(pEVPPKey->type)); + else throw OpenSSLException(); + break; + } + default: + throw NotImplementedException("EVPPKey:duplicate(); Key type: " + + NumberFormatter::format(keyType)); } } diff --git a/Crypto/src/PKCS12Container.cpp b/Crypto/src/PKCS12Container.cpp index 542bb4ae2..53ef6f0bf 100644 --- a/Crypto/src/PKCS12Container.cpp +++ b/Crypto/src/PKCS12Container.cpp @@ -99,7 +99,7 @@ void PKCS12Container::load(PKCS12* pPKCS12, const std::string& password) if(pBuffer) { _pkcsFriendlyname = pBuffer; - CRYPTO_free(pBuffer); + OPENSSL_free(pBuffer); }else _pkcsFriendlyname.clear(); if(pBags) sk_PKCS12_SAFEBAG_pop_free(pBags, PKCS12_SAFEBAG_free); } diff --git a/openssl b/openssl index 6dc14894c..af3dfc6ca 160000 --- a/openssl +++ b/openssl @@ -1 +1 @@ -Subproject commit 6dc14894cb5cb32d8079acca9cd7d2853ba425da +Subproject commit af3dfc6ca786061640f55618b022aa4a62dffb2e