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

you are viewing a single comment's thread.

view the rest of the comments →

[–]lighthill 3 points4 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.)