mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 20:57:36 +03:00
send post-handshake message in the handshake fuzzer
This commit is contained in:
parent
bed802aee5
commit
9430dbfbfb
2 changed files with 35 additions and 16 deletions
|
@ -81,9 +81,10 @@ func main() {
|
||||||
&wire.TransportParameters{},
|
&wire.TransportParameters{},
|
||||||
runner,
|
runner,
|
||||||
&tls.Config{
|
&tls.Config{
|
||||||
ServerName: "localhost",
|
ServerName: "localhost",
|
||||||
NextProtos: []string{alpn},
|
NextProtos: []string{alpn},
|
||||||
RootCAs: testdata.GetRootCA(),
|
RootCAs: testdata.GetRootCA(),
|
||||||
|
ClientSessionCache: tls.NewLRUClientSessionCache(1),
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
utils.NewRTTStats(),
|
utils.NewRTTStats(),
|
||||||
|
@ -143,6 +144,15 @@ messageLoop:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ticket, err := server.GetSessionTicket()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
if ticket == nil {
|
||||||
|
log.Fatal("expected a session ticket")
|
||||||
|
}
|
||||||
|
messages = append(messages, ticket)
|
||||||
|
|
||||||
for _, m := range messages {
|
for _, m := range messages {
|
||||||
if err := helper.WriteCorpusFileWithPrefix("corpus", m, fuzzhandshake.PrefixLen); err != nil {
|
if err := helper.WriteCorpusFileWithPrefix("corpus", m, fuzzhandshake.PrefixLen); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
@ -101,16 +101,14 @@ type handshakeRunner interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type runner struct {
|
type runner struct {
|
||||||
role string // only used for logging
|
errored bool
|
||||||
errored bool
|
|
||||||
|
|
||||||
client, server *handshake.CryptoSetup
|
client, server *handshake.CryptoSetup
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ handshakeRunner = &runner{}
|
var _ handshakeRunner = &runner{}
|
||||||
|
|
||||||
func newRunner(client, server *handshake.CryptoSetup, role string) *runner {
|
func newRunner(client, server *handshake.CryptoSetup) *runner {
|
||||||
return &runner{role: role, client: client, server: server}
|
return &runner{client: client, server: server}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runner) OnReceivedParams(*wire.TransportParameters) {}
|
func (r *runner) OnReceivedParams(*wire.TransportParameters) {}
|
||||||
|
@ -171,6 +169,8 @@ func Fuzz(data []byte) int {
|
||||||
enable0RTTClient := helper.NthBit(data[0], 0)
|
enable0RTTClient := helper.NthBit(data[0], 0)
|
||||||
enable0RTTServer := helper.NthBit(data[0], 1)
|
enable0RTTServer := helper.NthBit(data[0], 1)
|
||||||
useSessionTicketCache := helper.NthBit(data[0], 2)
|
useSessionTicketCache := helper.NthBit(data[0], 2)
|
||||||
|
sendPostHandshakeMessageToClient := helper.NthBit(data[0], 3)
|
||||||
|
sendPostHandshakeMessageToServer := helper.NthBit(data[0], 4)
|
||||||
messageToReplace := data[1] % 32
|
messageToReplace := data[1] % 32
|
||||||
messageToReplaceEncLevel := toEncryptionLevel(data[1] >> 6)
|
messageToReplaceEncLevel := toEncryptionLevel(data[1] >> 6)
|
||||||
data = data[PrefixLen:]
|
data = data[PrefixLen:]
|
||||||
|
@ -185,7 +185,7 @@ func Fuzz(data []byte) int {
|
||||||
}
|
}
|
||||||
cChunkChan, cInitialStream, cHandshakeStream := initStreams()
|
cChunkChan, cInitialStream, cHandshakeStream := initStreams()
|
||||||
var client, server handshake.CryptoSetup
|
var client, server handshake.CryptoSetup
|
||||||
clientRunner := newRunner(&client, &server, "client")
|
runner := newRunner(&client, &server)
|
||||||
client, _ = handshake.NewCryptoSetupClient(
|
client, _ = handshake.NewCryptoSetupClient(
|
||||||
cInitialStream,
|
cInitialStream,
|
||||||
cHandshakeStream,
|
cHandshakeStream,
|
||||||
|
@ -193,7 +193,7 @@ func Fuzz(data []byte) int {
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
&wire.TransportParameters{},
|
&wire.TransportParameters{},
|
||||||
clientRunner,
|
runner,
|
||||||
clientConf,
|
clientConf,
|
||||||
enable0RTTClient,
|
enable0RTTClient,
|
||||||
utils.NewRTTStats(),
|
utils.NewRTTStats(),
|
||||||
|
@ -202,7 +202,6 @@ func Fuzz(data []byte) int {
|
||||||
)
|
)
|
||||||
|
|
||||||
sChunkChan, sInitialStream, sHandshakeStream := initStreams()
|
sChunkChan, sInitialStream, sHandshakeStream := initStreams()
|
||||||
serverRunner := newRunner(&client, &server, "server")
|
|
||||||
server = handshake.NewCryptoSetupServer(
|
server = handshake.NewCryptoSetupServer(
|
||||||
sInitialStream,
|
sInitialStream,
|
||||||
sHandshakeStream,
|
sHandshakeStream,
|
||||||
|
@ -210,7 +209,7 @@ func Fuzz(data []byte) int {
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
&wire.TransportParameters{},
|
&wire.TransportParameters{},
|
||||||
serverRunner,
|
runner,
|
||||||
&tls.Config{
|
&tls.Config{
|
||||||
Certificates: []tls.Certificate{*cert},
|
Certificates: []tls.Certificate{*cert},
|
||||||
NextProtos: []string{alpn},
|
NextProtos: []string{alpn},
|
||||||
|
@ -229,7 +228,6 @@ func Fuzz(data []byte) int {
|
||||||
go func() {
|
go func() {
|
||||||
defer close(serverHandshakeCompleted)
|
defer close(serverHandshakeCompleted)
|
||||||
server.RunHandshake()
|
server.RunHandshake()
|
||||||
// TODO: send session ticket
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
clientHandshakeCompleted := make(chan struct{})
|
clientHandshakeCompleted := make(chan struct{})
|
||||||
|
@ -269,13 +267,24 @@ messageLoop:
|
||||||
case <-done: // test done
|
case <-done: // test done
|
||||||
break messageLoop
|
break messageLoop
|
||||||
}
|
}
|
||||||
if clientRunner.errored || serverRunner.errored {
|
if runner.errored {
|
||||||
break messageLoop
|
break messageLoop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<-serverHandshakeCompleted
|
<-done
|
||||||
<-clientHandshakeCompleted
|
if runner.errored {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
if sendPostHandshakeMessageToClient {
|
||||||
|
if _, err := server.GetSessionTicket(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
client.HandleMessage(data, messageToReplaceEncLevel)
|
||||||
|
}
|
||||||
|
if sendPostHandshakeMessageToServer {
|
||||||
|
server.HandleMessage(data, messageToReplaceEncLevel)
|
||||||
|
}
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue