Skip to content

Commit 53d1d50

Browse files
committed
sha3: fix compatibility with go1.18
1 parent d4e7c9c commit 53d1d50

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

sha3/xor.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package sha3
66

77
import (
8-
"crypto/subtle"
98
"encoding/binary"
109
"unsafe"
1110

@@ -22,7 +21,7 @@ func xorIn(d *state, buf []byte) {
2221
}
2322
} else {
2423
ab := (*[25 * 64 / 8]byte)(unsafe.Pointer(&d.a))
25-
subtle.XORBytes(ab[:], ab[:], buf)
24+
xorBytes(ab[:], ab[:], buf)
2625
}
2726
}
2827

sha3/xor_compat.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build !go1.19
6+
7+
package sha3
8+
9+
import _ "unsafe" // for go:linkname
10+
11+
//go:linkname xorBytes crypto/cipher.xorBytes
12+
//go:noescape
13+
func xorBytes(dst, a, b []byte)

sha3/xor_go119.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2015 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build go1.19
6+
7+
package sha3
8+
9+
import "crypto/subtle"
10+
11+
var xorBytes = subtle.XORBytes

0 commit comments

Comments
 (0)