mcrypt key modes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I've spent some time reading manpages and examples in vain; I cannot
figure out how the key modes function in mcrypt.

I would like to know what input mcrypt expects and what's done to the
key internally before encryption.

1. What´s the default input format? Binary? Hex? String?
2. Is the key hashed (SHA-1? as told in an old manpage),
padded/truncated to fit the algoritm?

I'm encrypting with a password (string). If I stick to the default key
mode, should the key passed to mcrypt be in binary form? Should it be
truncated to the appropriate length?

I've tested to hash the key to HEX, trunkate it and binarise it with
pack (as in the example in the manpage). As an alternative I've tested
to hash it directly to binary form and not truncate. Both ways work as a
charm, but are not compatible: the same password cannot decrypt both
variants.

    $ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key,
                                 $plaintext, MCRYPT_MODE_CBC, $iv);

Ideally I would like to use some keywrapping eg PBKDF2. What key mode
would be appropriate? How to proceed?

Yours,
Per Tunedal

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux