|
Andre - 2007-08-21 16:38:49
Does anyone know how to get the Initialization Vector? How do you decrypt an AES encrypted string in a different language(Java,Ruby) using this implementation?
Current Implementation I have in Ruby(ruby-aes) requires a Key,Key Length, IV, and Mode. I understand that I can match the KL to match 128bit, but what mode is this package and why isn't there an IV?
Great work and thank you for releasing it under LGPL.
Michael Modica - 2007-12-06 00:31:35 - In reply to message 1 from Andre
There is no mode or initialization vector involved because these are used to randomize a string of blocks before encryption, for greater security.
See: http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation
Two things that I'd like to point out, that wasn't obvious to me when first trying out this library:
The first is that this library encrypts and decrypts only one block (16 characters or 128 bits). To work with longer messages, you would have to do the grunt work of chopping your message up into blocks, using Cypher Block Chaining or some other block cypher mode (if desired), feeding the blocks to this library for encryption, one at a time, and sticking the results back together into one cyphertext string (reverse all these steps for decryption).
The other thing is that regular text messages should use the false value for boolHex (this is the default if the parameters are missing). The cyphertext that results from encoding (or is decoded) will be in pure binary, which is a little hard to deal with. It would be nice if there were an option for this to be in hexadecimal. For the time being, I've changed the library functions toHexString and fromHexString from Private to Public, which allows me to use them in my own code, like this:
$aes=new AES128(); /* BoolHex = false (or use no parameters) when you want to use plain text messages and keys */
$key=$aes->makeKey("This is my key!!"); /* key is 16 chars long */
$ct=$aes->blockEncrypt("This is my house", $key); /* message is 16 chars long */
$hexifiedCypher = $aes->toHexString($ct);
$cpt=$aes->blockDecrypt($aes->fromHexString($hexifiedCypher), $key);
echo("HexCypherText: $hexifiedCypher <br/> PlainText: $cpt <br/>");
Michael Modica - 2007-12-06 00:56:18 - In reply to message 2 from Michael Modica
Ooops, what I consider "no mode" has a name: Electronic Code Book. I think that if you set the mode to ECB, it might work for you. The comments about message length still applies.
|