MCPcopy Create free account
hub / github.com/XTLS/Go / updateBinders

Method updateBinders

handshake_messages.go:320–344  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

318// cached marshaled representation. The supplied binders must have the same
319// length as the current m.pskBinders.
320func (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
346func (m *clientHelloMsg) unmarshal(data []byte) bool {
347 *m = clientHelloMsg{raw: data}

Callers 2

loadSessionMethod · 0.80

Calls 1

marshalWithoutBindersMethod · 0.95

Tested by

no test coverage detected