Merge "Remove unused openssl-devel dependency" into tizen
[platform/upstream/iotivity.git] / resource / csdk / security / src / srmutility.c
index 2bd9bcd..80b836f 100644 (file)
@@ -27,6 +27,7 @@
 #include "oic_string.h"
 #include "base64.h"
 #include "doxmresource.h"
+#include "credresource.h"
 #include "pstatresource.h"
 #include "cacommon.h"
 #include "casecurityinterface.h"
@@ -141,6 +142,8 @@ const char* GetOxmString(OicSecOxm_t oxmType)
             return OXM_RANDOM_DEVICE_PIN;
         case OIC_MANUFACTURER_CERTIFICATE:
             return OXM_MANUFACTURER_CERTIFICATE;
+        case OIC_RAW_PUB_KEY:
+            return OXM_RAW_PUBLIC_KEY;
 #ifdef MULTIPLE_OWNER
         case OIC_PRECONFIG_PIN:
             return OXM_PRECONF_PIN;
@@ -336,6 +339,7 @@ void InvokeOtmEventHandler(const char* addr, uint16_t port,
             //Restore Pkix handler to initial state
             CAregisterPkixInfoHandler(GetPkixInfo);
             CAregisterGetCredentialTypesHandler(InitCipherSuiteList);
+            CAregisterPskCredentialsHandler(GetDtlsPskCredentials);
             break;
         default:
             OIC_LOG_V(ERROR, TAG, "Unknow OTM event : %d", event);
@@ -374,4 +378,47 @@ exit:
     }
     OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
 }
+
+const OicUuid_t THE_NIL_UUID = {.id={0000000000000000}};
+
+/**
+ * Compares two OicUuid_t structs.
+ *
+ * @return true if the two OicUuid_t structs are equal, else false.
+ */
+bool UuidCmp(const OicUuid_t *firstId, const OicUuid_t *secondId)
+{
+    bool ret = false;
+    VERIFY_NON_NULL(TAG, firstId, ERROR);
+    VERIFY_NON_NULL(TAG, secondId, ERROR);
+
+    if (0 == memcmp(firstId, secondId, sizeof(OicUuid_t)))
+    {
+        ret = true;
+    }
+
+exit:
+    OIC_LOG_V(DEBUG, TAG, "%s: returning %s.", __func__, ret?"true":"false");
+    return ret;
+}
+
+/**
+ * Compares OicUuid_t to Nil UUID {.id={0000000000000000}}
+ *
+ * @return true if the OicUuid_t is the Nil UUID.
+ */
+bool IsNilUuid(const OicUuid_t *uuid)
+{
+#if !defined(NDEBUG)
+    char *strUuid = NULL;
+    ConvertUuidToStr(uuid, &strUuid);
+    if (strUuid)
+    {
+        OIC_LOG_V(DEBUG, TAG, "%s: uuid: %s.", __func__, strUuid);
+        OICFree(strUuid);
+    }
+#endif
+    return UuidCmp(uuid, &THE_NIL_UUID);
+}
+
 #endif