z3rol0ve / slowaes

Automatically exported from code.google.com/p/slowaes
0 stars 0 forks source link

Implement PKCS7 padding #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What are the requirement to complete this task?

Implement PKCS7 padding as described on
http://code.google.com/p/slowaes/wiki/OpenSSLStandards

Please use labels and text to provide additional information.

Original issue reported on code.google.com by joshua.a...@gmail.com on 6 Aug 2008 at 12:45

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I started using this module and it seems to me that padding is absolutely 
necessary
for CBC mode. Otherwise you have to store the length of the original message, 
which
is a bad idea. So I added some high level functions complete with tests that 
include
padding/depadding.  This required one change in the original code that looks for
"originalsize", which is now just passed in as None.

Also, I'm wondering why "size" (keysize) is an argument to
AESModeOfOperation.encrypt/decrypt since it can be determined from the key 
itself. 
Am I missing something here?

The functions I added simplify usage.  An example:

key = aes.generateRandomKey()
cipher = aes.encryptData(key, plaintext_data)
decoded_message = aes.decryptData(key, cipher)

I attached an svn diff.

-Randall

Original comment by berryma...@gmail.com on 26 Jul 2009 at 10:11

Attachments:

GoogleCodeExporter commented 9 years ago
Great, thanks berryman77 -- your patch is fine and I have now committed it (SVN
revision 36). If you want committer status on this project just let me know!

Original comment by alea...@gmail.com on 27 Jul 2009 at 1:14

GoogleCodeExporter commented 9 years ago
Randall,

The likely reason for the size argument is because the code was originally 
converted
directly from ANSI C and in that context it probably made more sense. After the
initial conversion and some bug fixes this has remained largely untouched. As 
you
work through the code please make corrections you feel will improve performance,
reliability, and readability.

Josh

Original comment by joshua.a...@gmail.com on 27 Jul 2009 at 1:39

GoogleCodeExporter commented 9 years ago
The functions I added (encryptData and decryptData) apply padding regardless of 
the
mode.  Only CBC mode requires padding, so I added a check in the attached diff.

I chose to use this module because it's written in Python so I don't have to 
compile
for each platform I deploy on.  My current needs aren't performance sensitive.  
I'm
more focused on usability as is (hopefully) evident in the additions I made.  
I'll be
glad to help if/when fixes and improvements are needed.

-Randall

Original comment by berryma...@gmail.com on 27 Jul 2009 at 6:30

Attachments:

GoogleCodeExporter commented 9 years ago
aleaxit,

I would like committer status so I can apply this fix and any future fixes.

Original comment by berryma...@gmail.com on 4 Aug 2009 at 9:18

GoogleCodeExporter commented 9 years ago
berryman77, I'll be very happy to add you, but need your email address -- if 
you want to communicate it 
privately, I'm aleaxit at gmail period com;-).

Original comment by alea...@gmail.com on 5 Aug 2009 at 11:42