summaryrefslogtreecommitdiff
path: root/pipermail/pycrypto/2010q2/000230.html
diff options
context:
space:
mode:
Diffstat (limited to 'pipermail/pycrypto/2010q2/000230.html')
-rw-r--r--pipermail/pycrypto/2010q2/000230.html306
1 files changed, 306 insertions, 0 deletions
diff --git a/pipermail/pycrypto/2010q2/000230.html b/pipermail/pycrypto/2010q2/000230.html
new file mode 100644
index 0000000..4a2443b
--- /dev/null
+++ b/pipermail/pycrypto/2010q2/000230.html
@@ -0,0 +1,306 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML>
+ <HEAD>
+ <TITLE> [pycrypto] Pycrypto question.
+ </TITLE>
+ <LINK REL="Index" HREF="index.html" >
+ <LINK REL="made" HREF="mailto:pycrypto%40lists.dlitz.net?Subject=%5Bpycrypto%5D%20Pycrypto%20question.&In-Reply-To=4BE06ED7.7040003%40amberfisharts.com">
+ <META NAME="robots" CONTENT="index,nofollow">
+ <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
+ <LINK REL="Previous" HREF="000228.html">
+ <LINK REL="Next" HREF="000231.html">
+ </HEAD>
+ <BODY BGCOLOR="#ffffff">
+ <H1>[pycrypto] Pycrypto question.</H1>
+ <B>jd</B>
+ <A HREF="mailto:pycrypto%40lists.dlitz.net?Subject=%5Bpycrypto%5D%20Pycrypto%20question.&In-Reply-To=4BE06ED7.7040003%40amberfisharts.com"
+ TITLE="[pycrypto] Pycrypto question.">jdsw2002 at yahoo.com
+ </A><BR>
+ <I>Wed May 5 11:05:49 CST 2010</I>
+ <P><UL>
+ <LI>Previous message: <A HREF="000228.html">[pycrypto] Pycrypto question.
+</A></li>
+ <LI>Next message: <A HREF="000231.html">[pycrypto] Pycrypto question.
+</A></li>
+ <LI> <B>Messages sorted by:</B>
+ <a href="date.html#230">[ date ]</a>
+ <a href="thread.html#230">[ thread ]</a>
+ <a href="subject.html#230">[ subject ]</a>
+ <a href="author.html#230">[ author ]</a>
+ </LI>
+ </UL>
+ <HR>
+<!--beginarticle-->
+<PRE>Thanks this helps clarify few things.
+
+Couple od questions.
+1. I am on older version of pycrypto, can I simply use os.urandom for random # ?
+2. Do I really need a separate block encryption for the message ?
+
+ I know this may sound strange.. but asymmetric keys gives you ability to encrypt right ? So is there a big problem .. using it in the following manner ?
+
+ x=RSAkey.decrypt(&quot;Foo Bar&quot;) # This will use the private key
+
+ pub = RSAkey.publickey()
+ pub.encrypt(x,0) # This will use the public key and give me &quot;Foo Bar&quot; back.
+
+ Any restriction on the content being encrypted /decrypted ?
+
+Thanks for awesome response.
+/Jd
+
+
+--- On Tue, 5/4/10, Lorenz Quack &lt;<A HREF="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto">don at amberfisharts.com</A>&gt; wrote:
+
+&gt;<i> From: Lorenz Quack &lt;<A HREF="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto">don at amberfisharts.com</A>&gt;
+</I>&gt;<i> Subject: Re: [pycrypto] Pycrypto question.
+</I>&gt;<i> To: &quot;PyCrypto discussion list&quot; &lt;<A HREF="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto">pycrypto at lists.dlitz.net</A>&gt;
+</I>&gt;<i> Date: Tuesday, May 4, 2010, 12:00 PM
+</I>&gt;<i> Hi jd,
+</I>&gt;<i>
+</I>&gt;<i> some time ago I wrote a small module which provided me with
+</I>&gt;<i> a API that suited me better than that of PyCrypto.
+</I>&gt;<i> I attached a slightly modified version of it. I also added
+</I>&gt;<i> a short example to the end of it. I hope you can find the
+</I>&gt;<i> information you want in there.
+</I>&gt;<i>
+</I>&gt;<i> Concerning the documentation: I agree, it could be
+</I>&gt;<i> improved. I think you were looking for this [1].
+</I>&gt;<i>
+</I>&gt;<i> Concerning the import of externally generated keys: I think
+</I>&gt;<i> this came up before on the list or bug tracker.
+</I>&gt;<i> AFAIK, it is not directly supported by PyCrypto. However,
+</I>&gt;<i> you can create a key pair from a tuple of numbers
+</I>&gt;<i> (for example the public and private exponent and the
+</I>&gt;<i> modulus). This is done with construct function [2].
+</I>&gt;<i> You just have to find a way to get to those numbers of your
+</I>&gt;<i> externally generated keys.
+</I>&gt;<i>
+</I>&gt;<i> I probably should also point out that the usage of
+</I>&gt;<i> RandomPool is strongly discouraged [3] and that there is a
+</I>&gt;<i> Random
+</I>&gt;<i> module in PyCrypto-2.1 that you should use instead.
+</I>&gt;<i>
+</I>&gt;<i> sincerely yours
+</I>&gt;<i> //Lorenz
+</I>&gt;<i>
+</I>&gt;<i> [1] <A HREF="http://www.dlitz.net/software/pycrypto/apidoc/Crypto.PublicKey.pubkey.pubkey-class.html">http://www.dlitz.net/software/pycrypto/apidoc/Crypto.PublicKey.pubkey.pubkey-class.html</A>
+</I>&gt;<i> [2] <A HREF="http://www.dlitz.net/software/pycrypto/apidoc/Crypto.PublicKey.RSA-module.html">http://www.dlitz.net/software/pycrypto/apidoc/Crypto.PublicKey.RSA-module.html</A>
+</I>&gt;<i> [3] <A HREF="http://lists.dlitz.net/pipermail/pycrypto/2008q3/000000.html">http://lists.dlitz.net/pipermail/pycrypto/2008q3/000000.html</A>
+</I>&gt;<i>
+</I>&gt;<i>
+</I>&gt;<i>
+</I>&gt;<i> On 05/04/2010 07:04 PM, jd wrote:
+</I>&gt;<i> &gt; Thanks for the response.(Sorry ..for late response.
+</I>&gt;<i> Somehow this went in to my spam folder.)
+</I>&gt;<i> &gt;
+</I>&gt;<i> &gt; Yes, I indeed want to use private key to encrypt
+</I>&gt;<i> (oops.. sign) and decrypt (verify) using public/private key
+</I>&gt;<i> pairs.
+</I>&gt;<i> &gt;
+</I>&gt;<i> &gt;
+</I>&gt;<i> &gt; Would anyone point to the example usage/pseudo code
+</I>&gt;<i> that I can try out.
+</I>&gt;<i> &gt;
+</I>&gt;<i> &gt; Didnt find method details over here.
+</I>&gt;<i> &gt; <A HREF="http://www.dlitz.net/software/pycrypto/apidoc/Crypto.PublicKey.RSA-module.html">http://www.dlitz.net/software/pycrypto/apidoc/Crypto.PublicKey.RSA-module.html</A>
+</I>&gt;<i> &gt;
+</I>&gt;<i> &gt; I am assuming that the intent is clear from the
+</I>&gt;<i> example.
+</I>&gt;<i> &gt; Some Text ===&gt;&#160; Encrypt (optionally) sign
+</I>&gt;<i> (using private key) ===&gt;&#160; encrypted message
+</I>&gt;<i> &gt; encrypted message ==&gt;&#160; (optionally) Verify and
+</I>&gt;<i> decrypt (using public key) ==&gt;&#160; original message
+</I>&gt;<i> (Some Text)
+</I>&gt;<i> &gt;
+</I>&gt;<i> &gt; Also, would appreciate if instead of generating keys
+</I>&gt;<i> as in sample program, is there a way to use publick/private
+</I>&gt;<i> keys used by ssh-keygen -t rsa.
+</I>&gt;<i> &gt;
+</I>&gt;<i> &gt; Help is much appreciated.
+</I>&gt;<i> &gt; Thanks
+</I>&gt;<i> &gt;
+</I>&gt;<i> &gt;
+</I>&gt;<i> &gt;
+</I>&gt;<i> &gt;
+</I>&gt;<i> &gt; /Jd
+</I>&gt;<i> &gt;
+</I>&gt;<i> &gt;
+</I>&gt;<i> &gt; --- On Sun, 5/2/10, Lorenz Quack&lt;<A HREF="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto">don at amberfisharts.com</A>&gt;&#160;
+</I>&gt;<i> wrote:
+</I>&gt;<i> &gt;
+</I>&gt;<i> &gt;&gt; From: Lorenz Quack&lt;<A HREF="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto">don at amberfisharts.com</A>&gt;
+</I>&gt;<i> &gt;&gt; Subject: Re: [pycrypto] Pycrypto question.
+</I>&gt;<i> &gt;&gt; To: &quot;PyCrypto discussion list&quot;&lt;<A HREF="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto">pycrypto at lists.dlitz.net</A>&gt;
+</I>&gt;<i> &gt;&gt; Date: Sunday, May 2, 2010, 1:52 PM
+</I>&gt;<i> &gt;&gt; On 05/02/2010 10:36 PM, Glenn
+</I>&gt;<i> &gt;&gt; Linderman wrote:
+</I>&gt;<i> &gt;&gt;&gt; On 5/2/2010 1:13 PM, Lorenz Quack wrote:
+</I>&gt;<i> &gt;&gt;&gt;&gt; Hi Jd,
+</I>&gt;<i> &gt;&gt;&gt;&gt;
+</I>&gt;<i> &gt;&gt;&gt;&gt; On 05/02/2010 10:02 PM, jd wrote:
+</I>&gt;<i> &gt;&gt;&gt;&gt;
+</I>&gt;<i> &gt;&gt;&gt;&gt;&gt; Hi everyone,
+</I>&gt;<i> &gt;&gt;&gt;&gt;&gt;
+</I>&gt;<i> &gt;&gt;&gt;&gt;&gt; I am trying to implement a simple
+</I>&gt;<i> pub/private
+</I>&gt;<i> &gt;&gt; key scheme. Want to encrypt bunch of things and
+</I>&gt;<i> decrypt it
+</I>&gt;<i> &gt;&gt; using public
+</I>&gt;<i> &gt;&gt;&gt;&gt;&gt; key (which will be distributed).
+</I>&gt;<i> &gt;&gt;&gt;&gt;&gt;
+</I>&gt;<i> &gt;&gt;&gt;&gt; You seem to have some misconceptions about
+</I>&gt;<i> how
+</I>&gt;<i> &gt;&gt; public key cryptography works.
+</I>&gt;<i> &gt;&gt;&gt;&gt; I suggest you (re-)read up on it.
+</I>&gt;<i> Wikipedia will
+</I>&gt;<i> &gt;&gt; probably cover the basics.
+</I>&gt;<i> &gt;&gt;&gt;&gt; For starters, by definition you use the
+</I>&gt;<i> *public*
+</I>&gt;<i> &gt;&gt; key for encrypt and the privat one for
+</I>&gt;<i> decryption.
+</I>&gt;<i> &gt;&gt;&gt;&gt;
+</I>&gt;<i> &gt;&gt;&gt;
+</I>&gt;<i> &gt;&gt;&gt; Indeed, Wikipedia has an article. And in the
+</I>&gt;<i> first
+</I>&gt;<i> &gt;&gt; paragraph [1] they
+</I>&gt;<i> &gt;&gt;&gt; describe one use case for encrypting by public
+</I>&gt;<i> key,
+</I>&gt;<i> &gt;&gt; and decrypting by
+</I>&gt;<i> &gt;&gt;&gt; private key, and another use case for
+</I>&gt;<i> encrypting by
+</I>&gt;<i> &gt;&gt; private key, and
+</I>&gt;<i> &gt;&gt;&gt; decrypting by public key. It might be
+</I>&gt;<i> appropriate to
+</I>&gt;<i> &gt;&gt; figure out what use
+</I>&gt;<i> &gt;&gt;&gt; case the OP has before declaring definitions
+</I>&gt;<i> for a
+</I>&gt;<i> &gt;&gt; particular use case.
+</I>&gt;<i> &gt;&gt;&gt; Now as far as what the APIs are called, that
+</I>&gt;<i> might be
+</I>&gt;<i> &gt;&gt; a different story :)
+</I>&gt;<i> &gt;&gt;&gt;
+</I>&gt;<i> &gt;&gt;&gt; [1] *Public-key cryptography* is a
+</I>&gt;<i> cryptographic
+</I>&gt;<i> &gt;&gt;&gt; &lt;<A HREF="http://en.wikipedia.org/wiki/Cryptography">http://en.wikipedia.org/wiki/Cryptography</A>&gt;&#160;
+</I>&gt;<i> approach
+</I>&gt;<i> &gt;&gt; which involves the
+</I>&gt;<i> &gt;&gt;&gt; use of asymmetric key algorithms instead of or
+</I>&gt;<i> in
+</I>&gt;<i> &gt;&gt; addition to symmetric
+</I>&gt;<i> &gt;&gt;&gt; key algorithms&lt;<A HREF="http://en.wikipedia.org/wiki/Symmetric_key_algorithm">http://en.wikipedia.org/wiki/Symmetric_key_algorithm</A>&gt;.
+</I>&gt;<i> &gt;&gt;&gt; Unlike symmetric key algorithms, it does not
+</I>&gt;<i> require a
+</I>&gt;<i> &gt;&gt; secure
+</I>&gt;<i> &gt;&gt;&gt; &lt;<A HREF="http://en.wikipedia.org/wiki/Secure_channel">http://en.wikipedia.org/wiki/Secure_channel</A>&gt;&#160;
+</I>&gt;<i> initial
+</I>&gt;<i> &gt;&gt; exchange
+</I>&gt;<i> &gt;&gt;&gt; &lt;<A HREF="http://en.wikipedia.org/wiki/Key_exchange">http://en.wikipedia.org/wiki/Key_exchange</A>&gt;&#160; of
+</I>&gt;<i> one or
+</I>&gt;<i> &gt;&gt; more secret keys
+</I>&gt;<i> &gt;&gt;&gt; &lt;<A HREF="http://en.wikipedia.org/wiki/Secret_key">http://en.wikipedia.org/wiki/Secret_key</A>&gt;&#160; to
+</I>&gt;<i> both
+</I>&gt;<i> &gt;&gt; sender and receiver.
+</I>&gt;<i> &gt;&gt;&gt; The asymmetric key algorithms are used to
+</I>&gt;<i> create a
+</I>&gt;<i> &gt;&gt; mathematically
+</I>&gt;<i> &gt;&gt;&gt; related key pair: a secret private key and a
+</I>&gt;<i> published
+</I>&gt;<i> &gt;&gt; public key. Use
+</I>&gt;<i> &gt;&gt;&gt; of these keys allows protection of the
+</I>&gt;<i> authenticity
+</I>&gt;<i> &gt;&gt;&gt; &lt;<A HREF="http://en.wikipedia.org/wiki/Authenticity">http://en.wikipedia.org/wiki/Authenticity</A>&gt;&#160; of
+</I>&gt;<i> a
+</I>&gt;<i> &gt;&gt; message by creating a
+</I>&gt;<i> &gt;&gt;&gt; digital signature&lt;<A HREF="http://en.wikipedia.org/wiki/Digital_signature">http://en.wikipedia.org/wiki/Digital_signature</A>&gt;&#160;
+</I>&gt;<i> of
+</I>&gt;<i> &gt;&gt; a
+</I>&gt;<i> &gt;&gt;&gt; message using the private key, which can be
+</I>&gt;<i> verified
+</I>&gt;<i> &gt;&gt; using the public
+</I>&gt;<i> &gt;&gt;&gt; key. It also allows protection of the
+</I>&gt;<i> confidentiality
+</I>&gt;<i> &gt;&gt;&gt; &lt;<A HREF="http://en.wikipedia.org/wiki/Confidentiality">http://en.wikipedia.org/wiki/Confidentiality</A>&gt;&#160;
+</I>&gt;<i> and
+</I>&gt;<i> &gt;&gt; integrity
+</I>&gt;<i> &gt;&gt;&gt; &lt;<A HREF="http://en.wikipedia.org/wiki/Integrity">http://en.wikipedia.org/wiki/Integrity</A>&gt;&#160; of a
+</I>&gt;<i> &gt;&gt; message, by public key
+</I>&gt;<i> &gt;&gt;&gt; encryption&lt;<A HREF="http://en.wikipedia.org/wiki/Encryption">http://en.wikipedia.org/wiki/Encryption</A>&gt;,
+</I>&gt;<i> encrypting
+</I>&gt;<i> &gt;&gt; the
+</I>&gt;<i> &gt;&gt;&gt; message using the public key, which can only
+</I>&gt;<i> be
+</I>&gt;<i> &gt;&gt; decrypted using the
+</I>&gt;<i> &gt;&gt;&gt; private key.
+</I>&gt;<i> &gt;&gt;&gt;
+</I>&gt;<i> &gt;&gt;
+</I>&gt;<i> &gt;&gt; Granted &quot;definition&quot; may have been a poor choice
+</I>&gt;<i> of word.
+</I>&gt;<i> &gt;&gt; But AFAIK the use case of &quot;encrypting&quot; via the
+</I>&gt;<i> private key
+</I>&gt;<i> &gt;&gt; is generally called signing.
+</I>&gt;<i> &gt;&gt; So I assumed that the OP had the wrong idea about
+</I>&gt;<i> how the
+</I>&gt;<i> &gt;&gt; scheme is used because he didn't
+</I>&gt;<i> &gt;&gt; use the generally accept terminology. If that was
+</I>&gt;<i> &gt;&gt; presumptuous I hereby apologize.
+</I>&gt;<i> &gt;&gt;
+</I>&gt;<i> &gt;&gt; So, to come back to the OPs question:
+</I>&gt;<i> &gt;&gt; if you use a RSA key to encrypt a message like you
+</I>&gt;<i> did in
+</I>&gt;<i> &gt;&gt; your example internally it uses the public
+</I>&gt;<i> &gt;&gt; part of the key pair for encryption. you would
+</I>&gt;<i> then have to
+</I>&gt;<i> &gt;&gt; use the private part to decypt it.
+</I>&gt;<i> &gt;&gt; If on the other hand you really want to encrypt
+</I>&gt;<i> with the
+</I>&gt;<i> &gt;&gt; private part and decrypt with the public part
+</I>&gt;<i> &gt;&gt; then know that this is usually refered to as
+</I>&gt;<i> signing and
+</I>&gt;<i> &gt;&gt; verifying (verification?).
+</I>&gt;<i> &gt;&gt; There is also and API for this in PyCrypto.
+</I>&gt;<i> &gt;&gt;
+</I>&gt;<i> &gt;&gt; Hope this is clearer and more helpful than my
+</I>&gt;<i> last
+</I>&gt;<i> &gt;&gt; message.
+</I>&gt;<i> &gt;&gt;
+</I>&gt;<i> &gt;&gt; have a nice day
+</I>&gt;<i> &gt;&gt; //Lorenz
+</I>&gt;<i>
+</I>&gt;<i>
+</I>&gt;<i> -----Inline Attachment Follows-----
+</I>&gt;<i>
+</I>&gt;<i> _______________________________________________
+</I>&gt;<i> pycrypto mailing list
+</I>&gt;<i> <A HREF="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto">pycrypto at lists.dlitz.net</A>
+</I>&gt;<i> <A HREF="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto">http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto</A>
+</I>&gt;<i>
+</I>
+
+
+</PRE>
+
+
+
+
+
+<!--endarticle-->
+ <HR>
+ <P><UL>
+ <!--threads-->
+ <LI>Previous message: <A HREF="000228.html">[pycrypto] Pycrypto question.
+</A></li>
+ <LI>Next message: <A HREF="000231.html">[pycrypto] Pycrypto question.
+</A></li>
+ <LI> <B>Messages sorted by:</B>
+ <a href="date.html#230">[ date ]</a>
+ <a href="thread.html#230">[ thread ]</a>
+ <a href="subject.html#230">[ subject ]</a>
+ <a href="author.html#230">[ 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>