interface.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package handshake
  2. import (
  3. "crypto/x509"
  4. "io"
  5. "v2ray.com/core/external/github.com/lucas-clemente/quic-go/internal/protocol"
  6. "v2ray.com/core/external/github.com/marten-seemann/qtls"
  7. )
  8. // Opener opens a packet
  9. type Opener interface {
  10. Open(dst, src []byte, packetNumber protocol.PacketNumber, associatedData []byte) ([]byte, error)
  11. DecryptHeader(sample []byte, firstByte *byte, pnBytes []byte)
  12. }
  13. // Sealer seals a packet
  14. type Sealer interface {
  15. Seal(dst, src []byte, packetNumber protocol.PacketNumber, associatedData []byte) []byte
  16. EncryptHeader(sample []byte, firstByte *byte, pnBytes []byte)
  17. Overhead() int
  18. }
  19. // A tlsExtensionHandler sends and received the QUIC TLS extension.
  20. type tlsExtensionHandler interface {
  21. GetExtensions(msgType uint8) []qtls.Extension
  22. ReceivedExtensions(msgType uint8, exts []qtls.Extension) error
  23. }
  24. // CryptoSetup handles the handshake and protecting / unprotecting packets
  25. type CryptoSetup interface {
  26. RunHandshake() error
  27. io.Closer
  28. HandleMessage([]byte, protocol.EncryptionLevel) bool
  29. ConnectionState() ConnectionState
  30. GetSealer() (protocol.EncryptionLevel, Sealer)
  31. GetSealerWithEncryptionLevel(protocol.EncryptionLevel) (Sealer, error)
  32. GetOpener(protocol.EncryptionLevel) (Opener, error)
  33. }
  34. // ConnectionState records basic details about the QUIC connection.
  35. // Warning: This API should not be considered stable and might change soon.
  36. type ConnectionState struct {
  37. HandshakeComplete bool // handshake is complete
  38. ServerName string // server name requested by client, if any (server side only)
  39. PeerCertificates []*x509.Certificate // certificate chain presented by remote peer
  40. }