github.com/psiphon-Labs/psiphon-tunnel-core@v2.0.28+incompatible/psiphon/common/quic/gquic-go/internal/handshake/interface.go (about)

     1  package handshake
     2  
     3  import (
     4  	"crypto/x509"
     5  
     6  	"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/quic/gquic-go/internal/crypto"
     7  	"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/quic/gquic-go/internal/protocol"
     8  	"github.com/bifurcation/mint"
     9  )
    10  
    11  // Sealer seals a packet
    12  type Sealer interface {
    13  	Seal(dst, src []byte, packetNumber protocol.PacketNumber, associatedData []byte) []byte
    14  	Overhead() int
    15  }
    16  
    17  // mintTLS combines some methods needed to interact with mint.
    18  type mintTLS interface {
    19  	crypto.TLSExporter
    20  	Handshake() mint.Alert
    21  }
    22  
    23  // A TLSExtensionHandler sends and received the QUIC TLS extension.
    24  // It provides the parameters sent by the peer on a channel.
    25  type TLSExtensionHandler interface {
    26  	Send(mint.HandshakeType, *mint.ExtensionList) error
    27  	Receive(mint.HandshakeType, *mint.ExtensionList) error
    28  	GetPeerParams() <-chan TransportParameters
    29  }
    30  
    31  type baseCryptoSetup interface {
    32  	HandleCryptoStream() error
    33  	ConnectionState() ConnectionState
    34  
    35  	GetSealer() (protocol.EncryptionLevel, Sealer)
    36  	GetSealerWithEncryptionLevel(protocol.EncryptionLevel) (Sealer, error)
    37  	GetSealerForCryptoStream() (protocol.EncryptionLevel, Sealer)
    38  }
    39  
    40  // CryptoSetup is the crypto setup used by gQUIC
    41  type CryptoSetup interface {
    42  	baseCryptoSetup
    43  
    44  	Open(dst, src []byte, packetNumber protocol.PacketNumber, associatedData []byte) ([]byte, protocol.EncryptionLevel, error)
    45  }
    46  
    47  // CryptoSetupTLS is the crypto setup used by IETF QUIC
    48  type CryptoSetupTLS interface {
    49  	baseCryptoSetup
    50  
    51  	OpenHandshake(dst, src []byte, packetNumber protocol.PacketNumber, associatedData []byte) ([]byte, error)
    52  	Open1RTT(dst, src []byte, packetNumber protocol.PacketNumber, associatedData []byte) ([]byte, error)
    53  }
    54  
    55  // ConnectionState records basic details about the QUIC connection.
    56  // Warning: This API should not be considered stable and might change soon.
    57  type ConnectionState struct {
    58  	HandshakeComplete bool                // handshake is complete
    59  	ServerName        string              // server name requested by client, if any (server side only)
    60  	PeerCertificates  []*x509.Certificate // certificate chain presented by remote peer
    61  }