From b93f18e1dd303fb648bc350416f7f5ace536fd1f Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 7 Apr 2012 21:46:17 +0000 Subject: Blowfish now passes all standard test vectors on little endian. I don't know about big endian...we can hope. --- src/experimental/blowfish.cpp | 23 ++++++++++++++++------- src/experimental/blowfish.h | 22 +++++++++++----------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/experimental/blowfish.cpp b/src/experimental/blowfish.cpp index 401291c..3dda87a 100644 --- a/src/experimental/blowfish.cpp +++ b/src/experimental/blowfish.cpp @@ -18,11 +18,13 @@ Bu::Blowfish::~Blowfish() reset(); } +#define revBytes( x ) x = (((x&0xff)<<24)|((x&0xff00)<<8)|((x&0xff0000)>>8)|((x&0xff000000)>>24)) + void Bu::Blowfish::setPassword( const Bu::String &sPass ) { reset(); - unsigned int i,j,len=sPass.getSize(); + uint32_t i,j,len=sPass.getSize(); Word Work,null0,null1; if (len > 0) @@ -70,7 +72,7 @@ Bu::size Bu::Blowfish::stop() Bu::size Bu::Blowfish::read( void *pBuf, Bu::size iBytes ) { - unsigned int i; + uint32_t i; DWord dwWork; if (iBytes%8) @@ -83,8 +85,11 @@ Bu::size Bu::Blowfish::read( void *pBuf, Bu::size iBytes ) for (i=0;i