[IOT-2726] /cred fix for CT1.7.8.11 65/22665/4
authorAleksey Volkov <a.volkov@samsung.com>
Tue, 3 Oct 2017 10:35:25 +0000 (13:35 +0300)
committerNathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
Wed, 4 Oct 2017 23:37:01 +0000 (23:37 +0000)
This patch fixes `4.00 Bad Request` error on
/oic/sec/cred CON UPDATE request in CT1.7.8.11

This adds an additional check of the incoming credential
subjectid for OwnerPSK generation. Before, credresource
tried to generate owner psk for any subjectid in case if
doxm->owner value already saved, but doxm->owned flag
not yet set in true.
This led to an error at the POST handler return.

Change-Id: If2b683ee417bb058f954734ff0c1b64e145c9a6b
Signed-off-by: Aleksey Volkov <a.volkov@samsung.com>
resource/csdk/security/src/credresource.c

index fe24c13..f64eaf7 100644 (file)
@@ -2153,7 +2153,11 @@ static OCEntityHandlerResult HandleNewCredential(OCEntityHandlerRequest *ehReque
 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
     OicUuid_t emptyUuid = {.id={0}};
     const OicSecDoxm_t *doxm = GetDoxmResourceData();
-    if(NO_SECURITY_MODE != cred->credType && doxm && false == doxm->owned && memcmp(&(doxm->owner), &emptyUuid, sizeof(OicUuid_t)) != 0)
+    if( NO_SECURITY_MODE != cred->credType 
+        && doxm
+        && false == doxm->owned
+        && memcmp(&(doxm->owner), &emptyUuid, sizeof(OicUuid_t)) != 0
+        && memcmp(&(doxm->owner), &cred->subject, sizeof(OicUuid_t)) == 0 )
     {
         //in case of owner PSK
         switch(cred->credType)