public:
TRACKER() : m_lastSize(0), m_callCount(0), m_lastBlock(NULL) {}
~TRACKER() { delete[] m_lastBlock; }
- void Call(const void * block, size_t size)
+ bool Call(const void * block, size_t size)
{
delete[] m_lastBlock;
if (size > 0)
m_lastBlock = NULL;
m_lastSize = size;
++m_callCount;
+ return true;
}
size_t LastSize() const { return m_lastSize; }
size_t CallCount() const { return m_callCount; }
char * m_lastBlock;
};
-void Callback(const void * block, size_t size, void * data)
+bool Callback(const void * block, size_t size, void * data)
{
TRACKER & tracker = *static_cast<TRACKER *>(data);
-tracker.Call(block, size);
+return tracker.Call(block, size);
}
}
STG::ENCRYPT_STREAM estream("pr7Hhen", Callback, &tracker);
std::string source = "This is a test long string for checking stream encryption/decryption. \"abcdefghijklmnopqrstuvwxyz 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ\"";
char buffer[source.length() + 9];
+ memset(buffer, 0, sizeof(buffer));
estream.Put(source.c_str(), source.length() + 1, true);
ensure("Encryption long string LastSize()", tracker.LastSize() >= source.length() + 1);