blob: 5158f48c08ff7b933965345b969b187d1334ed0c [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]982f1ab2012-08-30 13:03:465#include "crypto/apple_keychain.h"
6
7#import <Foundation/Foundation.h>
[email protected]b9d3d002012-03-17 12:14:508
[email protected]d6e8fe62012-10-03 05:46:459#include "base/synchronization/lock.h"
10#include "crypto/mac_security_services_lock.h"
11
[email protected]b9d3d002012-03-17 12:14:5012namespace crypto {
13
[email protected]982f1ab2012-08-30 13:03:4614AppleKeychain::AppleKeychain() {}
[email protected]b9d3d002012-03-17 12:14:5015
[email protected]982f1ab2012-08-30 13:03:4616AppleKeychain::~AppleKeychain() {}
[email protected]32d0ef52009-05-26 20:17:5017
Justin Cohen2db15692018-06-06 16:54:0318OSStatus AppleKeychain::ItemDelete(AppleSecKeychainItemRef itemRef) const {
[email protected]d6e8fe62012-10-03 05:46:4519 base::AutoLock lock(GetMacSecurityServicesLock());
[email protected]0a21fde2009-07-13 23:44:0820 return SecKeychainItemDelete(itemRef);
21}
22
Justin Cohen2db15692018-06-06 16:54:0323OSStatus AppleKeychain::FindGenericPassword(
24 UInt32 serviceNameLength,
25 const char* serviceName,
26 UInt32 accountNameLength,
27 const char* accountName,
28 UInt32* passwordLength,
29 void** passwordData,
30 AppleSecKeychainItemRef* itemRef) const {
[email protected]d6e8fe62012-10-03 05:46:4531 base::AutoLock lock(GetMacSecurityServicesLock());
Justin Cohen2db15692018-06-06 16:54:0332 return SecKeychainFindGenericPassword(nullptr, serviceNameLength, serviceName,
33 accountNameLength, accountName,
34 passwordLength, passwordData, itemRef);
[email protected]ecbf2892010-07-16 01:51:4535}
36
Justin Cohen2db15692018-06-06 16:54:0337OSStatus AppleKeychain::ItemFreeContent(void* data) const {
[email protected]d6e8fe62012-10-03 05:46:4538 base::AutoLock lock(GetMacSecurityServicesLock());
Justin Cohen2db15692018-06-06 16:54:0339 return SecKeychainItemFreeContent(nullptr, data);
[email protected]ecbf2892010-07-16 01:51:4540}
41
Justin Cohen2db15692018-06-06 16:54:0342OSStatus AppleKeychain::AddGenericPassword(
43 UInt32 serviceNameLength,
44 const char* serviceName,
45 UInt32 accountNameLength,
46 const char* accountName,
47 UInt32 passwordLength,
48 const void* passwordData,
49 AppleSecKeychainItemRef* itemRef) const {
[email protected]d6e8fe62012-10-03 05:46:4550 base::AutoLock lock(GetMacSecurityServicesLock());
Justin Cohen2db15692018-06-06 16:54:0351 return SecKeychainAddGenericPassword(nullptr, serviceNameLength, serviceName,
52 accountNameLength, accountName,
53 passwordLength, passwordData, itemRef);
[email protected]ecbf2892010-07-16 01:51:4554}
55
[email protected]b9d3d002012-03-17 12:14:5056} // namespace crypto