cryptography
cryptography copied to clipboard
created addPadding for DartAesCbc to allow for chunked processing
I was wanting to be able to process large local files without having to process all the bytes at once. This commit lets you run the processing in a loop so that you can encrypt/decrypt smaller chunks of a file or input. This adds an addPadding and removePadding parameter to DartAesCbc's encrypt and decrypt functions. The loop will determine whether you have reached the final block and can add or remove padding.
One caveat is that if you don't add padding, the mac authentication step will fail since I have not figured a way to keep it rolling through the loop the way I have with cbc. Because of this, my example uses MacAlgorithm.empty.
The tests all still pass and I have added chunked_dartaescbc.dart to the example folder to clarify addPadding's and removePadding's functionality.
This pull request may help close https://github.com/dint-dev/cryptography/issues/86 as well.
AES-CBC in cryptography 2.2.0 has support for any paddingAlgorithm parameter, which can be any PaddingAlgorithm.