Skip to content

Commit

Permalink
Backport fix for CVE-2021-34558 (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
rod-hynes authored Jul 13, 2021
1 parent 2179f28 commit 0b2885c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion key_agreement.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ func (ka rsaKeyAgreement) generateClientKeyExchange(config *Config, clientHello
return nil, nil, err
}

encrypted, err := rsa.EncryptPKCS1v15(config.rand(), cert.PublicKey.(*rsa.PublicKey), preMasterSecret)
rsaKey, ok := cert.PublicKey.(*rsa.PublicKey)
if !ok {
return nil, nil, errors.New("tls: server certificate contains incorrect key type for selected ciphersuite")
}
encrypted, err := rsa.EncryptPKCS1v15(config.rand(), rsaKey, preMasterSecret)
if err != nil {
return nil, nil, err
}
Expand Down

0 comments on commit 0b2885c

Please sign in to comment.