[Patch #1] Refactored provisioning manager
[platform/upstream/iotivity.git] / resource / csdk / security / provisioning / include / internal / ownershiptransfermanager.h
1 /* *****************************************************************\r
2  *\r
3  * Copyright 2015 Samsung Electronics All Rights Reserved.\r
4  *\r
5  *\r
6  *\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  *\r
11  *     http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  *\r
19  * *****************************************************************/\r
20 \r
21 #ifndef OTM_OWNERSHIPTRANSFERMANAGER_H_\r
22 #define OTM_OWNERSHIPTRANSFERMANAGER_H_\r
23 \r
24 #include "pmtypes.h"\r
25 #include "ocstack.h"\r
26 #include "octypes.h"\r
27 #include "securevirtualresourcetypes.h"\r
28 \r
29 #ifdef __cplusplus\r
30 extern "C" {\r
31 #endif // __cplusplus\r
32 \r
33 #define OXM_STRING_MAX_LENGTH 32\r
34 \r
35 \r
36 /**\r
37  * Context for ownership transfer(OT)\r
38  */\r
39 typedef struct OTMContext{\r
40     void* userCtx; /**< Context for user**/\r
41     OCProvisionDev_t* selectedDeviceInfo; /**< Selected device info for OT */\r
42     uint16_t tempCredId;\r
43 }OTMContext_t;\r
44 \r
45 /**\r
46  * Do ownership transfer for un-owned device.\r
47  *\r
48  * @param[in] ctx Application context would be returned in result callback\r
49  * @param[in] selectedDeviceInfo selected device information\r
50  * @param[in] resultCB Result callback function to be invoked when ownership transfer finished.\r
51  * @return OC_STACK_OK in case of success and other value otherwise.\r
52  */\r
53 OCStackResult OTMDoOwnershipTransfer(void* ctx,\r
54                                      OCProvisionDev_t* selectedDeviceInfo, OCProvisionResultCB resultCB);\r
55 \r
56 /*\r
57  *Callback for load secret for temporal secure session\r
58  *\r
59  * e.g) in case of PIN based, input the pin through this callback\r
60  *       in case of X.509 based, input the certificate through this callback\r
61  */\r
62 typedef OCStackResult (*OTMLoadSecret)(OTMContext_t* otmCtx);\r
63 \r
64 \r
65 /*\r
66  * Callback for create secure channel using secret inputed from OTMLoadSecret callback\r
67  */\r
68 typedef OCStackResult (*OTMCreateSecureSession)(OTMContext_t* otmCtx);\r
69 \r
70 /*\r
71  * Callback for creating CoAP payload.\r
72  */\r
73 typedef char* (*OTMCreatePayloadCallback)(OTMContext_t* otmCtx);\r
74 \r
75 /**\r
76  * Required callback for performing ownership transfer\r
77  */\r
78 typedef struct OTMCallbackData{\r
79     OTMLoadSecret loadSecretCB;\r
80     OTMCreateSecureSession createSecureSessionCB;\r
81     OTMCreatePayloadCallback createSelectOxmPayloadCB;\r
82     OTMCreatePayloadCallback createOwnerTransferPayloadCB;\r
83 }OTMCallbackData_t;\r
84 \r
85 /**\r
86  * Set the callbacks for ownership transfer\r
87  *\r
88  * @param[in] oxm Ownership transfer method\r
89  * @param[in] callbackData the implementation of the ownership transfer function for each step.\r
90  * @return OC_STACK_OK in case of success and other value otherwise.\r
91  */\r
92 OCStackResult OTMSetOwnershipTransferCallbackData(OicSecOxm_t oxm, OTMCallbackData_t* callbackData);\r
93 \r
94 \r
95 #ifdef __cplusplus\r
96 }\r
97 #endif\r
98 #endif //OTM_OWNERSHIPTRANSFERMANAGER_H_