Skip to content

Commit

Permalink
Remove CryptAcquireContextLocked.
Browse files Browse the repository at this point in the history
With keygen gone, this is no longer called.

BUG=none

Review-Url: https://codereview.chromium.org/2606393002
Cr-Commit-Position: refs/heads/master@{#441226}
  • Loading branch information
davidben authored and Commit bot committed Jan 3, 2017
1 parent b19680f commit e125bd2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 57 deletions.
41 changes: 1 addition & 40 deletions crypto/capi_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,10 @@
#include "crypto/capi_util.h"

#include <stddef.h>

#include "base/macros.h"
#include "base/memory/singleton.h"
#include "base/synchronization/lock.h"

namespace {

class CAPIUtilSingleton {
public:
static CAPIUtilSingleton* GetInstance() {
return base::Singleton<CAPIUtilSingleton>::get();
}

// Returns a lock to guard calls to CryptAcquireContext with
// CRYPT_DELETEKEYSET or CRYPT_NEWKEYSET.
base::Lock& acquire_context_lock() {
return acquire_context_lock_;
}

private:
friend class base::Singleton<CAPIUtilSingleton>;
friend struct base::DefaultSingletonTraits<CAPIUtilSingleton>;

CAPIUtilSingleton() {}

base::Lock acquire_context_lock_;

DISALLOW_COPY_AND_ASSIGN(CAPIUtilSingleton);
};

} // namespace
#include <stdlib.h>

namespace crypto {

BOOL CryptAcquireContextLocked(HCRYPTPROV* prov,
LPCWSTR container,
LPCWSTR provider,
DWORD prov_type,
DWORD flags) {
base::AutoLock lock(CAPIUtilSingleton::GetInstance()->acquire_context_lock());
return CryptAcquireContext(prov, container, provider, prov_type, flags);
}

void* WINAPI CryptAlloc(size_t size) {
return malloc(size);
}
Expand Down
17 changes: 0 additions & 17 deletions crypto/capi_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,9 @@
#include <stddef.h>

#include "crypto/crypto_export.h"
#include "crypto/wincrypt_shim.h"

namespace crypto {

// CryptAcquireContext when passed CRYPT_NEWKEYSET or CRYPT_DELETEKEYSET in
// flags is not thread-safe. For such calls, we create a global lock to
// synchronize it.
//
// From "Threading Issues with Cryptographic Service Providers",
// <http://msdn.microsoft.com/en-us/library/aa388149(v=VS.85).aspx>:
//
// "The CryptAcquireContext function is generally thread safe unless
// CRYPT_NEWKEYSET or CRYPT_DELETEKEYSET is specified in the dwFlags
// parameter."
CRYPTO_EXPORT BOOL CryptAcquireContextLocked(HCRYPTPROV* prov,
LPCWSTR container,
LPCWSTR provider,
DWORD prov_type,
DWORD flags);

// Wrappers of malloc and free for CryptoAPI routines that need memory
// allocators, such as in CRYPT_DECODE_PARA. Such routines require WINAPI
// calling conventions.
Expand Down

0 comments on commit e125bd2

Please sign in to comment.