blob: 5b294535c5fa8397e967b3157a191fc412dad55f (
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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [pycrypto] Pycrypto openssl interoperability
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:pycrypto%40lists.dlitz.net?Subject=%5Bpycrypto%5D%20Pycrypto%20openssl%20interoperability&In-Reply-To=">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="000300.html">
<LINK REL="Next" HREF="000302.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[pycrypto] Pycrypto openssl interoperability</H1>
<B>Richard Moore</B>
<A HREF="mailto:pycrypto%40lists.dlitz.net?Subject=%5Bpycrypto%5D%20Pycrypto%20openssl%20interoperability&In-Reply-To="
TITLE="[pycrypto] Pycrypto openssl interoperability">richmoore44 at gmail.com
</A><BR>
<I>Thu Dec 16 07:44:25 CST 2010</I>
<P><UL>
<LI>Previous message: <A HREF="000300.html">[pycrypto] Rewrite bcrypt in PyCrypto so we can use it on Google App Engine
</A></li>
<LI>Next message: <A HREF="000302.html">[pycrypto] Pycrypto openssl interoperability
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#301">[ date ]</a>
<a href="thread.html#301">[ thread ]</a>
<a href="subject.html#301">[ subject ]</a>
<a href="author.html#301">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>Hi,
I'm new to pycrypto and have playing around with it a bit. I can
successfully encrypt and decrypt things using the library, however in
order to check I was doing things correctly, I've tried to decrypt
something encrypted with openssl - sadly without success.
Encrypt the file secrets.txt using openssl, AES 128bit CBC. The
password is read from the file pass.txt:
openssl enc -aes-128-cbc -pass file:pass.txt -a -in secrets.txt -out
secrets.txt.enc
Then decrypt the result using pycrypto:
from Crypto.Cipher import AES
from base64 import b64encode, b64decode
f = open('pass.txt')
key = f.read()
aes = AES.new(key, AES.MODE_CBC)
f = open('secrets.txt.enc')
b64_cipher_text = f.read()
cipher_text = b64decode(b64_cipher_text)
print aes.decrypt(cipher_text)
Can anyone tell me where I'm going wrong, or perhaps has an example of
working interoperability with openssl?
Cheers
Rich.
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="000300.html">[pycrypto] Rewrite bcrypt in PyCrypto so we can use it on Google App Engine
</A></li>
<LI>Next message: <A HREF="000302.html">[pycrypto] Pycrypto openssl interoperability
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#301">[ date ]</a>
<a href="thread.html#301">[ thread ]</a>
<a href="subject.html#301">[ subject ]</a>
<a href="author.html#301">[ 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>
|