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

Side by Side Diff: base/crypto/cssm_init.h

Issue 6659019: Separate GetMacSecurityServicesLock from cssm_init.h so that we can use... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Upload before checkin Created 9 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/base.gypi ('k') | base/crypto/cssm_init.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 BASE_CRYPTO_CSSM_INIT_H_ 5 #ifndef BASE_CRYPTO_CSSM_INIT_H_
6 #define BASE_CRYPTO_CSSM_INIT_H_ 6 #define BASE_CRYPTO_CSSM_INIT_H_
7 #pragma once 7 #pragma once
8 8
9 #include <Security/cssm.h> 9 #include <Security/cssm.h>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 12
13 namespace base { 13 namespace base {
14 14
15 class Lock;
16
17 // Initialize CSSM if it isn't already initialized. This must be called before 15 // Initialize CSSM if it isn't already initialized. This must be called before
18 // any other CSSM functions. This function is thread-safe, and CSSM will only 16 // any other CSSM functions. This function is thread-safe, and CSSM will only
19 // ever be initialized once. CSSM will be properly shut down on program exit. 17 // ever be initialized once. CSSM will be properly shut down on program exit.
20 void EnsureCSSMInit(); 18 void EnsureCSSMInit();
21 19
22 // Returns the shared CSP handle used by CSSM functions. 20 // Returns the shared CSP handle used by CSSM functions.
23 CSSM_CSP_HANDLE GetSharedCSPHandle(); 21 CSSM_CSP_HANDLE GetSharedCSPHandle();
24 22
25 // Returns the shared CL handle used by CSSM functions. 23 // Returns the shared CL handle used by CSSM functions.
26 CSSM_CL_HANDLE GetSharedCLHandle(); 24 CSSM_CL_HANDLE GetSharedCLHandle();
27 25
28 // Returns the shared TP handle used by CSSM functions. 26 // Returns the shared TP handle used by CSSM functions.
29 CSSM_TP_HANDLE GetSharedTPHandle(); 27 CSSM_TP_HANDLE GetSharedTPHandle();
30 28
31 // Set of pointers to memory function wrappers that are required for CSSM 29 // Set of pointers to memory function wrappers that are required for CSSM
32 extern const CSSM_API_MEMORY_FUNCS kCssmMemoryFunctions; 30 extern const CSSM_API_MEMORY_FUNCS kCssmMemoryFunctions;
33 31
34 // Utility function to log an error message including the error name. 32 // Utility function to log an error message including the error name.
35 void LogCSSMError(const char *function_name, CSSM_RETURN err); 33 void LogCSSMError(const char *function_name, CSSM_RETURN err);
36 34
37 // Utility functions to allocate and release CSSM memory. 35 // Utility functions to allocate and release CSSM memory.
38 void* CSSMMalloc(CSSM_SIZE size); 36 void* CSSMMalloc(CSSM_SIZE size);
39 void CSSMFree(void* ptr); 37 void CSSMFree(void* ptr);
40 38
41 // The OS X certificate and key management wrappers over CSSM are not
42 // thread-safe. In particular, code that accesses the CSSM database is
43 // problematic.
44 //
45 // http://developer.apple.com/mac/library/documentation/Security/Reference/certi fkeytrustservices/Reference/reference.html
46 Lock& GetMacSecurityServicesLock();
47
48 // Wrapper class for CSSM_DATA type. This should only be used when using the 39 // Wrapper class for CSSM_DATA type. This should only be used when using the
49 // CL/TP/CSP handles from above, since that's the only time we're guaranteed (or 40 // CL/TP/CSP handles from above, since that's the only time we're guaranteed (or
50 // supposed to be guaranteed) that our memory management functions will be used. 41 // supposed to be guaranteed) that our memory management functions will be used.
51 // Apple's Sec* APIs manage their own memory so it shouldn't be used for those. 42 // Apple's Sec* APIs manage their own memory so it shouldn't be used for those.
52 // The constructor initializes data_ to zero and the destructor releases the 43 // The constructor initializes data_ to zero and the destructor releases the
53 // data properly. 44 // data properly.
54 class ScopedCSSMData { 45 class ScopedCSSMData {
55 public: 46 public:
56 ScopedCSSMData(); 47 ScopedCSSMData();
57 ~ScopedCSSMData(); 48 ~ScopedCSSMData();
58 operator CSSM_DATA*() { return &data_; } 49 operator CSSM_DATA*() { return &data_; }
59 CSSM_DATA* operator ->() { return &data_; } 50 CSSM_DATA* operator ->() { return &data_; }
60 51
61 private: 52 private:
62 CSSM_DATA data_; 53 CSSM_DATA data_;
63 54
64 DISALLOW_COPY_AND_ASSIGN(ScopedCSSMData); 55 DISALLOW_COPY_AND_ASSIGN(ScopedCSSMData);
65 }; 56 };
66 57
67 } // namespace base 58 } // namespace base
68 59
69 #endif // BASE_CRYPTO_CSSM_INIT_H_ 60 #endif // BASE_CRYPTO_CSSM_INIT_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/crypto/cssm_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698