OLD | NEW |
---|---|
1 // Copyright (c) 2009 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 CHROME_BROWSER_KEYCHAIN_MAC_H_ | 5 #ifndef CRYPTO_KEYCHAIN_MAC_H_ |
6 #define CHROME_BROWSER_KEYCHAIN_MAC_H_ | 6 #define CRYPTO_KEYCHAIN_MAC_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <Security/Security.h> | 9 #include <Security/Security.h> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 | 12 |
13 namespace crypto { | |
14 | |
13 // Wraps the KeychainServices API in a very thin layer, to allow it to be | 15 // Wraps the KeychainServices API in a very thin layer, to allow it to be |
14 // mocked out for testing. | 16 // mocked out for testing. |
15 | 17 |
16 // See Keychain Services documentation for function documentation, as these call | 18 // See Keychain Services documentation for function documentation, as these call |
17 // through directly to their Keychain Services equivalents (Foo -> | 19 // through directly to their Keychain Services equivalents (Foo -> |
18 // SecKeychainFoo). The only exception is Free, which should be used for | 20 // SecKeychainFoo). The only exception is Free, which should be used for |
19 // anything returned from this class that would normally be freed with | 21 // anything returned from this class that would normally be freed with |
20 // CFRelease (to aid in testing). | 22 // CFRelease (to aid in testing). |
21 class MacKeychain { | 23 class MacKeychain { |
wtc
2012/03/19 22:42:28
The class is named MacKeychain, but the file is na
akalin
2012/03/19 22:50:03
Yeah, that's what I would guess. Although come to
wtc
2012/03/19 23:03:21
mac_keychain_mac looks weird. I am OK with keycha
| |
22 public: | 24 public: |
23 MacKeychain() {} | 25 MacKeychain(); |
24 virtual ~MacKeychain() {} | 26 virtual ~MacKeychain(); |
25 | 27 |
26 virtual OSStatus ItemCopyAttributesAndData( | 28 virtual OSStatus ItemCopyAttributesAndData( |
27 SecKeychainItemRef itemRef, SecKeychainAttributeInfo *info, | 29 SecKeychainItemRef itemRef, |
28 SecItemClass *itemClass, SecKeychainAttributeList **attrList, | 30 SecKeychainAttributeInfo* info, |
29 UInt32 *length, void **outData) const; | 31 SecItemClass* itemClass, |
32 SecKeychainAttributeList** attrList, | |
33 UInt32* length, | |
34 void** outData) const; | |
30 | 35 |
31 virtual OSStatus ItemModifyAttributesAndData( | 36 virtual OSStatus ItemModifyAttributesAndData( |
32 SecKeychainItemRef itemRef, const SecKeychainAttributeList *attrList, | 37 SecKeychainItemRef itemRef, |
33 UInt32 length, const void *data) const; | 38 const SecKeychainAttributeList* attrList, |
39 UInt32 length, | |
40 const void* data) const; | |
34 | 41 |
35 virtual OSStatus ItemFreeAttributesAndData(SecKeychainAttributeList *attrList, | 42 virtual OSStatus ItemFreeAttributesAndData(SecKeychainAttributeList* attrList, |
36 void *data) const; | 43 void* data) const; |
37 | 44 |
38 virtual OSStatus ItemDelete(SecKeychainItemRef itemRef) const; | 45 virtual OSStatus ItemDelete(SecKeychainItemRef itemRef) const; |
39 | 46 |
40 virtual OSStatus SearchCreateFromAttributes( | 47 virtual OSStatus SearchCreateFromAttributes( |
41 CFTypeRef keychainOrArray, SecItemClass itemClass, | 48 CFTypeRef keychainOrArray, |
42 const SecKeychainAttributeList *attrList, | 49 SecItemClass itemClass, |
43 SecKeychainSearchRef *searchRef) const; | 50 const SecKeychainAttributeList* attrList, |
51 SecKeychainSearchRef* searchRef) const; | |
44 | 52 |
45 virtual OSStatus SearchCopyNext(SecKeychainSearchRef searchRef, | 53 virtual OSStatus SearchCopyNext(SecKeychainSearchRef searchRef, |
46 SecKeychainItemRef *itemRef) const; | 54 SecKeychainItemRef* itemRef) const; |
47 | 55 |
48 virtual OSStatus AddInternetPassword(SecKeychainRef keychain, | 56 virtual OSStatus AddInternetPassword(SecKeychainRef keychain, |
49 UInt32 serverNameLength, | 57 UInt32 serverNameLength, |
50 const char *serverName, | 58 const char* serverName, |
51 UInt32 securityDomainLength, | 59 UInt32 securityDomainLength, |
52 const char *securityDomain, | 60 const char* securityDomain, |
53 UInt32 accountNameLength, | 61 UInt32 accountNameLength, |
54 const char *accountName, | 62 const char* accountName, |
55 UInt32 pathLength, const char *path, | 63 UInt32 pathLength, const char* path, |
56 UInt16 port, SecProtocolType protocol, | 64 UInt16 port, SecProtocolType protocol, |
57 SecAuthenticationType authenticationType, | 65 SecAuthenticationType authenticationType, |
58 UInt32 passwordLength, | 66 UInt32 passwordLength, |
59 const void *passwordData, | 67 const void* passwordData, |
60 SecKeychainItemRef *itemRef) const; | 68 SecKeychainItemRef* itemRef) const; |
61 | 69 |
62 virtual OSStatus FindGenericPassword(CFTypeRef keychainOrArray, | 70 virtual OSStatus FindGenericPassword(CFTypeRef keychainOrArray, |
63 UInt32 serviceNameLength, | 71 UInt32 serviceNameLength, |
64 const char *serviceName, | 72 const char* serviceName, |
65 UInt32 accountNameLength, | 73 UInt32 accountNameLength, |
66 const char *accountName, | 74 const char* accountName, |
67 UInt32 *passwordLength, | 75 UInt32* passwordLength, |
68 void **passwordData, | 76 void** passwordData, |
69 SecKeychainItemRef *itemRef) const; | 77 SecKeychainItemRef* itemRef) const; |
70 | 78 |
71 virtual OSStatus ItemFreeContent(SecKeychainAttributeList *attrList, | 79 virtual OSStatus ItemFreeContent(SecKeychainAttributeList* attrList, |
72 void *data) const; | 80 void* data) const; |
73 | 81 |
74 virtual OSStatus AddGenericPassword(SecKeychainRef keychain, | 82 virtual OSStatus AddGenericPassword(SecKeychainRef keychain, |
75 UInt32 serviceNameLength, | 83 UInt32 serviceNameLength, |
76 const char *serviceName, | 84 const char* serviceName, |
77 UInt32 accountNameLength, | 85 UInt32 accountNameLength, |
78 const char *accountName, | 86 const char* accountName, |
79 UInt32 passwordLength, | 87 UInt32 passwordLength, |
80 const void *passwordData, | 88 const void* passwordData, |
81 SecKeychainItemRef *itemRef) const; | 89 SecKeychainItemRef* itemRef) const; |
82 | 90 |
83 // Calls CFRelease on the given ref, after checking that |ref| is non-NULL. | 91 // Calls CFRelease on the given ref, after checking that |ref| is non-NULL. |
84 virtual void Free(CFTypeRef ref) const; | 92 virtual void Free(CFTypeRef ref) const; |
85 | 93 |
86 private: | 94 private: |
87 DISALLOW_COPY_AND_ASSIGN(MacKeychain); | 95 DISALLOW_COPY_AND_ASSIGN(MacKeychain); |
88 }; | 96 }; |
89 | 97 |
90 #endif // CHROME_BROWSER_KEYCHAIN_MAC_H_ | 98 } // namespace crypto |
99 | |
100 #endif // CRYPTO_KEYCHAIN_MAC_H_ | |
OLD | NEW |