generate a client nonce once, when reading a server config multiple times

This commit is contained in:
Marten Seemann
2016-11-11 10:50:50 +07:00
parent a2996f6343
commit 4b67aefb83
2 changed files with 19 additions and 3 deletions

View File

@@ -97,6 +97,7 @@ func (h *cryptoSetupClient) handleREJMessage(cryptoData map[Tag][]byte) error {
h.sno = sno
}
// TODO: what happens if the server sends a different server config in two packets?
if scfg, ok := cryptoData[TagSCFG]; ok {
h.serverConfig, err = parseServerConfig(scfg)
if err != nil {
@@ -104,9 +105,11 @@ func (h *cryptoSetupClient) handleREJMessage(cryptoData map[Tag][]byte) error {
}
// now that we have a server config, we can use its OBIT value to generate a client nonce
err = h.generateClientNonce()
if err != nil {
return err
if len(h.nonc) == 0 {
err = h.generateClientNonce()
if err != nil {
return err
}
}
}