Commit 5e353806 authored by Dan Mihai's avatar Dan Mihai

Don't call CA API from sample app.

Add OC API wrapper for CASelectCipherSuite.

Change-Id: I473847399eeeca86efc3679848280c4c4419b194
Signed-off-by: default avatarDan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/19023Reviewed-by: default avatarKevin Kane <kkane@microsoft.com>
Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
parent 82a06ca2
......@@ -559,7 +559,7 @@ static void *userRequests(void *data)
readInteger(&tmp, "Select Cipher Suite", "0 - ECDSA, other - RSA");
uint16_t cipher = tmp? MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256:
MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8;
if (CA_STATUS_OK != CASelectCipherSuite(cipher, CA_ADAPTER_TCP))
if (OC_STACK_OK != OCSelectCipherSuite(cipher, OC_ADAPTER_TCP))
{
OIC_LOG(ERROR, TAG, "CASelectCipherSuite returned an error");
}
......
......@@ -875,10 +875,30 @@ OCPersistentStorage *OCGetPersistentStorageHandler();
* @param[in] ifindex interface index.
* @param[out] zoneId pointer of zoneId string, caller should free
* zoneId using OICFree() when it returned CA_STATUS_OK.
* @return Returns ::OC_STACK_OK if success.
* @return Returns ::OC_STACK_OK if successful.
*/
OCStackResult OCGetLinkLocalZoneId(uint32_t ifindex, char **zoneId);
/**
* Select the cipher suite for dtls handshake.
*
* @param[in] cipher cipher suite (Note : Make sure endianness).
* TLS_RSA_WITH_AES_256_CBC_SHA256 0x3D
* TLS_RSA_WITH_AES_128_GCM_SHA256 0x009C
* TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 0xC02B
* TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 0xC0AE
* TLS_ECDHE_ECDSA_WITH_AES_128_CCM 0xC0AC
* TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 0xC023
* TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 0xC024
* TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 0xC02C
* TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 0xC037
* TLS_ECDH_anon_WITH_AES_128_CBC_SHA 0xC018
* @param[in] adapterType transport adapter (TCP/IP/BLE)
*
* @return Returns ::OC_STACK_OK if successful.
*/
OCStackResult OCSelectCipherSuite(uint16_t cipher, OCTransportAdapter adapterType);
#ifdef __cplusplus
}
#endif // __cplusplus
......
......@@ -2,7 +2,9 @@ LIBRARY octbstack
EXPORTS
; Windows octbstack.dll exports that are required for products.
; Windows octbstack.dll exports that are available regardless of the
; SCons command line parameters used to build IoTivity.
calcDimTotal
CloneOCStringLL
......@@ -126,6 +128,7 @@ OCResourcePayloadAddNewEndpoint
OCResourcePayloadAddStringLL
OCSecurityPayloadCreate
OCSecurityPayloadDestroy
OCSelectCipherSuite
OCSetDefaultDeviceEntityHandler
OCSetDeviceId
OCSetDeviceInfo
......
......@@ -5984,3 +5984,27 @@ OCStackResult OCGetLinkLocalZoneId(uint32_t ifindex, char **zoneId)
return CAResultToOCResult(CAGetLinkLocalZoneId(ifindex, zoneId));
}
#endif
OCStackResult OCSelectCipherSuite(uint16_t cipher, OCTransportAdapter adapterType)
{
// OCTransportAdapter and CATransportAdapter_t are using the same bits for each transport.
OC_STATIC_ASSERT(OC_ADAPTER_IP == CA_ADAPTER_IP, "OC/CA bit mismatch");
OC_STATIC_ASSERT(OC_ADAPTER_GATT_BTLE == CA_ADAPTER_GATT_BTLE, "OC/CA bit mismatch");
OC_STATIC_ASSERT(OC_ADAPTER_RFCOMM_BTEDR == CA_ADAPTER_RFCOMM_BTEDR, "OC/CA bit mismatch");
OC_STATIC_ASSERT(OC_ADAPTER_TCP == CA_ADAPTER_TCP, "OC/CA bit mismatch");
OC_STATIC_ASSERT(OC_ADAPTER_NFC == CA_ADAPTER_NFC, "OC/CA bit mismatch");
#ifdef RA_ADAPTER
OC_STATIC_ASSERT(OC_ADAPTER_REMOTE_ACCESS == CA_ADAPTER_REMOTE_ACCESS, "OC/CA bit mismatch");
#define ALL_OC_ADAPTER_TYPES (OC_ADAPTER_IP | OC_ADAPTER_GATT_BTLE | OC_ADAPTER_RFCOMM_BTEDR |\
OC_ADAPTER_TCP | OC_ADAPTER_NFC | OC_ADAPTER_REMOTE_ACCESS)
#else
#define ALL_OC_ADAPTER_TYPES (OC_ADAPTER_IP | OC_ADAPTER_GATT_BTLE | OC_ADAPTER_RFCOMM_BTEDR |\
OC_ADAPTER_TCP | OC_ADAPTER_NFC)
#endif
assert((adapterType & ~ALL_OC_ADAPTER_TYPES) == 0);
return CAResultToOCResult(CASelectCipherSuite(cipher, (CATransportAdapter_t)adapterType));
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment