summaryrefslogtreecommitdiff
path: root/src/tests/blowfish.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-05-03 07:23:37 +0000
committerMike Buland <eichlan@xagasoft.com>2012-05-03 07:23:37 +0000
commit0214b67982bfbba8184057f8423bd69b50c6dd3f (patch)
tree8cfb6b4d83ea19ee955c0ef49cda654e14b88f0e /src/tests/blowfish.cpp
parentdf6a899ad6c9a1c792582ef1a3b838c7eb6d330c (diff)
downloadlibbu++-0214b67982bfbba8184057f8423bd69b50c6dd3f.tar.gz
libbu++-0214b67982bfbba8184057f8423bd69b50c6dd3f.tar.bz2
libbu++-0214b67982bfbba8184057f8423bd69b50c6dd3f.tar.xz
libbu++-0214b67982bfbba8184057f8423bd69b50c6dd3f.zip
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.
Diffstat (limited to 'src/tests/blowfish.cpp')
-rw-r--r--src/tests/blowfish.cpp26
1 files changed, 26 insertions, 0 deletions
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] ={
48 48
49int main( int argc, char *argv[] ) 49int main( int argc, char *argv[] )
50{ 50{
51 MemBuf mb;
52 {
53 BlowfishEcb bf( mb );
54 bf.setPassword( "01234567" );
55 for( int j = 0; j < 4; j++ )
56 {
57 bf.write("this is a test!!"+j, 1 );
58 }
59 bf.write("this is a test!!"+4, 12 );
60 }
61 mb.setPos( 0 );
62 BlowfishEcb bf( mb );
63 bf.setPassword( "01234567" );
64 for( int j = 0; j < 3; j++ )
65 {
66 char c;
67 bf.read( &c, 1 );
68 sio << "char: '" << c << "'" << sio.nl;
69 }
70
71 char buf[100];
72 int iR = bf.read( buf, 100 );
73 buf[iR] = '\0';
74 sio << "Got(" << iR << ") = '" << buf << "'" << sio.nl;
75
76 return 0;
51 77
52 for( int j = 0; j < 34; j++ ) 78 for( int j = 0; j < 34; j++ )
53 { 79 {