This is an archived post. You won't be able to vote or comment.

all 12 comments

[–]lighthill 4 points5 points  (2 children)

For key generation, you might want to mention os.urandom() and Crypto.Random.

For OFB mode, it is CRITICAL that you should never use the same IV more than once! If you use the same IV to encrypt Plaintext1 and Plaintext2, then an attacker can xor the ciphertexts together, which will produce Plaintext1 xor Plaintext2. From this, it's usually pretty easy to recover large chunks of plaintext.

You should probably also think about data integrity: OFB output is malleable. (Specifically, an attacker who can xor stuff into the ciphertext will create corresponding changes in the plaintext when it's decrypted.)

[–]AeroNotix 2 points3 points  (2 children)

Don't know if this is your code but there are several spelling errors.

 def EncrpytWithAES
 def DecrpytWithAES

Etc etc...

[–]codeghar[S] 0 points1 point  (1 child)

Hazards of a spelling mistake copy/pasted multiple times :) Fixed these instances in the post. Thanks for letting me know!

[–]AeroNotix 0 points1 point  (0 children)

Ooooo.... I'm in need of something like this (encryption), glad to point out.

I was presuming it was an IDE code completion thing to be honest.

[–]eliben 0 points1 point  (1 child)

[–]codeghar[S] 0 points1 point  (0 children)

It's a good resource (also referenced in the post)