diff options
Diffstat (limited to 'pipermail/pycrypto/2015q1/000833.html')
-rw-r--r-- | pipermail/pycrypto/2015q1/000833.html | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/pipermail/pycrypto/2015q1/000833.html b/pipermail/pycrypto/2015q1/000833.html new file mode 100644 index 0000000..dfdd7ff --- /dev/null +++ b/pipermail/pycrypto/2015q1/000833.html @@ -0,0 +1,100 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<HTML> + <HEAD> + <TITLE> [pycrypto] Why does PyCrypto not produce the same ciphertext as OpenSSL in this example (AES-128 ECB) + </TITLE> + <LINK REL="Index" HREF="index.html" > + <LINK REL="made" HREF="mailto:pycrypto%40lists.dlitz.net?Subject=Re%3A%20%5Bpycrypto%5D%20Why%20does%20PyCrypto%20not%20produce%20the%20same%20ciphertext%20as%0A%20OpenSSL%20in%20this%20example%20%28AES-128%20ECB%29&In-Reply-To=%3CCAMp7mVurt-kQetrcEZtVtz-aJ721WoahjXmKyfySRczu-BmXWA%40mail.gmail.com%3E"> + <META NAME="robots" CONTENT="index,nofollow"> + <style type="text/css"> + pre { + white-space: pre-wrap; /* css-2.1, curent FF, Opera, Safari */ + } + </style> + <META http-equiv="Content-Type" content="text/html; charset=us-ascii"> + <LINK REL="Previous" HREF="000832.html"> + + </HEAD> + <BODY BGCOLOR="#ffffff"> + <H1>[pycrypto] Why does PyCrypto not produce the same ciphertext as OpenSSL in this example (AES-128 ECB)</H1> + <B>Richard Moore</B> + <A HREF="mailto:pycrypto%40lists.dlitz.net?Subject=Re%3A%20%5Bpycrypto%5D%20Why%20does%20PyCrypto%20not%20produce%20the%20same%20ciphertext%20as%0A%20OpenSSL%20in%20this%20example%20%28AES-128%20ECB%29&In-Reply-To=%3CCAMp7mVurt-kQetrcEZtVtz-aJ721WoahjXmKyfySRczu-BmXWA%40mail.gmail.com%3E" + TITLE="[pycrypto] Why does PyCrypto not produce the same ciphertext as OpenSSL in this example (AES-128 ECB)">richmoore44 at gmail.com + </A><BR> + <I>Sat Feb 21 07:38:05 PST 2015</I> + <P><UL> + <LI>Previous message: <A HREF="000832.html">[pycrypto] Why does PyCrypto not produce the same ciphertext as OpenSSL in this example (AES-128 ECB) +</A></li> + + <LI> <B>Messages sorted by:</B> + <a href="date.html#833">[ date ]</a> + <a href="thread.html#833">[ thread ]</a> + <a href="subject.html#833">[ subject ]</a> + <a href="author.html#833">[ author ]</a> + </LI> + </UL> + <HR> +<!--beginarticle--> +<PRE>On 21 February 2015 at 15:08, James McMurray <<A HREF="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto">jamesmcm03 at gmail.com</A>> wrote: + +><i> Hi, +</I>><i> +</I>><i> If I run the following, for openSSL: +</I>><i> +</I>><i> echo -n "0123456789abcdef0123456789abcdef" | openssl aes-128-ecb +</I>><i> -nosalt -nopad | xxd +</I>><i> +</I>><i> and enter the key "YELLOW SUBMARINE", I get the following ciphertext: +</I>><i> +</I>><i> a2a5 8316 129f c596 8341 c78a 0c36 5d20 +</I>><i> a2a5 8316 129f c596 8341 c78a 0c36 5d20 +</I>><i> +</I>><i> Yet in PyCrypto, the following code: +</I>><i> +</I>><i> from Crypto.Cipher import AES +</I>><i> key = b'YELLOW SUBMARINE' +</I>><i> cipher = AES.new(key, AES.MODE_ECB, "") +</I>><i> msg = cipher.encrypt(b'0123456789abcdef0123456789abcdef') +</I>><i> +</I>><i> Outputs: +</I>><i> +</I>><i> 20 1e 80 2f 7b 6a ce 6f 6c d0 a7 43 ba 78 ae ad +</I>><i> 20 1e 80 2f 7b 6a ce 6f 6c d0 a7 43 ba 78 ae ad +</I>><i> +</I>><i> (line breaks added for clarity) +</I>><i> +</I>><i> What is the cause of this discrepancy? Both are 128-bit AES in ECB +</I>><i> mode. PyCrypto doesn't appear to be salting, and padding should be +</I>><i> unnecessary in any case with this plaintext. +</I>><i> +</I> +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). + +Cheers + +Rich. +-------------- next part -------------- +An HTML attachment was scrubbed... +URL: <<A HREF="http://lists.dlitz.net/pipermail/pycrypto/attachments/20150221/b45aefe1/attachment.html">http://lists.dlitz.net/pipermail/pycrypto/attachments/20150221/b45aefe1/attachment.html</A>> +</PRE> + +<!--endarticle--> + <HR> + <P><UL> + <!--threads--> + <LI>Previous message: <A HREF="000832.html">[pycrypto] Why does PyCrypto not produce the same ciphertext as OpenSSL in this example (AES-128 ECB) +</A></li> + + <LI> <B>Messages sorted by:</B> + <a href="date.html#833">[ date ]</a> + <a href="thread.html#833">[ thread ]</a> + <a href="subject.html#833">[ subject ]</a> + <a href="author.html#833">[ author ]</a> + </LI> + </UL> + +<hr> +<a href="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto">More information about the pycrypto +mailing list</a><br> +</body></html> |