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 #include "crypto/apple_keychain.h"
7 #import <Foundation/Foundation.h>
9 #include "base/synchronization/lock.h"
10 #include "crypto/mac_security_services_lock.h"
14 AppleKeychain::AppleKeychain() {}
16 AppleKeychain::~AppleKeychain() {}
18 OSStatus AppleKeychain::ItemDelete(SecKeychainItemRef itemRef) const {
19 base::AutoLock lock(GetMacSecurityServicesLock());
20 return SecKeychainItemDelete(itemRef);
23 OSStatus AppleKeychain::FindGenericPassword(CFTypeRef keychainOrArray,
24 UInt32 serviceNameLength,
25 const char* serviceName,
26 UInt32 accountNameLength,
27 const char* accountName,
28 UInt32* passwordLength,
30 SecKeychainItemRef* itemRef) const {
31 base::AutoLock lock(GetMacSecurityServicesLock());
32 return SecKeychainFindGenericPassword(keychainOrArray,
42 OSStatus AppleKeychain::ItemFreeContent(SecKeychainAttributeList* attrList,
44 base::AutoLock lock(GetMacSecurityServicesLock());
45 return SecKeychainItemFreeContent(attrList, data);
48 OSStatus AppleKeychain::AddGenericPassword(SecKeychainRef keychain,
49 UInt32 serviceNameLength,
50 const char* serviceName,
51 UInt32 accountNameLength,
52 const char* accountName,
53 UInt32 passwordLength,
54 const void* passwordData,
55 SecKeychainItemRef* itemRef) const {
56 base::AutoLock lock(GetMacSecurityServicesLock());
57 return SecKeychainAddGenericPassword(keychain,