Serialization::Serialize(send, static_cast<int>(ControlCommand::UNLOCK_USER_KEY));
Serialization::Serialize(send, user);
Serialization::Serialize(send, password);
+ int retCode;
- int retCode = sendToServer(
+ if((int)user < 0) {
+ retCode = CKM_API_ERROR_INPUT_PARAM;
+ return retCode;
+ }
+
+ retCode = sendToServer(
SERVICE_SOCKET_CKM_CONTROL,
send.Pop(),
recv);
MessageBuffer send, recv;
Serialization::Serialize(send, static_cast<int>(ControlCommand::LOCK_USER_KEY));
Serialization::Serialize(send, user);
+ int retCode;
+
+ if((int)user < 0) {
+ retCode = CKM_API_ERROR_INPUT_PARAM;
+ return retCode;
+ }
- int retCode = sendToServer(
+ retCode = sendToServer(
SERVICE_SOCKET_CKM_CONTROL,
send.Pop(),
recv);
MessageBuffer send, recv;
Serialization::Serialize(send, static_cast<int>(ControlCommand::REMOVE_USER_DATA));
Serialization::Serialize(send, user);
+ int retCode;
- int retCode = sendToServer(
+ if((int)user < 0) {
+ retCode = CKM_API_ERROR_INPUT_PARAM;
+ return retCode;
+ }
+
+ retCode = sendToServer(
SERVICE_SOCKET_CKM_CONTROL,
send.Pop(),
recv);
Serialization::Serialize(send, user);
Serialization::Serialize(send, oldPassword);
Serialization::Serialize(send, newPassword);
+ int retCode;
+
+ if((int)user < 0) {
+ retCode = CKM_API_ERROR_INPUT_PARAM;
+ return retCode;
+ }
- int retCode = sendToServer(
+ retCode = sendToServer(
SERVICE_SOCKET_CKM_CONTROL,
send.Pop(),
recv);
Serialization::Serialize(send, static_cast<int>(ControlCommand::RESET_USER_PASSWORD));
Serialization::Serialize(send, user);
Serialization::Serialize(send, newPassword);
+ int retCode;
+
+ if((int)user < 0) {
+ retCode = CKM_API_ERROR_INPUT_PARAM;
+ return retCode;
+ }
- int retCode = sendToServer(
+ retCode = sendToServer(
SERVICE_SOCKET_CKM_CONTROL,
send.Pop(),
recv);
handle.crypto = CryptoLogic();
// TODO wipe key
}
+ } catch (const KeyProvider::Exception::PassWordError &e) {
+ LogError("Incorrect Password " << e.GetMessage());
+ retCode = CKM_API_ERROR_AUTHENTICATION_FAILED;
} catch (const KeyProvider::Exception::Base &e) {
LogError("Error in KeyProvider " << e.GetMessage());
retCode = CKM_API_ERROR_SERVER_ERROR;
const std::string &newPassword)
{
int retCode = CKM_API_SUCCESS;
- // TODO try-catch
- FileSystem fs(user);
- auto wrappedDomainKEK = fs.getDomainKEK();
- if (wrappedDomainKEK.empty()) {
- retCode = CKM_API_ERROR_BAD_REQUEST;
- } else {
- wrappedDomainKEK = KeyProvider::reencrypt(wrappedDomainKEK, oldPassword, newPassword);
- fs.saveDomainKEK(wrappedDomainKEK);
+ try {
+ FileSystem fs(user);
+ auto wrappedDomainKEK = fs.getDomainKEK();
+ if (wrappedDomainKEK.empty()) {
+ retCode = CKM_API_ERROR_BAD_REQUEST;
+ } else {
+ wrappedDomainKEK = KeyProvider::reencrypt(wrappedDomainKEK, oldPassword, newPassword);
+ fs.saveDomainKEK(wrappedDomainKEK);
+ }
+ } catch (const KeyProvider::Exception::PassWordError &e) {
+ LogError("Incorrect Password " << e.GetMessage());
+ retCode = CKM_API_ERROR_AUTHENTICATION_FAILED;
+ } catch (const KeyProvider::Exception::Base &e) {
+ LogError("Error in KeyProvider " << e.GetMessage());
+ retCode = CKM_API_ERROR_SERVER_ERROR;
+ } catch (const CKM::Exception &e) {
+ LogError("CKM::Exception: " << e.GetMessage());
+ retCode = CKM_API_ERROR_SERVER_ERROR;
}
+
MessageBuffer response;
Serialization::Serialize(response, retCode);
return response.Pop();