Fixes for AEAD output size calculations and use in cipher streams by timw · Pull Request #63 · bcgit/bc-java

added 6 commits

March 10, 2014 21:27
…er and appropriate handling of plaintext output during decryption prior to authentication.
…ers and make all implementations consistent.

Modified buffering in EAXBlockCipher to blockSize + macLength (instead of blockSize * 2) to align it with the OCB/GCM/CCM implementations and its own update-output size calculations (which often overestimated by a block size).
As a side-effect this reduces data copying a bit.
…ngthException in AEAD ciphers.
… and beef up testing.

Buffer underflows could occur when:
- decrypting data > internal buffer size in output stream (input stream was fixed in prior commit)
- packet mode AE cipher (e.g. CCM) is used with a data size > internal buffer size (since all output is buffered)

Buffer is now sized appropriately to every cipher operation immediately prior to it (using getUpdateOutputSize/getOutputSize as appropriate) in both streams.

Tests now run over boundaries of various block/buffer sizes to try to expose issues (0, 64 bit block, 128 bit block, 1K, 2K, 4K).

@timw timw deleted the feature/update-size-testing branch

March 11, 2014 19:06