// The service will use DKEK in plain text and encrypt it in encrypted form (using new password).
virtual int resetUserPassword(uid_t user, const Password &newPassword) = 0;
+ // Required for tizen 2.3.
+ // It will remove all application data owned by application identified
+ // by smackLabel. This function will remove application data from unlocked
+ // database only. This function may be used during application uninstallation.
+ virtual int removeApplicationData(const std::string &smackLabel) = 0;
+
virtual ~Control(){}
static ControlShPtr create();
});
}
+ virtual int removeApplicationData(const std::string &smackLabel) {
+ return try_catch([&] {
+ if (smackLabel.empty()) {
+ return CKM_API_ERROR_INPUT_PARAM;
+ }
+
+ MessageBuffer send,recv;
+ Serialization::Serialize(send, static_cast<int>(ControlCommand::REMOVE_APP_DATA));
+ Serialization::Serialize(send, smackLabel);
+
+ int retCode = sendToServer(
+ SERVICE_SOCKET_CKM_CONTROL,
+ send.Pop(),
+ recv);
+
+ if (CKM_API_SUCCESS != retCode) {
+ return retCode;
+ }
+
+ Deserialization::Deserialize(recv, retCode);
+
+ return retCode;
+ });
+ }
+
virtual ~ControlImpl(){}
};
LOCK_USER_KEY,
REMOVE_USER_DATA,
CHANGE_USER_PASSWORD,
- RESET_USER_PASSWORD
+ RESET_USER_PASSWORD,
+ REMOVE_APP_DATA
};
enum class LogicCommand : int {
return response.Pop();
}
+RawBuffer CKMLogic::removeApplicationData(const std::string &smackLabel) {
+ int retCode = CKM_API_SUCCESS;
+
+ try {
+
+ if (smackLabel.empty()) {
+ retCode = CKM_API_ERROR_INPUT_PARAM;
+ } else {
+ for(auto &handler: m_userDataMap) {
+ handler.second.database.deleteKey(smackLabel);
+ }
+ }
+
+ } catch (const DBCrypto::Exception::InternalError &e) {
+ LogError("DBCrypto couldn't remove data: " << e.GetMessage());
+ retCode = CKM_API_ERROR_DB_ERROR;
+ } catch (const DBCrypto::Exception::TransactionError &e) {
+ LogError("DBCrypto transaction failed with message " << e.GetMessage());
+ retCode = CKM_API_ERROR_DB_ERROR;
+ }
+
+ MessageBuffer response;
+ Serialization::Serialize(response, retCode);
+ return response.Pop();
+}
+
int CKMLogic::saveDataHelper(
Credentials &cred,
DBDataType dataType,
uid_t user,
const Password &newPassword);
+ RawBuffer removeApplicationData(const std::string &smackLabel);
+
RawBuffer saveData(
Credentials &cred,
int commandId,
uid_t user;
ControlCommand cc;
Password newPass, oldPass;
+ std::string smackLabel;
Deserialization::Deserialize(buffer, command);
- Deserialization::Deserialize(buffer, user);
LogDebug("Process control. Command: " << command);
switch(cc) {
case ControlCommand::UNLOCK_USER_KEY:
+ Deserialization::Deserialize(buffer, user);
Deserialization::Deserialize(buffer, newPass);
return m_logic->unlockUserKey(user, newPass);
case ControlCommand::LOCK_USER_KEY:
+ Deserialization::Deserialize(buffer, user);
return m_logic->lockUserKey(user);
case ControlCommand::REMOVE_USER_DATA:
+ Deserialization::Deserialize(buffer, user);
return m_logic->removeUserData(user);
case ControlCommand::CHANGE_USER_PASSWORD:
+ Deserialization::Deserialize(buffer, user);
Deserialization::Deserialize(buffer, oldPass);
Deserialization::Deserialize(buffer, newPass);
return m_logic->changeUserPassword(user, oldPass, newPass);
case ControlCommand::RESET_USER_PASSWORD:
+ Deserialization::Deserialize(buffer, user);
Deserialization::Deserialize(buffer, newPass);
return m_logic->resetUserPassword(user, newPass);
+ case ControlCommand::REMOVE_APP_DATA:
+ Deserialization::Deserialize(buffer, smackLabel);
+ return m_logic->removeApplicationData(smackLabel);
default:
Throw(Exception::BrokenProtocol);
}
// 1 2
"DELETE FROM CKM_TABLE WHERE alias=? AND label=?;";
+ const char *delete_data_with_key_cmd =
+ // 1
+ "DELETE FROM CKM_TABLE WHERE label=?;";
+
// KEY_TABLE (label TEXT, key BLOB)
const char *db_create_key_cmd =
void DBCrypto::deleteKey(const std::string& label) {
Try {
Transaction transaction(this);
+
SqlConnection::DataCommandUniquePtr deleteCommand =
m_connection->PrepareDataCommand(delete_key_cmd);
deleteCommand->BindString(1, label.c_str());
deleteCommand->Step();
+
+ SqlConnection::DataCommandUniquePtr deleteData =
+ m_connection->PrepareDataCommand(delete_data_with_key_cmd);
+ deleteData->BindString(1, label.c_str());
+ deleteData->Step();
+
transaction.commit();
return;
} Catch (SqlConnection::Exception::SyntaxError) {
int deleteDBRow(
const Alias& alias,
const std::string &label);
-
void saveKey(const std::string& label, const RawBuffer &key);
RawBufferOptional getKey(
const std::string& label);