OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CRYPTO_SCOPED_CAPI_TYPES_H_ | 5 #ifndef CRYPTO_SCOPED_CAPI_TYPES_H_ |
6 #define CRYPTO_SCOPED_CAPI_TYPES_H_ | 6 #define CRYPTO_SCOPED_CAPI_TYPES_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <wincrypt.h> | |
10 | 9 |
11 #include <algorithm> | 10 #include <algorithm> |
12 | 11 |
13 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "crypto/wincrypt_shim.h" |
14 | 14 |
15 namespace crypto { | 15 namespace crypto { |
16 | 16 |
17 // Simple destructor for the Free family of CryptoAPI functions, such as | 17 // Simple destructor for the Free family of CryptoAPI functions, such as |
18 // CryptDestroyHash, which take only a single argument to release. | 18 // CryptDestroyHash, which take only a single argument to release. |
19 template <typename CAPIHandle, BOOL (WINAPI *Destroyer)(CAPIHandle)> | 19 template <typename CAPIHandle, BOOL (WINAPI *Destroyer)(CAPIHandle)> |
20 struct CAPIDestroyer { | 20 struct CAPIDestroyer { |
21 void operator()(CAPIHandle handle) const { | 21 void operator()(CAPIHandle handle) const { |
22 if (handle) { | 22 if (handle) { |
23 BOOL ok = Destroyer(handle); | 23 BOOL ok = Destroyer(handle); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 typedef ScopedCAPIHandle< | 113 typedef ScopedCAPIHandle< |
114 HCRYPTKEY, CAPIDestroyer<HCRYPTKEY, CryptDestroyKey> > ScopedHCRYPTKEY; | 114 HCRYPTKEY, CAPIDestroyer<HCRYPTKEY, CryptDestroyKey> > ScopedHCRYPTKEY; |
115 | 115 |
116 typedef ScopedCAPIHandle< | 116 typedef ScopedCAPIHandle< |
117 HCRYPTHASH, CAPIDestroyer<HCRYPTHASH, CryptDestroyHash> > ScopedHCRYPTHASH; | 117 HCRYPTHASH, CAPIDestroyer<HCRYPTHASH, CryptDestroyHash> > ScopedHCRYPTHASH; |
118 | 118 |
119 } // namespace crypto | 119 } // namespace crypto |
120 | 120 |
121 #endif // CRYPTO_SCOPED_CAPI_TYPES_H_ | 121 #endif // CRYPTO_SCOPED_CAPI_TYPES_H_ |
OLD | NEW |