[IOT-1469] Fix MOT build issues for Windows
authorAlex Kelley <alexke@microsoft.com>
Tue, 1 Nov 2016 02:51:00 +0000 (19:51 -0700)
committerRandeep Singh <randeep.s@samsung.com>
Fri, 4 Nov 2016 04:13:37 +0000 (04:13 +0000)
- Added new .def file for MOT exports
- Fixed samples to use public APIs
- Updated PreconfigPin API names to align

Change-Id: Ib9b473b8b70eed243c8a7dbbd19e27eaa49a4edd
Signed-off-by: Alex Kelley <alexke@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/13921
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Soemin Tjong <stjong@microsoft.com>
Reviewed-by: David Antler <david.a.antler@intel.com>
Reviewed-by: Kevin Kane <kkane@microsoft.com>
Reviewed-by: Dave Thaler <dthaler@microsoft.com>
Reviewed-by: Chul Lee <chuls.lee@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
13 files changed:
resource/csdk/SConscript
resource/csdk/octbstack_product_secured_mot.def [new file with mode: 0644]
resource/csdk/security/include/pinoxmcommon.h
resource/csdk/security/provisioning/include/ocprovisioningmanager.h
resource/csdk/security/provisioning/include/oxm/oxmpreconfpin.h
resource/csdk/security/provisioning/sample/provisioningclient.c
resource/csdk/security/provisioning/sample/subownerclient.c
resource/csdk/security/provisioning/src/ocprovisioningmanager.c
resource/csdk/security/provisioning/src/ownershiptransfermanager.c
resource/csdk/security/provisioning/src/oxmpreconfpin.c
resource/csdk/security/provisioning/unittest/otmunittest.cpp
resource/csdk/security/src/credresource.c
resource/csdk/security/src/oxmpincommon.c

index e62e6be..2c4583a 100644 (file)
@@ -121,7 +121,10 @@ if target_os in ['windows', 'msys_nt']:
        if env.get('SECURED') == '1':
                # octbstack.dll is exporting ocpmapi APIs on Windows - there is no ocpmapi.dll.
                liboctbstack_env.PrependUnique(LIBS = ['ocpmapi'])
-               liboctbstack_env.Textfile(target = 'octbstack.def', source = [File('octbstack_not_secured.def'), File('octbstack_product_secured.def')])
+               if env.get('MULTIPLE_OWNER') == '1':
+                       liboctbstack_env.Textfile(target = 'octbstack.def', source = [File('octbstack_not_secured.def'), File('octbstack_product_secured.def'), File('octbstack_product_secured_mot.def')])
+               else:
+                       liboctbstack_env.Textfile(target = 'octbstack.def', source = [File('octbstack_not_secured.def'), File('octbstack_product_secured.def')])
        else:
                liboctbstack_env.Textfile(target = 'octbstack.def', source = [File('octbstack_not_secured.def')])
 
diff --git a/resource/csdk/octbstack_product_secured_mot.def b/resource/csdk/octbstack_product_secured_mot.def
new file mode 100644 (file)
index 0000000..0fc058c
--- /dev/null
@@ -0,0 +1,24 @@
+; Windows octbstack.dll exports that are required when building
+; with SECURED=1 and MULTIPLE_OWNER=1.
+
+CreatePreconfigPinBasedOwnerTransferPayload
+CreatePreconfigPinBasedSelectOxmPayload
+CreateSecureSessionPreconfigPinCallback
+GeneratePin
+LoadPreconfigPinCodeCallback
+
+OCAddPreconfigPin
+OCChangeMOTMode
+OCDiscoverMultipleOwnedDevices
+OCDiscoverMultipleOwnerEnabledDevices
+OCDoMultipleOwnershipTransfer
+OCProvisionPreconfigPin
+OCSelectMOTMethod
+
+PMGenerateQuery
+
+SetPreconfigPin
+
+; Depending on the outcome of IOT-1480 this export should be removed. For now
+; it has been added for compatibility reasons.
+GetDoxmDeviceID
\ No newline at end of file
index 3c4cabd..52e411f 100644 (file)
@@ -72,15 +72,6 @@ void SetGeneratePinCB(GeneratePinCallback pinCB);
  */
 void SetInputPinCB(InputPinCallback pinCB);
 
-#ifdef _ENABLE_MULTIPLE_OWNER_
-/**
- * Function to save the preconfig PIN getter from user.
- *
- * @param pinCB implementation of preconfig PIN function.
- */
-void SetGetPreconfigPinCB(InputPinCallback pinCB);
-#endif //_ENABLE_MULTIPLE_OWNER_
-
 /**
  * Function to unset the input PIN callback.
  * NOTE : Do not call this function while PIN based ownership transfer.
@@ -123,17 +114,7 @@ OCStackResult InputPin(char* pinBuffer, size_t bufferSize);
  *
  * @return ::OC_STACK_SUCCESS in case of success or other value in ccase of error.
  */
-OCStackResult SetPreconfigPin(const char* pinBuffer, size_t pinLength);
-
-/**
- * Function to read preconfig PIN.
- *
- * @param[in,out] pinBuffer is the reference to the buffer to store the preconfigured PIN.
- * @param[in] bufferSize is the size of buffer.
- *
- * @return ::OC_STACK_SUCCESS in case of success or other value in ccase of error.
- */
-OCStackResult GetPreconfigPin(char* pinBuffer, size_t bufferSize);
+OCStackResult SetPreconfigPin(const char *pinBuffer, size_t pinLength);
 #endif
 
 /**
index 939af63..9bba19a 100755 (executable)
@@ -233,32 +233,34 @@ OCStackResult OCProvisionCredentials(void *ctx, OicSecCredType_t type, size_t ke
 /**\r
  * API to provision preconfigured PIN to device(NOT LIST).\r
  * If device does not support the Preconfigured PIN OxM,\r
- * OCProvisionPreconfPin API will be update the device's Doxm\r
- * and then try prevonfigured PIN provisioning once again.\r
+ * OCProvisionPreconfigPin API will update the device's Doxm\r
+ * and then try preconfigured PIN provisioning once again.\r
  *\r
  * @param[in] ctx Application context would be returned in result callback.\r
  * @param[in] targetDeviceInfo Selected target device.\r
- * @param[in] preconfPin string of preconfigured PIN.\r
- * @param[in] preconfPinLen string length of 'preconfPin'.\r
+ * @param[in] preconfigPin string of preconfigured PIN.\r
+ * @param[in] preconfigPinLen string length of 'preconfigPin'.\r
  * @param[in] resultCallback callback provided by API user, callback will be called when\r
  *            provisioning request recieves a response from first resource server.\r
  * @return OC_STACK_OK in case of success and other value otherwise.\r
  */\r
-OCStackResult OCProvisionPreconfPin(void* ctx,\r
-                                               OCProvisionDev_t *targetDeviceInfo,\r
-                                               const char * preconfPin, size_t preconfPinLen,\r
-                                               OCProvisionResultCB resultCallback);\r
+OCStackResult OCProvisionPreconfigPin(void *ctx,\r
+                                      OCProvisionDev_t *targetDeviceInfo,\r
+                                      const char *preconfigPin,\r
+                                      size_t preconfigPinLen,\r
+                                      OCProvisionResultCB resultCallback);\r
 \r
 /**\r
  * API to add preconfigured PIN to local SVR DB.\r
  *\r
  * @param[in] targetDeviceInfo Selected target device.\r
- * @param[in] preconfPIN Preconfig PIN which is used while multiple owner authentication\r
- * @param[in] preconfPINLen Byte length of preconfig PIN\r
+ * @param[in] preconfigPin Preconfig PIN which is used while multiple owner authentication\r
+ * @param[in] preconfigPinLen Byte length of preconfigPin\r
  * @return OC_STACK_OK in case of success and other value otherwise.\r
  */\r
-OCStackResult OCAddPreconfigPIN(const OCProvisionDev_t *targetDeviceInfo,\r
-                                 const char* preconfPIN, size_t preconfPINLen);\r
+OCStackResult OCAddPreconfigPin(const OCProvisionDev_t *targetDeviceInfo,\r
+                                const char *preconfigPin,\r
+                                size_t preconfigPinLen);\r
 \r
 /**\r
  * API to update 'doxm.mom' to resource server.\r
index f00bb04..ec4ca76 100644 (file)
@@ -38,7 +38,7 @@ extern "C" {
  *
  * @return ::OC_STACK_SUCCESS in case of success and other value otherwise.
  */
-OCStackResult LoadPreconfPinCodeCallback(OTMContext_t *otmCtx);
+OCStackResult LoadPreconfigPinCodeCallback(OTMContext_t *otmCtx);
 
 /**
  * Callback implementation to establish a secure channel with PSK cipher suite.
@@ -47,7 +47,7 @@ OCStackResult LoadPreconfPinCodeCallback(OTMContext_t *otmCtx);
  *
  * @return ::OC_STACK_SUCCESS in case of success and other value otherwise.
  */
-OCStackResult CreateSecureSessionPreconfPinCallback(OTMContext_t *otmCtx);
+OCStackResult CreateSecureSessionPreconfigPinCallback(OTMContext_t *otmCtx);
 
 /**
  * Generate payload for select OxM request.
@@ -59,8 +59,8 @@ OCStackResult CreateSecureSessionPreconfPinCallback(OTMContext_t *otmCtx);
  *
  * @return ::OC_STACK_SUCCESS in case of success and other value otherwise.
  */
-OCStackResult CreatePreconfPinBasedSelectOxmPayload(OTMContext_t *otmCtx, uint8_t **cborPayload,
-                                             size_t *cborSize);
+OCStackResult CreatePreconfigPinBasedSelectOxmPayload(OTMContext_t *otmCtx, uint8_t **cborPayload,
+                                               size_t *cborSize);
 
 /**
  * Generate payload for owner transfer request.
@@ -72,8 +72,8 @@ OCStackResult CreatePreconfPinBasedSelectOxmPayload(OTMContext_t *otmCtx, uint8_
  *
  * @return ::OC_STACK_SUCCESS in case of success and other value otherwise.
  */
-OCStackResult CreatePreconfPinBasedOwnerTransferPayload(OTMContext_t *otmCtx, uint8_t **cborPayload,
-                                                 size_t *cborSize);
+OCStackResult CreatePreconfigPinBasedOwnerTransferPayload(OTMContext_t *otmCtx, uint8_t **cborPayload,
+                                                   size_t *cborSize);
 
 #ifdef __cplusplus
 }
index 761d898..e8c50cb 100644 (file)
@@ -1256,13 +1256,13 @@ static int changeMultipleOwnershipTrnasferMode(void)
     }
 
     OCProvisionDev_t* motDev = getDevInst(g_own_list, dev_num);
-    if(OC_STACK_OK == MOTChangeMode(NULL, motDev, (OicSecMomType_t)dev_num, updateDoxmForMOTCB))
+    if(OC_STACK_OK == OCChangeMOTMode(NULL, motDev, (OicSecMomType_t)dev_num, updateDoxmForMOTCB))
     {
         g_doneCB = false;
     }
     else
     {
-        OIC_LOG(ERROR, TAG, "MOTChangeMode API error");
+        OIC_LOG(ERROR, TAG, "OCChangeMOTMode API error");
         return -1;
     }
 
@@ -1327,13 +1327,13 @@ static int selectMultipleOwnershipTrnasferMethod(void)
     }
 
     OCProvisionDev_t* motDev = getDevInst(g_mot_enable_list, dev_num);
-    if(OC_STACK_OK ==  MOTSelectMOTMethod(NULL, motDev, (OicSecOxm_t)oxm, updateDoxmForMOTCB))
+    if(OC_STACK_OK ==  OCSelectMOTMethod(NULL, motDev, (OicSecOxm_t)oxm, updateDoxmForMOTCB))
     {
         g_doneCB = false;
     }
     else
     {
-        OIC_LOG(ERROR, TAG, "MOTSelectMOTMethod API error");
+        OIC_LOG(ERROR, TAG, "OCSelectMOTMethod API error");
         return -1;
     }
 
@@ -1374,23 +1374,23 @@ static int provisionPreconfigPIN()
         printf("     Entered Wrong Number. Please Enter Again\n");
     }
 
-    char preconfPIN[9] = {0};
-    printf("   > Input the PreconfigPIN (e.g. 12341234) : ");
+    char preconfigPin[9] = {0};
+    printf("   > Input the PreconfigPin (e.g. 12341234) : ");
     for(int ret=0; 1!=ret; )
     {
-        ret = scanf("%8s", preconfPIN);
+        ret = scanf("%8s", preconfigPin);
         for( ; 0x20<=getchar(); );  // for removing overflow garbages
                                     // '0x20<=code' is character region
     }
 
     OCProvisionDev_t* motDev = getDevInst(g_mot_enable_list, dev_num);
-    if(OC_STACK_OK == OCProvisionPreconfPin(NULL, motDev, preconfPIN, strlen(preconfPIN), provisionCredCB))
+    if(OC_STACK_OK == OCProvisionPreconfigPin(NULL, motDev, preconfigPin, strlen(preconfigPin), provisionCredCB))
     {
         g_doneCB = false;
     }
     else
     {
-        OIC_LOG(ERROR, TAG, "OCProvisionPreconfPin API error");
+        OIC_LOG(ERROR, TAG, "OCProvisionPreconfigPin API error");
         return -1;
     }
 
index bbc099f..d13f1d2 100644 (file)
@@ -328,8 +328,8 @@ static int multipleOwnershipTransfer(void)
         if(OIC_PRECONFIG_PIN == dev->doxm->oxmSel)
         {
             //Pre-Configured PIN initialization
-            const char* testPreconfPin = "12341234";
-            if(OC_STACK_OK != OCAddPreconfigPIN(dev, testPreconfPin, strlen(testPreconfPin)))
+            const char* testPreconfigPin = "12341234";
+            if(OC_STACK_OK != OCAddPreconfigPin(dev, testPreconfigPin, strlen(testPreconfigPin)))
             {
                 printf("\n\n\n*** %60s ***\n", "WARNNING : Failed to save the pre-configured PIN");
                 printf("*** %60s ***\n\n\n", "WARNNING : You can't use the pre-configured PIN OxM for MOT");
index f66ed79..0c49fbd 100755 (executable)
@@ -182,15 +182,16 @@ OCStackResult OCDiscoverMultipleOwnedDevices(unsigned short timeout, OCProvision
  * API to add preconfigured PIN to local SVR DB.
  *
  * @param[in] targetDeviceInfo Selected target device.
- * @param[in] preconfPIN Preconfig PIN which is used while multiple owner authentication
- * @param[in] preconfPINLen Byte length of preconfig PIN
+ * @param[in] preconfigPin Preconfig PIN which is used while multiple owner authentication
+ * @param[in] preconfigPinLen Byte length of preconfigPin
  *
  * @return OC_STACK_OK in case of success and other value otherwise.
  */
-OCStackResult OCAddPreconfigPIN(const OCProvisionDev_t *targetDeviceInfo,
-                                 const char* preconfPIN, size_t preconfPINLen)
+OCStackResult OCAddPreconfigPin(const OCProvisionDev_t *targetDeviceInfo,
+                                const char *preconfigPin, 
+                                size_t preconfigPinLen)
 {
-    return MOTAddPreconfigPIN( targetDeviceInfo, preconfPIN, preconfPINLen);
+    return MOTAddPreconfigPIN(targetDeviceInfo, preconfigPin, preconfigPinLen);
 }
 
 
@@ -364,10 +365,11 @@ static void AddPreconfPinOxMCB(void* ctx, int nOfRes, OCProvisionResult_t *arr,
     }
 }
 
-OCStackResult OCProvisionPreconfPin(void* ctx,
-                                               OCProvisionDev_t *targetDeviceInfo,
-                                               const char * preconfPin, size_t preconfPinLen,
-                                               OCProvisionResultCB resultCallback)
+OCStackResult OCProvisionPreconfigPin(void *ctx,
+                                      OCProvisionDev_t *targetDeviceInfo,
+                                      const char *preconfigPin,
+                                      size_t preconfigPinLen,
+                                      OCProvisionResultCB resultCallback)
 {
     if( NULL == targetDeviceInfo )
     {
@@ -375,7 +377,7 @@ OCStackResult OCProvisionPreconfPin(void* ctx,
     }
     if (NULL == resultCallback)
     {
-        OIC_LOG(INFO, TAG, "OCProvisionPreconfPINCredential : NULL Callback");
+        OIC_LOG(INFO, TAG, "OCProvisionPreconfigPinCredential : NULL Callback");
         return OC_STACK_INVALID_CALLBACK;
     }
 
@@ -386,8 +388,8 @@ OCStackResult OCProvisionPreconfPin(void* ctx,
     }
     provCtx->ctx = ctx;
     provCtx->devInfo = targetDeviceInfo;
-    provCtx->pin = preconfPin;
-    provCtx->pinLen = preconfPinLen;
+    provCtx->pin = preconfigPin;
+    provCtx->pinLen = preconfigPinLen;
     provCtx->resultCallback = resultCallback;
     /*
      * First of all, update OxMs to support preconfigured PIN OxM.
index 6ca41d9..eef6ba6 100644 (file)
@@ -115,10 +115,10 @@ OCStackResult OTMSetOTCallback(OicSecOxm_t oxm, OTMCallbackData_t* callbacks)
         return OC_STACK_INVALID_METHOD;
 #ifdef _ENABLE_MULTIPLE_OWNER_
     case OIC_PRECONFIG_PIN:
-        callbacks->loadSecretCB = LoadPreconfPinCodeCallback;
-        callbacks->createSecureSessionCB = CreateSecureSessionPreconfPinCallback;
-        callbacks->createSelectOxmPayloadCB = CreatePreconfPinBasedSelectOxmPayload;
-        callbacks->createOwnerTransferPayloadCB = CreatePreconfPinBasedOwnerTransferPayload;
+        callbacks->loadSecretCB = LoadPreconfigPinCodeCallback;
+        callbacks->createSecureSessionCB = CreateSecureSessionPreconfigPinCallback;
+        callbacks->createSelectOxmPayloadCB = CreatePreconfigPinBasedSelectOxmPayload;
+        callbacks->createOwnerTransferPayloadCB = CreatePreconfigPinBasedOwnerTransferPayload;
         break;
 #endif //_ENABLE_MULTIPLE_OWNER_
     default:
index 7083834..193a73a 100644 (file)
@@ -39,7 +39,7 @@
 
 #define TAG "OXM_PreconfigPIN"
 
-OCStackResult CreatePreconfPinBasedSelectOxmPayload(OTMContext_t* otmCtx, uint8_t **payload, size_t *size)
+OCStackResult CreatePreconfigPinBasedSelectOxmPayload(OTMContext_t *otmCtx, uint8_t **payload, size_t *size)
 {
     if(!otmCtx || !otmCtx->selectedDeviceInfo || !payload || *payload || !size)
     {
@@ -51,7 +51,7 @@ OCStackResult CreatePreconfPinBasedSelectOxmPayload(OTMContext_t* otmCtx, uint8_
     return DoxmToCBORPayload(otmCtx->selectedDeviceInfo->doxm, payload, size, true);
 }
 
-OCStackResult CreatePreconfPinBasedOwnerTransferPayload(OTMContext_t* otmCtx, uint8_t **payload, size_t *size)
+OCStackResult CreatePreconfigPinBasedOwnerTransferPayload(OTMContext_t *otmCtx, uint8_t **payload, size_t *size)
 {
     if(!otmCtx || !otmCtx->selectedDeviceInfo || !payload || *payload || !size)
     {
@@ -72,9 +72,9 @@ OCStackResult CreatePreconfPinBasedOwnerTransferPayload(OTMContext_t* otmCtx, ui
     return DoxmToCBORPayload(otmCtx->selectedDeviceInfo->doxm, payload, size, true);
 }
 
-OCStackResult LoadPreconfPinCodeCallback(OTMContext_t *otmCtx)
+OCStackResult LoadPreconfigPinCodeCallback(OTMContext_t *otmCtx)
 {
-    OIC_LOG(INFO, TAG, "IN LoadPreconfPinCodeCallback");
+    OIC_LOG(INFO, TAG, "IN LoadPreconfigPinCodeCallback");
     OCStackResult res = OC_STACK_ERROR;
     OicSecCred_t* cred = GetCredResourceData(&otmCtx->selectedDeviceInfo->doxm->deviceID);
     if(NULL == cred)
@@ -163,14 +163,14 @@ OCStackResult LoadPreconfPinCodeCallback(OTMContext_t *otmCtx)
     //Set the device id to derive temporal PSK
     SetUuidForPinBasedOxm(&(otmCtx->selectedDeviceInfo->doxm->deviceID));
 
-    OIC_LOG(INFO, TAG, "OUT LoadPreconfPinCodeCallback");
+    OIC_LOG(INFO, TAG, "OUT LoadPreconfigPinCodeCallback");
 
     return res;
 }
 
-OCStackResult CreateSecureSessionPreconfPinCallback(OTMContext_t* otmCtx)
+OCStackResult CreateSecureSessionPreconfigPinCallback(OTMContext_t* otmCtx)
 {
-    OIC_LOG(INFO, TAG, "IN CreateSecureSessionPreconfPinCallback");
+    OIC_LOG(INFO, TAG, "IN CreateSecureSessionPreconfigPinCallback");
 
     if (!otmCtx || !otmCtx->selectedDeviceInfo)
     {
@@ -209,7 +209,7 @@ OCStackResult CreateSecureSessionPreconfPinCallback(OTMContext_t* otmCtx)
         return OC_STACK_ERROR;
     }
 
-    OIC_LOG(INFO, TAG, "OUT CreateSecureSessionPreconfPinCallback");
+    OIC_LOG(INFO, TAG, "OUT CreateSecureSessionPreconfigPinCallback");
 
     return OC_STACK_OK;
 }
index 78ba0e0..abf6fb1 100644 (file)
@@ -632,7 +632,7 @@ TEST(EnableMOT, NullParam)
     EXPECT_NE((OCProvisionDev_t*)NULL, g_ownedDevices);
 
     g_doneCB = false;
-    result = MOTChangeMode(NULL, g_ownedDevices, OIC_MULTIPLE_OWNER_ENABLE, updateDoxmForMOTCB);
+    result = OCChangeMOTMode(NULL, g_ownedDevices, OIC_MULTIPLE_OWNER_ENABLE, updateDoxmForMOTCB);
     EXPECT_EQ(OC_STACK_OK, result);
     if(waitCallbackRet())  // input |g_doneCB| flag implicitly
     {
@@ -680,7 +680,7 @@ TEST(SelectMOTMethod, NullParam)
     OCStackResult result = OC_STACK_OK;
 
     g_doneCB = false;
-    result = MOTSelectMOTMethod(NULL, g_motEnabledDevices, OIC_PRECONFIG_PIN, updateDoxmForMOTCB);
+    result = OCSelectMOTMethod(NULL, g_motEnabledDevices, OIC_PRECONFIG_PIN, updateDoxmForMOTCB);
     EXPECT_EQ(OC_STACK_OK, result);
     if(waitCallbackRet())  // input |g_doneCB| flag implicitly
     {
index 1c0ecb5..fb273fa 100755 (executable)
@@ -2427,7 +2427,7 @@ int32_t GetDtlsPskCredentials(CADtlsPskCredType_t type,
                                 }
 
                                 //Set the PIN/PW to derive PSK
-                                if(OC_STACK_OK != SetPreconfigPin(pinBuffer, pinLength))
+                                if (OC_STACK_OK != SetPreconfigPin(pinBuffer, pinLength))
                                 {
                                     OICFree(pinBuffer);
                                     OIC_LOG(ERROR, TAG, "Failed to load PIN data.");
index dd8369f..c37f241 100644 (file)
@@ -254,7 +254,7 @@ OCStackResult InputPin(char* pinBuffer, size_t bufferSize)
 }
 
 #ifdef _ENABLE_MULTIPLE_OWNER_
-OCStackResult SetPreconfigPin(const charpinBuffer, size_t pinLength)
+OCStackResult SetPreconfigPin(const char *pinBuffer, size_t pinLength)
 {
     if(NULL == pinBuffer || OXM_PRECONFIG_PIN_MAX_SIZE < pinLength)
     {