Commit 1f1bf9e0 authored by Aleksey's avatar Aleksey Committed by Nathan Heldt-Sheller

[IOT-3293] Proper PSK hint for random pin

Use device uuid as psk hint for the random pin
otm TLS session

Change-Id: I02daa8b7cacdac46c6ce5b9d59f6d0932a2b5e15
Signed-off-by: Aleksey's avatarAleksey Volkov <a.volkov@samsung.com>
parent 4df2dc79
......@@ -451,21 +451,25 @@ int32_t GetDtlsPskForRandomPinOxm( CADtlsPskCredType_t type,
case CA_DTLS_PSK_HINT:
case CA_DTLS_PSK_IDENTITY:
{
/**
* The server will provide PSK hint to identify PSK according to RFC 4589 and RFC 4279.
*
* At this point, The server generate random hint and
* provide it to client through server key exchange message.
*/
if (!OCGetRandomBytes(result, result_length))
const OicSecDoxm_t* doxm = GetDoxmResourceData();
if (NULL == doxm)
{
OIC_LOG(ERROR, TAG, "Failed to generate random PSK hint");
break;
OIC_LOG(ERROR, TAG, "Cant get own uuid");
return ret;
}
ret = (int32_t)result_length;
if (sizeof(doxm->deviceID.id) > result_length)
{
OIC_LOG(ERROR, TAG, "Identity buffer is too small");
return ret;
}
memcpy(result, doxm->deviceID.id, sizeof(doxm->deviceID.id));
ret = sizeof(doxm->deviceID.id);
OIC_LOG(DEBUG, TAG, "PSK HINT : ");
OIC_LOG_BUFFER(DEBUG, TAG, result, result_length);
OIC_LOG_BUFFER(DEBUG, TAG, result, ret);
}
break;
......
......@@ -232,7 +232,7 @@ TEST_F(OXMPIN, GetDtlsPskForRandomPinOxm)
ASSERT_NE(nullptr, result);
EXPECT_EQ(GetDtlsPskForRandomPinOxm(CA_DTLS_PSK_KEY, NULL, 0, result, len), OWNER_PSK_LENGTH_128);
EXPECT_GT(GetDtlsPskForRandomPinOxm(CA_DTLS_PSK_HINT, NULL, 0, result, len), 0);
EXPECT_GT(GetDtlsPskForRandomPinOxm(CA_DTLS_PSK_HINT, NULL, 0, result, len), sizeof(OicUuid_t));
EXPECT_EQ(GetDtlsPskForRandomPinOxm((CADtlsPskCredType_t)3, NULL, 0, result, len), -1);
OICFree(result);
......
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