News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Looking for an algo

Started by Nieylana, January 23, 2011, 03:33:14 AM

Previous topic - Next topic

Nieylana

I'm working on a project that requires me to be able to decrypt some data that was encrypted with Blowfish in CBC mode, I've looked everywhere i can think of but cannot seem to find a CBC mode Blowfish Algorithm in MASM. I'm aware of Drizz's Crypto Collection, but from what I could tell his Blowfish implementation is EBC mode (please do correct me if i'm wrong). I was wondering if anyone had a CBC mode algorithm that's just laying around that they'd be willing to share.

I've tried searching here along with WinASM forums and google, all to no avail, all implementations i've been able to find do not support setting the Initialization Vector (CBC Specific??).

Any help would be appreciated!

Thanks

hutch--

Nieylana,

If you have a C version of the algo you could link it into a MASM application and might get you out of trouble while you are looking for a fast assembler one.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Nieylana

upon further investigation of what exactly CBC is and how it differes from ECB, it seems relatively simple to implement in an already-existing EBC version of the code. I'm going to try my luck and see where it gets me... If i'm successfull I will post it here for others to use :D... If i'm not successful i will look into the C option. thanks for the tip! i didn't know it was possible to use C code in a MASM app....

Tedd

As far as I understand it, the algorithm is the same regardless of the mode..

EBC means you encrypt each block, separately.
CBC means each block is first XOR'd with the previous block (after encryption), and is then itself encrypted (and used for the XOR on the next block.)

The need for an 'initialization vector' ("salt") is so that the first block has something to be XOR'd with.

So, you should be able to use the same blowfish implementation, regardless of the mode you use - as long as you set up the blocks correctly. The actual data to be used for salt is arbitrary, but usually random; for this reason it will be included at the start of the encrypted data.
No snowflake in an avalanche feels responsible.

Nieylana

#4
Here is my implementation of CBC mode for Blowfish:

http://pastebin.com/kdPCYHuU

As a basis i used WiteG's Blowfish implemenation that can be found on this forum. I simply wrote the wrapper routines that perform the CBC part.