Browse Source
noise: don't fail handshake when early data is received without handler (#1746)
pull/1752/head
Marten Seemann
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
5 additions and
7 deletions
-
p2p/security/noise/handshake.go
-
p2p/security/noise/transport_test.go
|
|
@ -122,8 +122,6 @@ func (s *secureSession) runHandshake(ctx context.Context) (err error) { |
|
|
|
if err := s.earlyDataHandler.Received(ctx, s.insecureConn, initialPayload); err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
} else if len(initialPayload) > 0 { |
|
|
|
return fmt.Errorf("received unexpected early data (%d bytes)", len(initialPayload)) |
|
|
|
} |
|
|
|
|
|
|
|
// stage 1 //
|
|
|
|
|
|
@ -510,7 +510,7 @@ func TestEarlyDataRejected(t *testing.T) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func TestEarlyDataRejectedWithNoHandler(t *testing.T) { |
|
|
|
func TestEarlyDataAcceptedWithNoHandler(t *testing.T) { |
|
|
|
clientEDH := &earlyDataHandler{ |
|
|
|
send: func(ctx context.Context, conn net.Conn, id peer.ID) []byte { return []byte("foobar") }, |
|
|
|
} |
|
|
@ -526,14 +526,14 @@ func TestEarlyDataRejectedWithNoHandler(t *testing.T) { |
|
|
|
errChan <- err |
|
|
|
}() |
|
|
|
|
|
|
|
_, err = initTransport.SecureOutbound(context.Background(), respConn, respTransport.localID) |
|
|
|
require.Error(t, err) |
|
|
|
conn, err := initTransport.SecureOutbound(context.Background(), respConn, respTransport.localID) |
|
|
|
require.NoError(t, err) |
|
|
|
defer conn.Close() |
|
|
|
|
|
|
|
select { |
|
|
|
case <-time.After(500 * time.Millisecond): |
|
|
|
t.Fatal("timeout") |
|
|
|
case err := <-errChan: |
|
|
|
require.Error(t, err) |
|
|
|
require.Contains(t, err.Error(), "received unexpected early data") |
|
|
|
require.NoError(t, err) |
|
|
|
} |
|
|
|
} |
|
|
|