mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
6fde3632ef
The vendor/ folder was created with the help of @FiloSottile's gvt and vendorcheck. Any dependencies of Caddy plugins outside this repo are not vendored. We do not remove any unused, vendored packages because vendorcheck -u only checks using the current build configuration; i.e. packages that may be imported by files toggled by build tags of other systems. CI tests have been updated to ignore the vendor/ folder. When Go 1.9 is released, a few of the go commands should be revised to again use ./... as it will ignore the vendor folder by default.
67 lines
1.8 KiB
Go
67 lines
1.8 KiB
Go
// Copyright (c) 2016 Andreas Auernhammer. All rights reserved.
|
|
// Use of this source code is governed by a license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// +build 386,!gccgo,!appengine,!nacl
|
|
|
|
package chacha
|
|
|
|
import "encoding/binary"
|
|
|
|
func init() {
|
|
useSSE2 = supportsSSE2()
|
|
useSSSE3 = supportsSSSE3()
|
|
useAVX2 = false
|
|
}
|
|
|
|
func initialize(state *[64]byte, key []byte, nonce *[16]byte) {
|
|
binary.LittleEndian.PutUint32(state[0:], sigma[0])
|
|
binary.LittleEndian.PutUint32(state[4:], sigma[1])
|
|
binary.LittleEndian.PutUint32(state[8:], sigma[2])
|
|
binary.LittleEndian.PutUint32(state[12:], sigma[3])
|
|
copy(state[16:], key[:])
|
|
copy(state[48:], nonce[:])
|
|
}
|
|
|
|
// This function is implemented in chacha_386.s
|
|
//go:noescape
|
|
func supportsSSE2() bool
|
|
|
|
// This function is implemented in chacha_386.s
|
|
//go:noescape
|
|
func supportsSSSE3() bool
|
|
|
|
// This function is implemented in chacha_386.s
|
|
//go:noescape
|
|
func hChaCha20SSE2(out *[32]byte, nonce *[16]byte, key *[32]byte)
|
|
|
|
// This function is implemented in chacha_386.s
|
|
//go:noescape
|
|
func hChaCha20SSSE3(out *[32]byte, nonce *[16]byte, key *[32]byte)
|
|
|
|
// This function is implemented in chacha_386.s
|
|
//go:noescape
|
|
func xorKeyStreamSSE2(dst, src []byte, block, state *[64]byte, rounds int) int
|
|
|
|
// This function is implemented in chacha_386.s
|
|
//go:noescape
|
|
func xorKeyStreamSSSE3(dst, src []byte, block, state *[64]byte, rounds int) int
|
|
|
|
func hChaCha20(out *[32]byte, nonce *[16]byte, key *[32]byte) {
|
|
if useSSSE3 {
|
|
hChaCha20SSSE3(out, nonce, key)
|
|
} else if useSSE2 {
|
|
hChaCha20SSE2(out, nonce, key)
|
|
} else {
|
|
hChaCha20Generic(out, nonce, key)
|
|
}
|
|
}
|
|
|
|
func xorKeyStream(dst, src []byte, block, state *[64]byte, rounds int) int {
|
|
if useSSSE3 {
|
|
return xorKeyStreamSSSE3(dst, src, block, state, rounds)
|
|
} else if useSSE2 {
|
|
return xorKeyStreamSSE2(dst, src, block, state, rounds)
|
|
}
|
|
return xorKeyStreamGeneric(dst, src, block, state, rounds)
|
|
}
|