Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1596)

Unified Diff: src/pkg/crypto/cipher/cbc.go

Issue 24250044: crypto/cipher: speed up xor operations in CBC, OBF, CTR... (Closed)
Patch Set: diff -r c8d3de543c1b https://code.google.com/p/go Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pkg/crypto/cipher/benchmark_test.go ('k') | src/pkg/crypto/cipher/cfb.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/crypto/cipher/cbc.go
===================================================================
--- a/src/pkg/crypto/cipher/cbc.go
+++ b/src/pkg/crypto/cipher/cbc.go
@@ -49,13 +49,9 @@
panic("crypto/cipher: output smaller than input")
}
for len(src) > 0 {
- for i := 0; i < x.blockSize; i++ {
- x.iv[i] ^= src[i]
- }
+ xorBytes(x.iv, x.iv, src[:x.blockSize])
x.b.Encrypt(x.iv, x.iv)
- for i := 0; i < x.blockSize; i++ {
- dst[i] = x.iv[i]
- }
+ copy(dst, x.iv)
src = src[x.blockSize:]
dst = dst[x.blockSize:]
}
@@ -91,12 +87,9 @@
}
for len(src) > 0 {
x.b.Decrypt(x.tmp, src[:x.blockSize])
- for i := 0; i < x.blockSize; i++ {
- x.tmp[i] ^= x.iv[i]
- x.iv[i] = src[i]
- dst[i] = x.tmp[i]
- }
-
+ xorBytes(x.tmp, x.tmp, x.iv)
+ copy(x.iv, src)
+ copy(dst, x.tmp)
src = src[x.blockSize:]
dst = dst[x.blockSize:]
}
« no previous file with comments | « src/pkg/crypto/cipher/benchmark_test.go ('k') | src/pkg/crypto/cipher/cfb.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b