Add OS_IOS defines for the mobile promo.
[chromium-blink-merge.git] / crypto / keychain_mac.h
blobbbcf8b1463cdd302f8c5d1c7053c0be65174fe57
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
3 // found in the LICENSE file.
5 #ifndef CRYPTO_KEYCHAIN_MAC_H_
6 #define CRYPTO_KEYCHAIN_MAC_H_
8 #include <Security/Security.h>
10 #include "base/basictypes.h"
11 #include "crypto/crypto_export.h"
13 namespace crypto {
15 // Wraps the KeychainServices API in a very thin layer, to allow it to be
16 // mocked out for testing.
18 // See Keychain Services documentation for function documentation, as these call
19 // through directly to their Keychain Services equivalents (Foo ->
20 // SecKeychainFoo). The only exception is Free, which should be used for
21 // anything returned from this class that would normally be freed with
22 // CFRelease (to aid in testing).
23 class CRYPTO_EXPORT MacKeychain {
24 public:
25 MacKeychain();
26 virtual ~MacKeychain();
28 virtual OSStatus ItemCopyAttributesAndData(
29 SecKeychainItemRef itemRef,
30 SecKeychainAttributeInfo* info,
31 SecItemClass* itemClass,
32 SecKeychainAttributeList** attrList,
33 UInt32* length,
34 void** outData) const;
36 virtual OSStatus ItemModifyAttributesAndData(
37 SecKeychainItemRef itemRef,
38 const SecKeychainAttributeList* attrList,
39 UInt32 length,
40 const void* data) const;
42 virtual OSStatus ItemFreeAttributesAndData(SecKeychainAttributeList* attrList,
43 void* data) const;
45 virtual OSStatus ItemDelete(SecKeychainItemRef itemRef) const;
47 virtual OSStatus SearchCreateFromAttributes(
48 CFTypeRef keychainOrArray,
49 SecItemClass itemClass,
50 const SecKeychainAttributeList* attrList,
51 SecKeychainSearchRef* searchRef) const;
53 virtual OSStatus SearchCopyNext(SecKeychainSearchRef searchRef,
54 SecKeychainItemRef* itemRef) const;
56 virtual OSStatus AddInternetPassword(SecKeychainRef keychain,
57 UInt32 serverNameLength,
58 const char* serverName,
59 UInt32 securityDomainLength,
60 const char* securityDomain,
61 UInt32 accountNameLength,
62 const char* accountName,
63 UInt32 pathLength, const char* path,
64 UInt16 port, SecProtocolType protocol,
65 SecAuthenticationType authenticationType,
66 UInt32 passwordLength,
67 const void* passwordData,
68 SecKeychainItemRef* itemRef) const;
70 virtual OSStatus FindGenericPassword(CFTypeRef keychainOrArray,
71 UInt32 serviceNameLength,
72 const char* serviceName,
73 UInt32 accountNameLength,
74 const char* accountName,
75 UInt32* passwordLength,
76 void** passwordData,
77 SecKeychainItemRef* itemRef) const;
79 virtual OSStatus ItemFreeContent(SecKeychainAttributeList* attrList,
80 void* data) const;
82 virtual OSStatus AddGenericPassword(SecKeychainRef keychain,
83 UInt32 serviceNameLength,
84 const char* serviceName,
85 UInt32 accountNameLength,
86 const char* accountName,
87 UInt32 passwordLength,
88 const void* passwordData,
89 SecKeychainItemRef* itemRef) const;
91 // Calls CFRelease on the given ref, after checking that |ref| is non-NULL.
92 virtual void Free(CFTypeRef ref) const;
94 private:
95 DISALLOW_COPY_AND_ASSIGN(MacKeychain);
98 } // namespace crypto
100 #endif // CRYPTO_KEYCHAIN_MAC_H_