+
+OCStackResult OCGetDeviceOwnedState(bool *isOwned)
+{
+ bool isDeviceOwned = true;
+ OCStackResult ret = OC_STACK_ERROR;
+
+ ret = GetDoxmIsOwned(&isDeviceOwned);
+ if (OC_STACK_OK == ret)
+ {
+ *isOwned = isDeviceOwned;
+ }
+ else
+ {
+ OIC_LOG(ERROR, TAG, "Device Owned State Get error");
+ }
+ return ret;
+}
+
+void OCClearCallBackList()
+{
+ DeleteClientCBList();
+}
+
+void OCClearObserverlist()
+{
+ DeleteObserverList();
+}
+
+int OCEncrypt(const unsigned char *pt, size_t pt_len,
+ unsigned char **ct, size_t *ct_len)
+{
+#ifndef __SECURE_PSI__
+ OIC_LOG_V(DEBUG, TAG, "Not Supported : %s", __func__);
+ return 0;
+#else
+ OIC_LOG_V(DEBUG, TAG, "%s", __func__);
+
+ return psiEncrypt(pt, pt_len, ct, ct_len);
+#endif // __SECURE_PSI__
+}
+
+int OCDecrypt(const unsigned char *ct, size_t ct_len,
+ unsigned char **pt, size_t *pt_len)
+{
+#ifndef __SECURE_PSI__
+ OIC_LOG_V(DEBUG, TAG, "Not Supported : %s", __func__);
+ return 0;
+#else
+ OIC_LOG_V(DEBUG, TAG, "%s", __func__);
+
+ return psiDecrypt(ct, ct_len, pt, pt_len);
+#endif // __SECURE_PSI__
+}
+
+OCStackResult OCSetKey(const unsigned char* key)
+{
+#ifndef __SECURE_PSI__
+ OIC_LOG_V(DEBUG, TAG, "Not Supported : %s", __func__);
+ return OC_STACK_OK;
+#else
+ OIC_LOG_V(DEBUG, TAG, "%s", __func__);
+
+ return psiSetKey(key);
+#endif // __SECURE_PSI__
+}
+
+OCStackResult OCGetKey(unsigned char* key)
+{
+#ifndef __SECURE_PSI__
+ OIC_LOG_V(DEBUG, TAG, "Not Supported : %s", __func__);
+ return OC_STACK_OK;
+#else
+ OIC_LOG_V(DEBUG, TAG, "%s", __func__);
+
+ return psiGetKey(key);
+#endif // __SECURE_PSI__
+}
+
+OCStackResult OCSetSecurePSI(const unsigned char *key, const OCPersistentStorage *psPlain,
+ const OCPersistentStorage *psEnc, const OCPersistentStorage *psRescue)
+{
+#ifndef __SECURE_PSI__
+ OIC_LOG_V(DEBUG, TAG, "Not Supported : %s", __func__);
+ return OC_STACK_OK;
+#else
+ OIC_LOG_V(DEBUG, TAG, "%s", __func__);
+
+ return setSecurePSI(key, psPlain, psEnc, psRescue);
+#endif // __SECURE_PSI__
+}
+
+#if defined(__WITH_DTLS__) || defined (__WITH_TLS__)
+static void OtmEventHandler(const char *addr, uint16_t port, const char *uuid, int event)
+{
+ if (g_otmEventHandler.cb)
+ {
+ g_otmEventHandler.cb(g_otmEventHandler.ctx, addr, port, uuid, event);
+ }
+}
+
+/* TODO Work-around
+ * It is already declared in srmutility.h.
+ * We can't include the header file, because of "redefined VERIFY_NON_NULL"
+ */
+typedef void (*OicSecOtmEventHandler_t)(const char* addr, uint16_t port,
+ const char* uuid, int event);
+void SetOtmEventHandler(OicSecOtmEventHandler_t otmEventHandler);
+#endif
+
+OCStackResult OCSetOtmEventHandler(void *ctx, OCOtmEventHandler cb)
+{
+#if defined(__WITH_DTLS__) || defined (__WITH_TLS__)
+ OIC_LOG_V(DEBUG, TAG, "%s", __func__);
+
+ g_otmEventHandler.cb = cb;
+ g_otmEventHandler.ctx = ctx;
+
+ if (g_otmEventHandler.cb)
+ {
+ OIC_LOG(DEBUG, TAG, "SET OCOtmEventHandler");
+ SetOtmEventHandler(OtmEventHandler);
+ }
+ else
+ {
+ OIC_LOG(DEBUG, TAG, "UNSET OCOtmEventHandler");
+ SetOtmEventHandler(NULL);
+ }
+#else
+ OIC_LOG_V(DEBUG, TAG, "Not Supported : %s", __func__);
+ OC_UNUSED(ctx);
+ OC_UNUSED(cb);
+#endif
+ return OC_STACK_OK;
+}