Reduce data copying in CCM mode by timw · Pull Request #34 · bcgit/bc-java

@timw

Remove unnecessary data copying in the CCM mode implementation:

  • ByteArrayOutputStream buffers for AD and data are accessed directly to avoid extra allocate+copy of each
  • The output buffer is used directly by processPacket output without allocate+copy of a temporary buffer

@timw

…buffers, and without allocating+copying the output buffer.

@peterdettman

Tim, this changes the signature of a public method (CCMBlockCipher.processPacket). Please preserve the old version (can deprecate it if you like) and its test coverage.

Also, it would be nice to return the number of output bytes from the new version of processPacket.

@bcgit

Actually, I think I can deal with this one, leave it with me - I'll add the return value.

@bcgit

Merged with minor changes - the main one beings I've made the ByteArrayOutputStream extension private to the class and I've added a return value to the processPacket method, leaving the other one in place.

@bcgit bcgit removed their assignment

May 26, 2020