blob: 4d5715b25d4dbae73e71839f588722052e6cc05f [file] [log] [blame]
[email protected]b9d3d002012-03-17 12:14:501// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]32d0ef52009-05-26 20:17:502// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]b9d3d002012-03-17 12:14:505#include "crypto/keychain_mac.h"
6
7namespace crypto {
8
9MacKeychain::MacKeychain() {}
10
11MacKeychain::~MacKeychain() {}
[email protected]32d0ef52009-05-26 20:17:5012
13OSStatus MacKeychain::ItemCopyAttributesAndData(
[email protected]b9d3d002012-03-17 12:14:5014 SecKeychainItemRef itemRef,
15 SecKeychainAttributeInfo* info,
16 SecItemClass* itemClass,
17 SecKeychainAttributeList** attrList,
18 UInt32* length,
19 void** outData) const {
[email protected]32d0ef52009-05-26 20:17:5020 return SecKeychainItemCopyAttributesAndData(itemRef, info, itemClass,
21 attrList, length, outData);
22}
23
[email protected]06139a22009-06-23 16:36:2024OSStatus MacKeychain::ItemModifyAttributesAndData(
[email protected]b9d3d002012-03-17 12:14:5025 SecKeychainItemRef itemRef,
26 const SecKeychainAttributeList* attrList,
27 UInt32 length,
28 const void* data) const {
[email protected]06139a22009-06-23 16:36:2029 return SecKeychainItemModifyAttributesAndData(itemRef, attrList, length,
30 data);
31}
32
[email protected]32d0ef52009-05-26 20:17:5033OSStatus MacKeychain::ItemFreeAttributesAndData(
[email protected]b9d3d002012-03-17 12:14:5034 SecKeychainAttributeList* attrList,
35 void* data) const {
[email protected]32d0ef52009-05-26 20:17:5036 return SecKeychainItemFreeAttributesAndData(attrList, data);
37}
38
[email protected]0a21fde2009-07-13 23:44:0839OSStatus MacKeychain::ItemDelete(SecKeychainItemRef itemRef) const {
40 return SecKeychainItemDelete(itemRef);
41}
42
[email protected]32d0ef52009-05-26 20:17:5043OSStatus MacKeychain::SearchCreateFromAttributes(
[email protected]b9d3d002012-03-17 12:14:5044 CFTypeRef keychainOrArray,
45 SecItemClass itemClass,
46 const SecKeychainAttributeList* attrList,
47 SecKeychainSearchRef* searchRef) const {
[email protected]32d0ef52009-05-26 20:17:5048 return SecKeychainSearchCreateFromAttributes(keychainOrArray, itemClass,
49 attrList, searchRef);
50}
51
52OSStatus MacKeychain::SearchCopyNext(SecKeychainSearchRef searchRef,
[email protected]b9d3d002012-03-17 12:14:5053 SecKeychainItemRef* itemRef) const {
[email protected]32d0ef52009-05-26 20:17:5054 return SecKeychainSearchCopyNext(searchRef, itemRef);
55}
56
[email protected]06139a22009-06-23 16:36:2057OSStatus MacKeychain::AddInternetPassword(
58 SecKeychainRef keychain,
[email protected]b9d3d002012-03-17 12:14:5059 UInt32 serverNameLength,
60 const char* serverName,
61 UInt32 securityDomainLength,
62 const char* securityDomain,
63 UInt32 accountNameLength,
64 const char* accountName,
65 UInt32 pathLength,
66 const char* path,
67 UInt16 port,
68 SecProtocolType protocol,
[email protected]06139a22009-06-23 16:36:2069 SecAuthenticationType authenticationType,
[email protected]b9d3d002012-03-17 12:14:5070 UInt32 passwordLength,
71 const void* passwordData,
72 SecKeychainItemRef* itemRef) const {
[email protected]06139a22009-06-23 16:36:2073 return SecKeychainAddInternetPassword(keychain,
74 serverNameLength, serverName,
75 securityDomainLength, securityDomain,
76 accountNameLength, accountName,
77 pathLength, path,
78 port, protocol, authenticationType,
79 passwordLength, passwordData,
80 itemRef);
81}
82
[email protected]ecbf2892010-07-16 01:51:4583OSStatus MacKeychain::FindGenericPassword(CFTypeRef keychainOrArray,
84 UInt32 serviceNameLength,
[email protected]b9d3d002012-03-17 12:14:5085 const char* serviceName,
[email protected]ecbf2892010-07-16 01:51:4586 UInt32 accountNameLength,
[email protected]b9d3d002012-03-17 12:14:5087 const char* accountName,
88 UInt32* passwordLength,
89 void** passwordData,
90 SecKeychainItemRef* itemRef) const {
[email protected]ecbf2892010-07-16 01:51:4591 return SecKeychainFindGenericPassword(keychainOrArray,
92 serviceNameLength,
93 serviceName,
94 accountNameLength,
95 accountName,
96 passwordLength,
97 passwordData,
98 itemRef);
99}
100
[email protected]b9d3d002012-03-17 12:14:50101OSStatus MacKeychain::ItemFreeContent(SecKeychainAttributeList* attrList,
102 void* data) const {
[email protected]ecbf2892010-07-16 01:51:45103 return SecKeychainItemFreeContent(attrList, data);
104}
105
106OSStatus MacKeychain::AddGenericPassword(SecKeychainRef keychain,
107 UInt32 serviceNameLength,
[email protected]b9d3d002012-03-17 12:14:50108 const char* serviceName,
[email protected]ecbf2892010-07-16 01:51:45109 UInt32 accountNameLength,
[email protected]b9d3d002012-03-17 12:14:50110 const char* accountName,
[email protected]ecbf2892010-07-16 01:51:45111 UInt32 passwordLength,
[email protected]b9d3d002012-03-17 12:14:50112 const void* passwordData,
113 SecKeychainItemRef* itemRef) const {
[email protected]ecbf2892010-07-16 01:51:45114 return SecKeychainAddGenericPassword(keychain,
115 serviceNameLength,
116 serviceName,
117 accountNameLength,
118 accountName,
119 passwordLength,
120 passwordData,
121 itemRef);
122}
123
[email protected]32d0ef52009-05-26 20:17:50124void MacKeychain::Free(CFTypeRef ref) const {
[email protected]b9d3d002012-03-17 12:14:50125 if (ref)
[email protected]32d0ef52009-05-26 20:17:50126 CFRelease(ref);
[email protected]32d0ef52009-05-26 20:17:50127}
[email protected]b9d3d002012-03-17 12:14:50128
129} // namespace crypto