porting rev.1912 from 1.4.4 (fixed SF# 3552597)

This commit is contained in:
Aleksandar Fabijanic 2012-08-18 02:19:34 +00:00
parent e7f2ade581
commit 662050937e
5 changed files with 35 additions and 2 deletions

View File

@ -116,7 +116,7 @@ namespace
&_ctx,
_pCipher,
&_key[0],
&_iv[0],
_iv.empty() ? 0 : &_iv[0],
(dir == DIR_ENCRYPT) ? 1 : 0);
}

View File

@ -145,6 +145,36 @@ void CryptoTest::testEncryptDecryptWithSalt()
}
void CryptoTest::testEncryptDecryptDESECB()
{
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("des-ecb", "password"));
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_NONE);
std::string result = pCipher->decryptString(out, Cipher::ENC_NONE);
poco_assert (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
std::string result = pCipher->decryptString(out, Cipher::ENC_BASE64);
poco_assert (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX);
std::string result = pCipher->decryptString(out, Cipher::ENC_BINHEX);
poco_assert (in == result);
}
}
void CryptoTest::testStreams()
{
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256"));
@ -218,6 +248,7 @@ CppUnit::Test* CryptoTest::suite()
CppUnit_addTest(pSuite, CryptoTest, testEncryptDecrypt);
CppUnit_addTest(pSuite, CryptoTest, testEncryptDecryptWithSalt);
CppUnit_addTest(pSuite, CryptoTest, testEncryptDecryptDESECB);
CppUnit_addTest(pSuite, CryptoTest, testStreams);
CppUnit_addTest(pSuite, CryptoTest, testCertificate);

View File

@ -53,6 +53,7 @@ public:
void testEncryptDecrypt();
void testEncryptDecryptWithSalt();
void testEncryptDecryptDESECB();
void testStreams();
void testCertificate();

View File

@ -155,7 +155,7 @@ class Foundation_API FileChannel: public Channel
/// The purgeAge property can have the following values:
///
/// * "none" or "" no purging
/// * <n> [seconds] the maximum age is <n> seconds.
/// * <n> [seconds]: the maximum age is <n> seconds.
/// * <n> minutes: the maximum age is <n> minutes.
/// * <n> hours: the maximum age is <n> hours.
/// * <n> days: the maximum age is <n> days.

View File

@ -241,6 +241,7 @@ void SecureSocketImpl::shutdown()
// done with it.
int rc = SSL_shutdown(_pSSL);
if (rc < 0) handleError(rc);
if (_pSocket->getBlocking()) _pSocket->shutdown();
}
}
}