Update snapshot(2017-11-23)
[platform/upstream/iotivity.git] / resource / csdk / security / src / pkix_interface.c
index dc807d3..5b1dc61 100644 (file)
@@ -106,6 +106,10 @@ void CheckInvalidDERSignature(uint8_t *crtBuf, size_t *crtBufLen)
         return;
     }
 
+    OIC_LOG_V(INFO, TAG, "Cert Buf Length: %lu", *crtBufLen);
+    OIC_LOG(INFO, TAG, "[Cert Buf] : ");
+    OIC_LOG_BUFFER(INFO, TAG, crtBuf, *crtBufLen);
+
     mbedtls_x509_crt deviceCert;
     int ret = 0;
 
@@ -431,8 +435,13 @@ int SetHwPkixCallbacks(GetHwKeyContext getHwKeyContext,
 {
     OIC_LOG_V(INFO, TAG, "In %s", __func__);
 
-    if (NULL == getHwKeyContext || NULL == freeHwKeyContext
-        || NULL == getOwnCertCb || NULL == setupPkContextCb)
+    if (NULL == getHwKeyContext && NULL == freeHwKeyContext
+        && NULL == getOwnCertCb && NULL == setupPkContextCb)
+    {
+        OIC_LOG(INFO, TAG, "Unregistering callbacks");
+    }
+    else if (NULL == getHwKeyContext || NULL == freeHwKeyContext
+             || NULL == getOwnCertCb || NULL == setupPkContextCb)
     {
         OIC_LOG(ERROR, TAG, "NULL Passed");
         OIC_LOG(ERROR, TAG, "Callback function parameters can not be null");
@@ -444,7 +453,7 @@ int SetHwPkixCallbacks(GetHwKeyContext getHwKeyContext,
     gHwPkixCtx.getOwnCertCb = getOwnCertCb;
     gHwPkixCtx.setupPkContextCb = setupPkContextCb;
 
-    if (gHwPkixCtx.hwKeyCtx)
+    if (gHwPkixCtx.hwKeyCtx && NULL != freeHwKeyContext)
     {
         gHwPkixCtx.freeHwKeyContext(gHwPkixCtx.hwKeyCtx);
     }