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

Unified Diff: net/ssl/openssl_platform_key_win.cc

Issue 1156173008: Call CryptSignHash twice in client certificate logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@capi-leak
Patch Set: Created 5 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ssl/openssl_platform_key_win.cc
diff --git a/net/ssl/openssl_platform_key_win.cc b/net/ssl/openssl_platform_key_win.cc
index 4a399fb20d03e100eedc4ae4ee18ea385be40ae2..9033c6e8e4b3d99929846258c29926ced129d2a1 100644
--- a/net/ssl/openssl_platform_key_win.cc
+++ b/net/ssl/openssl_platform_key_win.cc
@@ -317,7 +317,20 @@ int RsaMethodSign(int hash_nid,
OpenSSLPutNetError(FROM_HERE, ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED);
return 0;
}
- DWORD signature_len = RSA_size(rsa);
+ // Determine the output length.
+ DWORD signature_len = 0;
+ if (!CryptSignHash(hash.get(), ex_data->key->dwKeySpec, nullptr, 0, nullptr,
+ &signature_len)) {
+ PLOG(ERROR) << "CryptSignHash failed";
+ OpenSSLPutNetError(FROM_HERE, ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED);
+ return 0;
+ }
+ if (signature_len == 0 || signature_len > RSA_size(rsa)) {
+ LOG(ERROR) << "Bad signature length";
+ OpenSSLPutNetError(FROM_HERE, ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED);
+ return 0;
+ }
+ // Sign the hash.
if (!CryptSignHash(hash.get(), ex_data->key->dwKeySpec, nullptr, 0, out,
&signature_len)) {
PLOG(ERROR) << "CryptSignHash failed";
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698