]> Cypherpunks.ru repositories - gogost.git/blob - gost3412128/xor_words.go
Optimized Kuznechik
[gogost.git] / gost3412128 / xor_words.go
1 //go:build amd64 || 386 || ppc64 || ppc64le || s390x
2 // +build amd64 386 ppc64 ppc64le s390x
3
4 // Fast XOR taken from native crypto/cipher
5
6 package gost3412128
7
8 import (
9         "unsafe"
10 )
11
12 const xorWords = BlockSize / int(unsafe.Sizeof(uintptr(0)))
13
14 func xor(dst, a, b []byte) {
15         dw := *(*[]uintptr)(unsafe.Pointer(&dst))
16         aw := *(*[]uintptr)(unsafe.Pointer(&a))
17         bw := *(*[]uintptr)(unsafe.Pointer(&b))
18         for i := 0; i < xorWords; i++ {
19                 dw[i] = aw[i] ^ bw[i]
20         }
21 }