forked from quic-go/quic-go
rename Handshake to CryptoSetup
This commit is contained in:
@@ -9,17 +9,17 @@ import (
|
||||
"github.com/lucas-clemente/quic-go/protocol"
|
||||
)
|
||||
|
||||
// The Handshake handles all things crypto for the Session
|
||||
type Handshake struct {
|
||||
// The CryptoSetup handles all things crypto for the Session
|
||||
type CryptoSetup struct {
|
||||
connID protocol.ConnectionID
|
||||
version protocol.VersionNumber
|
||||
aead crypto.AEAD
|
||||
scfg *ServerConfig
|
||||
}
|
||||
|
||||
// NewHandshake creates a new Handshake instance
|
||||
func NewHandshake(connID protocol.ConnectionID, version protocol.VersionNumber, scfg *ServerConfig) *Handshake {
|
||||
return &Handshake{
|
||||
// NewCryptoSetup creates a new CryptoSetup instance
|
||||
func NewCryptoSetup(connID protocol.ConnectionID, version protocol.VersionNumber, scfg *ServerConfig) *CryptoSetup {
|
||||
return &CryptoSetup{
|
||||
connID: connID,
|
||||
version: version,
|
||||
aead: &crypto.NullAEAD{},
|
||||
@@ -28,17 +28,17 @@ func NewHandshake(connID protocol.ConnectionID, version protocol.VersionNumber,
|
||||
}
|
||||
|
||||
// Open a message
|
||||
func (h *Handshake) Open(packetNumber protocol.PacketNumber, associatedData []byte, ciphertext io.Reader) (*bytes.Reader, error) {
|
||||
func (h *CryptoSetup) Open(packetNumber protocol.PacketNumber, associatedData []byte, ciphertext io.Reader) (*bytes.Reader, error) {
|
||||
return h.aead.Open(packetNumber, associatedData, ciphertext)
|
||||
}
|
||||
|
||||
// Seal a messageTag
|
||||
func (h *Handshake) Seal(packetNumber protocol.PacketNumber, b *bytes.Buffer, associatedData []byte, plaintext []byte) {
|
||||
func (h *CryptoSetup) Seal(packetNumber protocol.PacketNumber, b *bytes.Buffer, associatedData []byte, plaintext []byte) {
|
||||
h.aead.Seal(packetNumber, b, associatedData, plaintext)
|
||||
}
|
||||
|
||||
// HandleCryptoMessage handles the crypto handshake and returns the answer
|
||||
func (h *Handshake) HandleCryptoMessage(data []byte) ([]byte, error) {
|
||||
func (h *CryptoSetup) HandleCryptoMessage(data []byte) ([]byte, error) {
|
||||
messageTag, cryptoData, err := ParseHandshakeMessage(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -65,16 +65,17 @@ func (h *Handshake) HandleCryptoMessage(data []byte) ([]byte, error) {
|
||||
if h.version > protocol.VersionNumber(30) {
|
||||
chloOrNil = data
|
||||
}
|
||||
|
||||
proof, err := h.scfg.Sign(chloOrNil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var serverReply bytes.Buffer
|
||||
WriteHandshakeMessage(&serverReply, TagREJ, map[Tag][]byte{
|
||||
TagSCFG: h.scfg.Get(),
|
||||
TagCERT: h.scfg.GetCertCompressed(),
|
||||
TagPROF: proof,
|
||||
})
|
||||
|
||||
return serverReply.Bytes(), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user