1
2
3
4
5 package hkdf
6
7 import (
8 "bytes"
9 "crypto/internal/fips140"
10 _ "crypto/internal/fips140/check"
11 "crypto/internal/fips140/sha256"
12 "errors"
13 )
14
15 func init() {
16 fips140.CAST("HKDF-SHA2-256", func() error {
17 input := []byte{
18 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
19 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
20 }
21 want := []byte{
22 0xb6, 0x53, 0x00, 0x5b, 0x51, 0x6d, 0x2b, 0xc9,
23 0x4a, 0xe4, 0xf9, 0x51, 0x73, 0x1f, 0x71, 0x21,
24 0xa6, 0xc1, 0xde, 0x42, 0x4f, 0x2c, 0x99, 0x60,
25 0x64, 0xdb, 0x66, 0x3e, 0xec, 0xa6, 0x37, 0xff,
26 }
27 got := Key(sha256.New, input, input, string(input), len(want))
28 if !bytes.Equal(got, want) {
29 return errors.New("unexpected result")
30 }
31 return nil
32 })
33 }
34
View as plain text