[IOT-2291] Remove OCProvisionCRL from ocprovisioningmanager.h
[platform/upstream/iotivity.git] / resource / csdk / security / provisioning / include / ocprovisioningmanager.h
1 /* *****************************************************************
2  *
3  * Copyright 2015 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
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
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  * *****************************************************************/
20
21 #ifndef OCPROVISIONINGMANAGER_H_
22 #define OCPROVISIONINGMANAGER_H_
23
24 #include "octypes.h"
25 #include "pmtypes.h"
26 #include "ownershiptransfermanager.h"
27 #ifdef MULTIPLE_OWNER
28 #include "securevirtualresourcetypes.h"
29 #endif //MULTIPLE_OWNER
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif // __cplusplus
34
35 /**
36  * The function is responsible for initializaton of the provisioning manager. It will load
37  * provisioning database which have owned device's list and their linked status.
38  * TODO: In addition, if there is a device(s) which has not up-to-date credentials, this function will
39  * automatically try to update the deivce(s).
40  *
41  * @param[in] dbPath file path of the sqlite3 db
42  *
43  * @return OC_STACK_OK in case of success and other value otherwise.
44  */
45 OCStackResult OCInitPM(const char* dbPath);
46
47 /**
48  * API to cleanup PDM in case of timeout.
49  * It will remove the PDM_DEVICE_INIT state devices from PDM.
50  *
51  * @return OC_STACK_OK in case of success and other value otherwise.
52  */
53 OCStackResult OCPDMCleanupForTimeout();
54
55 /**
56  * The function is responsible for discovery of owned/unowned device is specified endpoint/deviceID.
57  * It will return the found device even though timeout is not exceeded.
58  *
59  * @param[in] timeout Timeout in seconds, value till which function will listen to responses from
60  *                    server before returning the device.
61  * @param[in] deviceID         deviceID of target device.
62  * @param[out] ppFoundDevice     OCProvisionDev_t of found device
63  * @return OTM_SUCCESS in case of success and other value otherwise.
64  */
65 OCStackResult OCDiscoverSingleDevice(unsigned short timeout, const OicUuid_t* deviceID,
66                              OCProvisionDev_t **ppFoundDevice);
67
68 /**
69  * The function is responsible for discovery of owned/unowned device is specified endpoint/MAC
70  * address.
71  * It will return the found device even though timeout is not exceeded.
72  *
73  * @param[in] timeout Timeout in seconds, value till which function will listen to responses from
74  *                    server before returning the device.
75  * @param[in] deviceID         deviceID of target device.
76  * @param[in] hostAddress       MAC address of target device.
77  * @param[in] connType       ConnectivityType for discovery.
78  * @param[out] ppFoundDevice     OCProvisionDev_t of found device.
79  * @return OTM_SUCCESS in case of success and other value otherwise.
80  */
81 OCStackResult OCDiscoverSingleDeviceInUnicast(unsigned short timeout, const OicUuid_t* deviceID,
82                              const char* hostAddress, OCConnectivityType connType,
83                              OCProvisionDev_t **ppFoundDevice);
84
85 /**
86  * The function is responsible for discovery of device is current subnet. It will list
87  * all the device in subnet which are not yet owned. Please call OCInit with OC_CLIENT_SERVER as
88  * OCMode.
89  *
90  * @param[in] waittime Timeout in seconds, value till which function will listen to responses from
91  *                    server before returning the list of devices.
92  * @param[out] ppList List of candidate devices to be provisioned
93  * @return OTM_SUCCESS in case of success and other value otherwise.
94  */
95 OCStackResult OCDiscoverUnownedDevices(unsigned short waittime, OCProvisionDev_t **ppList);
96
97 /**
98  * Do ownership transfer for un-owned device.
99  *
100  * @param[in] ctx Application context would be returned in result callback
101  * @param[in] targetDevices List of devices to perform ownership transfer.
102  * @param[in] resultCallback Result callback function to be invoked when ownership transfer finished.
103  * @return OC_STACK_OK in case of success and other value otherwise.
104  */
105 OCStackResult OCDoOwnershipTransfer(void* ctx,
106                                     OCProvisionDev_t *targetDevices,
107                                     OCProvisionResultCB resultCallback);
108
109 /**
110  * API to set a allow status of OxM
111  *
112  * @param[in] oxm Owership transfer method (ref. OicSecOxm_t)
113  * @param[in] allowStatus allow status (true = allow, false = not allow)
114  *
115  * @return OC_STACK_OK in case of success and other value otherwise.
116  */
117 OCStackResult OCSetOxmAllowStatus(const OicSecOxm_t oxm, const bool allowStatus);
118
119 #ifdef MULTIPLE_OWNER
120 /**
121  * API to perfrom multiple ownership transfer for MOT enabled device.
122  *
123  * @param[in] ctx Application context would be returned in result callback
124  * @param[in] targetDevices List of devices to perform ownership transfer.
125  * @param[in] resultCallback Result callback function to be invoked when ownership transfer finished.
126  * @return OC_STACK_OK in case of success and other value otherwise.
127  */
128 OCStackResult OCDoMultipleOwnershipTransfer(void* ctx,
129                                       OCProvisionDev_t *targetDevices,
130                                       OCProvisionResultCB resultCallback);
131 #endif //MULTIPLE_OWNER
132
133 /**
134  * API to register for particular OxM.
135  *
136  * @param[in] oxm transfer method.
137  * @param[in] callbackData of callback functions for owership transfer.
138  * @return OC_STACK_OK in case of success and other value otherwise.
139  */
140 OCStackResult OCSetOwnerTransferCallbackData(OicSecOxm_t oxm, OTMCallbackData_t* callbackData);
141
142 /**
143  * The function is responsible for discovery of owned device is current subnet. It will list
144  * all the device in subnet which are owned by calling provisioning client.
145  *
146  * @param[in] timeout Timeout in seconds, value till which function will listen to responses from
147  *                    server before returning the list of devices.
148  * @param[out] ppList List of device owned by provisioning tool.
149  * @return OTM_SUCCESS in case of success and other value otherwise.
150  */
151 OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList);
152
153 #ifdef MULTIPLE_OWNER
154 /**
155  * The function is responsible for the discovery of an MOT-enabled device with the specified deviceID.
156  * The function will return when security information for device with deviceID has been obtained or the
157  * timeout has been exceeded.
158  *
159  * @param[in]  timeoutSeconds  Maximum time, in seconds, this function will listen for responses from
160  *                             servers before returning.
161  * @param[in]  deviceID        deviceID of target device.
162  * @param[out] ppFoundDevice   OCProvisionDev_t of discovered device. Caller should use
163  *                             OCDeleteDiscoveredDevices to delete the device.
164  * @return OC_STACK_OK in case of success and other values otherwise.
165  */
166 OCStackResult OCDiscoverMultipleOwnerEnabledSingleDevice(unsigned short timeoutSeconds,
167                                                          const OicUuid_t *deviceID,
168                                                          OCProvisionDev_t **ppFoundDevice);
169
170 /**
171  * The function is responsible for discovery of MOT enabled device is current subnet.
172  *
173  * @param[in] timeout Timeout in seconds, value till which function will listen to responses from
174  *                    server before returning the list of devices.
175  * @param[out] ppList List of MOT enabled devices.
176  * @return OC_STACK_OK in case of success and other value otherwise.
177  */
178 OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList);
179
180 /**
181  * The function is responsible for discovery of Multiple Owned device is current subnet.
182  *
183  * @param[in] timeout Timeout in seconds, value till which function will listen to responses from
184  *                    server before returning the list of devices.
185  * @param[out] ppList List of Multiple Owned devices.
186  * @return OC_STACK_OK in case of success and other value otherwise.
187  */
188 OCStackResult OCDiscoverMultipleOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList);
189
190 /**
191  * The function is responsible for determining if the caller is a subowner of the specified device.
192  *
193  * @param[in]  device      MOT enabled device that contains a list of subowners.
194  * @param[out] isSubowner  Bool indicating whether the caller is a subowner of device.
195  * @return OC_STACK_OK in case of success and other value otherwise.
196  */
197 OCStackResult OCIsSubownerOfDevice(OCProvisionDev_t *device, bool *isSubowner);
198 #endif //MULTIPLE_OWNER
199
200 /**
201  * API to provision credentials between two devices and ACLs for the devices who act as a server.
202  *
203  * @param[in] ctx Application context returned in the result callback.
204  * @param[in] type Type of credentials to be provisioned to the device.
205  * @param[in] keySize size of key
206  * @param[in] pDev1 Pointer to OCProvisionDev_t instance,respresenting device to be provisioned.
207  * @param[in] pDev1Acl ACL for device 1. If this is not required set NULL.
208  * @param[in] pDev2 Pointer to OCProvisionDev_t instance,respresenting device to be provisioned.
209  * @param[in] pDev2Acl ACL for device 2. If this is not required set NULL.
210  * @param[in] resultCallback callback provided by API user, callback will be called when
211  *            provisioning request recieves a response from first resource server.
212  * @return OC_STACK_OK in case of success and other value otherwise.
213  */
214 OCStackResult OCProvisionPairwiseDevices(void* ctx, OicSecCredType_t type, size_t keySize,
215                                          const OCProvisionDev_t *pDev1, OicSecAcl_t *pDev1Acl,
216                                          const OCProvisionDev_t *pDev2, OicSecAcl_t *pDev2Acl,
217                                          OCProvisionResultCB resultCallback);
218
219 /**
220  * API to send version 1 ACL information to device.
221  *
222  * @param[in] ctx Application context returned in the result callback.
223  * @param[in] selectedDeviceInfo Selected target device.
224  * @param[in] acl ACL to provision.
225  * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
226               request recieves a response from resource server.
227  * @return OC_STACK_OK in case of success and other value otherwise.
228  */
229 OCStackResult OCProvisionACL(void *ctx, const OCProvisionDev_t *selectedDeviceInfo, OicSecAcl_t *acl,
230                              OCProvisionResultCB resultCallback);
231
232 /**
233  * API to send version 2 ACL information to device.
234  *
235  * @param[in] ctx Application context returned in the result callback.
236  * @param[in] selectedDeviceInfo Selected target device.
237  * @param[in] acl ACL to provision.
238  * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
239               request recieves a response from resource server.
240  * @return OC_STACK_OK in case of success and other value otherwise.
241  */
242 OCStackResult OCProvisionACL2(void *ctx, const OCProvisionDev_t *selectedDeviceInfo, OicSecAcl_t *acl,
243                               OCProvisionResultCB resultCallback);
244
245 /**
246  * function to save ACL which has several ACE into Acl of SVR.
247  *
248  * @param acl ACL to be saved in Acl of SVR.
249  * @return  OC_STACK_OK in case of success and other value otherwise.
250  */
251 OCStackResult OCSaveACL(const OicSecAcl_t* acl);
252
253 /**
254  * this function requests CRED information to resource.
255  *
256  * @param[in] ctx Application context returned in the result callback.
257  * @param[in] selectedDeviceInfo Selected target device.
258  * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
259               request recieves a response from resource server.
260  * @return  OC_STACK_OK in case of success and other value otherwise.
261  */
262 OCStackResult OCGetCredResource(void* ctx, const OCProvisionDev_t *selectedDeviceInfo,
263                              OCProvisionResultCB resultCallback);
264
265 /**
266  * this function requests version 1 ACL information to resource.
267  *
268  * @param[in] ctx Application context returned in the result callback.
269  * @param[in] selectedDeviceInfo Selected target device.
270  * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
271               request recieves a response from resource server.
272  * @return  OC_STACK_OK in case of success and other value otherwise.
273  */
274 OCStackResult OCGetACLResource(void* ctx, const OCProvisionDev_t *selectedDeviceInfo,
275                              OCProvisionResultCB resultCallback);
276
277 /**
278  * this function requests version 2 ACL information to resource.
279  *
280  * @param[in] ctx Application context returned in the result callback.
281  * @param[in] selectedDeviceInfo Selected target device.
282  * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
283               request recieves a response from resource server.
284  * @return  OC_STACK_OK in case of success and other value otherwise.
285  */
286 OCStackResult OCGetACL2Resource(void* ctx, const OCProvisionDev_t *selectedDeviceInfo,
287                                OCProvisionResultCB resultCallback);
288
289 /**
290  * This function requests the device provide its Certificate Signing Request (CSR).
291  *
292  * @param[in] ctx Application context returned in the result callback.
293  * @param[in] selectedDeviceInfo Selected target device.
294  * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
295               request recieves a response from resource server.
296  * @return  OC_STACK_OK in case of success and other value otherwise.
297  */
298 OCStackResult OCGetCSRResource(void* ctx, const OCProvisionDev_t *selectedDeviceInfo,
299                                OCGetCSRResultCB resultCallback);
300
301 /**
302  * This function requests the device provide its roles resource, listing the role certificates
303  * it has for the local requestor.
304  *
305  * @param[in] ctx Application context that is returned in the result callback.
306  * @param[in] selectedDeviceInfo Selected target device.
307  * @param[in] resultCallback callback provided by the API user. Callback will be called when provisioning
308  *                           request receives a response from the resource server.
309  * @return OC_STACK_OK in case of success, and error value otherwise.
310  */
311 OCStackResult OCGetRolesResource(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
312                                  OCGetRolesResultCB resultCallback);
313
314 /**
315  * This function requests the device delete a particular role certificate by credId.
316  *
317  * @param[in] ctx Application context that is returned in the result callback.
318  * @param[in] selectedDeviceInfo Selected target device.
319  * @param[in] resultCallback callback provided by the API user. Callback will be called when request receives
320  *            a response from the resource server.
321  * @param[in] credId credId to request be deleted. If 0, delete all role certificates for this peer.
322  *
323  * @return OC_STACK_OK in case of success, and error value otherwise.
324  */
325 OCStackResult OCDeleteRoleCertificateByCredId(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
326                                               OCProvisionResultCB resultCallback, uint32_t credId);
327
328 /**
329  * this function sends Direct-Pairing Configuration to a device.
330  *
331  * @param[in] ctx Application context returned in the result callback.
332  * @param[in] selectedDeviceInfo Selected target device.
333  * @param[in] pconf PCONF pointer.
334  * @param[in] resultCallback callback provided by API user, callback will be called when provisioning
335               request recieves a response from resource server.
336  * @return  OC_STACK_OK in case of success and other value otherwise.
337  */
338 OCStackResult OCProvisionDirectPairing(void* ctx, const OCProvisionDev_t *selectedDeviceInfo, OicSecPconf_t *pconf,
339                              OCProvisionResultCB resultCallback);
340
341 /**
342  * API to provision credential to devices.
343  *
344  * @param[in] ctx Application context returned in the result callback.
345  * @param[in] type Type of credentials to be provisioned to the device.
346  * @param[in] keySize size of key
347  * @param[in] pDev1 Pointer to OCProvisionDev_t instance, representing the resource to be provisioned.
348  * @param[in] pDev2 Pointer to OCProvisionDev_t instance, representing the resource to be provisioned.
349  * @param[in] resultCallback callback provided by API user, callback will be called when
350  *            provisioning request recieves a response from first resource server.
351  * @return OC_STACK_OK in case of success and other value otherwise.
352  */
353 OCStackResult OCProvisionCredentials(void *ctx, OicSecCredType_t type, size_t keySize,
354                                       const OCProvisionDev_t *pDev1,
355                                       const OCProvisionDev_t *pDev2,
356                                       OCProvisionResultCB resultCallback);
357
358 /**
359  * API to provision symmetric pair-wise key credentials to devices that grant a role.
360  *
361  * @param[in] ctx Application context returned in the result callback.
362  * @param[in] type Type of credentials to be provisioned to the device.
363  * @param[in] keySize size of key
364  * @param[in] pDev1 Pointer to OCProvisionDev_t instance, representing the resource to be provisioned.
365  * @param[in] pDev2 Pointer to OCProvisionDev_t instance, representing the resource to be provisioned. 
366  *                  Use NULL to indicate the local device.
367  * @param[in] role1 The role which the device indicated by pDev1 will have when communicating with pDev2.
368  *                  Use NULL to associate no role with this credential.
369  * @param[in] role2 The role which the device indicated by pDev2 will have when communicating with pDev1.
370  *                  Use NULL to associate no role with this credential.
371  * @param[in] resultCallback callback provided by API user, callback will be called when
372  *            provisioning request receives a response from first resource server.
373  * @return OC_STACK_OK in case of success and other value otherwise.
374  */
375 OCStackResult OCProvisionSymmetricRoleCredentials(void *ctx, OicSecCredType_t type, size_t keySize,
376                                                   const OCProvisionDev_t *pDev1,
377                                                   const OCProvisionDev_t *pDev2,
378                                                   const OicSecRole_t *role1,
379                                                   const OicSecRole_t *role2,
380                                                   OCProvisionResultCB resultCallback);
381
382 /**
383  * API to provision a certificate to a device.
384  *
385  * @param[in] ctx Application context returned in result callback.
386  * @param[in] pDev Pointer to OCProvisionDev_t instance, respresenting the device to be provsioned.
387  * @param[in] pemCert Certificate to provision, encoded as PEM
388  * @param[in] resultCallback callback provided by API user, callback will be called when
389  *            provisioning request receives a response from first resource server.
390  * @return OC_STACK_OK in case of success and other value otherwise.
391  */
392 OCStackResult OCProvisionCertificate(void *ctx,
393                                      const OCProvisionDev_t *pDev,
394                                      const char* pemCert,
395                                      OCProvisionResultCB resultCallback);
396
397 #ifdef MULTIPLE_OWNER
398 /**
399  * API to provision preconfigured PIN to device(NOT LIST).
400  * If device does not support the Preconfigured PIN OxM,
401  * OCProvisionPreconfigPin API will update the device's Doxm
402  * and then try preconfigured PIN provisioning once again.
403  *
404  * @param[in] ctx Application context returned in the result callback.
405  * @param[in] targetDeviceInfo Selected target device.
406  * @param[in] preconfigPin string of preconfigured PIN.
407  * @param[in] preconfigPinLen string length of 'preconfigPin'.
408  * @param[in] resultCallback callback provided by API user, callback will be called when
409  *            provisioning request recieves a response from first resource server.
410  * @return OC_STACK_OK in case of success and other value otherwise.
411  */
412 OCStackResult OCProvisionPreconfigPin(void *ctx,
413                                       OCProvisionDev_t *targetDeviceInfo,
414                                       const char *preconfigPin,
415                                       size_t preconfigPinLen,
416                                       OCProvisionResultCB resultCallback);
417
418 /**
419  * API to add preconfigured PIN to local SVR DB.
420  *
421  * @param[in] targetDeviceInfo Selected target device.
422  * @param[in] preconfigPin Preconfig PIN which is used while multiple owner authentication
423  * @param[in] preconfigPinLen Byte length of preconfigPin
424  * @return OC_STACK_OK in case of success and other value otherwise.
425  */
426 OCStackResult OCAddPreconfigPin(const OCProvisionDev_t *targetDeviceInfo,
427                                 const char *preconfigPin,
428                                 size_t preconfigPinLen);
429
430 /**
431  * API to update 'doxm.mom' to resource server.
432  *
433  * @param[in] targetDeviceInfo Selected target device.
434  * @param[in] momType Mode of multiple ownership transfer (ref. oic.sec.mom)
435  * @param[in] resultCallback callback provided by API user, callback will be called when
436  *            POST 'mom' request recieves a response from resource server.
437  * @return OC_STACK_OK in case of success and other value otherwise.
438  */
439 OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo,
440                             const OicSecMomType_t momType, OCProvisionResultCB resultCallback);
441
442 /**
443  * API to update 'doxm.oxmsel' to resource server.
444  *
445  * @param[in] targetDeviceInfo Selected target device.
446  * @param[in] oxmSelValue Method of multiple ownership transfer (ref. oic.sec.doxmtype)
447  * @param[in] resultCallback callback provided by API user, callback will be called when
448  *            POST 'oxmsel' request recieves a response from resource server.
449  * @return OC_STACK_OK in case of success and other value otherwise.
450  */
451 OCStackResult OCSelectMOTMethod(void *ctx, const OCProvisionDev_t *targetDeviceInfo,
452                                  const OicSecOxm_t oxmSelValue, OCProvisionResultCB resultCallback);
453 #endif //MULTIPLE_OWNER
454
455 /**
456  * Function to unlink devices.
457  * This function will remove the credential & relasionship between the two devices.
458  *
459  * @param[in] ctx Application context would be returned in result callback
460  * @param[in] pTargetDev1 fitst device information to be unlinked.
461  * @param[in] pTargetDev2 second device information to be unlinked.
462  * @param[in] resultCallback callback provided by API user, callback will be called when
463  *            device unlink is finished.
464  * @return OC_STACK_OK in case of success and other value otherwise.
465  */
466 OCStackResult OCUnlinkDevices(void* ctx,
467                               const OCProvisionDev_t* pTargetDev1,
468                               const OCProvisionDev_t* pTargetDev2,
469                               OCProvisionResultCB resultCallback);
470
471 /**
472  * Function for device revocation
473  * This function will remove credential of target device from all devices in subnet.
474  *
475  * @param[in] ctx Application context would be returned in result callback
476  * @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
477  * @param[in] pTargetDev Device information to be revoked.
478  * @param[in] resultCallback callback provided by API user, callback will be called when
479  *            credential revocation is finished.
480  * @return OC_STACK_OK in case of success and other value otherwise.
481  *         if OC_STACK_OK is returned, the caller of this API should wait for callback.
482  *         OC_STACK_CONTINUE means operation is success but no need to wait for callback.
483  */
484 OCStackResult OCRemoveDevice(void* ctx,
485                              unsigned short waitTimeForOwnedDeviceDiscovery,
486                              const OCProvisionDev_t* pTargetDev,
487                              OCProvisionResultCB resultCallback);
488
489 /**
490  * Function to device revocation
491  * This function will remove credential of target device from all devices in subnet.
492  *
493  * @param[in] ctx Application context would be returned in result callback
494  * @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
495  * @param[in] pTargetUuid Device information to be revoked.
496  * @param[in] resultCallback callback provided by API user, callback will be called when
497  *            credential revocation is finished.
498  * @return  OC_STACK_OK in case of success and other value otherwise.
499  */
500 OCStackResult OCRemoveDeviceWithUuid(void* ctx,
501                                      unsigned short waitTimeForOwnedDeviceDiscovery,
502                                      const OicUuid_t* pTargetUuid,
503                                      OCProvisionResultCB resultCallback);
504
505 /**
506  * Function to reset the target device.
507  * This function will remove credential and ACL of target device from all devices in subnet.
508  *
509  * @param[in] ctx Application context would be returned in result callback
510  * @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
511  * @param[in] pTargetDev Device information to be revoked.
512  * @param[in] resultCallback callback provided by API user, callback will be called when
513  *            credential revocation is finished.
514  * @return  OC_STACK_OK in case of success and other value otherwise.
515  */
516 OCStackResult OCResetDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDiscovery,
517                             const OCProvisionDev_t* pTargetDev,
518                             OCProvisionResultCB resultCallback);
519
520 /**
521  * This function resets SVR DB to its factory setting.
522  *
523  *@return OC_STACK_OK in case of successful reset and other value otherwise.
524  */
525 OCStackResult OCResetSVRDB(void);
526
527 /**
528  * This function configures SVR DB as self-ownership.
529  *
530  *@return OC_STACK_OK in case of successful configue and other value otherwise.
531  */
532 OCStackResult OCConfigSelfOwnership(void);
533
534 /**
535  * API to get status of all the devices in current subnet. The status include endpoint information
536  * and doxm information which can be extracted duing owned and unowned discovery. Along with this
537  * information. The API will provide information about devices' status
538  * Device can have following states
539  *  - ON/OFF: Device is switched on or off.
540  *
541  * NOTE: Caller need to call OCDeleteDiscoveredDevices to delete memory allocated by this API for out
542  * variables pOwnedDevList and pUnownedDevList.
543  *
544  * @param[in] waittime Wait time for the API. The wait time will be divided by 2, and half of wait time
545  * will be used for unowned discovery and remaining half for owned discovery. So the wait time should be
546  * equal to or more than 2.
547  * @param[out] pOwnedDevList  list of owned devices.
548  * @param[out] pUnownedDevList  list of unowned devices.
549  * @return OC_STACK_OK in case of success and other value otherwise.
550  */
551 OCStackResult OCGetDevInfoFromNetwork(unsigned short waittime,
552                                        OCProvisionDev_t** pOwnedDevList,
553                                        OCProvisionDev_t** pUnownedDevList);
554 /**
555  * This method is used to get linked devices' IDs.
556  *
557  * @param[in] uuidOfDevice a target device's uuid.
558  * @param[out] uuidList information about the list of linked devices' uuids.
559  * @param[out] numOfDevices total number of linked devices.
560  * @return OC_STACK_OK in case of success and other value otherwise.
561  */
562 OCStackResult OCGetLinkedStatus(const OicUuid_t* uuidOfDevice,
563                                   OCUuidList_t** uuidList,
564                                   size_t* numOfDevices);
565
566 /**
567  * Remove locally stored credentials with the specified subject UUID.
568  *
569  * @param[in] subjectUuid The subject UUID of the credentials to remove
570  *
571  * @return OC_STACK_RESOURCE_DELETED if credentials were removed, or
572  * OC_STACK_ERROR if no credentials were removed.
573  */
574 OCStackResult OCRemoveCredential(const OicUuid_t* subjectUuid);
575
576 /**
577  * API to delete memory allocated to linked list created by OCDiscover_XXX_Devices API.
578  *
579  * @param[in] pList Pointer to OCProvisionDev_t which should be deleted.
580  */
581 void OCDeleteDiscoveredDevices(OCProvisionDev_t *pList);
582
583 /**
584  * API to delete memory allocated to OicUuid_t list.
585  *
586  * @param[in] pList Pointer to OicUuid_t list which should be deleted.
587  */
588 void OCDeleteUuidList(OCUuidList_t* pList);
589
590 /**
591  * This function deletes ACL data.
592  *
593  * @param pAcl Pointer to OicSecAcl_t structure.
594  */
595 void OCDeleteACLList(OicSecAcl_t* pAcl);
596
597 /**
598  * This function deletes PDACL data.
599  *
600  * @param pPdAcl Pointer to OicSecPdAcl_t structure.
601  */
602 void OCDeletePdAclList(OicSecPdAcl_t* pPdAcl);
603
604 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
605 /**
606  * function to provision Trust certificate chain to devices.
607  *
608  * @param[in] ctx Application context returned in the result callback.
609  * @param[in] type Type of credentials to be provisioned to the device.
610  * @param[in] credId CredId of trust certificate chain to be provisioned to the device.
611  * @param[in] selectedDeviceInfo Pointer to OCProvisionDev_t instance,respresenting resource to be provsioned.
612  * @param[in] resultCallback callback provided by API user, callback will be called when
613  *            provisioning request recieves a response from first resource server.
614  * @return  OC_STACK_OK in case of success and other value otherwise.
615  */
616 OCStackResult OCProvisionTrustCertChain(void *ctx, OicSecCredType_t type, uint16_t credId,
617                                       const OCProvisionDev_t *selectedDeviceInfo,
618                                       OCProvisionResultCB resultCallback);
619 /**
620  * function to save Trust certificate chain into Cred of SVR.
621  *
622  * @param[in] trustCertChain Trust certificate chain to be saved in Cred of SVR.
623  * @param[in] chainSize Size of trust certificate chain to be saved in Cred of SVR
624  * @param[in] encodingType Encoding type of trust certificate chain to be saved in Cred of SVR
625  * @param[out] credId CredId of saved trust certificate chain in Cred of SVR.
626  * @return  OC_STACK_OK in case of success and other value otherwise.
627  */
628 OCStackResult OCSaveTrustCertChain(const uint8_t *trustCertChain, size_t chainSize,
629                                    OicEncodingType_t encodingType, uint16_t *credId);
630
631 /**
632  * Function to save an identity certificate chain into Cred of SVR.
633  *
634  * @param[in] cert Certificate chain to be saved in Cred of SVR, PEM encoded, null terminated
635  * @param[in] key private key corresponding to the certificate, PEM encoded, null terminated
636  * @param[out] credId CredId of saved certificate chain in Cred of SVR.
637  * @return  OC_STACK_OK in case of success and other value otherwise.
638  */
639 OCStackResult OCSaveOwnCertChain(const char* cert, const char* key, uint16_t *credId);
640
641 /**
642  * Function to save own role certificate into Cred of SVR.
643  *
644  * @param[in] cert Certificate chain to be saved in Cred of SVR, PEM encoded, null terminated
645  * @param[out] credId CredId of saved trust certificate chain in Cred of SVR.
646  * @return  OC_STACK_OK in case of success and other value otherwise.
647  *
648  * @note The certificate public key must be the same as public key in the identity
649  *       certificate (installed by OCSaveOwnCertChain).
650  */
651 OCStackResult OCSaveOwnRoleCert(const char* cert, uint16_t *credId);
652
653 /**
654  * function to register callback, for getting notification for TrustCertChain change.
655  *
656  * @param[in] TrustCertChainChangeCB notifier callback function
657  * @return OC_STACK_OK in case of success and other value otherwise.
658  */
659 OCStackResult OCRegisterTrustCertChainNotifier(void *cb, TrustCertChainChangeCB CB);
660
661 /**
662  * function to de-register TrustCertChain notification callback.
663  */
664 void OCRemoveTrustCertChainNotifier(void);
665
666 /**
667  * Function to read Trust certificate chain from SVR.
668  * Caller must free when done using the returned trust certificate
669  * @param[in] credId CredId of trust certificate chain in SVR.
670  * @param[out] trustCertChain Trust certificate chain.
671  * @param[out] chainSize Size of trust certificate chain
672  * @return  OC_STACK_OK in case of success and other value otherwise.
673  */
674 OCStackResult OCReadTrustCertChain(uint16_t credId, uint8_t **trustCertChain,
675                                      size_t *chainSize);
676
677 /**
678  * Function to select appropriate security provisioning method.
679  *
680  * @param[in] supportedMethods   Array of supported methods
681  * @param[in] numberOfMethods   number of supported methods
682  * @param[out]  selectedMethod         Selected methods
683  * @param[in] ownerType type of owner device (SUPER_OWNER or SUB_OWNER)
684  * @return  OC_STACK_OK on success
685  */
686 OCStackResult OCSelectOwnershipTransferMethod(const OicSecOxm_t *supportedMethods,
687         size_t numberOfMethods, OicSecOxm_t *selectedMethod, OwnerType_t ownerType);
688
689 #endif // __WITH_DTLS__ || __WITH_TLS__
690
691
692 #ifdef __cplusplus
693 }
694 #endif // __cplusplus
695
696 #endif /* OCPROVISIONINGMANAGER_H_ */