BaH.Crypto

BlitzMax Modules Forums/Brucey's Modules/BaH.Crypto

Well, it's been such a long time since I came out with a new module (if you don't count the one from a week or so ago :-p ), that I thought I should just knock together something for the weekend.

The Crypto module uses OpenSSL's crypto libs ( "libcrypto" on Linux/Mac and "eay32.dll" on Win32) to do all the hard work of ciphering.

It currently supports BlowFish, CAST, DES, RC2, RC4 and RC5, in various modes (see HERE for a good description of the modes and how they work).

Currently only tested on OS X, which has OpenSSL installed by default. Linux should be okay too, as most distros package OpenSSL, although you may need to download the Dev package.

On Win32, you'll need the OpenSSL DLLs. I've shipped the MinGW .a and includes, so it might compile. (Haven't tested this yet.. Later today hopefully - once Eskom turn the power back on - bloody rolling blackouts!)

Available in SVN only until it's all working fine on all platforms...

http://code.google.com/p/maxmods/wiki/CryptoModule

:o)


Oh, and I hope to be adding Digest support in the not too distant future too. (eg. HMAC, MD2, MD5, MDC2, SHA and RIPEMD-160)

Now working fine on Win32... Yay!

Seems RC5 isn't compiled into the "usual" libs on Windows, so I've left it out of the module on that platform.

Downloading and installing "Win32 OpenSSL v0.9.8g Light" from HERE is enough to get the examples running. Note, if you want to distribute the libs with your app, you might want to include the libeay32.dll that gets installed into the system32 folder.

:o)

Since everything *appears* to be working as expected so far... the first release is now available from HERE.

Compiled mod, then installed "Win32 OpenSSL v0.9.8g Light".

BOTH examples give me this error.
The procedure entry point EVP_bf_cfb64 could not be located in the dynamic link library libeay32.dll.


Did I miss anything?

Haw... that's strange.

Originally tested it on XP, worked okay.
Just installed OpenSSL on Win2k and it is also working as expected.

Are you sure that you are using that latest dll? (perhaps there is another on your PATH that is found first?)

Try copying it into the app dir and see if that works better?
(when I installed v0.9.8g onto the win2k, it did ask if I wanted to overwrite the DLLs in System32 - which I said yes to).

Ahh.. the problem was, I initially installed an older version (didn't look to much at the instructions you gave) of the OpenSSL dll, which I placed in the app and sys32 dir.

After installing v0.9.8g I didn't replace the one in the app dir with the new dll (which the installer placed in sys32).

Works now :)

Any idea when IDEA will be supported Brucey?

Also, which encryption in the mod is the fastest?

IDEA seems to excluded from most default builds of OpenSSL because of patent issues with Ascom-Tech AG. It appears you need a license for commercial apps.

As for the fastest, I haven't given them all a thorough test. You might wish to try the different combinations of the algorithms with the various modes.

is this module used to encrypt files?

If you like.

There's an example which shows how to use a TStream for input/output.
In theory you could then also use a RamStream and do stuff in-memory, assuming you setup enough space for it (streaming out of ram shouldn't be a problem).

The other example shows encryption from/to a String.

Basically, all you need is some kind of data to feed it.