handshake: use new crypto/tls 0-RTT API (#4953)

* handshake: simplify method signature of cryptoSetup.handleEvent

* use the new crypto/tls 0-RTT API
This commit is contained in:
Marten Seemann
2025-02-14 03:17:01 +01:00
committed by GitHub
parent b32f1fa0e4
commit bf28da8346
10 changed files with 182 additions and 380 deletions

View File

@@ -1,6 +1,7 @@
package handshake
import (
"bytes"
"errors"
"fmt"
"time"
@@ -52,3 +53,20 @@ func (t *sessionTicket) Unmarshal(b []byte, using0RTT bool) error {
t.RTT = time.Duration(rtt) * time.Microsecond
return nil
}
const extraPrefix = "quic-go1"
func addSessionStateExtraPrefix(b []byte) []byte {
return append([]byte(extraPrefix), b...)
}
func findSessionStateExtraData(extras [][]byte) []byte {
prefix := []byte(extraPrefix)
for _, extra := range extras {
if len(extra) < len(prefix) || !bytes.Equal(prefix, extra[:len(prefix)]) {
continue
}
return extra[len(prefix):]
}
return nil
}