replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / security / provisioning / include / internal / ownershiptransfermanager.h
index 546bb28..1d0aa24 100644 (file)
@@ -31,21 +31,10 @@ extern "C" {
 #endif // __cplusplus\r
 \r
 #define OXM_STRING_MAX_LENGTH 32\r
-#define WRONG_PIN_MAX_ATTEMP 5\r
+#define WRONG_PIN_MAX_ATTEMP 1\r
 \r
-/**\r
- * Context for ownership transfer(OT)\r
- */\r
-typedef struct OTMContext{\r
-    void* userCtx;                            /**< Context for user.*/\r
-    OCProvisionDev_t* selectedDeviceInfo;     /**< Selected device info for OT. */\r
-    OicUuid_t subIdForPinOxm;                 /**< Subject Id which uses PIN based OTM. */\r
-    OCProvisionResultCB ctxResultCallback;    /**< Function pointer to store result callback. */\r
-    OCProvisionResult_t* ctxResultArray;      /**< Result array having result of all device. */\r
-    size_t ctxResultArraySize;                /**< No of elements in result array. */\r
-    bool ctxHasError;                         /**< Does OT process have any error. */\r
-    int attemptCnt;\r
-}OTMContext_t;\r
+typedef struct OTMCallbackData OTMCallbackData_t;\r
+typedef struct OTMContext OTMContext_t;\r
 \r
 /**\r
  * Do ownership transfer for the unowned devices.\r
@@ -58,6 +47,17 @@ typedef struct OTMContext{
 OCStackResult OTMDoOwnershipTransfer(void* ctx,\r
                                      OCProvisionDev_t* selectedDeviceList, OCProvisionResultCB resultCB);\r
 \r
+/**\r
+ * API to set a allow status of OxM\r
+ *\r
+ * @param[in] oxm Owership transfer method (ref. OicSecOxm_t)\r
+ * @param[in] allowStatus allow status (true = allow, false = not allow)\r
+ *\r
+ * @return OC_STACK_OK in case of success and other value otherwise.\r
+ */\r
+OCStackResult OTMSetOxmAllowStatus(const OicSecOxm_t oxm, const bool allowStatus);\r
+\r
+\r
 /*\r
  *Callback for load secret for temporal secure session\r
  *\r
@@ -66,7 +66,6 @@ OCStackResult OTMDoOwnershipTransfer(void* ctx,
  */\r
 typedef OCStackResult (*OTMLoadSecret)(OTMContext_t* otmCtx);\r
 \r
-\r
 /*\r
  * Callback for create secure channel using secret inputed from OTMLoadSecret callback\r
  */\r
@@ -81,15 +80,32 @@ typedef OCStackResult (*OTMCreatePayloadCallback)(OTMContext_t* otmCtx, uint8_t
 /**\r
  * Required callback for performing ownership transfer\r
  */\r
-typedef struct OTMCallbackData\r
+struct OTMCallbackData\r
 {\r
     OTMLoadSecret loadSecretCB;\r
     OTMCreateSecureSession createSecureSessionCB;\r
     OTMCreatePayloadCallback createSelectOxmPayloadCB;\r
     OTMCreatePayloadCallback createOwnerTransferPayloadCB;\r
-} OTMCallbackData_t;\r
+};\r
 \r
 /**\r
+ * Context for ownership transfer(OT)\r
+ */\r
+struct OTMContext{\r
+    void* userCtx;                            /**< Context for user.*/\r
+    OCProvisionDev_t* selectedDeviceInfo;     /**< Selected device info for OT. */\r
+    OicUuid_t subIdForPinOxm;                 /**< Subject Id which uses PIN based OTM. */\r
+    OCProvisionResultCB ctxResultCallback;    /**< Function pointer to store result callback. */\r
+    OCProvisionResult_t* ctxResultArray;      /**< Result array having result of all device. */\r
+    size_t ctxResultArraySize;                /**< No of elements in result array. */\r
+    bool ctxHasError;                         /**< Does OT process have any error. */\r
+    OCDoHandle ocDoHandle;                    /** <A handle for latest request message*/\r
+    OTMCallbackData_t otmCallback; /**< OTM callbacks to perform the OT/MOT. **/\r
+    int attemptCnt;\r
+};\r
+\r
+// TODO: Remove this OTMSetOwnershipTransferCallbackData, Please see the jira ticket IOT-1484\r
+/**\r
  * Set the callbacks for ownership transfer\r
  *\r
  * @param[in] oxm Ownership transfer method\r
@@ -98,6 +114,47 @@ typedef struct OTMCallbackData
  */\r
 OCStackResult OTMSetOwnershipTransferCallbackData(OicSecOxm_t oxm, OTMCallbackData_t* callbackData);\r
 \r
+/**\r
+ * API to assign the OTMCallback for each OxM.\r
+ *\r
+ * @param[out] callbacks Instance of OTMCallback_t\r
+ * @param[in] oxm Ownership transfer method\r
+ * @return  OC_STACK_OK on success\r
+ */\r
+OCStackResult OTMSetOTCallback(OicSecOxm_t oxm, OTMCallbackData_t* callbacks);\r
+\r
+/**\r
+ * Function to save the result of provisioning.\r
+ *\r
+ * @param[in,out] otmCtx   Context value of ownership transfer.\r
+ * @param[in] res   result of provisioning\r
+ */\r
+void SetResult(OTMContext_t* otmCtx, const OCStackResult res);\r
+\r
+/**\r
+ * Function to select appropriate security provisioning method.\r
+ *\r
+ * @param[in] supportedMethods   Array of supported methods\r
+ * @param[in] numberOfMethods   number of supported methods\r
+ * @param[out]  selectedMethod         Selected methods\r
+ * @param[in] ownerType type of owner device (SUPER_OWNER or SUB_OWNER)\r
+ * @return  OC_STACK_OK on success\r
+ */\r
+OCStackResult OTMSelectOwnershipTransferMethod(const OicSecOxm_t *supportedMethods,\r
+        size_t numberOfMethods, OicSecOxm_t *selectedMethod, OwnerType_t ownerType);\r
+\r
+/**\r
+ * This function configures SVR DB as self-ownership.\r
+ *\r
+ *@return OC_STACK_OK in case of successful configue and other value otherwise.\r
+ */\r
+OCStackResult ConfigSelfOwnership(void);\r
+\r
+/**\r
+ * API to terminate the OTM process when terminating OCStack\r
+ */\r
+void OTMTerminate();\r
+\r
 #ifdef __cplusplus\r
 }\r
 #endif\r