Skip to content

crypto/cipher: move xorBytes function to internal #28465

Closed
@mengzhuo

Description

@mengzhuo

Some packages need an efficient xor function bytes, for example:

gogrep -x 'for $*_ { $m[i] = $k[i] ^ $l[i] }' std cmd
src/crypto/rand/rand_unix.go:149:3: for i := 0; i < aes.BlockSize; i++ { r.dst[i] = r.time[i] ^ r.seed[i]; }
src/crypto/rand/rand_unix.go:153:3: for i := 0; i < aes.BlockSize; i++ { r.seed[i] = r.time[i] ^ r.dst[i]; }

And about 18 code pieces in golang.org/x/crypto https://github.com/golang/crypto/search?l=Go&q=xor

If this CL( https://go-review.googlesource.com/c/go/+/125316 ) get merged in master we will get a SIMD xorBytes which will be a benefit for all other package that use xor function and reduce redundancy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Proposal-CryptoProposal related to crypto packages or other security issues

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions