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 ed096c3368d6df4d9c975b3ea4b49e0ace56f1aa..780f54e934a8d26be78bc0bb8e9db7982e7a1627 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 a6e7586f784a2fb8543ba6a98726239e114257c5..48ad20cf4d86cb65c159668c6b22d086992ab6b2 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 4ff6e3d69dcecf704951259c311fecd758be4568..5c0070ec4ee0dca0ac6523a1b760cf9447979ba3 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 5fc4b453f83e7ff69f74c4b9b60eb9d8fa72ed83..e1bd2a6b84d87944b81873f33ebee5e637ae0ea4 100644 (file)
@@ -168,6 +168,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 8ada3ee8efd1999938f415d045584b7210054e65..7f227cdfe7591b584514898f37e0eb473e9d5849 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 cb0742e6351079ae83a2039a8cae491323104866..f905034b583b68923548f0485b57d7bfca754e72 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 dc6fc6366267f10c7f0790598413d544840083b0..c2cc199c0426a0cad4ae73e05f94ab2d7841a94a 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 ddbe6a119c1e21b711f707c738b25ecee99caec5..a915a16751eff2961c3009efab8d5c643f77f4a3 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 c821c5d31521432d1c9d23b991397ae9512cd0fb..7ed8206f2423def11359dc4019a90dcbfbc35a87 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 9b5d4169379671175baf64b3931cee31294b6d3e..47c6ae1d8e186e15f99e1791d9a4139f5d0d6fd2 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)
 {