ODE API negative tests: internal encryption
[platform/core/test/security-tests.git] / src / ode / ode-tests-common.cpp
index e3b314d..651ded7 100644 (file)
  *  @brief  Tests for the ODE API
  */
 
+#include <iostream>
+#include <string>
+
 #include <dpl/log/log.h>
+
 #include <ode/keys.h>
+#include <ode/internal-encryption.h>
 #include "ode-tests-common.h"
 
 #define ERRORDESCRIBE(name) case name: return #name
@@ -42,6 +47,8 @@ const char* ODEErrorToString(int error) {
 
 #undef ERRORDESCRIBE
 
+// helper classes
+
 HelperKeys::HelperKeys(const char* device, const char* password, bool initialize) {
     dev = device;
     pass = password;
@@ -59,4 +66,20 @@ HelperKeys::HelperKeys(const char* device, const char* password, bool initialize
 HelperKeys::~HelperKeys() {
     ode_key_remove_master_key(dev);
     ode_key_remove(dev, pass);
-};
+}
+
+HelperInternalEncryption::HelperInternalEncryption(const char* password) {
+    pass = password;
+
+    bool result;
+    assert_positive(ode_internal_encryption_is_password_initialized, &result);
+
+    if (!result) {
+        assert_positive(ode_internal_encryption_init_password, pass);
+    }
+}
+
+HelperInternalEncryption::~HelperInternalEncryption() {
+    ode_internal_encryption_umount();
+    ode_internal_encryption_clean_password(pass);
+}