MCPcopy Create free account
hub / github.com/pion/dtls / TestHandshakeCacheSessionHash

Function TestHandshakeCacheSessionHash

handshake_cache_test.go:128–219  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

126}
127
128func TestHandshakeCacheSessionHash(t *testing.T) {
129 for _, test := range []struct {
130 Name string
131 Rule []handshakeCachePullRule
132 Input []handshakeCacheItem
133 Expected []byte
134 }{
135 {
136 Name: "Standard Handshake",
137 Input: []handshakeCacheItem{
138 {handshake.TypeClientHello, true, 0, 0, []byte{0x00}},
139 {handshake.TypeServerHello, false, 0, 1, []byte{0x01}},
140 {handshake.TypeCertificate, false, 0, 2, []byte{0x02}},
141 {handshake.TypeServerKeyExchange, false, 0, 3, []byte{0x03}},
142 {handshake.TypeServerHelloDone, false, 0, 4, []byte{0x04}},
143 {handshake.TypeClientKeyExchange, true, 0, 5, []byte{0x05}},
144 },
145 Expected: []byte{
146 0x17, 0xe8, 0x8d, 0xb1, 0x87, 0xaf, 0xd6, 0x2c, 0x16, 0xe5, 0xde, 0xbf, 0x3e, 0x65, 0x27, 0xcd,
147 0x00, 0x6b, 0xc0, 0x12, 0xbc, 0x90, 0xb5, 0x1a, 0x81, 0x0c, 0xd8, 0x0c, 0x2d, 0x51, 0x1f, 0x43,
148 },
149 },
150 {
151 Name: "Handshake With Client Cert Request",
152 Input: []handshakeCacheItem{
153 {handshake.TypeClientHello, true, 0, 0, []byte{0x00}},
154 {handshake.TypeServerHello, false, 0, 1, []byte{0x01}},
155 {handshake.TypeCertificate, false, 0, 2, []byte{0x02}},
156 {handshake.TypeServerKeyExchange, false, 0, 3, []byte{0x03}},
157 {handshake.TypeCertificateRequest, false, 0, 4, []byte{0x04}},
158 {handshake.TypeServerHelloDone, false, 0, 5, []byte{0x05}},
159 {handshake.TypeClientKeyExchange, true, 0, 6, []byte{0x06}},
160 },
161 Expected: []byte{
162 0x57, 0x35, 0x5a, 0xc3, 0x30, 0x3c, 0x14, 0x8f, 0x11, 0xae, 0xf7, 0xcb, 0x17, 0x94, 0x56, 0xb9,
163 0x23, 0x2c, 0xde, 0x33, 0xa8, 0x18, 0xdf, 0xda, 0x2c, 0x2f, 0xcb, 0x93, 0x25, 0x74, 0x9a, 0x6b,
164 },
165 },
166 {
167 Name: "Handshake Ignores after ClientKeyExchange",
168 Input: []handshakeCacheItem{
169 {handshake.TypeClientHello, true, 0, 0, []byte{0x00}},
170 {handshake.TypeServerHello, false, 0, 1, []byte{0x01}},
171 {handshake.TypeCertificate, false, 0, 2, []byte{0x02}},
172 {handshake.TypeServerKeyExchange, false, 0, 3, []byte{0x03}},
173 {handshake.TypeCertificateRequest, false, 0, 4, []byte{0x04}},
174 {handshake.TypeServerHelloDone, false, 0, 5, []byte{0x05}},
175 {handshake.TypeClientKeyExchange, true, 0, 6, []byte{0x06}},
176 {handshake.TypeCertificateVerify, true, 0, 7, []byte{0x07}},
177 {handshake.TypeFinished, true, 1, 7, []byte{0x08}},
178 {handshake.TypeFinished, false, 1, 7, []byte{0x09}},
179 },
180 Expected: []byte{
181 0x57, 0x35, 0x5a, 0xc3, 0x30, 0x3c, 0x14, 0x8f, 0x11, 0xae, 0xf7, 0xcb, 0x17, 0x94, 0x56, 0xb9,
182 0x23, 0x2c, 0xde, 0x33, 0xa8, 0x18, 0xdf, 0xda, 0x2c, 0x2f, 0xcb, 0x93, 0x25, 0x74, 0x9a, 0x6b,
183 },
184 },
185 {

Callers

nothing calls this directly

Calls 5

HashFuncMethod · 0.95
newHandshakeCacheFunction · 0.85
sessionHashMethod · 0.80
EqualMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…