From 0214b67982bfbba8184057f8423bd69b50c6dd3f Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 3 May 2012 07:23:37 +0000 Subject: The cipher base class does nice buffering now based on the blocksize. This means that you can write odd numbers of bytes or read odd numbers of bytes from/to the ciphers and it'll just buffer until it gets a full block. Next up is adding padding support. Right now it doesn't flush the buffers with padding if you don't fill the last block. For that matter, it doesn't do any padding at all. --- src/tests/blowfish.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/tests/blowfish.cpp') diff --git a/src/tests/blowfish.cpp b/src/tests/blowfish.cpp index 293539d..89183e4 100644 --- a/src/tests/blowfish.cpp +++ b/src/tests/blowfish.cpp @@ -48,6 +48,32 @@ static const char *testdat[34][3] ={ int main( int argc, char *argv[] ) { + MemBuf mb; + { + BlowfishEcb bf( mb ); + bf.setPassword( "01234567" ); + for( int j = 0; j < 4; j++ ) + { + bf.write("this is a test!!"+j, 1 ); + } + bf.write("this is a test!!"+4, 12 ); + } + mb.setPos( 0 ); + BlowfishEcb bf( mb ); + bf.setPassword( "01234567" ); + for( int j = 0; j < 3; j++ ) + { + char c; + bf.read( &c, 1 ); + sio << "char: '" << c << "'" << sio.nl; + } + + char buf[100]; + int iR = bf.read( buf, 100 ); + buf[iR] = '\0'; + sio << "Got(" << iR << ") = '" << buf << "'" << sio.nl; + + return 0; for( int j = 0; j < 34; j++ ) { -- cgit v1.2.3