summaryrefslogtreecommitdiff
path: root/vendor/github.com/zeebo/blake3/internal/consts
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/zeebo/blake3/internal/consts')
-rw-r--r--vendor/github.com/zeebo/blake3/internal/consts/consts.go29
-rw-r--r--vendor/github.com/zeebo/blake3/internal/consts/cpu.go17
-rw-r--r--vendor/github.com/zeebo/blake3/internal/consts/cpu_big.go5
-rw-r--r--vendor/github.com/zeebo/blake3/internal/consts/cpu_little.go5
-rw-r--r--vendor/github.com/zeebo/blake3/internal/consts/cpu_other.go7
5 files changed, 63 insertions, 0 deletions
diff --git a/vendor/github.com/zeebo/blake3/internal/consts/consts.go b/vendor/github.com/zeebo/blake3/internal/consts/consts.go
new file mode 100644
index 000000000..89f08fe10
--- /dev/null
+++ b/vendor/github.com/zeebo/blake3/internal/consts/consts.go
@@ -0,0 +1,29 @@
+package consts
+
+var IV = [...]uint32{IV0, IV1, IV2, IV3, IV4, IV5, IV6, IV7}
+
+const (
+ IV0 = 0x6A09E667
+ IV1 = 0xBB67AE85
+ IV2 = 0x3C6EF372
+ IV3 = 0xA54FF53A
+ IV4 = 0x510E527F
+ IV5 = 0x9B05688C
+ IV6 = 0x1F83D9AB
+ IV7 = 0x5BE0CD19
+)
+
+const (
+ Flag_ChunkStart uint32 = 1 << 0
+ Flag_ChunkEnd uint32 = 1 << 1
+ Flag_Parent uint32 = 1 << 2
+ Flag_Root uint32 = 1 << 3
+ Flag_Keyed uint32 = 1 << 4
+ Flag_DeriveKeyContext uint32 = 1 << 5
+ Flag_DeriveKeyMaterial uint32 = 1 << 6
+)
+
+const (
+ BlockLen = 64
+ ChunkLen = 1024
+)
diff --git a/vendor/github.com/zeebo/blake3/internal/consts/cpu.go b/vendor/github.com/zeebo/blake3/internal/consts/cpu.go
new file mode 100644
index 000000000..1eebff943
--- /dev/null
+++ b/vendor/github.com/zeebo/blake3/internal/consts/cpu.go
@@ -0,0 +1,17 @@
+package consts
+
+import (
+ "os"
+
+ "golang.org/x/sys/cpu"
+)
+
+var (
+ HasAVX2 = cpu.X86.HasAVX2 &&
+ os.Getenv("BLAKE3_DISABLE_AVX2") == "" &&
+ os.Getenv("BLAKE3_PUREGO") == ""
+
+ HasSSE41 = cpu.X86.HasSSE41 &&
+ os.Getenv("BLAKE3_DISABLE_SSE41") == "" &&
+ os.Getenv("BLAKE3_PUREGO") == ""
+)
diff --git a/vendor/github.com/zeebo/blake3/internal/consts/cpu_big.go b/vendor/github.com/zeebo/blake3/internal/consts/cpu_big.go
new file mode 100644
index 000000000..fb730464f
--- /dev/null
+++ b/vendor/github.com/zeebo/blake3/internal/consts/cpu_big.go
@@ -0,0 +1,5 @@
+// +build mips mips64 ppc64 s390x
+
+package consts
+
+const IsLittleEndian = false
diff --git a/vendor/github.com/zeebo/blake3/internal/consts/cpu_little.go b/vendor/github.com/zeebo/blake3/internal/consts/cpu_little.go
new file mode 100644
index 000000000..1bae02a74
--- /dev/null
+++ b/vendor/github.com/zeebo/blake3/internal/consts/cpu_little.go
@@ -0,0 +1,5 @@
+// +build amd64 386 arm arm64 mipsle mips64le ppc64le riscv64 wasm
+
+package consts
+
+const IsLittleEndian = true
diff --git a/vendor/github.com/zeebo/blake3/internal/consts/cpu_other.go b/vendor/github.com/zeebo/blake3/internal/consts/cpu_other.go
new file mode 100644
index 000000000..5f7407a6a
--- /dev/null
+++ b/vendor/github.com/zeebo/blake3/internal/consts/cpu_other.go
@@ -0,0 +1,7 @@
+// +build !mips,!mips64,!ppc64,!s390x,!amd64,!386,!arm,!arm64,!mipsle,!mips64le,!ppc64le,!riscv64,!wasm
+
+package consts
+
+import "unsafe"
+
+var IsLittleEndian = *(*uint16)(unsafe.Pointer(&[2]byte{0, 1})) != 1