From 367287a4c564d9d3985b939271f9f517b6bea0e1 Mon Sep 17 00:00:00 2001 From: Oleksii Beketov Date: Thu, 12 Oct 2017 14:19:55 +0300 Subject: [PATCH] [IOT-2709] MOT fix sampleserver_randompin and sampleserver_preconfpin MOT fix Change-Id: Iadb02e4370604c33b8070ea45f2d8a42ecfafae1 https://jira.iotivity.org/browse/IOT-2709 Signed-off-by: Oleksii Beketov --- .../csdk/security/provisioning/src/oxmpreconfpin.c | 22 ++++++++++++++++++ .../csdk/security/provisioning/src/oxmrandompin.c | 26 ++++++++++++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/resource/csdk/security/provisioning/src/oxmpreconfpin.c b/resource/csdk/security/provisioning/src/oxmpreconfpin.c index f011fa8..06eca4e 100644 --- a/resource/csdk/security/provisioning/src/oxmpreconfpin.c +++ b/resource/csdk/security/provisioning/src/oxmpreconfpin.c @@ -203,6 +203,28 @@ OCStackResult CreateSecureSessionPreconfigPinCallback(OTMContext_t* otmCtx) } OIC_LOG(INFO, TAG, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 cipher suite selected."); + CAEndpoint_t endpoint; + OCProvisionDev_t* selDevInfo = otmCtx->selectedDeviceInfo; + CopyDevAddrToEndpoint(&selDevInfo->endpoint, &endpoint); + + if (CA_ADAPTER_IP == endpoint.adapter) + { + endpoint.port = selDevInfo->securePort; + } +#ifdef WITH_TCP + else if (CA_ADAPTER_TCP == endpoint.adapter) + { + endpoint.port = selDevInfo->tcpSecurePort; + } +#endif + + caresult = CAInitiateHandshake(&endpoint); + if (CA_STATUS_OK != caresult) + { + OIC_LOG_V(ERROR, TAG, "DTLS handshake failure."); + return OC_STACK_ERROR; + } + OIC_LOG(INFO, TAG, "OUT CreateSecureSessionPreconfigPinCallback"); return OC_STACK_OK; diff --git a/resource/csdk/security/provisioning/src/oxmrandompin.c b/resource/csdk/security/provisioning/src/oxmrandompin.c index d969447..d43606e 100644 --- a/resource/csdk/security/provisioning/src/oxmrandompin.c +++ b/resource/csdk/security/provisioning/src/oxmrandompin.c @@ -132,7 +132,7 @@ OCStackResult InputPinCodeCallback(OTMContext_t *otmCtx) OCStackResult CreateSecureSessionRandomPinCallback(OTMContext_t* otmCtx) { - OIC_LOG(INFO, TAG, "IN CreateSecureSessionRandomPinCallbak"); + OIC_LOG(INFO, TAG, "IN CreateSecureSessionRandomPinCallback"); if (!otmCtx || !otmCtx->selectedDeviceInfo) { @@ -155,7 +155,29 @@ OCStackResult CreateSecureSessionRandomPinCallback(OTMContext_t* otmCtx) } OIC_LOG(INFO, TAG, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 cipher suite selected."); - OIC_LOG(INFO, TAG, "OUT CreateSecureSessionRandomPinCallbak"); + CAEndpoint_t endpoint; + OCProvisionDev_t* selDevInfo = otmCtx->selectedDeviceInfo; + CopyDevAddrToEndpoint(&selDevInfo->endpoint, &endpoint); + + if (CA_ADAPTER_IP == endpoint.adapter) + { + endpoint.port = selDevInfo->securePort; + } +#ifdef WITH_TCP + else if (CA_ADAPTER_TCP == endpoint.adapter) + { + endpoint.port = selDevInfo->tcpSecurePort; + } +#endif + + caresult = CAInitiateHandshake(&endpoint); + if (CA_STATUS_OK != caresult) + { + OIC_LOG_V(ERROR, TAG, "DTLS handshake failure."); + return OC_STACK_ERROR; + } + + OIC_LOG(INFO, TAG, "OUT CreateSecureSessionRandomPinCallback"); return OC_STACK_OK; } -- 2.7.4