From e7d2b4593a412a9f63b0264eb2ecd549c966ac4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Obiltschnig?= Date: Tue, 6 Mar 2018 22:58:14 +0100 Subject: [PATCH] fix for OpenSSL 1.0 --- Crypto/include/Poco/Crypto/CryptoTransform.h | 8 +++---- Crypto/src/CipherImpl.cpp | 20 ++++++++-------- Crypto/src/RSACipherImpl.cpp | 24 ++++++++++---------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Crypto/include/Poco/Crypto/CryptoTransform.h b/Crypto/include/Poco/Crypto/CryptoTransform.h index e2046bff3..9fa3806c6 100644 --- a/Crypto/include/Poco/Crypto/CryptoTransform.h +++ b/Crypto/include/Poco/Crypto/CryptoTransform.h @@ -45,12 +45,12 @@ public: /// Returns the block size for this CryptoTransform. virtual int setPadding(int padding); - /// Enables or disables padding. By default encryption operations are padded using standard block - /// padding and the padding is checked and removed when decrypting. If the padding parameter is zero then - /// no padding is performed, the total amount of data encrypted or decrypted must then be a multiple of + /// Enables or disables padding. By default encryption operations are padded using standard block + /// padding and the padding is checked and removed when decrypting. If the padding parameter is zero then + /// no padding is performed, the total amount of data encrypted or decrypted must then be a multiple of /// the block size or an error will occur. - virtual std::string getTag(std::size_t tagSize = 16) const = 0; + virtual std::string getTag(std::size_t tagSize = 16) = 0; /// Returns the GCM tag after encrypting using GCM mode. /// /// Must be called after finalize(). diff --git a/Crypto/src/CipherImpl.cpp b/Crypto/src/CipherImpl.cpp index af48dc595..2edfd1c62 100644 --- a/Crypto/src/CipherImpl.cpp +++ b/Crypto/src/CipherImpl.cpp @@ -29,7 +29,7 @@ namespace { unsigned long err; std::string msg; - + while ((err = ERR_get_error())) { if (!msg.empty()) @@ -59,10 +59,10 @@ namespace Direction dir); ~CryptoTransformImpl(); - + std::size_t blockSize() const; - int setPadding(int padding); - std::string getTag(std::size_t tagSize) const; + int setPadding(int padding); + std::string getTag(std::size_t tagSize); void setTag(const std::string& tag); std::streamsize transform( @@ -70,7 +70,7 @@ namespace std::streamsize inputLength, unsigned char* output, std::streamsize outputLength); - + std::streamsize finalize( unsigned char* output, std::streamsize length); @@ -147,7 +147,7 @@ namespace #endif } - + int CryptoTransformImpl::setPadding(int padding) { #if OPENSSL_VERSION_NUMBER >= 0x10100000L @@ -156,9 +156,9 @@ namespace return EVP_CIPHER_CTX_set_padding(&_context, padding); #endif } - - std::string CryptoTransformImpl::getTag(std::size_t tagSize) const + + std::string CryptoTransformImpl::getTag(std::size_t tagSize) { std::string tag; #if OPENSSL_VERSION_NUMBER >= 0x10000000L @@ -224,7 +224,7 @@ namespace std::streamsize length) { poco_assert (length >= blockSize()); - + int len = static_cast(length); // Use the '_ex' version that does not perform implicit cleanup since we @@ -238,7 +238,7 @@ namespace if (rc == 0) throwError(); - + return static_cast(len); } } diff --git a/Crypto/src/RSACipherImpl.cpp b/Crypto/src/RSACipherImpl.cpp index 34a04ba83..5c2e493ed 100644 --- a/Crypto/src/RSACipherImpl.cpp +++ b/Crypto/src/RSACipherImpl.cpp @@ -30,7 +30,7 @@ namespace { unsigned long err; std::string msg; - + while ((err = ERR_get_error())) { if (!msg.empty()) @@ -66,10 +66,10 @@ namespace public: RSAEncryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode); ~RSAEncryptImpl(); - + std::size_t blockSize() const; std::size_t maxDataSize() const; - std::string getTag(std::size_t) const; + std::string getTag(std::size_t); void setTag(const std::string&); std::streamsize transform( @@ -77,7 +77,7 @@ namespace std::streamsize inputLength, unsigned char* output, std::streamsize outputLength); - + std::streamsize finalize(unsigned char* output, std::streamsize length); private: @@ -129,7 +129,7 @@ namespace } - std::string RSAEncryptImpl::getTag(std::size_t) const + std::string RSAEncryptImpl::getTag(std::size_t) { return std::string(); } @@ -167,7 +167,7 @@ namespace output += n; outputLength -= n; _pos = 0; - + } else { @@ -203,9 +203,9 @@ namespace public: RSADecryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode); ~RSADecryptImpl(); - + std::size_t blockSize() const; - std::string getTag(std::size_t) const; + std::string getTag(std::size_t); void setTag(const std::string&); std::streamsize transform( @@ -213,7 +213,7 @@ namespace std::streamsize inputLength, unsigned char* output, std::streamsize outputLength); - + std::streamsize finalize( unsigned char* output, std::streamsize length); @@ -248,7 +248,7 @@ namespace } - std::string RSADecryptImpl::getTag(std::size_t) const + std::string RSADecryptImpl::getTag(std::size_t) { return std::string(); } @@ -265,7 +265,7 @@ namespace unsigned char* output, std::streamsize outputLength) { - + // always fill up the buffer before decrypting! std::streamsize rsaSize = static_cast(blockSize()); poco_assert_dbg(_pos <= rsaSize); @@ -285,7 +285,7 @@ namespace output += tmp; outputLength -= tmp; _pos = 0; - + } else {