cryptography icon indicating copy to clipboard operation
cryptography copied to clipboard

created addPadding for DartAesCbc to allow for chunked processing

Open hootyjeremy opened this issue 3 years ago • 1 comments
trafficstars

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.

hootyjeremy avatar Oct 10 '22 19:10 hootyjeremy

This pull request may help close https://github.com/dint-dev/cryptography/issues/86 as well.

hootyjeremy avatar Oct 10 '22 19:10 hootyjeremy

AES-CBC in cryptography 2.2.0 has support for any paddingAlgorithm parameter, which can be any PaddingAlgorithm.

terrier989 avatar Mar 03 '23 19:03 terrier989