Exposing CASelectCipherSuite to OC layer
authorDmitriy Zhuravlev <d.zhuravlev@samsung.com>
Thu, 8 Sep 2016 09:22:27 +0000 (12:22 +0300)
committerRandeep Singh <randeep.s@samsung.com>
Wed, 28 Sep 2016 03:43:41 +0000 (03:43 +0000)
Select the cipher suite for TLS/DTLS handshake

Change-Id: Idb346fc2c5eb3bfa7f624562ef72a02c37db821b
Signed-off-by: Dmitriy Zhuravlev <d.zhuravlev@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11567
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
(cherry picked from commit 4536668a99c836329753e75a17c479ff81e7d4a8)
Reviewed-on: https://gerrit.iotivity.org/gerrit/12031

resource/include/CAManager.h
resource/src/CAManager.cpp

index d10437d0a11159424d613196580781ab901ea5fc..3a19a07170e2257884ecce127f274a1b0e0b6fe5 100644 (file)
@@ -67,6 +67,20 @@ namespace OC
         * @return Returns currently assigned port number.
         */
         uint16_t getAssignedPortNumber(OCTransportAdapter adapter, OCTransportFlags flag);
+
+#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
+        /**
+         * Select the cipher suite for TLS/DTLS handshake.
+         * @param cipher  cipher suite (Note : Make sure endianness).
+         *                    0x35   : TLS_RSA_WITH_AES_256_CBC_SHA
+         *                    0xC018 : TLS_ECDH_anon_WITH_AES_128_CBC_SHA
+         *                    0xC037 : TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256
+         *                    0xC0AE : TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8
+         * @param adapter transport adapter type.
+         * @return Returns ::OC_STACK_OK if success.
+         */
+        OCStackResult setCipherSuite(const uint16_t cipher, OCTransportAdapter adapter);
+#endif // defined(__WITH_DTLS__) || defined(__WITH_TLS__)
     }
 }
 
index 384b6ec98c12660d3c780e0c6cf6c5d76f3a2f84..d32a7a0b428a70d0ab6a2ab04926363bff3a7ac4 100644 (file)
@@ -28,6 +28,7 @@
 #include "OCApi.h"
 #include "CAManager.h"
 #include "cautilinterface.h"
+#include "casecurityinterface.h"
 
 using namespace OC;
 
@@ -115,3 +116,10 @@ uint16_t CAManager::getAssignedPortNumber(OCTransportAdapter adapter, OCTranspor
 {
     return CAGetAssignedPortNumber((CATransportAdapter_t) adapter, (CATransportFlags_t) flag);
 }
+#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
+OCStackResult CAManager::setCipherSuite(const uint16_t cipher, OCTransportAdapter adapter)
+{
+    CAResult_t ret = CASelectCipherSuite(cipher, (CATransportAdapter_t) adapter);
+    return convertCAResultToOCResult(ret);
+}
+#endif // defined(__WITH_DTLS__) || defined(__WITH_TLS__)