randomly generate the server config ID and check whether it matches

This commit is contained in:
Lucas Clemente
2016-04-16 00:09:50 +02:00
parent 06a4201d65
commit 13c0445bb4
3 changed files with 16 additions and 3 deletions

View File

@@ -47,7 +47,8 @@ func (h *CryptoSetup) HandleCryptoMessage(data []byte) ([]byte, error) {
return nil, errors.New("Session: expected CHLO")
}
if _, ok := cryptoData[TagSCID]; ok {
if scid, ok := cryptoData[TagSCID]; ok && bytes.Equal(h.scfg.ID, scid) {
// We have a CHLO matching our server config, we can continue with the 0-RTT handshake
var sharedSecret []byte
sharedSecret, err = h.scfg.kex.CalculateSharedKey(cryptoData[TagPUBS])
if err != nil {
@@ -61,6 +62,8 @@ func (h *CryptoSetup) HandleCryptoMessage(data []byte) ([]byte, error) {
return nil, nil
}
// We have an inacholate or non-matching CHLO, we now send a rejection
var chloOrNil []byte
if h.version > protocol.VersionNumber(30) {
chloOrNil = data