updateBinders updates the m.pskBinders field, if necessary updating the cached marshaled representation. The supplied binders must have the same length as the current m.pskBinders.
(pskBinders [][]byte)
| 318 | // cached marshaled representation. The supplied binders must have the same |
| 319 | // length as the current m.pskBinders. |
| 320 | func (m *clientHelloMsg) updateBinders(pskBinders [][]byte) { |
| 321 | if len(pskBinders) != len(m.pskBinders) { |
| 322 | panic("tls: internal error: pskBinders length mismatch") |
| 323 | } |
| 324 | for i := range m.pskBinders { |
| 325 | if len(pskBinders[i]) != len(m.pskBinders[i]) { |
| 326 | panic("tls: internal error: pskBinders length mismatch") |
| 327 | } |
| 328 | } |
| 329 | m.pskBinders = pskBinders |
| 330 | if m.raw != nil { |
| 331 | lenWithoutBinders := len(m.marshalWithoutBinders()) |
| 332 | b := cryptobyte.NewFixedBuilder(m.raw[:lenWithoutBinders]) |
| 333 | b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { |
| 334 | for _, binder := range m.pskBinders { |
| 335 | b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { |
| 336 | b.AddBytes(binder) |
| 337 | }) |
| 338 | } |
| 339 | }) |
| 340 | if out, err := b.Bytes(); err != nil || len(out) != len(m.raw) { |
| 341 | panic("tls: internal error: failed to update binders") |
| 342 | } |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | func (m *clientHelloMsg) unmarshal(data []byte) bool { |
| 347 | *m = clientHelloMsg{raw: data} |
no test coverage detected