2 * Copyright (c) 2009-2010,2012-2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 #include <securityd/spi.h>
26 #include <ipc/securityd_client.h>
27 #include <securityd/SecPolicyServer.h>
28 #include <securityd/SecItemBackupServer.h>
29 #include <securityd/SecItemServer.h>
30 #include <securityd/SecTrustStoreServer.h>
31 #include <Security/SecureObjectSync/SOSPeerInfo.h>
32 #include <CoreFoundation/CFString.h>
33 #include <CoreFoundation/CFError.h>
34 #include <securityd/SOSCloudCircleServer.h>
35 #include <securityd/SecOTRRemote.h>
36 #include <securityd/SecLogSettingsServer.h>
38 #include <CoreFoundation/CFXPCBridge.h>
39 #include "utilities/iOSforOSX.h"
40 #include "utilities/SecFileLocations.h"
41 #include "OTATrustUtilities.h"
43 static struct securityd spi
= {
45 /* Trustd must xpc to secd to use these. */
46 .sec_item_add
= _SecItemAdd
,
47 .sec_item_copy_matching
= _SecItemCopyMatching
,
48 .sec_item_update
= _SecItemUpdate
,
49 .sec_item_delete
= _SecItemDelete
,
51 .sec_add_shared_web_credential
= _SecAddSharedWebCredential
,
52 .sec_copy_shared_web_credential
= _SecCopySharedWebCredential
,
54 .sec_trust_store_for_domain
= SecTrustStoreForDomainName
,
55 .sec_trust_store_contains
= SecTrustStoreContainsCertificateWithDigest
,
56 .sec_trust_store_set_trust_settings
= _SecTrustStoreSetTrustSettings
,
57 .sec_trust_store_remove_certificate
= SecTrustStoreRemoveCertificateWithDigest
,
58 .sec_truststore_remove_all
= _SecTrustStoreRemoveAll
,
59 .sec_item_delete_all
= _SecItemDeleteAll
,
61 #if TRUSTD_SERVER || TARGET_OS_IPHONE
62 /* Local trust evaluation only occurs in trustd and iOS securityd */
63 .sec_trust_evaluate
= SecTrustServerEvaluate
,
66 /* Trustd must xpc to secd to use these. */
67 .sec_keychain_backup
= _SecServerKeychainCreateBackup
,
68 .sec_keychain_restore
= _SecServerKeychainRestore
,
69 .sec_keychain_backup_syncable
= _SecServerBackupSyncable
,
70 .sec_keychain_restore_syncable
= _SecServerRestoreSyncable
,
71 .sec_item_backup_copy_names
= SecServerItemBackupCopyNames
,
72 .sec_item_backup_handoff_fd
= SecServerItemBackupHandoffFD
,
73 .sec_item_backup_set_confirmed_manifest
= SecServerItemBackupSetConfirmedManifest
,
74 .sec_item_backup_restore
= SecServerItemBackupRestore
,
75 .sec_otr_session_create_remote
= _SecOTRSessionCreateRemote
,
76 .sec_otr_session_process_packet_remote
= _SecOTRSessionProcessPacketRemote
,
77 .sec_ota_pki_asset_version
= SecOTAPKIGetCurrentAssetVersion
,
78 .soscc_TryUserCredentials
= SOSCCTryUserCredentials_Server
,
79 .soscc_SetUserCredentials
= SOSCCSetUserCredentials_Server
,
80 .soscc_SetUserCredentialsAndDSID
= SOSCCSetUserCredentialsAndDSID_Server
,
81 .soscc_CanAuthenticate
= SOSCCCanAuthenticate_Server
,
82 .soscc_PurgeUserCredentials
= SOSCCPurgeUserCredentials_Server
,
83 .soscc_ThisDeviceIsInCircle
= SOSCCThisDeviceIsInCircle_Server
,
84 .soscc_RequestToJoinCircle
= SOSCCRequestToJoinCircle_Server
,
85 .soscc_RequestToJoinCircleAfterRestore
= SOSCCRequestToJoinCircleAfterRestore_Server
,
86 .soscc_RequestEnsureFreshParameters
= SOSCCRequestEnsureFreshParameters_Server
,
87 .soscc_GetAllTheRings
= SOSCCGetAllTheRings_Server
,
88 .soscc_ApplyToARing
= SOSCCApplyToARing_Server
,
89 .soscc_WithdrawlFromARing
= SOSCCWithdrawlFromARing_Server
,
90 .soscc_EnableRing
= SOSCCEnableRing_Server
,
91 .soscc_RingStatus
= SOSCCRingStatus_Server
,
92 .soscc_SetToNew
= SOSCCAccountSetToNew_Server
,
93 .soscc_ResetToOffering
= SOSCCResetToOffering_Server
,
94 .soscc_ResetToEmpty
= SOSCCResetToEmpty_Server
,
95 .soscc_View
= SOSCCView_Server
,
96 .soscc_ViewSet
= SOSCCViewSet_Server
,
97 .soscc_SecurityProperty
= SOSCCSecurityProperty_Server
,
98 .soscc_RemoveThisDeviceFromCircle
= SOSCCRemoveThisDeviceFromCircle_Server
,
99 .soscc_RemovePeersFromCircle
= SOSCCRemovePeersFromCircle_Server
,
100 .soscc_LoggedOutOfAccount
= SOSCCLoggedOutOfAccount_Server
,
101 .soscc_BailFromCircle
= SOSCCBailFromCircle_Server
,
102 .soscc_AcceptApplicants
= SOSCCAcceptApplicants_Server
,
103 .soscc_RejectApplicants
= SOSCCRejectApplicants_Server
,
104 .soscc_CopyApplicantPeerInfo
= SOSCCCopyApplicantPeerInfo_Server
,
105 .soscc_CopyGenerationPeerInfo
= SOSCCCopyGenerationPeerInfo_Server
,
106 .soscc_CopyValidPeerPeerInfo
= SOSCCCopyValidPeerPeerInfo_Server
,
107 .soscc_ValidateUserPublic
= SOSCCValidateUserPublic_Server
,
108 .soscc_CopyNotValidPeerPeerInfo
= SOSCCCopyNotValidPeerPeerInfo_Server
,
109 .soscc_CopyRetirementPeerInfo
= SOSCCCopyRetirementPeerInfo_Server
,
110 .soscc_CopyViewUnawarePeerInfo
= SOSCCCopyViewUnawarePeerInfo_Server
,
111 .soscc_CopyEngineState
= SOSCCCopyEngineState_Server
,
112 .soscc_CopyPeerInfo
= SOSCCCopyPeerPeerInfo_Server
,
113 .soscc_CopyConcurringPeerInfo
= SOSCCCopyConcurringPeerPeerInfo_Server
,
114 .ota_CopyEscrowCertificates
= SecOTAPKICopyCurrentEscrowCertificates
,
115 .sec_ota_pki_get_new_asset
= SecOTAPKISignalNewAsset
,
116 .soscc_ProcessSyncWithAllPeers
= SOSCCProcessSyncWithAllPeers_Server
,
117 .soscc_EnsurePeerRegistration
= SOSCCProcessEnsurePeerRegistration_Server
,
118 .sec_roll_keys
= _SecServerRollKeysGlue
,
119 .soscc_CopyDeviceID
= SOSCCCopyDeviceID_Server
,
120 .soscc_SetDeviceID
= SOSCCSetDeviceID_Server
,
121 .soscc_CheckIDSRegistration
= SOSCCIDSServiceRegistrationTest_Server
,
122 .soscc_PingTest
= SOSCCIDSPingTest_Server
,
123 .soscc_GetIDSIDFromIDS
= SOSCCIDSDeviceIDIsAvailableTest_Server
,
124 .sec_keychain_sync_update_message
= _SecServerKeychainSyncUpdateMessage
,
125 .soscc_HandleIDSMessage
= SOSCCHandleIDSMessage_Server
,
126 .sec_get_log_settings
= SecCopyLogSettings_Server
,
127 .sec_set_xpc_log_settings
= SecSetXPCLogSettings_Server
,
128 .sec_set_circle_log_settings
= SecSetCircleLogSettings_Server
,
129 .soscc_CopyMyPeerInfo
= SOSCCCopyMyPeerInfo_Server
,
130 .soscc_SetLastDepartureReason
= SOSCCSetLastDepartureReason_Server
,
131 .soscc_SetHSA2AutoAcceptInfo
= SOSCCSetHSA2AutoAcceptInfo_Server
,
132 .soscc_SetNewPublicBackupKey
= SOSCCSetNewPublicBackupKey_Server
,
133 .soscc_RegisterSingleRecoverySecret
= SOSCCRegisterSingleRecoverySecret_Server
,
134 .soscc_WaitForInitialSync
= SOSCCWaitForInitialSync_Server
,
135 .soscc_CopyYetToSyncViewsList
= SOSCCCopyYetToSyncViewsList_Server
,
136 .soscc_SetEscrowRecords
= SOSCCSetEscrowRecord_Server
,
137 .soscc_CopyEscrowRecords
= SOSCCCopyEscrowRecord_Server
,
138 .soscc_PeerAvailability
= SOSCCCheckPeerAvailability_Server
,
139 .sosbskb_WrapToBackupSliceKeyBagForView
= SOSWrapToBackupSliceKeyBagForView_Server
,
140 .soscc_CopyAccountState
= SOSCCCopyAccountState_Server
,
141 .soscc_DeleteAccountState
= SOSCCDeleteAccountState_Server
,
142 .soscc_CopyEngineData
= SOSCCCopyEngineData_Server
,
143 .soscc_DeleteEngineState
= SOSCCDeleteEngineState_Server
,
144 .soscc_AccountHasPublicKey
= SOSCCAccountHasPublicKey_Server
,
145 .soscc_AccountIsNew
= SOSCCAccountIsNew_Server
,
146 .sec_item_update_token_items
= _SecItemUpdateTokenItems
,
147 .sec_trust_store_copy_all
= _SecTrustStoreCopyAll
,
148 .sec_trust_store_copy_usage_constraints
= _SecTrustStoreCopyUsageConstraints
,
149 .sec_delete_items_with_access_groups
= _SecItemServerDeleteAllWithAccessGroups
,
150 .soscc_IsThisDeviceLastBackup
= SOSCCkSecXPCOpIsThisDeviceLastBackup_Server
,
151 .soscc_requestSyncWithPeerOverKVS
= SOSCCRequestSyncWithPeerOverKVS_Server
,
152 .soscc_requestSyncWithPeerOverIDS
= SOSCCRequestSyncWithPeerOverIDS_Server
,
153 .soscc_SOSCCPeersHaveViewsEnabled
= SOSCCPeersHaveViewsEnabled_Server
,
155 #endif /* !TRUSTD_SERVER */
158 void securityd_init_server(void) {
160 SecPolicyServerInitalize();
163 void securityd_init(char* home_path
) {
165 SetCustomHomeURL(home_path
);
167 securityd_init_server();