How exactly does mcrypt implement rijndael-256 and how to make compatible

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jens Müller

    How exactly does mcrypt implement rijndael-256 and how to make compatible

    Hello,

    I try to program a Rijndael encryption in Windows which has to be
    compatible with php.

    In php I use the code below to encrypt with a 256 Bit Key and a 256 Bit
    block cipher.
    My windows code has the same specs, but the outcome is different.

    So far I use no iv to facilitate.

    I want to get more information on mcrypt_generic - how is the data
    padded to multiples of 32 - my code adds Ascii 0.
    I read somewhere on the internet that mcrypt added not ascii 0 but the
    ascii value of the number of the padded bytes - still with this
    modification of my code the result is different.

    Where is the information about the length of the encoded string stored?
    My code uses the first 4 bytes (but even if I do not store the length,
    the outcome is different).

    If no detailed information about mcrypt is available, I would be helped
    if I could find a pute php Rijndael implementation so that I can adjust
    it to work with my windows code. Is such an implementation available?

    Thanks a lot,
    Jens


    $key = 'Key';
    $string = 'Plain text';
    $td = mcrypt_module_o pen('rijndael-256', '', 'cbc', '');
    $iv_size = mcrypt_enc_get_ iv_size($td);
    $iv = str_repeat(chr( 0), $iv_size);
    if (mcrypt_generic _init($td, $key, $iv) != -1) {
    $c_t = mcrypt_generic( $td, $string);
    mcrypt_generic_ deinit($td);
    mcrypt_module_c lose($td);
    }

Working...