summaryrefslogtreecommitdiff
path: root/pipermail/pycrypto/2013q4/000740.html
blob: 4a6794e92e6e8240097f2ee0552c48dee4566c7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
 <HEAD>
   <TITLE> [pycrypto] DES3 problem
   </TITLE>
   <LINK REL="Index" HREF="index.html" >
   <LINK REL="made" HREF="mailto:pycrypto%40lists.dlitz.net?Subject=Re%3A%20%5Bpycrypto%5D%20DES3%20problem&In-Reply-To=%3CCAEncD4cvcMRpxO9diu%3DJ4ixpmPRmz-g7pADQTQPzPjfpb%2BsBzA%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="000739.html">
   <LINK REL="Next"  HREF="000741.html">
 </HEAD>
 <BODY BGCOLOR="#ffffff">
   <H1>[pycrypto] DES3 problem</H1>
    <B>Dave Pawson</B> 
    <A HREF="mailto:pycrypto%40lists.dlitz.net?Subject=Re%3A%20%5Bpycrypto%5D%20DES3%20problem&In-Reply-To=%3CCAEncD4cvcMRpxO9diu%3DJ4ixpmPRmz-g7pADQTQPzPjfpb%2BsBzA%40mail.gmail.com%3E"
       TITLE="[pycrypto] DES3 problem">dave.pawson at gmail.com
       </A><BR>
    <I>Fri Nov 29 07:49:07 PST 2013</I>
    <P><UL>
        <LI>Previous message: <A HREF="000739.html">[pycrypto] DES3 problem
</A></li>
        <LI>Next message: <A HREF="000741.html">[pycrypto] DES3 problem
</A></li>
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#740">[ date ]</a>
              <a href="thread.html#740">[ thread ]</a>
              <a href="subject.html#740">[ subject ]</a>
              <a href="author.html#740">[ author ]</a>
         </LI>
       </UL>
    <HR>  
<!--beginarticle-->
<PRE>On 29 November 2013 15:16, Legrandin &lt;<A HREF="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto">helderijs at gmail.com</A>&gt; wrote:

&gt;<i> The DES3 example you are looking for is actually here:
</I>&gt;<i>
</I>&gt;<i> <A HREF="https://www.dlitz.net/software/pycrypto/api/current/Crypto.Cipher.DES-module.html">https://www.dlitz.net/software/pycrypto/api/current/Crypto.Cipher.DES-module.html</A>
</I>

I can't get that working.

Request please?
Assuming I'm not unusual in wanting to both encrypt and then decrypt.
It would be very helpful to show the decrypt after the encrypt?
the oddities I'm finding,
1. Why is it sometimes (I don't know why) shown creating two ciphers,
one for encrypt, one for decrypt.
2. The use of a nonce (as per above)
Is it normal to decrypt using

ciphertext=iv + ciphere.encrypt(plaintext)
plain = cipherd.decrypt(ciphertext[16:])

Using the example....

&gt;&gt;&gt;<i> from Crypto.Cipher import DES3
</I>&gt;&gt;&gt;<i> from Crypto import Random
</I>&gt;&gt;&gt;<i> key = b'Sixteen byte key'
</I>&gt;&gt;&gt;<i> iv = Random.new().read(DES3.block_size)
</I>&gt;&gt;&gt;<i> cipher = DES3.new(key, DES3.MODE_OFB, iv)
</I>&gt;&gt;&gt;<i> plaintext = b'sona si latine loqueris '
</I>&gt;&gt;&gt;<i> msg = iv + cipher.encrypt(plaintext)
</I>&gt;&gt;&gt;<i> p = cipher.decrypt(msg[16:])
</I>&gt;&gt;&gt;<i> print(p)
</I>b'\xc0/)~\xc1\xa4\xb0\xb3\x0c\x92y_\x9a\xaa\xe3\xa0'

Any ideas please?


TiA






-- 
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
<A HREF="http://www.dpawson.co.uk">http://www.dpawson.co.uk</A>
</PRE>


<!--endarticle-->
    <HR>
    <P><UL>
        <!--threads-->
	<LI>Previous message: <A HREF="000739.html">[pycrypto] DES3 problem
</A></li>
	<LI>Next message: <A HREF="000741.html">[pycrypto] DES3 problem
</A></li>
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#740">[ date ]</a>
              <a href="thread.html#740">[ thread ]</a>
              <a href="subject.html#740">[ subject ]</a>
              <a href="author.html#740">[ 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>