Search code examples
phpsecuritycryptographyrijndael

How can I recover the key from RIJNDAEL 128?


I have code like this:

$result = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $plain_text, "ecb");

Also, I have values of $result and $plain_text.

Is there any way to recover the $key?


Solution

  • You cannot recover the key from direct cryptanalysis.

    You can use known-plaintext attacks to correlate known/repeated ciphertexts, especially if ECB mode is being reused. You can use Vaudenay's CBC padding oracle attack to decrypt a message one byte at a time (via a chosen ciphertext attack). You can exploit a CTR mode nonce reuse to recover plaintext from ciphertext.

    You cannot simply recover the key given plaintext and ciphertext.

    There are side-channel attacks, such as cache-timing attacks against AES (PDF), which allow an attacker to recover the key. But if you're using constant-time AES (i.e. provided by AES-NI), then these are off the table.