Resumable AES GCM in Python 3?

84 views Asked by At

Is there an implementation of AES GCM for Python 3 which not only accepts piecewise messages, but also allows the working state of the cipher to be serialized, stored, and later resumed?

(I have an AES256-GCM stream, a key, and a nonce. The stream comes in to my Flask app as a series of messages, and I don't think my app will be able to run continuously for the entire time. I will lose the working-state of the ongoing crypto operation whenever the app terminates.)

I tried using Cryptodome.Cipher.AES in the GCM mode, which does allow piecewise operation through an update() / update_and_digest() mechanism, but I don't see a way to save the internal state and resume it later.

I tried pickling the AES object, but pickle complains that it can't serialize it because it is a module.

I am able to store the key and nonce, and maybe it's possible to periodically digest the message and store that, but It's not clear to me if that would help to reinstantiate an AES object and resume an operation.

0

There are 0 answers