X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fsecurity%2Fprovisioning%2Fsrc%2Foxmjustworks.c;h=ce696ff5fbc60aa2eaedef5efc2dacea714107cc;hb=3c093548382bb2542c87a67e6e5fa32552c29cb3;hp=d8518ff624bb83df5eedff5df85f4519910c4307;hpb=200999544972ec5e66997c142244df84d2725df4;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/security/provisioning/src/oxmjustworks.c b/resource/csdk/security/provisioning/src/oxmjustworks.c index d8518ff..ce696ff 100644 --- a/resource/csdk/security/provisioning/src/oxmjustworks.c +++ b/resource/csdk/security/provisioning/src/oxmjustworks.c @@ -26,11 +26,10 @@ #include "cainterface.h" #include "oic_malloc.h" #include "logger.h" -#include "global.h" #include "pmtypes.h" #include "ownershiptransfermanager.h" -#define TAG "OXM_JustWorks" +#define TAG "OIC_OXM_JustWorks" OCStackResult CreateJustWorksSelectOxmPayload(OTMContext_t *otmCtx, uint8_t **payload, size_t *size) { @@ -91,10 +90,10 @@ OCStackResult CreateSecureSessionJustWorksCallback(OTMContext_t* otmCtx) } OIC_LOG(INFO, TAG, "Anonymous cipher suite Enabled."); - caresult = CASelectCipherSuite(TLS_ECDH_anon_WITH_AES_128_CBC_SHA_256); + caresult = CASelectCipherSuite(MBEDTLS_TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256, otmCtx->selectedDeviceInfo->endpoint.adapter); if (CA_STATUS_OK != caresult) { - OIC_LOG_V(ERROR, TAG, "Failed to select TLS_ECDH_anon_WITH_AES_128_CBC_SHA_256"); + OIC_LOG_V(ERROR, TAG, "Failed to select TLS_ECDH_anon_WITH_AES_128_CBC_SHA256"); caresult = CAEnableAnonECDHCipherSuite(false); if (CA_STATUS_OK != caresult) { @@ -106,25 +105,50 @@ OCStackResult CreateSecureSessionJustWorksCallback(OTMContext_t* otmCtx) } return OC_STACK_ERROR; } - OIC_LOG(INFO, TAG, "TLS_ECDH_anon_WITH_AES_128_CBC_SHA_256 cipher suite selected."); + OIC_LOG(INFO, TAG, "TLS_ECDH_anon_WITH_AES_128_CBC_SHA256 cipher suite selected."); OCProvisionDev_t *selDevInfo = otmCtx->selectedDeviceInfo; - CAEndpoint_t *endpoint = (CAEndpoint_t *)OICCalloc(1, sizeof (CAEndpoint_t)); - if(NULL == endpoint) + CAEndpoint_t endpoint; + memcpy(&endpoint, &selDevInfo->endpoint, sizeof(CAEndpoint_t)); + + if(CA_ADAPTER_IP == endpoint.adapter) { - return OC_STACK_NO_MEMORY; + endpoint.port = selDevInfo->securePort; + caresult = CAInitiateHandshake(&endpoint); } - memcpy(endpoint, &selDevInfo->endpoint, sizeof(CAEndpoint_t)); - endpoint->port = selDevInfo->securePort; - - caresult = CAInitiateHandshake(endpoint); - OICFree(endpoint); + else if (CA_ADAPTER_GATT_BTLE == endpoint.adapter) + { + caresult = CAInitiateHandshake(&endpoint); + } +#ifdef __WITH_TLS__ + else + { + endpoint.port = selDevInfo->tcpPort; + caresult = CAinitiateSslHandshake(&endpoint); + } +#endif if (CA_STATUS_OK != caresult) { - OIC_LOG_V(ERROR, TAG, "DTLS handshake failure."); + OIC_LOG_V(ERROR, TAG, "DTLS/TLS handshake failure."); return OC_STACK_ERROR; } OIC_LOG(INFO, TAG, "OUT CreateSecureSessionJustWorksCallback"); return OC_STACK_OK; } + +OCStackResult CreateMVJustWorksSelectOxmPayload(OTMContext_t *otmCtx, uint8_t **cborPayload, + size_t *cborSize) +{ + if (!otmCtx || !otmCtx->selectedDeviceInfo || !cborPayload || *cborPayload || !cborSize) + { + return OC_STACK_INVALID_PARAM; + } + + otmCtx->selectedDeviceInfo->doxm->oxmSel = OIC_MV_JUST_WORKS; + *cborPayload = NULL; + *cborSize = 0; + + return DoxmToCBORPayload(otmCtx->selectedDeviceInfo->doxm, cborPayload, cborSize, true); +} +