Crypto++ and blowfish-compat

32 views
Skip to first unread message

Razvan Cojocaru

unread,
Aug 22, 2019, 6:18:09 AM8/22/19
to Crypto++ Users
Hello,

Is it possible to trick crypto++ into using blowfish-compat?


I saw ByteOrder being used in several headers, but it doesn't appear to apply to this case. The blowfish algorithm itself appears to ignore it and the comments say it's only relevant for other encryption types.

Thanks,
Razvan

Razvan Cojocaru

unread,
Aug 22, 2019, 3:21:18 PM8/22/19
to cryptop...@googlegroups.com
As it turns out, only this change appears to be needed:

diff --git a/blowfish.cpp b/blowfish.cpp
index e615da3b..12213c0e 100644
--- a/blowfish.cpp
+++ b/blowfish.cpp
@@ -70,7 +70,7 @@ void Blowfish::Base::crypt_block(const word32 in[2],
word32 out[2]) const

void Blowfish::Base::ProcessAndXorBlock(const byte *inBlock, const byte
*xorBlock, byte *outBlock) const
{
- typedef BlockGetAndPut<word32, BigEndian> Block;
+ typedef BlockGetAndPut<word32, LittleEndian> Block;

word32 left, right;
Block::Get(inBlock)(left)(right);

But I'd like to do a proper pull request and have this upstream. I'm
guessing the way to go is to add a new BlowfishCompat class, like XTEA
is for TEA? In which case we need to think about the statics in
bfinit.cpp, we probably don't want to copy-paste them.

Or can we somehow add a parameter to the current Blowfish class
somewhere to switch on the compat behaviour when needed?


Thanks,
Razvan

Razvan Cojocaru

unread,
Aug 24, 2019, 12:52:41 PM8/24/19
to cryptop...@googlegroups.com
On 8/22/19 1:18 PM, Razvan Cojocaru wrote:
Pull request submitted: https://github.com/weidai11/cryptopp/pull/877

Razvan Cojocaru

unread,
Sep 9, 2019, 2:44:27 AM9/9/19
to cryptop...@googlegroups.com
Hello again, when you've got a spare moment please don't forget to check
if the latest incarnation of the pull request (about two weeks old now)
is to your liking.

I'm happy to update it if it needs more work in any way.


Thanks,
Razvan
Reply all
Reply to author
Forward
0 new messages