Add APIs to verify password 41/111641/3
authorSungbae Yoo <sungbae.yoo@samsung.com>
Mon, 23 Jan 2017 07:25:27 +0000 (16:25 +0900)
committerSeok Hong <seok85.hong@samsung.com>
Tue, 24 Jan 2017 07:56:58 +0000 (16:56 +0900)
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Change-Id: Ib9486d8cff39d72bce8bea3792742c79d84ff842

lib/external-encryption.cpp
lib/internal-encryption.cpp
lib/ode/external-encryption.cpp
lib/ode/external-encryption.h
lib/ode/internal-encryption.cpp
lib/ode/internal-encryption.h
rmi/external-encryption.h
rmi/internal-encryption.h
server/external-encryption.cpp
server/internal-encryption.cpp

index ed096c3..780f54e 100644 (file)
@@ -62,6 +62,16 @@ int ExternalEncryption::decrypt(const std::string& password)
        }
 }
 
+int ExternalEncryption::verifyPassword(const std::string& password)
+{
+       try {
+               return context->methodCall<int>("ExternalEncryption::verifyPassword",
+                                                                               password);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
+}
+
 int ExternalEncryption::changePassword(const std::string& oldPassword,
                                                                        const std::string& newPassword)
 {
index a6e7586..48ad20c 100644 (file)
@@ -62,6 +62,16 @@ int InternalEncryption::decrypt(const std::string& password)
        }
 }
 
+int InternalEncryption::verifyPassword(const std::string& password)
+{
+       try {
+               return context->methodCall<int>("InternalEncryption::verifyPassword",
+                                                                               password);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
+}
+
 int InternalEncryption::changePassword(const std::string& oldPassword,
                                                                        const std::string& newPassword)
 {
index 4ff6e3d..5c0070e 100644 (file)
@@ -64,6 +64,22 @@ int ode_external_encryption_decrypt(const char* password)
        return external.decrypt(password);
 }
 
+int ode_external_encryption_verify_password(const char *password, int *result)
+{
+       RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(result, ODE_ERROR_INVALID_PARAMETER);
+
+       ODEContext client;
+       RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
+       ExternalEncryption external = client.createInterface<ExternalEncryption>();
+       int ret = external.verifyPassword(password);
+
+       RET_ON_FAILURE(ret < 0, ODE_ERROR_INVALID_PARAMETER);
+
+       *result = ret;
+       return ODE_ERROR_NONE;
+}
+
 int ode_external_encryption_change_password(const char* old_password,
                                                                                        const char* new_password)
 {
index 5fc4b45..e1bd2a6 100644 (file)
@@ -169,6 +169,22 @@ typedef enum {
 ODE_API int ode_external_encryption_get_supported_options(unsigned int* options);
 
 /**
+ * @brief       Verify if given password is external encryption password.
+ * @details     Administrator can use this API to find if a password is used
+                by external encryption
+ * @since_tizen 3.0
+ * @param[out]  password The password to be verified
+ * @return      #ODE_ERROR_NONE on success, otherwise a negative value
+ * @retval      #ODE_ERROR_NONE Successful
+ * @retval      #ODE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #ODE_ERROR_TIMED_OUT Time out
+ * @retval      #ODE_ERROR_PERMISSION_DENIED The application does not have
+ *              the privilege to call this API
+ * @see         ode_external_encryption_encrypt()
+ */
+ODE_API int ode_external_encryption_verify_password(const char *password);
+
+/**
  * @}
  */
 
index 8ada3ee..7f227cd 100644 (file)
@@ -64,6 +64,22 @@ int ode_internal_encryption_decrypt(const char* password)
        return internal.decrypt(password);
 }
 
+int ode_internal_encryption_verify_password(const char *password, int *result)
+{
+    RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(result, ODE_ERROR_INVALID_PARAMETER);
+
+    ODEContext client;
+    RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
+       InternalEncryption internal = client.createInterface<InternalEncryption>();
+       int ret = internal.verifyPassword(password);
+
+       RET_ON_FAILURE(ret < 0, ODE_ERROR_INVALID_PARAMETER);
+
+       *result = ret;
+    return ODE_ERROR_NONE;
+}
+
 int ode_internal_encryption_change_password(const char* old_password,
                                                                                        const char* new_password)
 {
index cb0742e..f905034 100644 (file)
@@ -166,6 +166,22 @@ typedef enum {
  */
 ODE_API int ode_internal_encryption_get_supported_options(unsigned int* options);
 
+/**
+ * @brief       Verify if given password is internal encryption password.
+ * @details     Administrator can use this API to find if a password is used
+                by internal encryption
+ * @since_tizen 3.0
+ * @param[out]  password The password to be verified
+ * @return      #ODE_ERROR_NONE on success, otherwise a negative value
+ * @retval      #ODE_ERROR_NONE Successful
+ * @retval      #ODE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #ODE_ERROR_TIMED_OUT Time out
+ * @retval      #ODE_ERROR_PERMISSION_DENIED The application does not have
+ *              the privilege to call this API
+ * @see         ode_internal_encryption_encrypt()
+ */
+ODE_API int ode_internal_encryption_verify_password(const char *password);
+
 /*
  * @}
  */
index dc6fc63..c2cc199 100644 (file)
@@ -39,6 +39,7 @@ public:
        int encrypt(const std::string& password, unsigned int options);
        int decrypt(const std::string& password);
 
+       int verifyPassword(const std::string& password);
        int changePassword(const std::string& oldPW, const std::string& newPW);
 
        enum State {
index ddbe6a1..a915a16 100644 (file)
@@ -36,6 +36,7 @@ public:
        int encrypt(const std::string& password, unsigned int options);
        int decrypt(const std::string& password);
 
+       int verifyPassword(const std::string& password);
        int changePassword(const std::string& oldPW, const std::string& newPW);
 
        enum State {
index c821c5d..7ed8206 100644 (file)
@@ -243,6 +243,17 @@ int ExternalEncryption::decrypt(const std::string &password)
        return 0;
 }
 
+int ExternalEncryption::verifyPassword(const std::string& password)
+{
+    KeyManager::data data(password.begin(), password.end());
+    KeyManager keyManager(engine.getKeyMeta());
+
+    if (!keyManager.verifyPassword(data)) {
+        return 1;
+    }
+    return 0;
+}
+
 int ExternalEncryption::changePassword(const std::string &oldPassword,
                                                                           const std::string &newPassword)
 {
index 9b5d416..47c6ae1 100644 (file)
@@ -244,6 +244,17 @@ int InternalEncryption::decrypt(const std::string& password)
        return 0;
 }
 
+int InternalEncryption::verifyPassword(const std::string& password)
+{
+       KeyManager::data data(password.begin(), password.end());
+       KeyManager keyManager(engine.getKeyMeta());
+
+       if (keyManager.verifyPassword(data)) {
+               return 1;
+       }
+       return 0;
+}
+
 int InternalEncryption::changePassword(const std::string& oldPassword,
                                                                                const std::string& newPassword)
 {