diff options
Diffstat (limited to 'pipermail/pycrypto/attachments/20150221/b45aefe1/attachment.html')
-rw-r--r-- | pipermail/pycrypto/attachments/20150221/b45aefe1/attachment.html | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/pipermail/pycrypto/attachments/20150221/b45aefe1/attachment.html b/pipermail/pycrypto/attachments/20150221/b45aefe1/attachment.html new file mode 100644 index 0000000..b8ba66e --- /dev/null +++ b/pipermail/pycrypto/attachments/20150221/b45aefe1/attachment.html @@ -0,0 +1,32 @@ +<tt> +<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> +<br><br> +If I run the following, for openSSL:<br><br> +<br><br> +echo -n "0123456789abcdef0123456789abcdef" | openssl aes-128-ecb<br><br> +-nosalt -nopad | xxd<br><br> +<br><br> +and enter the key "YELLOW SUBMARINE", I get the following ciphertext:<br><br> +<br><br> +a2a5 8316 129f c596 8341 c78a 0c36 5d20<br><br> +a2a5 8316 129f c596 8341 c78a 0c36 5d20<br><br> +<br><br> +Yet in PyCrypto, the following code:<br><br> +<br><br> +from Crypto.Cipher import AES<br><br> +key = b'YELLOW SUBMARINE'<br><br> +cipher = AES.new(key, AES.MODE_ECB, "")<br><br> +msg = cipher.encrypt(b'0123456789abcdef0123456789abcdef')<br><br> +<br><br> +Outputs:<br><br> +<br><br> +20 1e 80 2f 7b 6a ce 6f 6c d0 a7 43 ba 78 ae ad<br><br> +20 1e 80 2f 7b 6a ce 6f 6c d0 a7 43 ba 78 ae ad<br><br> +<br><br> +(line breaks added for clarity)<br><br> +<br><br> +What is the cause of this discrepancy? Both are 128-bit AES in ECB<br><br> +mode. PyCrypto doesn't appear to be salting, and padding should be<br><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><br> + +</tt> |