aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/seccomp/hash_test.go
blob: 24f6b1c7134e12f8f242aca0e010e24fa0a28c0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package seccomp_test

import (
	"encoding/hex"

	"hakurei.app/container/bits"
	"hakurei.app/container/seccomp"
)

type (
	bpfPreset = struct {
		seccomp.ExportFlag
		bits.FilterPreset
	}
	bpfLookup map[bpfPreset][]byte
)

func toHash(s string) []byte {
	if len(s) != 128 {
		panic("bad sha512 string length")
	}
	if v, err := hex.DecodeString(s); err != nil {
		panic(err.Error())
	} else if len(v) != 64 {
		panic("unreachable")
	} else {
		return v
	}
}