From e3123545f2f768b22623aac44bfae548d8e0e9a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Thu, 2 Feb 2023 11:50:33 +0800 Subject: [PATCH] Fix crypto/cipher.xorWords removed --- shadowaead_2022/xor.go | 8 ++++---- shadowaead_2022/xor_go119.go | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 shadowaead_2022/xor_go119.go diff --git a/shadowaead_2022/xor.go b/shadowaead_2022/xor.go index 3e09591..007742f 100644 --- a/shadowaead_2022/xor.go +++ b/shadowaead_2022/xor.go @@ -1,7 +1,7 @@ +//go:build go1.20 + package shadowaead_2022 -import _ "unsafe" +import "crypto/subtle" -//go:linkname xorWords crypto/cipher.xorWords -//go:noescape -func xorWords(dst, a, b []byte) +var xorWords = subtle.XORBytes diff --git a/shadowaead_2022/xor_go119.go b/shadowaead_2022/xor_go119.go new file mode 100644 index 0000000..35fb48c --- /dev/null +++ b/shadowaead_2022/xor_go119.go @@ -0,0 +1,9 @@ +//go:build !go1.20 + +package shadowaead_2022 + +import _ "unsafe" + +//go:linkname xorWords crypto/cipher.xorWords +//go:noescape +func xorWords(dst, a, b []byte)