From eccab535b59d0459d64983a00b13450cde9d3e88 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 4 Jan 2016 17:56:13 +0100 Subject: [PATCH] GH #1050 Crypto: fix gcc -Wshadow warnings --- Crypto/src/CipherKey.cpp | 14 +++++++------- Crypto/src/CipherKeyImpl.cpp | 34 +++++++++++++++++----------------- Crypto/src/RSAKeyImpl.cpp | 12 ++++++------ 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Crypto/src/CipherKey.cpp b/Crypto/src/CipherKey.cpp index 82a099776..43af25827 100644 --- a/Crypto/src/CipherKey.cpp +++ b/Crypto/src/CipherKey.cpp @@ -21,21 +21,21 @@ namespace Poco { namespace Crypto { -CipherKey::CipherKey(const std::string& name, const std::string& passphrase, const std::string& salt, int iterationCount, - const std::string &digest): - _pImpl(new CipherKeyImpl(name, passphrase, salt, iterationCount, digest)) +CipherKey::CipherKey(const std::string& rName, const std::string& passphrase, const std::string& salt, int iterationCount, + const std::string & rDigest): + _pImpl(new CipherKeyImpl(rName, passphrase, salt, iterationCount, rDigest)) { } -CipherKey::CipherKey(const std::string& name, const ByteVec& key, const ByteVec& iv): - _pImpl(new CipherKeyImpl(name, key, iv)) +CipherKey::CipherKey(const std::string& rName, const ByteVec& key, const ByteVec& iv): + _pImpl(new CipherKeyImpl(rName, key, iv)) { } -CipherKey::CipherKey(const std::string& name): - _pImpl(new CipherKeyImpl(name)) +CipherKey::CipherKey(const std::string& rName): + _pImpl(new CipherKeyImpl(rName)) { } diff --git a/Crypto/src/CipherKeyImpl.cpp b/Crypto/src/CipherKeyImpl.cpp index 7f496aa07..cac2df8c6 100644 --- a/Crypto/src/CipherKeyImpl.cpp +++ b/Crypto/src/CipherKeyImpl.cpp @@ -27,28 +27,28 @@ namespace Poco { namespace Crypto { -CipherKeyImpl::CipherKeyImpl(const std::string& name, +CipherKeyImpl::CipherKeyImpl(const std::string& rName, const std::string& passphrase, const std::string& salt, int iterationCount, - const std::string& digest): + const std::string& rDigest): _pCipher(0), _pDigest(0), - _name(name), + _name(rName), _key(), _iv() { // dummy access to Cipherfactory so that the EVP lib is initilaized CipherFactory::defaultFactory(); - _pCipher = EVP_get_cipherbyname(name.c_str()); + _pCipher = EVP_get_cipherbyname(rName.c_str()); if (!_pCipher) - throw Poco::NotFoundException("Cipher " + name + " was not found"); + throw Poco::NotFoundException("Cipher " + rName + " was not found"); - _pDigest = EVP_get_digestbyname(digest.c_str()); + _pDigest = EVP_get_digestbyname(rDigest.c_str()); if (!_pDigest) - throw Poco::NotFoundException("Digest " + name + " was not found"); + throw Poco::NotFoundException("Digest " + rName + " was not found"); _key = ByteVec(keySize()); @@ -57,35 +57,35 @@ CipherKeyImpl::CipherKeyImpl(const std::string& name, } -CipherKeyImpl::CipherKeyImpl(const std::string& name, +CipherKeyImpl::CipherKeyImpl(const std::string& rName, const ByteVec& key, const ByteVec& iv): _pCipher(0), - _name(name), + _name(rName), _key(key), _iv(iv) { // dummy access to Cipherfactory so that the EVP lib is initilaized CipherFactory::defaultFactory(); - _pCipher = EVP_get_cipherbyname(name.c_str()); + _pCipher = EVP_get_cipherbyname(rName.c_str()); if (!_pCipher) - throw Poco::NotFoundException("Cipher " + name + " was not found"); + throw Poco::NotFoundException("Cipher " + rName + " was not found"); } -CipherKeyImpl::CipherKeyImpl(const std::string& name): +CipherKeyImpl::CipherKeyImpl(const std::string& rName): _pCipher(0), - _name(name), + _name(rName), _key(), _iv() { // dummy access to Cipherfactory so that the EVP lib is initilaized CipherFactory::defaultFactory(); - _pCipher = EVP_get_cipherbyname(name.c_str()); + _pCipher = EVP_get_cipherbyname(rName.c_str()); if (!_pCipher) - throw Poco::NotFoundException("Cipher " + name + " was not found"); + throw Poco::NotFoundException("Cipher " + rName + " was not found"); _key = ByteVec(keySize()); _iv = ByteVec(ivSize()); generateKey(); @@ -165,7 +165,7 @@ void CipherKeyImpl::generateKey( } // Now create the key and IV, using the digest set in the constructor. - int keySize = EVP_BytesToKey( + int cipherKeySize = EVP_BytesToKey( _pCipher, _pDigest, (salt.empty() ? 0 : saltBytes), @@ -176,7 +176,7 @@ void CipherKeyImpl::generateKey( ivBytes); // Copy the buffers to our member byte vectors. - _key.assign(keyBytes, keyBytes + keySize); + _key.assign(keyBytes, keyBytes + cipherKeySize); if (ivSize() == 0) _iv.clear(); diff --git a/Crypto/src/RSAKeyImpl.cpp b/Crypto/src/RSAKeyImpl.cpp index 8333453ce..8c917497c 100644 --- a/Crypto/src/RSAKeyImpl.cpp +++ b/Crypto/src/RSAKeyImpl.cpp @@ -87,10 +87,10 @@ RSAKeyImpl::RSAKeyImpl( RSA* pubKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, 0, 0); if (!pubKey) { - int rc = BIO_reset(bio); + int ret = BIO_reset(bio); // BIO_reset() normally returns 1 for success and 0 or -1 for failure. // File BIOs are an exception, they return 0 for success and -1 for failure. - if (rc != 0) throw Poco::FileException("Failed to load public key", publicKeyFile); + if (ret != 0) throw Poco::FileException("Failed to load public key", publicKeyFile); pubKey = PEM_read_bio_RSA_PUBKEY(bio, &_pRSA, 0, 0); } BIO_free(bio); @@ -287,8 +287,8 @@ void RSAKeyImpl::save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyS throw Poco::WriteFileException("Failed to write public key to stream"); } char* pData; - long size = BIO_get_mem_data(bio, &pData); - pPublicKeyStream->write(pData, static_cast(size)); + long keySize = BIO_get_mem_data(bio, &pData); + pPublicKeyStream->write(pData, static_cast(keySize)); BIO_free(bio); } @@ -309,8 +309,8 @@ void RSAKeyImpl::save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyS throw Poco::FileException("Failed to write private key to stream"); } char* pData; - long size = BIO_get_mem_data(bio, &pData); - pPrivateKeyStream->write(pData, static_cast(size)); + long keySize = BIO_get_mem_data(bio, &pData); + pPrivateKeyStream->write(pData, static_cast(keySize)); BIO_free(bio); } }