}
}
-int ExternalEncryption::isPasswordCreated()
+int ExternalEncryption::isPasswordInitialized()
{
try {
- return context->methodCall<int>("ExternalEncryption::isPasswordCreated");
+ return context->methodCall<int>("ExternalEncryption::isPasswordInitialized");
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExternalEncryption::createPassword(const std::string& password)
+int ExternalEncryption::initPassword(const std::string& password)
{
try {
- return context->methodCall<int>("ExternalEncryption::createPassword",
+ return context->methodCall<int>("ExternalEncryption::initPassword",
password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExternalEncryption::deletePassword(const std::string& password)
+int ExternalEncryption::cleanPassword(const std::string& password)
{
try {
- return context->methodCall<int>("ExternalEncryption::deletePassword",
+ return context->methodCall<int>("ExternalEncryption::cleanPassword",
password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int InternalEncryption::isPasswordCreated()
+int InternalEncryption::isPasswordInitialized()
{
try {
- return context->methodCall<int>("InternalEncryption::isPasswordCreated");
+ return context->methodCall<int>("InternalEncryption::isPasswordInitialized");
} catch (runtime::Exception& e) {
return -1;
}
}
-int InternalEncryption::createPassword(const std::string& password)
+int InternalEncryption::initPassword(const std::string& password)
{
try {
- return context->methodCall<int>("InternalEncryption::createPassword",
+ return context->methodCall<int>("InternalEncryption::initPassword",
password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int InternalEncryption::deletePassword(const std::string& password)
+int InternalEncryption::cleanPassword(const std::string& password)
{
try {
- return context->methodCall<int>("InternalEncryption::deletePassword",
+ return context->methodCall<int>("InternalEncryption::cleanPassword",
password);
} catch (runtime::Exception& e) {
return -1;
return external.decrypt(password);
}
-int ode_external_encryption_is_password_created(bool *result)
+int ode_external_encryption_is_password_initialized(bool* result)
{
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.isPasswordCreated();
+ int ret = external.isPasswordInitialized();
- RET_ON_FAILURE(ret < 0, ODE_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(ret >= 0, ODE_ERROR_INVALID_PARAMETER);
*result = ret;
return ODE_ERROR_NONE;
}
-int ode_external_encryption_create_password(const char *password)
+int ode_external_encryption_init_password(const char* password)
{
RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
ExternalEncryption external = client.createInterface<ExternalEncryption>();
- return external.createPassword(password);
+ return external.initPassword(password);
}
-int ode_external_encryption_delete_password(const char *password)
+int ode_external_encryption_clean_password(const char* password)
{
RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
ExternalEncryption external = client.createInterface<ExternalEncryption>();
- return external.deletePassword(password);
+ return external.cleanPassword(password);
}
int ode_external_encryption_change_password(const char* old_password,
return external.changePassword(old_password, new_password);
}
-int ode_external_encryption_verify_password(const char *password, int *result)
+int ode_external_encryption_verify_password(const char* password, bool* result)
{
RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(result, ODE_ERROR_INVALID_PARAMETER);
ExternalEncryption external = client.createInterface<ExternalEncryption>();
int ret = external.verifyPassword(password);
- RET_ON_FAILURE(ret < 0, ODE_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(ret >= 0, ODE_ERROR_INVALID_PARAMETER);
*result = ret;
return ODE_ERROR_NONE;
ExternalEncryption external = client.createInterface<ExternalEncryption>();
int ret = external.getState();
- RET_ON_FAILURE(ret < 0, ODE_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(ret >= 0, ODE_ERROR_INVALID_PARAMETER);
*state = ret;
return ODE_ERROR_NONE;
* @retval #ODE_ERROR_PERMISSION_DENIED The application does not have
* the privilege to call this API
* @pre The password must match with what is set by
- * ode_external_encryption_create_password().
+ * ode_external_encryption_init_password().
* @see ode_external_encryption_encrypt()
* @see ode_external_encryption_umount()
*/
* @retval #ODE_ERROR_PERMISSION_DENIED The application does not have
* the privilege to call this API
* @pre The password must match with what is set by
- * ode_external_encryption_create_password().
+ * ode_external_encryption_init_password().
* @see ode_external_encryption_encrypt()
*/
ODE_API int ode_external_encryption_decrypt(const char* password);
* @retval #ODE_ERROR_NOT_PERMITTED Operation not permitted
* @retval #ODE_ERROR_PERMISSION_DENIED The application does not have
* the privilege to call this API
- * @see ode_external_encryption_created_password()
- * @see ode_external_encryption_delete_password()
+ * @see ode_external_encryption_init_password()
+ * @see ode_external_encryption_clean_password()
*/
-ODE_API int ode_external_encryption_is_password_created(bool* result);
+ODE_API int ode_external_encryption_is_password_initialized(bool* result);
/**
* @brief Initialize external encryption password to given password
* @retval #ODE_ERROR_PERMISSION_DENIED The application does not have
* the privilege to call this API
* @see ode_external_encryption_change_password()
- * @see ode_external_encryption_delete_password()
+ * @see ode_external_encryption_clean_password()
* @see ode_external_encryption_encrypt()
* @see ode_external_encryption_decrypt()
* @see ode_external_encryption_mount()
*/
-ODE_API int ode_external_encryption_create_password(const char* password);
+ODE_API int ode_external_encryption_init_password(const char* password);
/**
* @brief Remove external encryption password
* @details Administrator can use this API to delete password that was set
- by ode_external_encryption_create_password().
+ by ode_external_encryption_init_password().
* @since_tizen 3.0
* @param[in] password The password to delete
* @return #ODE_ERROR_NONE on success, otherwise a negative value
* @retval #ODE_ERROR_PERMISSION_DENIED The application does not have
* the privilege to call this API
* @pre The password must match with what is set by
- * ode_external_encryption_create_password().
- * @see ode_external_encryption_create_password()
+ * ode_external_encryption_init_password().
+ * @see ode_external_encryption_init_password()
*/
-ODE_API int ode_external_encryption_delete_password(const char* password);
+ODE_API int ode_external_encryption_clean_password(const char* password);
/**
* @brief Change the password for external storage.
* @retval #ODE_ERROR_PERMISSION_DENIED The application does not have
* the privilege to call this API
* @pre The password must match with what is set by
- * ode_external_encryption_create_password().
+ * ode_external_encryption_init_password().
* @see ode_external_encryption_encrypt()
*/
ODE_API int ode_external_encryption_change_password(const char* old_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
+ * @param[int] password The password to be verified
+ * @param[out] result The result of verification
* @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_PERMISSION_DENIED The application does not have
* the privilege to call this API
* @pre The password must match with what is set by
- * ode_external_encryption_create_password().
+ * ode_external_encryption_init_password().
* @see ode_external_encryption_encrypt()
*/
-ODE_API int ode_external_encryption_verify_password(const char *password);
+ODE_API int ode_external_encryption_verify_password(const char* password, bool* result);
/**
* @brief Get current encryption state of external storage.
return internal.decrypt(password);
}
-int ode_internal_encryption_is_password_created(int *result)
+int ode_internal_encryption_is_password_initialized(bool* result)
{
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.isPasswordCreated();
+ int ret = internal.isPasswordInitialized();
- RET_ON_FAILURE(ret < 0, ODE_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(ret >= 0, ODE_ERROR_INVALID_PARAMETER);
*result = ret;
return ODE_ERROR_NONE;
}
-int ode_internal_encryption_create_password(const char *password)
+int ode_internal_encryption_init_password(const char* password)
{
RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
InternalEncryption internal = client.createInterface<InternalEncryption>();
- return internal.createPassword(password);
+ return internal.initPassword(password);
}
-int ode_internal_encryption_delete_password(const char *password)
+int ode_internal_encryption_clean_password(const char* password)
{
RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
InternalEncryption internal = client.createInterface<InternalEncryption>();
- return internal.deletePassword(password);
+ return internal.cleanPassword(password);
}
int ode_internal_encryption_change_password(const char* old_password,
return internal.changePassword(old_password, new_password);
}
-int ode_internal_encryption_verify_password(const char *password, int *result)
+int ode_internal_encryption_verify_password(const char* password, bool* result)
{
RET_ON_FAILURE(password, ODE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(result, ODE_ERROR_INVALID_PARAMETER);
InternalEncryption internal = client.createInterface<InternalEncryption>();
int ret = internal.verifyPassword(password);
- RET_ON_FAILURE(ret < 0, ODE_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(ret >= 0, ODE_ERROR_INVALID_PARAMETER);
*result = ret;
return ODE_ERROR_NONE;
InternalEncryption internal = client.createInterface<InternalEncryption>();
int ret = internal.getState();
- RET_ON_FAILURE(ret < 0, ODE_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(ret >= 0, ODE_ERROR_INVALID_PARAMETER);
*state = ret;
return ODE_ERROR_NONE;
* @retval #ODE_ERROR_PERMISSION_DENIED The application does not have
* the privilege to call this API
* @pre The password must match with what is set by
- * ode_internal_encryption_create_password().
+ * ode_internal_encryption_init_password().
* @see ode_internal_encryption_encrypt()
* @see ode_internal_encryption_umount()
*/
* @retval #ODE_ERROR_NOT_SUPPORTED Given options are not supported
* the privilege to call this API
* @pre The password must match with what is set by
- * ode_internal_encryption_create_password().
+ * ode_internal_encryption_init_password().
* @see ode_internal_encryption_mount()
* @see ode_internal_encryption_decrypt()
* @see ode_internal_encryption_get_supported_options()
* @retval #ODE_ERROR_PERMISSION_DENIED The application does not have
* the privilege to call this API
* @pre The password must match with what is set by
- * ode_internal_encryption_create_password().
+ * ode_internal_encryption_init_password().
* @see ode_internal_encryption_encrypt()
*/
ODE_API int ode_internal_encryption_decrypt(const char* password);
* @retval #ODE_ERROR_NOT_PERMITTED Operation not permitted
* @retval #ODE_ERROR_PERMISSION_DENIED The application does not have
* the privilege to call this API
- * @see ode_internal_encryption_created_password()
- * @see ode_internal_encryption_delete_password()
+ * @see ode_internal_encryption_init_password()
+ * @see ode_internal_encryption_clean_password()
*/
-ODE_API int ode_internal_encryption_is_password_created(bool* result);
+ODE_API int ode_internal_encryption_is_password_initialized(bool* result);
/**
* @brief Initialize internal encryption password to given password
* @retval #ODE_ERROR_PERMISSION_DENIED The application does not have
* the privilege to call this API
* @see ode_internal_encryption_change_password()
- * @see ode_internal_encryption_delete_password()
+ * @see ode_internal_encryption_clean_password()
* @see ode_internal_encryption_encrypt()
* @see ode_internal_encryption_decrypt()
* @see ode_internal_encryption_mount()
*/
-ODE_API int ode_internal_encryption_create_password(const char* password);
+ODE_API int ode_internal_encryption_init_password(const char* password);
/**
* @brief Remove internal encryption password
* @details Administrator can use this API to delete password that was set
- by ode_internal_encryption_create_password().
+ by ode_internal_encryption_init_password().
* @since_tizen 3.0
* @param[in] password The password to delete
* @return #ODE_ERROR_NONE on success, otherwise a negative value
* @retval #ODE_ERROR_PERMISSION_DENIED The application does not have
* the privilege to call this API
* @pre The password must match with what is set by
- * ode_internal_encryption_create_password().
- * @see ode_internal_encryption_create_password()
+ * ode_internal_encryption_init_password().
+ * @see ode_internal_encryption_init_password()
*/
-ODE_API int ode_internal_encryption_delete_password(const char* password);
+ODE_API int ode_internal_encryption_clean_password(const char* password);
/**
* @brief Change the password for internal storage.
* @retval #ODE_ERROR_PERMISSION_DENIED The application does not have
* the privilege to call this API
* @pre Old password must match with what is set by
- * ode_internal_encryption_create_password().
- * @see ode_internal_encryption_create_password()
+ * ode_internal_encryption_init_password().
+ * @see ode_internal_encryption_init_password()
*/
ODE_API int ode_internal_encryption_change_password(const char* old_password,
const char* new_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
+ * @param[in] password The password to be verified
+ * @param[out] result The result of verification
* @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_PERMISSION_DENIED The application does not have
* the privilege to call this API
* @pre The password must match with what is set by
- * ode_internal_encryption_create_password().
- * @see ode_internal_encryption_create_password()
+ * ode_internal_encryption_init_password().
+ * @see ode_internal_encryption_init_password()
* @see ode_internal_encryption_change_password()
*/
-ODE_API int ode_internal_encryption_verify_password(const char *password);
+ODE_API int ode_internal_encryption_verify_password(const char* password, bool* result);
/**
* @brief Get current encryption state of internal storage.
int encrypt(const std::string& password, unsigned int options);
int decrypt(const std::string& password);
- int isPasswordCreated();
- int createPassword(const std::string& password);
- int deletePassword(const std::string& password);
+ int isPasswordInitialized();
+ int initPassword(const std::string& password);
+ int cleanPassword(const std::string& password);
int changePassword(const std::string& oldPW, const std::string& newPW);
int verifyPassword(const std::string& password);
int encrypt(const std::string& password, unsigned int options);
int decrypt(const std::string& password);
- int isPasswordCreated();
- int createPassword(const std::string& password);
- int deletePassword(const std::string& password);
+ int isPasswordInitialized();
+ int initPassword(const std::string& password);
+ int cleanPassword(const std::string& password);
int changePassword(const std::string& oldPW, const std::string& newPW);
int verifyPassword(const std::string& password);
destroyCryptoBlkDev(DM_LABEL);
}
-bool DMCryptEngine::isKeyMetaCreated()
+bool DMCryptEngine::isKeyMetaSet()
{
return FileFooter::exist(source);
}
void encrypt(const data &key, unsigned int options);
void decrypt(const data &key, unsigned int options);
- bool isKeyMetaCreated();
+ bool isKeyMetaSet();
const data getKeyMeta();
void setKeyMeta(const data &data);
void clearKeyMeta();
progress.done();
}
-bool EcryptfsEngine::isKeyMetaCreated()
+bool EcryptfsEngine::isKeyMetaSet()
{
return FileFooter::exist(source);
}
void encrypt(const data& key, unsigned int);
void decrypt(const data& key, unsigned int);
- bool isKeyMetaCreated();
+ bool isKeyMetaSet();
const data getKeyMeta();
void setKeyMeta(const data &data);
void clearKeyMeta();
::remove(secondMountPoint.c_str());
}
-bool Ext4Engine::isKeyMetaCreated()
+bool Ext4Engine::isKeyMetaSet()
{
return FileFooter::exist(source);
}
void encrypt(const data &key, unsigned int options);
void decrypt(const data &key, unsigned int options);
- bool isKeyMetaCreated();
+ bool isKeyMetaSet();
const data getKeyMeta();
void setKeyMeta(const data &data);
void clearKeyMeta();
context.registerNonparametricMethod(this, "", (int)(ExternalEncryption::umount));
context.registerParametricMethod(this, "", (int)(ExternalEncryption::encrypt)(std::string, unsigned int));
context.registerParametricMethod(this, "", (int)(ExternalEncryption::decrypt)(std::string));
- context.registerNonparametricMethod(this, "", (int)(ExternalEncryption::isPasswordCreated));
- context.registerParametricMethod(this, "", (int)(ExternalEncryption::createPassword)(std::string));
- context.registerParametricMethod(this, "", (int)(ExternalEncryption::deletePassword)(std::string));
+ context.registerNonparametricMethod(this, "", (int)(ExternalEncryption::isPasswordInitialized));
+ context.registerParametricMethod(this, "", (int)(ExternalEncryption::initPassword)(std::string));
+ context.registerParametricMethod(this, "", (int)(ExternalEncryption::cleanPassword)(std::string));
context.registerParametricMethod(this, "", (int)(ExternalEncryption::changePassword)(std::string, std::string));
context.registerParametricMethod(this, "", (int)(ExternalEncryption::verifyPassword)(std::string));
context.registerNonparametricMethod(this, "", (int)(ExternalEncryption::getState));
return 0;
}
-int ExternalEncryption::isPasswordCreated()
+int ExternalEncryption::isPasswordInitialized()
{
- if (engine.isKeyMetaCreated()) {
+ if (engine.isKeyMetaSet()) {
return 1;
}
return 0;
}
-
-int ExternalEncryption::createPassword(const std::string& password)
+int ExternalEncryption::initPassword(const std::string& password)
{
KeyManager::data pwData(password.begin(), password.end());
KeyManager keyManager;
- if (engine.isKeyMetaCreated()) {
- return -2;
- }
-
keyManager.initPassword(pwData);
engine.setKeyMeta(keyManager.serialize());
return 0;
}
-int ExternalEncryption::deletePassword(const std::string& password)
+int ExternalEncryption::cleanPassword(const std::string& password)
{
KeyManager::data pwData(password.begin(), password.end());
KeyManager keyManager(engine.getKeyMeta());
KeyManager::data pwData(password.begin(), password.end());
KeyManager keyManager(engine.getKeyMeta());
- if (!keyManager.verifyPassword(pwData)) {
+ if (keyManager.verifyPassword(pwData)) {
return 1;
}
return 0;
context.registerNonparametricMethod(this, "", (int)(InternalEncryption::umount));
context.registerParametricMethod(this, "", (int)(InternalEncryption::encrypt)(std::string, unsigned int));
context.registerParametricMethod(this, "", (int)(InternalEncryption::decrypt)(std::string));
- context.registerNonparametricMethod(this, "", (int)(InternalEncryption::isPasswordCreated));
- context.registerParametricMethod(this, "", (int)(InternalEncryption::createPassword)(std::string));
- context.registerParametricMethod(this, "", (int)(InternalEncryption::deletePassword)(std::string));
+ context.registerNonparametricMethod(this, "", (int)(InternalEncryption::isPasswordInitialized));
+ context.registerParametricMethod(this, "", (int)(InternalEncryption::initPassword)(std::string));
+ context.registerParametricMethod(this, "", (int)(InternalEncryption::cleanPassword)(std::string));
context.registerParametricMethod(this, "", (int)(InternalEncryption::changePassword)(std::string, std::string));
context.registerParametricMethod(this, "", (int)(InternalEncryption::verifyPassword)(std::string));
context.registerNonparametricMethod(this, "", (int)(InternalEncryption::getState));
return 0;
}
-int InternalEncryption::isPasswordCreated()
+int InternalEncryption::isPasswordInitialized()
{
- if (engine.isKeyMetaCreated()) {
+ if (engine.isKeyMetaSet()) {
return 1;
}
return 0;
}
-int InternalEncryption::createPassword(const std::string& password)
+int InternalEncryption::initPassword(const std::string& password)
{
KeyManager::data pwData(password.begin(), password.end());
KeyManager keyManager;
- if (engine.isKeyMetaCreated()) {
- return -2;
- }
-
keyManager.initPassword(pwData);
engine.setKeyMeta(keyManager.serialize());
return 0;
}
-int InternalEncryption::deletePassword(const std::string& password)
+int InternalEncryption::cleanPassword(const std::string& password)
{
KeyManager::data pwData(password.begin(), password.end());
KeyManager keyManager(engine.getKeyMeta());
int ret;
if (name == "internal") {
+ bool result = false;
+ ode_internal_encryption_is_password_initialized(&result);
+
+ if (!result) {
+ std::cout << "New ";
+ std::string password = getPassword();
+ ode_internal_encryption_init_password(password.c_str());
+ }
+
+ result = false;
+ std::cout << "Confirm ";
std::string password = getPassword();
- ode_internal_encryption_create_password(password.c_str());
+ ode_internal_encryption_verify_password(password.c_str(), &result);
+
+ if (!result) {
+ std::cerr << "Confirm password doesn't match" << std::endl;
+ return -1;
+ }
unsigned int options = 0;
ode_internal_encryption_get_supported_options(&options);
}
ret = ode_internal_encryption_encrypt(password.c_str(), options);
} else if (name == "external") {
+ bool result = false;
+ ode_external_encryption_is_password_initialized(&result);
+
+ if (!result) {
+ std::cout << "New ";
+ std::string password = getPassword();
+ ode_external_encryption_init_password(password.c_str());
+ }
+
+ result = false;
+ std::cout << "Confirm ";
std::string password = getPassword();
- ode_external_encryption_create_password(password.c_str());
+ ode_external_encryption_verify_password(password.c_str(), &result);
+
+ if (!result) {
+ std::cerr << "Confirm password doesn't match" << std::endl;
+ return -1;
+ }
unsigned int options;
ode_external_encryption_get_supported_options(&options);
if (name == "internal") {
std::string password = getPassword();
ret = ode_internal_encryption_decrypt(password.c_str());
- ode_internal_encryption_delete_password(password.c_str());
+ if (ret == 0) {
+ ode_internal_encryption_clean_password(password.c_str());
+ }
} else if (name == "external") {
std::string password = getPassword();
ret = ode_external_encryption_decrypt(password.c_str());
- ode_external_encryption_delete_password(password.c_str());
+ if (ret == 0) {
+ ode_external_encryption_clean_password(password.c_str());
+ }
} else {
printSelectableStorage();
return -1;