From 2c6cbad869b0e60b37859c3c4f0c850721d057ce Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 7 Apr 2012 18:01:20 +0000 Subject: Basic blowfish encryption filter. It needs to be silghtly more clever. I'm going to steal the extra cleverness from the AesFilter in fishtrax. --- src/config.h | 5 +- src/experimental/blowfish.cpp | 444 ++++++++++++++++++++++++++++++++++++++++++ src/experimental/blowfish.h | 73 +++++++ 3 files changed, 521 insertions(+), 1 deletion(-) create mode 100644 src/experimental/blowfish.cpp create mode 100644 src/experimental/blowfish.h diff --git a/src/config.h b/src/config.h index 260d406..72f5870 100644 --- a/src/config.h +++ b/src/config.h @@ -20,7 +20,10 @@ #ifndef WIN32 #include "bu/autoconfig.h" #else -#warning Cannot generate an autoinclude file for windows yet +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __PDP_ENDIAN 3412 +#define __BYTE_ORDER __LITTLE_ENDIAN #endif diff --git a/src/experimental/blowfish.cpp b/src/experimental/blowfish.cpp new file mode 100644 index 0000000..401291c --- /dev/null +++ b/src/experimental/blowfish.cpp @@ -0,0 +1,444 @@ +#include "bu/blowfish.h" + +#include "bu/sio.h" + +using Bu::sio; + +#define F(x) \ + (((SB[0][x.byte.zero] + SB[1][x.byte.one]) ^ SB[2][x.byte.two]) + \ + SB[3][x.byte.three]) + +Bu::Blowfish::Blowfish( Bu::Stream &rNext ) : + Bu::Filter( rNext ) +{ +} + +Bu::Blowfish::~Blowfish() +{ + reset(); +} + +void Bu::Blowfish::setPassword( const Bu::String &sPass ) +{ + reset(); + + unsigned int i,j,len=sPass.getSize(); + Word Work,null0,null1; + + if (len > 0) + { + j = 0; + for (i=0;i