diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-04-10 08:32:23 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-04-10 08:32:23 +0000 |
commit | d49fc3aeac4daa65416751f94943b6611ad247d3 (patch) | |
tree | 2d843ebe59284d06fea389744a3a08aad423868d /src/tests | |
parent | 1e9d8f7a92e43f61e4d9f478f6e8dd5ae206616e (diff) | |
download | libbu++-d49fc3aeac4daa65416751f94943b6611ad247d3.tar.gz libbu++-d49fc3aeac4daa65416751f94943b6611ad247d3.tar.bz2 libbu++-d49fc3aeac4daa65416751f94943b6611ad247d3.tar.xz libbu++-d49fc3aeac4daa65416751f94943b6611ad247d3.zip |
Rearranged the Cipher system, and added four modes of operation. It's pretty
slick, really, and we actually support four of the most common modes.
Blowfish is still a template, but it doesn't really need to be anymore...
Diffstat (limited to '')
-rw-r--r-- | src/tests/blowfish.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/tests/blowfish.cpp b/src/tests/blowfish.cpp index c7486e1..293539d 100644 --- a/src/tests/blowfish.cpp +++ b/src/tests/blowfish.cpp | |||
@@ -4,6 +4,8 @@ | |||
4 | #include <bu/hex.h> | 4 | #include <bu/hex.h> |
5 | #include <bu/strfilter.h> | 5 | #include <bu/strfilter.h> |
6 | #include <bu/sio.h> | 6 | #include <bu/sio.h> |
7 | #include <bu/ciphermodecfb.h> | ||
8 | #include <bu/ciphermodeecb.h> | ||
7 | 9 | ||
8 | using namespace Bu; | 10 | using namespace Bu; |
9 | 11 | ||
@@ -50,13 +52,13 @@ int main( int argc, char *argv[] ) | |||
50 | for( int j = 0; j < 34; j++ ) | 52 | for( int j = 0; j < 34; j++ ) |
51 | { | 53 | { |
52 | MemBuf mb; | 54 | MemBuf mb; |
53 | Blowfish bf( mb ); | 55 | BlowfishEcb bf( mb ); |
54 | bf.setPassword( decodeStr<Hex>( testdat[j][0] ) ); | 56 | bf.setPassword( decodeStr<Hex>( testdat[j][0] ) ); |
55 | bf.write( decodeStr<Hex>( testdat[j][1] ) ); | 57 | bf.write( decodeStr<Hex>( testdat[j][1] ) ); |
56 | sio << "Test " << j << ": " << (mb.getString() == decodeStr<Hex>( testdat[j][2] )) << " (" << encodeStr<Hex>( mb.getString(), true ) << " == " << testdat[j][2] << ")" << sio.nl; | 58 | sio << "Test " << j << ": " << (mb.getString() == decodeStr<Hex>( testdat[j][2] )) << " (" << encodeStr<Hex>( mb.getString(), true ) << " == " << testdat[j][2] << ")" << sio.nl; |
57 | 59 | ||
58 | mb.setPos( 0 ); | 60 | mb.setPos( 0 ); |
59 | Blowfish bf2( mb ); | 61 | BlowfishEcb bf2( mb ); |
60 | bf2.setPassword( decodeStr<Hex>( testdat[j][0] ) ); | 62 | bf2.setPassword( decodeStr<Hex>( testdat[j][0] ) ); |
61 | char buf[8]; | 63 | char buf[8]; |
62 | bf2.read( buf, 8 ); | 64 | bf2.read( buf, 8 ); |
@@ -64,29 +66,27 @@ int main( int argc, char *argv[] ) | |||
64 | sio << " - Back: " << (Bu::String(testdat[j][1]) == encodeStr<Hex>(String(buf,8),true)) << sio.nl; | 66 | sio << " - Back: " << (Bu::String(testdat[j][1]) == encodeStr<Hex>(String(buf,8),true)) << sio.nl; |
65 | } | 67 | } |
66 | 68 | ||
67 | /* | ||
68 | { | 69 | { |
69 | File fIn("data.plain", File::Read ); | 70 | File fIn("data.plain", File::Read ); |
70 | File fOut("data.crypt", File::WriteNew ); | 71 | File fOut("data.crypt", File::WriteNew ); |
71 | 72 | ||
72 | Blowfish bOut( fOut ); | 73 | BlowfishOfb bOut( fOut ); |
74 | bOut.setIv("01234567"); | ||
73 | bOut.setPassword("abcdefghijklmnop"); | 75 | bOut.setPassword("abcdefghijklmnop"); |
74 | bOut.write( fIn.readAll() ); | 76 | bOut.write( fIn.readAll() ); |
75 | } | 77 | } |
76 | */ | ||
77 | /* | ||
78 | { | 78 | { |
79 | File fIn("data.java", File::Read ); | 79 | File fIn("data.java", File::Read ); |
80 | File fOut("data.stuff", File::WriteNew ); | 80 | File fOut("data.stuff", File::WriteNew ); |
81 | 81 | ||
82 | Blowfish bIn( fIn ); | 82 | BlowfishOfb bIn( fIn ); |
83 | bIn.setIv("01234567"); | ||
83 | bIn.setPassword("abcdefghijklmnop"); | 84 | bIn.setPassword("abcdefghijklmnop"); |
84 | char buf[64]; | 85 | char buf[64]; |
85 | bIn.read( buf, 64 ); | 86 | bIn.read( buf, 64 ); |
86 | fOut.write( buf, 64 ); | 87 | fOut.write( buf, 64 ); |
87 | sio << sio.nl << "All done." << sio.nl; | 88 | sio << sio.nl << "All done." << sio.nl; |
88 | } | 89 | } |
89 | */ | ||
90 | 90 | ||
91 | return 0; | 91 | return 0; |
92 | } | 92 | } |