Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(774)

Unified Diff: net/third_party/nss/ssl/ssl3con.c

Issue 23889028: Merge 221609 "Prefer to generate SHA-1 signatures for TLS 1.2 cl..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1599/src/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/third_party/nss/patches/tls12backuphash.patch ('k') | net/third_party/nss/ssl/sslimpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/third_party/nss/ssl/ssl3con.c
===================================================================
--- net/third_party/nss/ssl/ssl3con.c (revision 223078)
+++ net/third_party/nss/ssl/ssl3con.c (working copy)
@@ -3675,7 +3675,6 @@
return SECFailure;
}
-#ifdef _WIN32
/* A backup SHA-1 hash for a potential client auth signature. */
if (!ss->sec.isServer) {
ss->ssl3.hs.md5 = PK11_CreateDigestContext(SEC_OID_SHA1);
@@ -3689,7 +3688,6 @@
return SECFailure;
}
}
-#endif
} else {
/* Both ss->ssl3.hs.md5 and ss->ssl3.hs.sha should be NULL or
* created successfully. */
@@ -6786,14 +6784,40 @@
if (isTLS12 && ss->ssl3.hs.md5) {
PRBool need_backup_hash = PR_FALSE;
+ PRBool prefer_sha1 = PR_FALSE;
#ifdef _WIN32
/* If the key is in CAPI, assume conservatively that the CAPI
* service provider may be unable to sign SHA-256 hashes.
- * Use SHA-1 if the server supports it. */
+ */
if (ss->ssl3.platformClientKey->dwKeySpec !=
CERT_NCRYPT_KEY_SPEC) {
+ /* CAPI only supports RSA and DSA signatures, so we don't
+ * need to check the key type. */
+ prefer_sha1 = PR_TRUE;
+ }
+#endif /* _WIN32 */
+ /* If the key is a 1024-bit RSA or DSA key, assume
+ * conservatively that it may be unable to sign SHA-256
+ * hashes. This is the case for older Estonian ID cards that
+ * have 1024-bit RSA keys. In FIPS 186-2 and older, DSA key
+ * size is at most 1024 bits and the hash function must be
+ * SHA-1.
+ */
+ if (!prefer_sha1) {
+ SECKEYPublicKey *pubk =
+ CERT_ExtractPublicKey(ss->ssl3.clientCertificate);
+ if (pubk == NULL) {
+ errCode = SSL_ERROR_EXTRACT_PUBLIC_KEY_FAILURE;
+ goto loser;
+ }
+ if (pubk->keyType == rsaKey || pubk->keyType == dsaKey) {
+ prefer_sha1 = SECKEY_PublicKeyStrength(pubk) <= 128;
+ }
+ SECKEY_DestroyPublicKey(pubk);
+ }
+ /* Use SHA-1 if the server supports it. */
+ if (prefer_sha1) {
for (i = 0; i < algorithms.len; i += 2) {
- /* CAPI only supports RSA and DSA signatures. */
if (algorithms.data[i] == tls_hash_sha1 &&
(algorithms.data[i+1] == tls_sig_rsa ||
algorithms.data[i+1] == tls_sig_dsa)) {
@@ -6802,7 +6826,6 @@
}
}
}
-#endif /* _WIN32 */
if (!need_backup_hash) {
PK11_DestroyContext(ss->ssl3.hs.md5, PR_TRUE);
ss->ssl3.hs.md5 = NULL;
« no previous file with comments | « net/third_party/nss/patches/tls12backuphash.patch ('k') | net/third_party/nss/ssl/sslimpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698