summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authordavidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-23 22:46:04 +0000
committerdavidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-23 22:46:04 +0000
commit3bcd57900283dc8dad7621bec74b3a6ced101021 (patch)
tree8a6508ff3e3dcbf3d7913bfd588ba7d91006ec2b /net
parent6e3408a22c7b089f16bb54b05edd55e87d3e01f6 (diff)
downloadchromium_src-3bcd57900283dc8dad7621bec74b3a6ced101021.zip
chromium_src-3bcd57900283dc8dad7621bec74b3a6ced101021.tar.gz
chromium_src-3bcd57900283dc8dad7621bec74b3a6ced101021.tar.bz2
Add a locked version of CryptAcquireContext
The function is not thread-safe when called with certain flags. This will be useful when we move keygen onto a worker thread. BUG=none TEST=KeygenHandlerTest.SmokeTest (existing) Review URL: http://codereview.chromium.org/2828019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50661 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/keygen_handler_win.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/net/base/keygen_handler_win.cc b/net/base/keygen_handler_win.cc
index 42997b6..3d97d17 100644
--- a/net/base/keygen_handler_win.cc
+++ b/net/base/keygen_handler_win.cc
@@ -16,6 +16,7 @@
#include "base/base64.h"
#include "base/basictypes.h"
+#include "base/crypto/capi_util.h"
#include "base/logging.h"
#include "base/string_piece.h"
#include "base/string_util.h"
@@ -250,8 +251,9 @@ std::string KeygenHandler::GenKeyAndSignChallenge() {
// Only create new key containers, so that existing key containers are not
// overwritten.
- ok = CryptAcquireContext(&prov, new_key_id.c_str(), NULL, PROV_RSA_FULL,
- CRYPT_SILENT | CRYPT_NEWKEYSET);
+ ok = base::CryptAcquireContextLocked(&prov, new_key_id.c_str(), NULL,
+ PROV_RSA_FULL,
+ CRYPT_SILENT | CRYPT_NEWKEYSET);
if (ok || GetLastError() != NTE_BAD_KEYSET)
break;
@@ -301,8 +303,9 @@ std::string KeygenHandler::GenKeyAndSignChallenge() {
prov = NULL;
if (!stores_key_) {
// Fully destroys any of the keys that were created and releases prov.
- CryptAcquireContext(&prov, new_key_id.c_str(), NULL, PROV_RSA_FULL,
- CRYPT_SILENT | CRYPT_DELETEKEYSET);
+ base::CryptAcquireContextLocked(&prov, new_key_id.c_str(), NULL,
+ PROV_RSA_FULL,
+ CRYPT_SILENT | CRYPT_DELETEKEYSET);
}
}