[wip] Switch AES encryption to authenticated AES-GCM.
Review Request #15123 — Created June 16, 2026 and updated — Latest diff uploaded
The
AES-CFB8cipher is unauthenticated, and susceptible to
bit-flipping attacks. As a result, thecryptographylibrary is going
to be moving this into thedecrepitnamespace in an upcoming version.This change updates
aes_encrypt()to produce authenticated output
usingAES-GCMoutput instead of AES-CFB8. The output carries a 2-byte
magic prefix soaes_decrypt()can tell new GCM data from legacy CFB8
data and decrypt either. Tampered or incorrect-key data now raises an
InvalidTagexception instead of silently returning garbage.Legacy CFB8 data (including data at rest from older installs and the
PyCrypto-era format) still decrypts. The streamingaes_encrypt_iter()
andaes_decrypt_iter()remain on CFB8, since GCM cannot stream safely
(its tag is only verified at the end). For those, callers must
authenticate the full payload independently before acting on streamed
plaintext.The cache test helper now mirrors the cache's streaming CFB8 encryption
rather than single-shot encryption, so its generated chunk data matches
what the cache stores.
- Ran unit tests.
- Verified that existing encrypted data decrypted properly as a
fallback.