1 /* *****************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * *****************************************************************/
21 #ifndef SRP_SECURERESOURCEPROVIDER_H
22 #define SRP_SECURERESOURCEPROVIDER_H
25 #include "securevirtualresourcetypes.h"
36 * API to send ACL information to resource.
38 * @param[in] selectedDeviceInfo Selected target device.
39 * @param[in] acl ACL to provision.
40 * @param[in] resultCallback callback provided by API user, callback will be called when
41 * provisioning request recieves a response from resource server.
42 * @return OC_STACK_OK in case of success and other value otherwise.
44 OCStackResult SRPProvisionACL(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
45 OicSecAcl_t *acl, OCProvisionResultCB resultCallback);
48 * API to save ACL which has several ACE into Acl of SVR.
50 * @param acl ACL to be saved in Acl of SVR.
51 * @return OC_STACK_OK in case of success and other value otherwise.
53 OCStackResult SRPSaveACL(const OicSecAcl_t *acl);
56 * API to request CRED information to resource.
58 * @param[in] selectedDeviceInfo Selected target device.
59 * @param[in] resultCallback callback provided by API user, callback will be called when
60 * provisioning request recieves a response from resource server.
61 * @return OC_STACK_OK in case of success and other value otherwise.
63 OCStackResult SRPGetCredResource(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
64 OCProvisionResultCB resultCallback);
67 * API to request ACL information to resource.
69 * @param[in] selectedDeviceInfo Selected target device.
70 * @param[in] resultCallback callback provided by API user, callback will be called when
71 * provisioning request recieves a response from resource server.
72 * @return OC_STACK_OK in case of success and other value otherwise.
74 OCStackResult SRPGetACLResource(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
75 OCProvisionResultCB resultCallback);
77 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
80 * function to provision Trust certificate chain to devices.
82 * @param[in] ctx Application context would be returned in result callback.
83 * @param[in] type Type of credentials to be provisioned to the device.
84 * @param[in] credId CredId of trust certificate chain to be provisioned to the device.
85 * @param[in] selectedDeviceInfo Pointer to OCProvisionDev_t instance,respresenting resource to be provsioned.
86 * @param[in] resultCallback callback provided by API user, callback will be called when
87 * provisioning request recieves a response from first resource server.
88 * @return OC_STACK_OK in case of success and other value otherwise.
90 OCStackResult SRPProvisionTrustCertChain(void *ctx, OicSecCredType_t type, uint16_t credId,
91 const OCProvisionDev_t *selectedDeviceInfo,
92 OCProvisionResultCB resultCallback);
95 * function to save Trust certificate chain into Cred of SVR.
97 * @param[in] trustCertChain Trust certificate chain to be saved in Cred of SVR.
98 * @param[in] chainSize Size of trust certificate chain to be saved in Cred of SVR
99 * @param[in] encodingType Encoding type of trust certificate chain to be saved in Cred of SVR
100 * @param[out] credId CredId of saved trust certificate chain in Cred of SVR.
101 * @return OC_STACK_OK in case of success and other value otherwise.
103 OCStackResult SRPSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize,
104 OicEncodingType_t encodingType,uint16_t *credId);
107 * function to save own certificate chain into Cred of SVR.
109 * @param[in] cert own certificate chain to be saved in Cred of SVR.
110 * @param[in] key own secret key to be saved in Cred of SVR.
111 * @param[out] credId CredId of saved trust certificate chain in Cred of SVR.
112 * @return OC_STACK_OK in case of success and other value otherwise.
114 OCStackResult SRPSaveOwnCertChain(OicSecKey_t * cert, OicSecKey_t * key, uint16_t *credId);
117 * function to register callback, for getting notification for TrustCertChain change.
119 * @param[in] ctx user context to be passed.
120 * @param[in] TrustCertChainChangeCB notifier callback function
121 * @return OC_STACK_OK in case of success and other value otherwise.
123 OCStackResult SRPRegisterTrustCertChainNotifier(void *ctx, TrustCertChainChangeCB callback);
126 * function to de-register TrustCertChain notification callback.
128 void SRPRemoveTrustCertChainNotifier(void);
130 #endif // __WITH_DTLS__ || __WITH_TLS__
132 * API to send Direct-Pairing Configuration to a device.
134 * @param[in] selectedDeviceInfo Selected target device.
135 * @param[in] pconf PCONF pointer.
136 * @param[in] resultCallback callback provided by API user, callback will be called when
137 * provisioning request recieves a response from resource server.
138 * @return OC_STACK_OK in case of success and other value otherwise.
140 OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
141 OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
144 * API to send Direct-Pairing Configuration to a device.
146 * @param[in] selectedDeviceInfo Selected target device.
147 * @param[in] pconf PCONF pointer.
148 * @param[in] resultCallback callback provided by API user, callback will be called when
149 * provisioning request recieves a response from resource server.
150 * @return OC_STACK_OK in case of success and other value otherwise.
152 OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
153 OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
156 * API to provision credential to devices.
158 * @param[in] type Type of credentials to be provisioned to the device.
159 * @param[in] pDev1 Pointer to PMOwnedDeviceInfo_t instance,respresenting resource to be provsioned.
160 @param[in] pDev2 Pointer to PMOwnedDeviceInfo_t instance,respresenting resource to be provsioned.
161 * @param[in] resultCallback callback provided by API user, callback will be called when
162 * provisioning request recieves a response from first resource server.
163 * @return OC_STACK_OK in case of success and other value otherwise.
165 OCStackResult SRPProvisionCredentials(void *ctx,OicSecCredType_t type, size_t keySize,
166 const OCProvisionDev_t *pDev1,
167 const OCProvisionDev_t *pDev2,
168 OCProvisionResultCB resultCallback);
171 * Function to unlink devices.
172 * This function will remove the credential & relationship between the two devices.
174 * @param[in] ctx Application context would be returned in result callback
175 * @param[in] pTargetDev1 first device information to be unlinked.
176 * @param[in] pTargetDev2 second device information to be unlinked.
177 * @param[in] resultCallback callback provided by API user, callback will be called when
178 * device unlink is finished.
179 * when there is an error, this user callback is called immediately.
180 * @return OC_STACK_OK in case of success and other value otherwise.
182 OCStackResult SRPUnlinkDevices(void* ctx,
183 const OCProvisionDev_t* pTargetDev1,
184 const OCProvisionDev_t* pTargetDev2,
185 OCProvisionResultCB resultCallback);
188 * Function to device revocation.
189 * This function will remove credential of target device from all devices in subnet.
191 * @param[in] ctx Application context would be returned in result callback
192 * @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
193 * @param[in] pTargetDev Device information to be revoked.
194 * @param[in] resultCallback callback provided by API user, callback will be called when
195 * credential revocation is finished.
196 * when there is an error, this user callback is called immediately.
197 * @return OC_STACK_OK in case of success and other value otherwise.
198 * If OC_STACK_OK is returned, the caller of this API should wait for callback.
199 * OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
201 OCStackResult SRPRemoveDevice(void* ctx,
202 unsigned short waitTimeForOwnedDeviceDiscovery,
203 const OCProvisionDev_t* pTargetDev,
204 OCProvisionResultCB resultCallback);
207 * Function to device revocation
208 * This function will remove credential of target device from all devices in subnet.
210 * @param[in] ctx Application context would be returned in result callback
211 * @param[in] pOwnedDevList List of owned devices
212 * @param[in] pTargetDev Device information to be revoked.
213 * @param[in] resultCallback callback provided by API user, callback will be called when
214 * credential revocation is finished.
215 * @return OC_STACK_OK in case of success and other value otherwise.
216 * If OC_STACK_OK is returned, the caller of this API should wait for callback.
217 * OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
219 OCStackResult SRPRemoveDeviceWithoutDiscovery(void* ctx, const OCProvisionDev_t* pOwnedDevList,
220 const OCProvisionDev_t* pTargetDev, OCProvisionResultCB resultCallback);
223 * Function to sync-up credential and ACL of the target device.
224 * This function will remove credential and ACL of target device from all devices in subnet.
226 * @param[in] ctx Application context would be returned in result callback
227 * @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
228 * @param[in] pTargetDev Device information to be revoked.
229 * @param[in] resultCallback callback provided by API user, callback will be called when
230 * credential revocation is finished.
231 * when there is an error, this user callback is called immediately.
232 * @return OC_STACK_OK in case of success and other value otherwise.
233 * If OC_STACK_OK is returned, the caller of this API should wait for callback.
234 * OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
236 OCStackResult SRPSyncDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDiscovery,
237 const OCProvisionDev_t* pTargetDev, OCProvisionResultCB resultCallback);
240 * Function for remote reset
241 * This function will send pstat POST(modify) message to the target device
242 * to change current mode to reset state in order to initiate remote reset.
244 * @param[in] pTargetDev Device information to be revoked.
245 * @param[in] resultCallback callback provided by API user, callback will be called when
246 * credential revocation is finished.
247 * when there is an error, this user callback is called immediately.
248 * @return OC_STACK_OK in case of success and other value otherwise.
249 * If OC_STACK_OK is returned, the caller of this API should wait for callback.
250 * OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
252 OCStackResult SRPResetDevice(const OCProvisionDev_t* pTargetDev,
253 OCProvisionResultCB resultCallback);
256 * Function to read Trust certificate chain from SVR.
257 * Caller must free when done using the returned trust certificate
258 * @param[in] credId CredId of trust certificate chain in SVR.
259 * @param[out] trustCertChain Trust certificate chain.
260 * @param[out] chainSize Size of trust certificate chain
261 * @return OC_STACK_OK in case of success and other value otherwise.
263 OCStackResult SRPReadTrustCertChain(uint16_t credId, uint8_t **trustCertChain,
268 #endif //SRP_SECURERESOURCEPROVIDER_H