This commit is contained in:
bluepython508 committed 2026-10-22 12:27:19 +01:00
1 parent 3530afb854
commit 6903fcff27
2146 files changed
+112256 -190703

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
//go:build arm
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved.
*/
package device
import (
"crypto/cipher"
"os"
"golang.org/x/crypto/chacha20poly1305"
asmAEAD "github.com/tailscale/wireguard-go/tsasm/arm/chacha20poly1305"
)
// chacha20poly1305New returns a ChaCha20-Poly1305 AEAD. On GOARCH=arm
// (32-bit, any GOOS) it uses the assembly kernels from tsasm/arm/.
// The cookie path (which uses the extended-nonce variant via
// chacha20poly1305.NewX) is left on the x/crypto path because it is
// not on the per-packet hot path.
//
// As an escape hatch for hardware regressions or asm bugs, setting
// the environment variable TS_WG_ASM=0 forces the pure-Go x/crypto
// implementation instead.
func chacha20poly1305New(key []byte) (cipher.AEAD, error) {
if os.Getenv("TS_WG_ASM") == "0" {
return chacha20poly1305.New(key)
}
return asmAEAD.New(key)
}