Add msgpack wire protocol with halfsiphash checksums
This commit is contained in:
31
lib/halfsiphash/halfsiphash_test.go
Normal file
31
lib/halfsiphash/halfsiphash_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package halfsiphash
|
||||
|
||||
import "testing"
|
||||
|
||||
// Test vectors from the reference implementation.
|
||||
// Key: 00 01 02 03 04 05 06 07
|
||||
// Input: sequence 00, 00 01, 00 01 02, ...
|
||||
var vectors32 = []uint32{
|
||||
0x5b9f35a9,
|
||||
0xb85a4727,
|
||||
0x03a662fa,
|
||||
0x04e7fe8a,
|
||||
0x89466e2a,
|
||||
0x69b6fac5,
|
||||
0x23fc6358,
|
||||
0xc563cf8b,
|
||||
}
|
||||
|
||||
func TestSum32(t *testing.T) {
|
||||
key := [8]byte{0, 1, 2, 3, 4, 5, 6, 7}
|
||||
for i, want := range vectors32 {
|
||||
data := make([]byte, i)
|
||||
for j := range data {
|
||||
data[j] = byte(j)
|
||||
}
|
||||
got := Sum32(data, key)
|
||||
if got != want {
|
||||
t.Errorf("Sum32(len=%d) = %08x, want %08x", i, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user