]> Cypherpunks repositories - gostls13.git/commit
crypto/subtle: add XORBytes
authorRuss Cox <rsc@golang.org>
Fri, 5 Aug 2022 17:34:29 +0000 (13:34 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 17 Aug 2022 18:47:33 +0000 (18:47 +0000)
commit57d05512feebed4fbe1e7a19305c8722a4ac627f
treed76190998eba10aa0750666a99a5ebfa4eb8e35b
parent90466e1ddf0e4305bc56f6eac61a690704e6fab8
crypto/subtle: add XORBytes

Export cipher.xorBytes as subtle.XORBytes, for proposal #53021,
to provide fast XOR to cryptography libraries outside crypto/cipher.

Along with the move, implement the alignment check TODO
in xor_generic.go, so that systems with neither unaligned
accesses nor custom assembly can still XOR a word at a time
in word-based algorithms like GCM. This removes the need
for the separate cipher.xorWords.

Fixes #53021.

Change-Id: I58f80a922f1cff671b5ebc6168eb046e702b5a4c
Reviewed-on: https://go-review.googlesource.com/c/go/+/421435
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
21 files changed:
api/next/53021.txt [new file with mode: 0644]
src/crypto/cipher/cbc.go
src/crypto/cipher/cfb.go
src/crypto/cipher/ctr.go
src/crypto/cipher/export_test.go
src/crypto/cipher/gcm.go
src/crypto/cipher/ofb.go
src/crypto/cipher/xor_amd64.go [deleted file]
src/crypto/cipher/xor_arm64.go [deleted file]
src/crypto/cipher/xor_generic.go [deleted file]
src/crypto/cipher/xor_ppc64x.go [deleted file]
src/crypto/cipher/xor_test.go [deleted file]
src/crypto/subtle/xor.go [new file with mode: 0644]
src/crypto/subtle/xor_amd64.go [new file with mode: 0644]
src/crypto/subtle/xor_amd64.s [moved from src/crypto/cipher/xor_amd64.s with 93% similarity]
src/crypto/subtle/xor_arm64.go [new file with mode: 0644]
src/crypto/subtle/xor_arm64.s [moved from src/crypto/cipher/xor_arm64.s with 93% similarity]
src/crypto/subtle/xor_generic.go [new file with mode: 0644]
src/crypto/subtle/xor_ppc64x.go [new file with mode: 0644]
src/crypto/subtle/xor_ppc64x.s [moved from src/crypto/cipher/xor_ppc64x.s with 94% similarity]
src/crypto/subtle/xor_test.go [new file with mode: 0644]