]> Cypherpunks repositories - gostls13.git/commit
crypto/cipher: improved cbc performance
authorLuke Curley <qpingu@gmail.com>
Fri, 17 Jan 2014 16:07:04 +0000 (11:07 -0500)
committerAdam Langley <agl@golang.org>
Fri, 17 Jan 2014 16:07:04 +0000 (11:07 -0500)
commit701982f173d65cca3f8a88df825c008b203775c8
tree49f54978cb1379ebd0c00d27b7ea0d837833680d
parenta75875fc0841b64a122b3769e0fe33908573fb8a
crypto/cipher: improved cbc performance

decrypt: reduced the number of copy calls from 2n to 1.
encrypt: reduced the number of copy calls from n to 1.

Encryption is straight-forward: use dst instead of tmp when
xoring the block with the iv.

Decryption now loops backwards through the blocks abusing the
fact that the previous block's ciphertext (src) is the iv. This
means we don't need to copy the iv every time, in addition to
using dst instead of tmp like encryption.

R=golang-codereviews, agl, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/50900043
src/pkg/crypto/cipher/cbc.go
src/pkg/crypto/cipher/cbc_aes_test.go