<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 21 February 2015 at 15:08, James McMurray <span dir="ltr"><<a href="mailto:jamesmcm03@gmail.com" target="_blank">jamesmcm03@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
If I run the following, for openSSL:<br>
<br>
echo -n "0123456789abcdef0123456789abcdef" | openssl aes-128-ecb<br>
-nosalt -nopad | xxd<br>
<br>
and enter the key "YELLOW SUBMARINE", I get the following ciphertext:<br>
<br>
a2a5 8316 129f c596 8341 c78a 0c36 5d20<br>
a2a5 8316 129f c596 8341 c78a 0c36 5d20<br>
<br>
Yet in PyCrypto, the following code:<br>
<br>
from Crypto.Cipher import AES<br>
key = b'YELLOW SUBMARINE'<br>
cipher = AES.new(key, AES.MODE_ECB, "")<br>
msg =  cipher.encrypt(b'0123456789abcdef0123456789abcdef')<br>
<br>
Outputs:<br>
<br>
20 1e 80 2f 7b 6a ce 6f 6c d0 a7 43 ba 78 ae ad<br>
20 1e 80 2f 7b 6a ce 6f 6c d0 a7 43 ba 78 ae ad<br>
<br>
(line breaks added for clarity)<br>
<br>
What is the cause of this discrepancy? Both are 128-bit AES in ECB<br>
mode. PyCrypto doesn't appear to be salting, and padding should be<br>
unnecessary in any case with this plaintext.<br></blockquote><div><br></div><div>OpenSSL doesn't use the passphrase directly, it applies a key derivation function to it. Use -K to specify a key explicitly (as a string of hex).</div><div><br></div><div>Cheers</div><div><br></div><div>Rich. </div></div></div></div>