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 #include "chrome/browser/keychain_mac.h" | 5 #include "crypto/keychain_mac.h" |
| 6 |
| 7 namespace crypto { |
| 8 |
| 9 MacKeychain::MacKeychain() {} |
| 10 |
| 11 MacKeychain::~MacKeychain() {} |
6 | 12 |
7 OSStatus MacKeychain::ItemCopyAttributesAndData( | 13 OSStatus MacKeychain::ItemCopyAttributesAndData( |
8 SecKeychainItemRef itemRef, SecKeychainAttributeInfo *info, | 14 SecKeychainItemRef itemRef, |
9 SecItemClass *itemClass, SecKeychainAttributeList **attrList, | 15 SecKeychainAttributeInfo* info, |
10 UInt32 *length, void **outData) const { | 16 SecItemClass* itemClass, |
| 17 SecKeychainAttributeList** attrList, |
| 18 UInt32* length, |
| 19 void** outData) const { |
11 return SecKeychainItemCopyAttributesAndData(itemRef, info, itemClass, | 20 return SecKeychainItemCopyAttributesAndData(itemRef, info, itemClass, |
12 attrList, length, outData); | 21 attrList, length, outData); |
13 } | 22 } |
14 | 23 |
15 OSStatus MacKeychain::ItemModifyAttributesAndData( | 24 OSStatus MacKeychain::ItemModifyAttributesAndData( |
16 SecKeychainItemRef itemRef, const SecKeychainAttributeList *attrList, | 25 SecKeychainItemRef itemRef, |
17 UInt32 length, const void *data) const { | 26 const SecKeychainAttributeList* attrList, |
| 27 UInt32 length, |
| 28 const void* data) const { |
18 return SecKeychainItemModifyAttributesAndData(itemRef, attrList, length, | 29 return SecKeychainItemModifyAttributesAndData(itemRef, attrList, length, |
19 data); | 30 data); |
20 } | 31 } |
21 | 32 |
22 OSStatus MacKeychain::ItemFreeAttributesAndData( | 33 OSStatus MacKeychain::ItemFreeAttributesAndData( |
23 SecKeychainAttributeList *attrList, void *data) const { | 34 SecKeychainAttributeList* attrList, |
| 35 void* data) const { |
24 return SecKeychainItemFreeAttributesAndData(attrList, data); | 36 return SecKeychainItemFreeAttributesAndData(attrList, data); |
25 } | 37 } |
26 | 38 |
27 OSStatus MacKeychain::ItemDelete(SecKeychainItemRef itemRef) const { | 39 OSStatus MacKeychain::ItemDelete(SecKeychainItemRef itemRef) const { |
28 return SecKeychainItemDelete(itemRef); | 40 return SecKeychainItemDelete(itemRef); |
29 } | 41 } |
30 | 42 |
31 OSStatus MacKeychain::SearchCreateFromAttributes( | 43 OSStatus MacKeychain::SearchCreateFromAttributes( |
32 CFTypeRef keychainOrArray, SecItemClass itemClass, | 44 CFTypeRef keychainOrArray, |
33 const SecKeychainAttributeList *attrList, | 45 SecItemClass itemClass, |
34 SecKeychainSearchRef *searchRef) const { | 46 const SecKeychainAttributeList* attrList, |
| 47 SecKeychainSearchRef* searchRef) const { |
35 return SecKeychainSearchCreateFromAttributes(keychainOrArray, itemClass, | 48 return SecKeychainSearchCreateFromAttributes(keychainOrArray, itemClass, |
36 attrList, searchRef); | 49 attrList, searchRef); |
37 } | 50 } |
38 | 51 |
39 OSStatus MacKeychain::SearchCopyNext(SecKeychainSearchRef searchRef, | 52 OSStatus MacKeychain::SearchCopyNext(SecKeychainSearchRef searchRef, |
40 SecKeychainItemRef *itemRef) const { | 53 SecKeychainItemRef* itemRef) const { |
41 return SecKeychainSearchCopyNext(searchRef, itemRef); | 54 return SecKeychainSearchCopyNext(searchRef, itemRef); |
42 } | 55 } |
43 | 56 |
44 OSStatus MacKeychain::AddInternetPassword( | 57 OSStatus MacKeychain::AddInternetPassword( |
45 SecKeychainRef keychain, | 58 SecKeychainRef keychain, |
46 UInt32 serverNameLength, const char *serverName, | 59 UInt32 serverNameLength, |
47 UInt32 securityDomainLength, const char *securityDomain, | 60 const char* serverName, |
48 UInt32 accountNameLength, const char *accountName, | 61 UInt32 securityDomainLength, |
49 UInt32 pathLength, const char *path, | 62 const char* securityDomain, |
50 UInt16 port, SecProtocolType protocol, | 63 UInt32 accountNameLength, |
| 64 const char* accountName, |
| 65 UInt32 pathLength, |
| 66 const char* path, |
| 67 UInt16 port, |
| 68 SecProtocolType protocol, |
51 SecAuthenticationType authenticationType, | 69 SecAuthenticationType authenticationType, |
52 UInt32 passwordLength, const void *passwordData, | 70 UInt32 passwordLength, |
53 SecKeychainItemRef *itemRef) const { | 71 const void* passwordData, |
| 72 SecKeychainItemRef* itemRef) const { |
54 return SecKeychainAddInternetPassword(keychain, | 73 return SecKeychainAddInternetPassword(keychain, |
55 serverNameLength, serverName, | 74 serverNameLength, serverName, |
56 securityDomainLength, securityDomain, | 75 securityDomainLength, securityDomain, |
57 accountNameLength, accountName, | 76 accountNameLength, accountName, |
58 pathLength, path, | 77 pathLength, path, |
59 port, protocol, authenticationType, | 78 port, protocol, authenticationType, |
60 passwordLength, passwordData, | 79 passwordLength, passwordData, |
61 itemRef); | 80 itemRef); |
62 } | 81 } |
63 | 82 |
64 OSStatus MacKeychain::FindGenericPassword(CFTypeRef keychainOrArray, | 83 OSStatus MacKeychain::FindGenericPassword(CFTypeRef keychainOrArray, |
65 UInt32 serviceNameLength, | 84 UInt32 serviceNameLength, |
66 const char *serviceName, | 85 const char* serviceName, |
67 UInt32 accountNameLength, | 86 UInt32 accountNameLength, |
68 const char *accountName, | 87 const char* accountName, |
69 UInt32 *passwordLength, | 88 UInt32* passwordLength, |
70 void **passwordData, | 89 void** passwordData, |
71 SecKeychainItemRef *itemRef) const { | 90 SecKeychainItemRef* itemRef) const { |
72 return SecKeychainFindGenericPassword(keychainOrArray, | 91 return SecKeychainFindGenericPassword(keychainOrArray, |
73 serviceNameLength, | 92 serviceNameLength, |
74 serviceName, | 93 serviceName, |
75 accountNameLength, | 94 accountNameLength, |
76 accountName, | 95 accountName, |
77 passwordLength, | 96 passwordLength, |
78 passwordData, | 97 passwordData, |
79 itemRef); | 98 itemRef); |
80 } | 99 } |
81 | 100 |
82 OSStatus MacKeychain::ItemFreeContent(SecKeychainAttributeList *attrList, | 101 OSStatus MacKeychain::ItemFreeContent(SecKeychainAttributeList* attrList, |
83 void *data) const { | 102 void* data) const { |
84 return SecKeychainItemFreeContent(attrList, data); | 103 return SecKeychainItemFreeContent(attrList, data); |
85 } | 104 } |
86 | 105 |
87 OSStatus MacKeychain::AddGenericPassword(SecKeychainRef keychain, | 106 OSStatus MacKeychain::AddGenericPassword(SecKeychainRef keychain, |
88 UInt32 serviceNameLength, | 107 UInt32 serviceNameLength, |
89 const char *serviceName, | 108 const char* serviceName, |
90 UInt32 accountNameLength, | 109 UInt32 accountNameLength, |
91 const char *accountName, | 110 const char* accountName, |
92 UInt32 passwordLength, | 111 UInt32 passwordLength, |
93 const void *passwordData, | 112 const void* passwordData, |
94 SecKeychainItemRef *itemRef) const { | 113 SecKeychainItemRef* itemRef) const { |
95 return SecKeychainAddGenericPassword(keychain, | 114 return SecKeychainAddGenericPassword(keychain, |
96 serviceNameLength, | 115 serviceNameLength, |
97 serviceName, | 116 serviceName, |
98 accountNameLength, | 117 accountNameLength, |
99 accountName, | 118 accountName, |
100 passwordLength, | 119 passwordLength, |
101 passwordData, | 120 passwordData, |
102 itemRef); | 121 itemRef); |
103 } | 122 } |
104 | 123 |
105 void MacKeychain::Free(CFTypeRef ref) const { | 124 void MacKeychain::Free(CFTypeRef ref) const { |
106 if (ref) { | 125 if (ref) |
107 CFRelease(ref); | 126 CFRelease(ref); |
108 } | |
109 } | 127 } |
| 128 |
| 129 } // namespace crypto |
OLD | NEW |