endif\r
\r
include $(CLEAR_VARS)\r
+ifeq ($(SECURE), 1)\r
+ LOCAL_CFLAGS += -D__WITH_DTLS__\r
+endif\r
OIC_SRC_PATH := ../../../resource\r
LOCAL_MODULE := libca-interface\r
LOCAL_SRC_FILES := JniCaInterface.c\r
LOCAL_CPPFLAGS += -D__WITH_TLS__\r
endif\r
\r
+ifeq ($(SECURED), 1)\r
+ LOCAL_CPPFLAGS += -D__WITH_DTLS__\r
+endif\r
+\r
MQ_FLAG = 0\r
ifeq ($(WITH_MQ_PUB), 1)\r
LOCAL_CFLAGS += -DWITH_MQ -DMQ_PUBLISHER\r
CAUtilSetLEScanInterval(intervalTime, workignCount);
}
+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);
+ return ret;
+#else
+ LOGE("Method not supported");
+ return -1;
+#endif // __WITH_DTLS__ || __WITH_TLS__
+}
+
JNIEXPORT void JNICALL Java_org_iotivity_ca_CaInterface_setLeScanIntervalTimeImpl
(JNIEnv *, jclass, jint, jint);
+ /*
+ * Class: org_iotivity_ca_CaInterface
+ * Method: setCipherSuiteImpl
+ * Signature: (Lorg/iotivity/ca/OicCipher;Lorg/iotivity/ca/CATransportAdapter;)I
+ */
+ JNIEXPORT jint JNICALL Java_org_iotivity_ca_CaInterface_setCipherSuiteImpl
+ (JNIEnv *, jclass, jint, jint);
+
#ifdef __cplusplus
}
#endif
}
private static native void setLeScanIntervalTimeImpl(int intervalTime, int workingCount);
+
+
+ public synchronized static int setCipherSuite(OicCipher cipher, OcConnectivityType connType){
+ return CaInterface.setCipherSuiteImpl(cipher.getValue(), connType.getValue());
+ }
+ private static native int setCipherSuiteImpl(int cipher, int adapter);
+
}
--- /dev/null
+/* ****************************************************************\r
+ *\r
+ * Copyright 2016 Samsung Electronics All Rights Reserved.\r
+ *\r
+ *\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ ******************************************************************/\r
+\r
+package org.iotivity.ca;\r
+\r
+public enum OicCipher {\r
+ TLS_ECDH_anon_WITH_AES_128_CBC_SHA(0xC018),\r
+ TLS_PSK_WITH_AES_128_CCM_8(0xC0A8),\r
+ TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8(0xC0AE),\r
+ TLS_RSA_WITH_AES_256_CBC_SHA(0x35);\r
+\r
+ private int cipher;\r
+\r
+ private OicCipher(int cipher) {\r
+ this.cipher = cipher;\r
+ }\r
+\r
+ public int getValue(){\r
+ return cipher;\r
+ }\r
+}\r
import java.util.EnumSet;
import java.util.List;
+import org.iotivity.ca.OicCipher;
+import org.iotivity.base.OcConnectivityType;
+import org.iotivity.ca.CaInterface;
+
+
public class ProvisioningClient extends Activity implements
OcSecureResource.DoOwnershipTransferListener, OcSecureResource.ProvisionPairwiseDevicesListener {
}
initOICStack();
saveCertChain();
+ int ret = CaInterface.setCipherSuite(OicCipher.TLS_ECDH_anon_WITH_AES_128_CBC_SHA,
+ OcConnectivityType.CT_ADAPTER_IP);
+ Log.e(TAG,"CaInterface.setCipherSuite returned = "+ret);
}
/**
#if defined (__WITH_DTLS__) || defined(__WITH_TLS__)
CAResult_t CASelectCipherSuite(const uint16_t cipher, CATransportAdapter_t adapter)
{
- OIC_LOG_V(DEBUG, TAG, "CASelectCipherSuite");
+ OIC_LOG_V(DEBUG, TAG, "IN CASelectCipherSuite");
+ OIC_LOG_V(DEBUG, TAG, "cipher : %d , CATransportAdapter : %d",cipher, adapter);
if(CA_ADAPTER_IP == adapter)
{
if (CA_STATUS_OK != CADtlsSelectCipherSuite(cipher))
{
+ OIC_LOG_V(DEBUG, TAG, "CADtlsSelectCipherSuite failed");
return CA_STATUS_FAILED;
}
}
{
if (CA_STATUS_OK != CAsetTlsCipherSuite(cipher))
{
+ OIC_LOG_V(DEBUG, TAG, "CAsetTlsCipherSuite failed");
return CA_STATUS_FAILED;
}
}
#endif
+ OIC_LOG_V(DEBUG, TAG, "CASelectCipherSuite OK");
return CA_STATUS_OK;
}