Exemple #1
0
func TestBasic(t *testing.T) {
	var h skein.Hash

	for num, test := range basicVectors {
		h.Init(uint64(len(test.out)), nil)

		wn, err := h.Write(test.in)
		if wn != len(test.in) || err != nil {
			t.Errorf("basic %d: couldn't write %d bytes (%d, %v)", num, len(test.in), wn, err)
			continue
		}

		out := make([]byte, len(test.out))
		rn, err := h.Read(out)
		if rn != len(out) || err != nil {
			t.Errorf("basic %d: couldn't read %d bytes (%d, %v)", num, len(out), rn, err)
			continue
		}

		if !bytes.Equal(out, test.out) {
			t.Errorf("basic %d: expected %x, got %x", num, test.out, out)
			continue
		}
	}
}
Exemple #2
0
func (s Secret) deriveRaw(n uint64, id string) (result CValue) {
	args := skein.Args{
		Key:    s[:],
		Person: []byte(personKDF),
		KeyId:  []byte(id),
	}

	var hash skein.Hash
	hash.Init(n, &args)
	_, _ = hash.Read(result[:n])
	return
}