GH #1050 Crypto: fix gcc -Wshadow warnings

This commit is contained in:
Miklos Vajna 2016-01-04 17:56:13 +01:00
parent 3078a8eac3
commit eccab535b5
3 changed files with 30 additions and 30 deletions

View File

@ -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))
{
}

View File

@ -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();

View File

@ -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<std::streamsize>(size));
long keySize = BIO_get_mem_data(bio, &pData);
pPublicKeyStream->write(pData, static_cast<std::streamsize>(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<std::streamsize>(size));
long keySize = BIO_get_mem_data(bio, &pData);
pPrivateKeyStream->write(pData, static_cast<std::streamsize>(keySize));
BIO_free(bio);
}
}