• Luke Curley's avatar
    crypto/cipher: improved cbc performance · 701982f1
    Luke Curley authored
    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
    701982f1
cbc.go 3.46 KB