Removed SECURED define dependency from JNI.
authorChul Lee <chuls.lee@samsung.com>
Fri, 11 Nov 2016 12:34:58 +0000 (21:34 +0900)
committerRandeep Singh <randeep.s@samsung.com>
Tue, 15 Nov 2016 03:51:07 +0000 (03:51 +0000)
Change-Id: I7fd578d3d18a220e86794ce558e3cc704784b605
Signed-off-by: Chul Lee <chuls.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14229
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
android/android_api/base/jni/JniCaInterface.c
resource/csdk/connectivity/src/caconnectivitymanager.c

index 9499b55..8fdedd9 100644 (file)
@@ -360,14 +360,13 @@ JNIEXPORT jint JNICALL Java_org_iotivity_ca_CaInterface_setCipherSuiteImpl
   (JNIEnv *env, jclass clazz, jint cipherSuite, jint adapter)
 {
     LOGI("setCipherSuiteImpl");
-#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
     (void)env;
     (void)clazz;
     CAResult_t ret = CASelectCipherSuite(cipherSuite, (CATransportAdapter_t) adapter);
+    if (CA_STATUS_OK != ret)
+    {
+        LOGE("CASelectCipherSuite has failed");
+    }
     return ret;
-#else
-    LOGE("Method not supported");
-    return -1;
-#endif //  __WITH_DTLS__ || __WITH_TLS__
 }
 
index 13ebf36..9cbc52f 100644 (file)
@@ -475,33 +475,41 @@ CAResult_t CAHandleRequestResponse()
     return CA_STATUS_OK;
 }
 
-#if defined (__WITH_DTLS__) || defined(__WITH_TLS__)
 CAResult_t CASelectCipherSuite(const uint16_t cipher, CATransportAdapter_t adapter)
 {
     OIC_LOG_V(DEBUG, TAG, "IN %s", __func__);
     OIC_LOG_V(DEBUG, TAG, "cipher : %d , CATransportAdapter : %d", cipher, adapter);
-    if (CA_STATUS_OK != CAsetTlsCipherSuite(cipher))
+    CAResult_t res = CA_STATUS_FAILED;
+#if defined (__WITH_DTLS__) || defined(__WITH_TLS__)
+    res = CAsetTlsCipherSuite(cipher);
+    if (CA_STATUS_OK != res)
     {
-        OIC_LOG_V(ERROR, TAG, "Out %s", __func__);
-        return CA_STATUS_FAILED;
+        OIC_LOG_V(ERROR, TAG, "Failed to CAsetTlsCipherSuite : %d", res);
     }
+#else
+    OIC_LOG(ERROR, TAG, "Method not supported");
+#endif
     OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
-    return CA_STATUS_OK;
+    return res;
 }
 
 CAResult_t CAEnableAnonECDHCipherSuite(const bool enable)
 {
     OIC_LOG_V(DEBUG, TAG, "CAEnableAnonECDHCipherSuite");
-
+    CAResult_t res = CA_STATUS_FAILED;
 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
     // TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256    0xFF00 replaces 0xC018
     // TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256    0xC037
-    if (CA_STATUS_OK != CAsetTlsCipherSuite(enable ? 0xFF00 : 0xC037))
+    res = CAsetTlsCipherSuite(enable ? 0xFF00 : 0xC037);
+    if (CA_STATUS_OK != res)
     {
-        return CA_STATUS_FAILED;
+        OIC_LOG_V(ERROR, TAG, "Failed to CAsetTlsCipherSuite : %d", res);
     }
+#else
+    OIC_LOG(ERROR, TAG, "Method not supported");
 #endif
-    return CA_STATUS_OK;
+    OIC_LOG_V(ERROR, TAG, "Out %s", __func__);
+    return res;
 }
 
 CAResult_t CAGenerateOwnerPSK(const CAEndpoint_t* endpoint,
@@ -511,9 +519,8 @@ CAResult_t CAGenerateOwnerPSK(const CAEndpoint_t* endpoint,
                     uint8_t* ownerPSK, const size_t ownerPskSize)
 {
     OIC_LOG_V(DEBUG, TAG, "IN : CAGenerateOwnerPSK");
-
-    CAResult_t res = CA_STATUS_OK;
-
+    CAResult_t res = CA_STATUS_FAILED;
+#if defined (__WITH_DTLS__) || defined(__WITH_TLS__)
     //newOwnerLabel and prevOwnerLabe can be NULL
     if (!endpoint || !label || 0 == labelLen || !ownerPSK || 0 == ownerPskSize)
     {
@@ -524,22 +531,22 @@ CAResult_t CAGenerateOwnerPSK(const CAEndpoint_t* endpoint,
                                       rsrcServerDeviceID, rsrcServerDeviceIDLen,
                                       provServerDeviceID, provServerDeviceIDLen,
                                       ownerPSK, ownerPskSize);
-
     if (CA_STATUS_OK != res)
     {
         OIC_LOG_V(ERROR, TAG, "Failed to CAGenerateOwnerPSK : %d", res);
     }
-
+#else
+    OIC_LOG(ERROR, TAG, "Method not supported");
+#endif
     OIC_LOG_V(DEBUG, TAG, "OUT : CAGenerateOwnerPSK");
-
     return res;
 }
 
 CAResult_t CAInitiateHandshake(const CAEndpoint_t *endpoint)
 {
     OIC_LOG_V(DEBUG, TAG, "IN : CAInitiateHandshake");
-    CAResult_t res = CA_STATUS_OK;
-
+    CAResult_t res = CA_STATUS_FAILED;
+#if defined (__WITH_DTLS__) || defined(__WITH_TLS__)
     if (!endpoint)
     {
         return CA_STATUS_INVALID_PARAM;
@@ -550,17 +557,18 @@ CAResult_t CAInitiateHandshake(const CAEndpoint_t *endpoint)
     {
         OIC_LOG_V(ERROR, TAG, "Failed to CAinitiateSslHandshake : %d", res);
     }
-
+#else
+        OIC_LOG(ERROR, TAG, "Method not supported");
+#endif
     OIC_LOG_V(DEBUG, TAG, "OUT : CAInitiateHandshake");
-
     return res;
 }
 
 CAResult_t CAcloseSslSession(const CAEndpoint_t *endpoint)
 {
     OIC_LOG_V(DEBUG, TAG, "IN : CAcloseSslSession");
-    CAResult_t res = CA_STATUS_OK;
-
+    CAResult_t res = CA_STATUS_FAILED;
+#if defined (__WITH_DTLS__) || defined(__WITH_TLS__)
     if (!endpoint)
     {
         return CA_STATUS_INVALID_PARAM;
@@ -571,14 +579,13 @@ CAResult_t CAcloseSslSession(const CAEndpoint_t *endpoint)
     {
         OIC_LOG_V(ERROR, TAG, "Failed to CAsslClose : %d", res);
     }
-
+#else
+    OIC_LOG(ERROR, TAG, "Method not supported");
+#endif
     OIC_LOG_V(DEBUG, TAG, "OUT : CAcloseSslSession");
-
     return res;
 }
 
-#endif /* __WITH_DTLS__ */
-
 #ifdef TCP_ADAPTER
 void CARegisterKeepAliveHandler(CAKeepAliveConnectionCallback ConnHandler)
 {