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