-
Notifications
You must be signed in to change notification settings - Fork 0
/
prf_test.go
32 lines (27 loc) · 996 Bytes
/
prf_test.go
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
30
31
32
package toyls
import . "gopkg.in/check.v1"
func (s *ToySuite) TestPRF(c *C) {
secret := []byte{0x01}
label := "slithy toves"
seed := []byte{0x01}
result := make([]byte, 5)
prf(result, secret, label, seed)
c.Assert(result, DeepEquals, []byte{0xe9, 0x98, 0xd, 0xad, 0xa3})
}
func (s *ToySuite) TestKeysFromMasterSecret(c *C) {
params := securityParameters{
macKeyLength: 1,
encKeyLength: 2,
fixedIVLength: 3,
masterSecret: [48]byte{},
clientRandom: [32]byte{},
serverRandom: [32]byte{},
}
writeParams := keysFromMasterSecret(params)
c.Assert(len(writeParams.clientMAC), Equals, int(params.macKeyLength))
c.Assert(len(writeParams.serverMAC), Equals, int(params.macKeyLength))
c.Assert(len(writeParams.clientKey), Equals, int(params.encKeyLength))
c.Assert(len(writeParams.serverKey), Equals, int(params.encKeyLength))
c.Assert(len(writeParams.clientIV), Equals, int(params.fixedIVLength))
c.Assert(len(writeParams.serverIV), Equals, int(params.fixedIVLength))
}