Add AES encryption/decryption functions for working on iterables.

Review Request #12371 — Created June 14, 2022 and submitted

Information

Djblets
release-3.x

Reviewers

This introduces new aes_encrypt_iter() and aes_decrypt_iter()
functions in djblets.secrets.crypto, which can operate on iterables.

aes_encrypt_iter() iterates through an iterable that yields byte or
Unicode strings to encrypt. It then yields the encrypted blocks. It's
smart enough to include the IV in the first block and the finalizer in
the final block.

aes_decrypt_iter() iterates through an iterable of encrypted byte
strings. It yields the decrypted blocks.

These will be used internally for encrypted caching, but can also be
useful for things like streaming data to files or HTTP responses.

Unit tests pass.

Summary ID
Add AES encryption/decryption functions for working on iterables.
This introduces new `aes_encrypt_iter()` and `aes_decrypt_iter()` functions in `djblets.secrets.crypto`, which can operate on iterables. `aes_encrypt_iter()` iterates through an iterable that yields byte or Unicode strings to encrypt. It then yields the encrypted blocks. It's smart enough to include the IV in the first block and the finalizer in the final block. `aes_decrypt_iter()` iterates through an iterable of encrypted byte strings. It yields the decrypted blocks. These will be used internally for encrypted caching, but can also be useful for things like streaming data to files or HTTP responses.
c79c7adc2e3a1991ef5319f34a879c6ade76dbea
Description From Last Updated

This should be "decrypted", no?

daviddavid

What is "the IV"? We should probably also have consistent capitalization of it.

daviddavid
david
  1. 
      
  2. djblets/secrets/crypto.py (Diff revision 1)
     
     
    Show all issues

    This should be "decrypted", no?

  3. djblets/secrets/crypto.py (Diff revision 1)
     
     
     
     
     
     
     
    Show all issues

    What is "the IV"? We should probably also have consistent capitalization of it.

  4. 
      
chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-3.x (af4022c)