473,395 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

block ciphers


(I know this has come up before, but the previous discussions I could
find seemed inconclusive, so I hope people don't mind...)
Q: How about adding block ciphers to Python 2.4?

PEP 272 defines an API, and there's an excellent library that implements
it [1]. It would be very little work to copy the AES and DES3 modules
into stdlib (perhaps in a 'ciphers' package).

As far as legal issues, US Export is no problem - you just email in a
notice [2]. A few countries have import issues, though I believe
they're widely disregarded (the windows installer comes with SSL; has
anyone complained?). Furthermore, it would be easy to provide a
no-crypto distribution.

It's hard to distribute pure-python crypto software without this. You
have to include or reference 3rd-party extension modules, which some
users won't want to install, some will have trouble installing (like
Windows users without a compiler), and some won't be able to install
(Jython or IronPython users, for example).

So is this totally out of the question? Or would it be worth pursuing,
through a PEP, or patch, or discussion on python-dev?
Trevor
[1] http://www.amk.ca/python/code/crypto.html
[2] http://www.bxa.doc.gov/Encryption/Pu...odeNofify.html
Jul 18 '05 #1
4 2307
Trevor Perrin <tr********@trevp.net> writes:
Q: How about adding block ciphers to Python 2.4?

PEP 272 defines an API, and there's an excellent library that
implements it [1]. It would be very little work to copy the AES and
DES3 modules into stdlib (perhaps in a 'ciphers' package).
PEP 272 has an API for both block and stream ciphers, and the block
cipher API is kind of cumbersome. I did some work a while back on
defining a new block cipher API and posted some about it back then.
I've been meaning to get that code out of mothballs and propose a new
PEP. A sample implementation is at

http://www.nightsong.com/phr/crypto/blockcipher.tgz

but there are some things about it that I want to change. I recently
used it to write a pure-Python script that decrypts PGP files, if
that's of any interest too.
So is this totally out of the question? Or would it be worth
pursuing, through a PEP, or patch, or discussion on python-dev?


I'm not sure exactly what you're asking.
Jul 18 '05 #2
Paul Rubin wrote:
[...]
PEP 272 has an API for both block and stream ciphers, and the block
cipher API is kind of cumbersome.
In what way? It seems to me quite simple:
from Crypto.Cipher import AES

context = AES.new(key, AES.MODE_CBC, iv)
ciphertext = context.encrypt(plaintext)

context = AES.new(key, AES.MODE_CBC, iv)
plaintext = context.decrypt(ciphertext)
A couple of the keyword arguments could be changed ('rounds', and
'counter'), and the IV should probably be writeable as well as readable
(which is how PyCrypto, which implements this PEP, actually works).

Other than that, I've been using this API (and wrapping a few other
cipher libraries with it), and I find it about as close to transparent
and painless as you can get!

I did some work a while back on
defining a new block cipher API and posted some about it back then.
I've been meaning to get that code out of mothballs and propose a new
PEP. A sample implementation is at

http://www.nightsong.com/phr/crypto/blockcipher.tgz


I'd be happy with that too, but it seems a smidgen less simple, at least
for the user:
from blockcipher import CBC
import AES

context = CBC(AES.ecb(key), 'e', iv)
ciphertext = context.update(plaintext)


More importantly though, PEP 272 is already implemented (in PyCrypto),
and it's been in use awhile so people (like me) have code built around
it, and experience with it.

Again, I'd be happy with either, but PEP 272 / PyCrypto seems the
leading horse in this race.
[Trevor]So is this totally out of the question? Or would it be worth
pursuing, through a PEP, or patch, or discussion on python-dev?

I'm not sure exactly what you're asking.


Me neither, exactly... ;-) I'm just trying to gauge the interest or
resistance to this, and see if there's any way I could help.
Trevor

Jul 18 '05 #3
On Tue, 20 Apr 2004 02:41:58 +0000, Trevor Perrin wrote:
Me neither, exactly... ;-) I'm just trying to gauge the interest or
resistance to this, and see if there's any way I could help.


I would definitely like to see better crypto in the standard library.
N.
Jul 18 '05 #4
Nick Efford wrote:
On Tue, 20 Apr 2004 02:41:58 +0000, Trevor Perrin wrote:
Me neither, exactly... ;-) I'm just trying to gauge the interest or
resistance to this, and see if there's any way I could help.


I would definitely like to see better crypto in the standard library.
N.


Agreed. See http://privaria.org for an example of what I might do with it.

Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
4
by: Christopher | last post by:
This should be a quick one. URL: http://cfa-www.harvard.edu/~cpilman/Stuff/flush.html Code: ============================= <!DOCTYPE HTML Public "-//W3C//DTD HTML 4.01//EN">...
2
by: TadPole | last post by:
Hi all, My main problems are::::::::: 1. Set a value within a block container that can be used and changed by subsequent templates/block-containers/tables etc.. 2. get/determine/find the...
2
by: morrell | last post by:
I have a request to find out is there an easy way to solve this little poblem. ___________________ | Block 1 | | | | | | |...
6
by: foolmelon | last post by:
If a childThread is in the middle of a catch block and handling an exception caught, the main thread calls childThread.Abort(). At that time a ThreadAbortException is thrown in the childThread. ...
8
by: Alvin | last post by:
I'm making a very simple game in SDL, and I'm not asking for SDL help I hope - this looks like something C++ related, so I'll ask here. I have a class for a simple block, or tile, in the game,...
6
by: dave8421 | last post by:
Hi, I'm a bit confused about the definition about "Prinicpal Block Boxes" in CSS 2.1 draft specification. ( http://www.w3.org/TR/2006/WD-CSS21-20061106 ) <pre> 9.2.1 Block-level elements and...
2
by: Bob Greschke | last post by:
This is the idea Block = pack("240s", "") Block = pack(">H", W) Block = pack(">H", X) Block = pack(">B", Y) Block = pack(">H", Z)) but, of course, Block, a str, can't be sliced. The real...
15
by: cssExp | last post by:
hello, Rather than going on a wild explanation on what's the the problem, it'll be much quicker and easier if i let you look at it yourself, so I'll post my page source (actual contents taken out,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.