Update snapshot(2018-01-17)
[platform/upstream/iotivity.git] / resource / include / OCProvisioningManager.hpp
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 OC_PROVISIONINGMANAGER_CXX_H_
22 #define OC_PROVISIONINGMANAGER_CXX_H_
23
24 #include <thread>
25
26 #include "pinoxmcommon.h"
27 #ifdef __APPLE__
28 #include "../csdk/security/provisioning/include/ocprovisioningmanager.h"
29 #else
30 #include "ocprovisioningmanager.h"
31 #endif
32 #include "OCApi.h"
33 #include "OCPlatform_impl.h"
34 #include "oxmverifycommon.h"
35 #include "casecurityinterface.h"
36 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
37 #include "mbedtls/x509_crt.h"
38 #endif
39
40 namespace OC
41 {
42     class OCSecureResource;
43
44     typedef std::vector<std::shared_ptr<OCSecureResource>> DeviceList_t;
45     typedef std::vector<OicUuid_t> UuidList_t;
46     typedef std::vector<OCProvisionResult_t> PMResultList_t;
47     typedef std::function<void(PMResultList_t *result, int hasError)> ResultCallBack;
48     typedef std::function<void(uint16_t credId, uint8_t *trustCertChain,
49             size_t chainSize)>CertChainCallBack;
50     typedef std::function<OCStackResult(uint8_t verifNum[])> DisplayNumCB;
51     typedef std::function<OCStackResult()> UserConfirmNumCB;
52 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
53     typedef std::function<OCStackResult(const mbedtls_x509_crt *peerCert,
54             int depth)> PeerCertCB;
55 #endif
56
57     struct ProvisionContext
58     {
59         ResultCallBack callback;
60         ProvisionContext(ResultCallBack cb) : callback(cb){}
61     };
62
63     struct TrustCertChainContext
64     {
65         CertChainCallBack callback;
66         TrustCertChainContext(CertChainCallBack cb) : callback(cb){}
67     };
68
69     struct DisplayNumContext
70     {
71         DisplayNumCB callback;
72         DisplayNumContext(DisplayNumCB cb) : callback(cb){}
73     };
74
75     struct UserConfirmNumContext
76     {
77         UserConfirmNumCB callback;
78         UserConfirmNumContext(UserConfirmNumCB cb) : callback(cb){}
79     };
80
81 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
82     struct PeerCertContext
83     {
84         PeerCertCB callback;
85         PeerCertContext(PeerCertCB cb) : callback(cb){}
86     };
87 #endif
88
89     /**
90      * This class is for credential's to be set to devices.
91      * The types supported are
92      *              0:  no security mode
93      *              1:  symmetric pair-wise key
94      *              2:  symmetric group key
95      *              4:  asymmetric key
96      *              8:  signed asymmetric key (aka certificate)
97      *              16: PIN /password
98      */
99     class Credential
100     {
101             OicSecCredType_t type;
102             size_t keySize;
103         public:
104             Credential() = default;
105             Credential(OicSecCredType_t type, size_t size) : type(type), keySize(size)
106             {}
107
108             /**
109              * API to get credential type of device.
110              * @return credential type of device.
111              */
112             OicSecCredType_t getCredentialType() const
113             {
114                 return type;
115             }
116
117             /**
118              * API to get size of credential key type.
119              * @return size of credential key type.
120              */
121             size_t getCredentialKeySize() const
122             {
123                 return keySize;
124             }
125
126             /**
127              * API to set credential type of device.
128              * Device can have following credential types
129              *  - symmetric pair-wise key
130              *  - symmetric group key
131              *  - asymmetric key
132              *  - signed asymmetric key (aka certificate)
133              *  - PIN /password
134              * @param type credential type.
135              */
136             void setCredentialType(OicSecCredType_t type)
137             {
138                 this->type = type;
139             }
140
141             /**
142              * API to set size of credential key type.
143              * @param keySize credential key size.
144              * @note can be either 128 or 256 for symmetric pair-wise key
145              */
146             void setCredentialKeySize(size_t keySize)
147             {
148                 this->keySize = keySize;
149             }
150     };
151
152     class OCSecure
153     {
154         public:
155             /**
156              * The API is responsible for initialization of the provisioning manager. It will load
157              * provisioning database which have owned device's list and their linked status.
158              *
159              * @param dbPath file path of the sqlite3 database.
160              *
161              * @return ::OC_STACK_OK in case of success and other value otherwise.
162              */
163             static OCStackResult provisionInit(const std::string& dbPath);
164
165             /**
166              * API to terminate the OTM process
167              *
168              * @return ::OC_STACK_OK in case of success and other value otherwise.
169              */
170             static OCStackResult terminatePM();
171
172             /**
173              * API is responsible for discovery of devices in it's subnet. It will list
174              * all the device in subnet which are not yet owned.
175              *
176              * @param timeout Timeout in seconds, time until which function will listen to
177              *                    responses from server before returning the list of devices.
178              * @param list List of candidate devices to be provisioned.
179              * @return ::OC_STACK_OK in case of success and other value otherwise.
180              */
181             static OCStackResult discoverUnownedDevices(unsigned short timeout,
182                     DeviceList_t &list);
183
184             /**
185              * API is responsible for discovery of devices in it's subnet. It will list
186              * all the device in subnet which are already owned by calling provisioning client.
187              *
188              * @param timeout Timeout in seconds, time until which function will listen to
189              *                    responses from server before returning the list of devices.
190              * @param list List of owned devices.
191              * @return ::OC_STACK_OK in case of success and other value otherwise.
192              */
193             static OCStackResult discoverOwnedDevices(unsigned short timeout,
194                     DeviceList_t &list);
195
196             /**
197              * API is responsible for discovery of devices in specified endpoint/deviceID.
198              * And this function will only return the specified device's response.
199              *
200              * @param timeout Timeout in seconds, time until which function will listen to
201              *                    responses from server before returning the specified device.
202              * @param deviceID  deviceID of target device
203              * @param foundDevice OCSecureResource object of found device.
204              * @return ::OC_STACK_OK in case of success and other value otherwise.\n
205              *         ::OC_STACK_INVALID_PARAM when deviceID is NULL or ppFoundDevice is not
206              *                                  initailized.
207              */
208             static OCStackResult discoverSingleDevice(unsigned short timeout,
209                     const OicUuid_t* deviceID,
210                     std::shared_ptr<OCSecureResource> &foundDevice);
211
212             /**
213              * API is responsible for discovery of devices in specified endpoint/deviceID.
214              * And this function will only return the specified device's response.
215              *
216              * @param timeout Timeout in seconds, time until which function will listen to
217              *                    responses from server before returning the specified device.
218              * @param deviceID  deviceID of target device.
219              * @param hostAddress  MAC address of target device.
220              * @param connType  ConnectivityType for discovery.
221              * @param foundDevice OCSecureResource object of found device.
222              * @return ::OC_STACK_OK in case of success and other value otherwise.
223              *         ::OC_STACK_INVALID_PARAM when deviceID is NULL or ppFoundDevice is not
224              *                                  initailized.
225              */
226             static OCStackResult discoverSingleDeviceInUnicast(unsigned short timeout,
227                     const OicUuid_t* deviceID,
228                     const std::string& hostAddress,
229                     OCConnectivityType connType,
230                     std::shared_ptr<OCSecureResource> &foundDevice);
231
232 #ifdef MULTIPLE_OWNER
233              /**
234              * API is responsible for discovery of MOT(Mutilple Owner Transfer)
235              * devices in current subnet.
236              *
237              * @param timeout Timeout in seconds, time until which function will listen to
238              *                    responses from server before returning the list of devices.
239              * @param list List of MOT enabled devices.
240              * @return ::OC_STACK_OK in case of success and other value otherwise.
241              */
242             static OCStackResult discoverMultipleOwnerEnabledDevices(unsigned short timeout,
243                     DeviceList_t &list);
244
245              /**
246              * API is responsible for discovery of Multiple owned device in
247              * current subnet.
248              *
249              * @param timeout Timeout in seconds, time until which function will listen to
250              *                    responses from server before returning the list of devices.
251              * @param list List of Multiple Owned devices.
252              * @return ::OC_STACK_OK in case of success and other value otherwise.
253              */
254             static OCStackResult discoverMultipleOwnedDevices(unsigned short timeout,
255                     DeviceList_t &list);
256
257 #endif
258
259             /**
260              * API for registering Pin Callback.
261              *
262              * @param InputPinCallback inputPin callback function.
263              * @return ::OC_STACK_OK in case of success and other value otherwise.
264              */
265             static OCStackResult setInputPinCallback(InputPinCallback inputPin);
266
267            /**
268              * API for de-registering Pin Callback.
269              *
270              * @return ::OC_STACK_OK in case of success and other value otherwise.
271              */
272             static OCStackResult unsetInputPinCallback();
273
274             /**
275              * API to set Pin Type policy.
276              *
277              * @param  pinSize pin Size
278              * @param  pinType Type of the pin.
279              * @return OC_STACK_OK in case of success and other value otherwise.
280              */
281             static OCStackResult setRandomPinPolicy(size_t pinSize, OicSecPinType_t pinType);
282
283             /**
284              * API to get status of all the devices in current subnet. The status include endpoint
285              * information and doxm information which can be extracted during owned and unowned
286              * discovery. Along with this information, API will provide information about
287              * devices' status.
288              * Device can have following states
289              *  - ON/OFF: Device is switched on or off.
290              *
291              * @param timeout Wait time for the API.
292              * @param ownedDevList  List of owned devices.
293              * @param unownedDevList  List of unowned devices.
294              * @return ::OC_STACK_OK in case of success and other value otherwise.
295              */
296             static OCStackResult getDevInfoFromNetwork(unsigned short timeout,
297                     DeviceList_t &ownedDevList,
298                     DeviceList_t &unownedDevList);
299             /**
300              * Server API to register callback to display stack generated PIN.
301              *
302              * @param displayPin Callback Method to Display generated PIN.
303              * @return ::OC_STACK_OK in case of success and other value otherwise.
304              */
305             static OCStackResult setDisplayPinCB(GeneratePinCallback displayPin);
306
307             /**
308              * API to remove device credential and ACL from all devices in subnet.
309              *
310              * @param resultCallback Callback provided by API user, callback will be called when
311              *            credential revocation is finished.
312              * @param uuid Device uuid to be revoked.
313              * @param waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device
314              *            discovery in seconds.
315              * @return  ::OC_STACK_OK in case of success and other value otherwise.
316              */
317             static OCStackResult removeDeviceWithUuid(unsigned short waitTimeForOwnedDeviceDiscovery,
318                     std::string uuid,
319                     ResultCallBack resultCallback);
320
321             /**
322              * API to save ACL which has several ACE into Acl of SVR.
323              *
324              * @param acl ACL to be saved in Acl of SVR.
325              * @return  OC_STACK_OK in case of success and other value otherwise.
326              */
327             static OCStackResult saveACL(const OicSecAcl_t* acl);
328
329             /**
330              *  api to register Callback for displaying verifNum in verification Just-Works
331              *
332              * @param displayNumCB Callback which is to be registered.
333              * @return  OC_STACK_OK in case of success and other value otherwise.
334              */
335             static OCStackResult registerDisplayNumCallback(DisplayNumCB displayNumCB);
336
337              /**
338              * API to De-register Callback for displaying verifNum in verification Just-Works
339              *
340              * @return  OC_STACK_OK in case of success and other value otherwise.
341              */
342             static OCStackResult deregisterDisplayNumCallback();
343
344             /**
345              * API to reister Callback for getting user confirmation in verification Just-Works
346              *@param userConfirmCB Callback which is to be registered.
347              * @return  OC_STACK_OK in case of success and other value otherwise.
348              */
349             static OCStackResult registerUserConfirmCallback(UserConfirmNumCB userConfirmCB);
350
351              /**
352              * API to De-register Callback for getting user confirmation in verification Just-Works
353              *
354              * @return  OC_STACK_OK in case of success and other value otherwise.
355              */
356             static OCStackResult deregisterUserConfirmCallback();
357
358              /*
359              * Set option for Mutual Verified Just-Works
360              * The default is both display PIN and get user confirmation.
361              */
362             static OCStackResult setVerifyOptionMask(VerifyOptionBitmask_t optionMask);
363
364             /**
365              * Callback function to display Verification Number.
366              *
367              * @param[in] ctx  User context returned in callback
368              * @param[in] verifNum  Array of MUTUAL_VERIF_NUM_LEN size bytes
369              *
370              * @return OC_STACK_OK in case of success and other value otherwise.
371              */
372             static OCStackResult displayNumCallbackWrapper(void* ctx,
373                     uint8_t verifNum[MUTUAL_VERIF_NUM_LEN]);
374
375              /**
376              * Callback function to get 'Num' verification result.
377              *
378              * @return OC_STACK_OK in case of success and other value otherwise.
379              */
380             static OCStackResult confirmUserCallbackWrapper(void* ctx);
381
382             /**
383              * API to cleanup PDM in case of timeout.
384              * It will remove the PDM_DEVICE_INIT state devices from PDM.
385              *
386              * @return OC_STACK_OK in case of success and other value otherwise.
387              */
388              static OCStackResult pdmCleanupForTimeout();
389
390 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
391             /**
392              * API to save Trust certificate chain into Cred of SVR.
393              *
394              * @param[in] trustCertChain Trust certificate chain to be saved in Cred of SVR.
395              * @param[in] chainSize Size of trust certificate chain to be saved in Cred of SVR
396              * @param[in] encodingType Encoding type of trust certificate chain to be saved in Cred of SVR
397              * @param[out] credId CredId of saved trust certificate chain in Cred of SVR.
398              * @return  OC_STACK_OK in case of success and other value otherwise.
399              */
400             static OCStackResult saveTrustCertChain(uint8_t *trustCertChain, size_t chainSize,
401                                         OicEncodingType_t encodingType, uint16_t *credId);
402
403             /*
404             * API to read Trust certificate chain from SVR.
405             * Caller must free when done using the returned trust certificate
406             * @param[in] credId CredId of trust certificate chain in SVR.
407             * @param[out] trustCertChain Trust certificate chain.
408             * @param[out] chainSize Size of trust certificate chain
409             * @return  OC_STACK_OK in case of success and other value otherwise.
410             */
411             static OCStackResult readTrustCertChain(uint16_t credId, uint8_t **trustCertChain,
412                                      size_t *chainSize);
413
414             /**
415              * API to register Notifier for trustCertChain change.
416              *
417              * @param[in] TrustCertChainChangeCB trustCertChain Change will be
418              * notified asynchronously. User need to "delete[]" trustCertChain
419              * in the callback function.
420              * @return  OC_STACK_OK in case of success and other value otherwise.
421              */
422             static OCStackResult registerTrustCertChangeNotifier(CertChainCallBack);
423
424             /**
425              * API to remove Already registered Notifier.
426              *
427              *@return  OC_STACK_OK always, kept it for symmetry.
428              */
429             static OCStackResult removeTrustCertChangeNotifier();
430
431             /**
432              * Notifier wrapper for trustCertChain change.
433              *
434              * @param[in] ctx  User context returned in callback
435              * @param[in] credId  trustCertChain changed for this ID
436              * @param[in] trustCertChain trustcertchain binary blob
437              * @param[in] chainSize size of trustCertChain
438              */
439             static void certCallbackWrapper(void* ctx, uint16_t credId, uint8_t *trustCertChain,
440                                 size_t chainSize);
441
442             /**
443              * Wrapper to save the seed value to generate device UUID
444              *
445              * @param[in] seed  buffer of seed value
446              * @param[in] seedSize byte length of seed
447              */
448             static OCStackResult setDeviceIdSeed(const uint8_t* seed, size_t seedSize);
449
450             /**
451              * Callback wrapper for getting peer certificate.
452              *
453              * @param[in] ctx User context returned in callback
454              * @param[in] cert certificate
455              * @param[in] depth depth of chain
456              */
457             static int peerCertCallbackWrapper(void *ctx, const mbedtls_x509_crt *cert,
458                     int depth);
459
460             /**
461              * API to set the function for getting peer certificate.
462              */
463             static OCStackResult setPeerCertCallback(PeerCertCB cb);
464 #endif // __WITH_DTLS__ || __WITH_TLS__
465
466             /**
467              * This function configures SVR DB as self-ownership.
468              *
469              *@return OC_STACK_OK in case of successful configue and other value otherwise.
470              */
471             static OCStackResult configSelfOwnership();
472
473     };
474
475     /**
476      * This class represents a secure virtual device, which can be provisioned by the
477      * provisioning client.
478      */
479     class OCSecureResource
480     {
481         private:
482             std::weak_ptr<std::recursive_mutex> m_csdkLock;
483             OCProvisionDev_t *devPtr;   // pointer to device.
484             ProvisionContext* context;
485
486         public:
487             OCSecureResource();
488             OCSecureResource(std::weak_ptr<std::recursive_mutex> csdkLock, OCProvisionDev_t *dPtr);
489
490             ~OCSecureResource();
491
492             /**
493              * API to provision credentials between two devices and ACLs for the devices who
494              * act as a server.
495              *
496              * @param cred  Type of credentials & key size to be provisioned to the device.
497              * @param acl1  ACL for device 1. If this is not required set NULL.
498              * @param device2  Second device to be provisioned.
499              * @param acl2  ACL for device 2. If this is not required set NULL.
500              * @param resultCallback Callback will be called when provisioning request receives
501              *                           a response from first resource server.
502              * @return  ::OC_STACK_OK in case of success and other value otherwise.
503              */
504             OCStackResult provisionPairwiseDevices(const Credential &cred, const OicSecAcl_t* acl1,
505                     const OCSecureResource &device2, const OicSecAcl_t* acl2,
506                     ResultCallBack resultCallback);
507
508             /**
509              * API to do ownership transfer for un-owned device.
510              *
511              * @param resultCallback Result callback function to be invoked when
512              *                           ownership transfer finished.
513              * @return ::OC_STACK_OK in case of success and other value otherwise.
514              */
515             OCStackResult doOwnershipTransfer(ResultCallBack resultCallback);
516             OCStackResult doOwnershipTransfer(ResultCallBack resultCallback, const OicSecOxm_t method);
517
518             /**
519              * API to send ACL information to resource.
520              *
521              * @param acl ACL to provision.
522              * @param resultCallback Callback will be called when provisioning request
523              *                           receives a response from resource server.
524              * @return  ::OC_STACK_OK in case of success and other value otherwise.
525              */
526             OCStackResult provisionACL(const OicSecAcl_t* acl,
527                     ResultCallBack resultCallback);
528
529             /**
530              * API to provision credential to devices.
531              *
532              * @param cred Type of credentials to be provisioned to the device.
533              * @param device2 Second device' instance, representing resource to be provisioned.
534              * @param resultCallback Callback will be called when provisioning request receives
535              *                           a response from first resource server.
536              * @return  ::OC_STACK_OK in case of success and other value otherwise.
537              */
538             OCStackResult provisionCredentials(const Credential &cred,
539                     const OCSecureResource &device2,
540                     ResultCallBack resultCallback);
541
542            /**
543             * API to remove the credential & relationship between the two devices.
544             *
545             * @param device2 Second device information to be unlinked.
546             * @param resultCallback Callback provided by API user, callback will be called when
547             *            device unlink is finished.
548             * @return  ::OC_STACK_OK in case of success and other value otherwise.
549             */
550             OCStackResult unlinkDevices(const OCSecureResource &device2,
551                     ResultCallBack resultCallback);
552
553             /**
554              * API to remove device credential from all devices in subnet.
555              *
556              * @param resultCallback Callback provided by API user, callback will be called when
557              *            credential revocation is finished.
558              * @param waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device
559              *            discovery in seconds.
560              * @return  ::OC_STACK_OK in case of success and other value otherwise.
561              */
562             OCStackResult removeDevice(unsigned short waitTimeForOwnedDeviceDiscovery,
563                     ResultCallBack resultCallback);
564
565             /**
566              * API to provision DirectPairing to devices.
567              *
568              * @param pconf pointer to PCONF (Pairing Configuration).
569              * @param resultCallback Callback will be called when provisioning request receives
570              *                           a response from first resource server.
571              * @return  ::OC_STACK_OK in case of success and other value otherwise.
572              */
573             OCStackResult provisionDirectPairing(const OicSecPconf_t *pconf,
574                     ResultCallBack resultCallback);
575
576 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
577             /**
578              * API to provision cert.
579              *
580              * @param type type of cred.
581              * @param credId id of cert.
582              * @param resultCallback Callback will be called when provisioning request
583              *                           receives a response from resource server.
584              * @return  ::OC_STACK_OK in case of success and other value otherwise.
585              */
586             OCStackResult provisionTrustCertChain(OicSecCredType_t type, uint16_t credId,
587                     ResultCallBack resultCallback);
588
589 #endif // __WITH_DTLS__ or __WITH_TLS__
590
591             /**
592              * This method is used to get linked devices' IDs.
593              *
594              * @param uuidList Information about the list of linked devices uuids.
595              * @return  ::OC_STACK_OK in case of success and other value otherwise.
596              */
597             OCStackResult getLinkedDevices(UuidList_t &uuidList);
598
599             /**
600              * API to get the device ID of this resource.
601              * @return device ID.
602              */
603             std::string getDeviceID();
604
605             /**
606              * API to get the information of device for provisioning.
607              * @return  @ref OCProvisionDev_t Reference provides information of device for provisioning.
608              */
609             OCProvisionDev_t* getDevPtr()const;
610
611             /**
612              * This function returns the device's IP address.
613              * @return device address.
614              */
615             std::string getDevAddr();
616
617             /**
618              * This function returns the device's Status.
619              * @return Device status (1 = ON and 2 = OFF).
620              */
621             int getDeviceStatus();
622
623             /**
624              * This function provides the owned status of the device.
625              * @return Device owned status.
626              */
627             bool getOwnedStatus();
628
629             /**
630              * API to get the proper OxM for OT.
631              *
632              * @param oxm Address to save the selected OxM.
633              *
634              * @return ::OC_STACK_OK in case of success and other value otherwise.
635              */
636             OCStackResult getOTMethod(OicSecOxm_t* oxm);
637
638             /**
639              * Common callback wrapper, which will be called from OC-APIs.
640              */
641             static void callbackWrapper(void* ctx, int nOfRes,
642                     OCProvisionResult_t *arr, bool hasError);
643
644 #ifdef MULTIPLE_OWNER
645             /**
646              * API to update 'doxm.oxmsel' to resource server.
647              *
648              * @param resultCallback Callback provided by API user, callback will be
649              *            called when credential revocation is finished.
650              * @param oxmSelVal Method of multiple ownership transfer (ref. oic.sec.oxm)
651              * @return  ::OC_STACK_OK in case of success and other value otherwise.
652              */
653             OCStackResult selectMOTMethod( const OicSecOxm_t oxmSelVal,
654                     ResultCallBack resultCallback);
655
656             /**
657              * API to update 'doxm.mom' to resource server.
658              *
659              * @param resultCallback Callback provided by API user, callback will be
660              *            called when credential revocation is finished.
661              * @param momType Mode of multiple ownership transfer (ref. oic.sec.mom)
662              * @return  ::OC_STACK_OK in case of success and other value otherwise.
663              */
664              OCStackResult changeMOTMode( const OicSecMomType_t momType,
665                     ResultCallBack resultCallback);
666
667             /**
668              * API to add preconfigured PIN to local SVR DB.
669              *
670              * @param preconfPIN Preconfig PIN which is used while multiple owner authentication
671              * @param preconfPINLength Byte length of preconfig PIN
672              * @return  ::OC_STACK_OK in case of success and other value otherwise.
673              */
674              OCStackResult addPreconfigPIN(const char* preconfPIN,
675                     size_t preconfPINLength);
676
677             /**
678              * API to provision preconfigured PIN.
679              *
680              * @param resultCallback Callback provided by API user, callback will be called when
681              *            credential revocation is finished.
682              * @param preconfPin Preconfig PIN which is used while multiple owner authentication
683              * @param preconfPinLength Byte length of preconfig PIN
684              * @return  ::OC_STACK_OK in case of success and other value otherwise.
685              */
686              OCStackResult provisionPreconfPin(const char * preconfPin,
687                     size_t preconfPinLength, ResultCallBack resultCallback);
688
689              /**
690              * API to do multiple ownership transfer for MOT enabled device.
691              *
692              * @param resultCallback Result callback function to be invoked when
693              *                           multiple ownership transfer finished.
694              * @return ::OC_STACK_OK in case of success and other value otherwise.
695              */
696             OCStackResult doMultipleOwnershipTransfer(ResultCallBack resultCallback);
697
698             /**
699              * API to remove sub-owner from resource server
700              *
701              * @param[in] subOwner sub-owner UUID to be removed
702              * @param[in] resultCallback callback provided by API user, callback will be invoked when
703              *            DELETE 'subowneruuid' request recieves a response from resource server.
704              * @return ::OC_STACK_OK in case of success and other value otherwise.
705              */
706             OCStackResult removeSubOwner(const OicUuid_t* subOwnerId, ResultCallBack resultCallback);
707
708             /**
709              * API to remove all sub-owner from resource server
710              *
711              * @param[in] resultCallback callback provided by API user, callback will be invoked when
712              *            DELETE 'subowneruuid' request recieves a response from resource server.
713              * @return ::OC_STACK_OK in case of success and other value otherwise.
714              */
715             OCStackResult removeAllSubOwner(ResultCallBack resultCallback);
716
717             /**
718              * API to get a sub-owner list
719              *
720              * @param[out] Sub-owner list of resource server
721              * @return ::OC_STACK_OK in case of success and other value otherwise.
722              */
723             OCStackResult getSubOwnerList(UuidList_t &uuidList);
724
725             /**
726              * API to get the proper OxM for MOT.
727              *
728              * @param oxm Address to save the selected OxM.
729              *
730              * @return ::OC_STACK_OK in case of success and other value otherwise.
731              */
732             OCStackResult getMOTMethod( OicSecOxm_t* oxm);
733
734             /**
735              * API to check whether MOT is supported.
736              *
737              * @return ::true in case of MOT supported.
738              */
739             bool isMOTSupported();
740
741             /**
742              * API to check whether MOT is enabled.
743              *
744              * @return ::true in case of MOT enabled.
745              */
746             bool isMOTEnabled();
747
748
749 #endif // MULTIPLE_OWNER
750
751         private:
752             void validateSecureResource();
753     };
754
755 }
756 #endif // OC_PROVISIONINGMANAGER_CXX_H_