+static OCStackResult configSelfOwnership(void)
+{
+ OCStackResult res = OC_STACK_ERROR;
+ OIC_LOG(INFO, TAG, "Configures SVR DB as self-ownership.");
+
+ res = OCConfigSelfOwnership();
+
+ if (OC_STACK_OK != res)
+ {
+ OIC_LOG(ERROR, TAG, "OCConfigSelfOwnership API error. Please check SVR DB");
+ }
+ else
+ {
+ OIC_LOG(INFO, TAG, "Success to configures SVR DB as self-ownership");
+ }
+
+ return res;
+}
+
+static void configSecureStorageHwEmulation()
+{
+ OIC_LOG(INFO, TAG, "Enable Secure Storage HW Emulation");
+
+ printf(" Enter Own Certificate File Path[~4095]: ");
+ char cert_filepath[4096] = {0,};
+ for(int ret=0; 1!=ret; )
+ {
+ ret = scanf("%255s", cert_filepath);
+ for( ; 0x20<=getchar(); ); // for removing overflow garbages
+ // '0x20<=code' is character region
+ }
+
+ printf(" Enter Private Key File Path[~4095]: ");
+ char key_filepath[4096] = {0,};
+ for(int ret=0; 1!=ret; )
+ {
+ ret = scanf("%255s", key_filepath);
+ for( ; 0x20<=getchar(); ); // for removing overflow garbages
+ // '0x20<=code' is character region
+ }
+
+ printf(" Enter Password for Key Password[~31][Press (Enter) to not set]: ");
+ char pwd[32] = {0,};
+ for(int i=0; i < 31; i++)
+ {
+ pwd[i] = (char)getchar();
+ if (0x20 <= pwd[i])
+ {
+ pwd[i--] = '\0';
+ continue;
+ }
+ if (0x0A == pwd[i])
+ {
+ pwd[i] = '\0';
+ break;
+ }
+ }
+
+ if (0 != SSemulSetCertkeyFilepath(cert_filepath, key_filepath, pwd))
+ {
+ OIC_LOG(ERROR, TAG, " Fail to set cert/key file path");
+ return;
+ }
+
+ if (0 != SetHwPkixCallbacks(HWGetKeyContext,
+ HWFreeKeyContext,
+ HWGetOwnCertificateChain,
+ HWSetupPkContext))
+ {
+ OIC_LOG(ERROR, TAG, " Fail to regist HW Pkix Callbacks");
+ return;
+ }
+ OIC_LOG(INFO, TAG, " Success to regist HW Pkix Callbacks");
+}
+