* @retval #ODE_ERROR_PERMISSION_DENIED The application does not have
* the privilege to call this API
* @pre A password must be set by
- * ode_external_encryption_set_mount_password().
+ * ode_external_encryption_set_mount_password() before every
+ * mount attempt.
* @see ode_external_encryption_set_mount_password()
* @see ode_external_encryption_umount()
*/
* @retval #ODE_ERROR_PERMISSION_DENIED The application does not have
* the privilege to call this API
* @pre A password must be set by
- * ode_internal_encryption_set_mount_password().
+ * ode_internal_encryption_set_mount_password() before every
+ * mount attempt.
* @see ode_internal_encryption_set_mount_password()
* @see ode_internal_encryption_umount()
*/
int ExternalEncryptionServer::mount()
{
+ if (mountKey.empty()) {
+ ERROR(SINK, "You need to call set_mount_password() first");
+ return -1;
+ }
+
+ KeyManager::data key = mountKey;
+ mountKey.clear();
+
if (getState() != State::Encrypted) {
return -1;
}
INFO(SINK, "Mount external storage...");
try {
- engine->mount(mountKey, getOptions());
- mountKey.clear();
+ engine->mount(key, getOptions());
} catch (runtime::Exception &e) {
- mountKey.clear();
ERROR(SINK, "Failed to mount: " + std::string(e.what()));
return -3;
}
int InternalEncryptionServer::mount()
{
+ if (mountKey.empty()) {
+ ERROR(SINK, "You need to call set_mount_password() first");
+ return -1;
+ }
+
+ KeyManager::data key = mountKey;
+ mountKey.clear();
+
if (getState() != State::Encrypted) {
return -1;
}
try {
INFO(SINK, "Mount internal storage...");
- engine->mount(mountKey, getOptions());
- mountKey.clear();
+ engine->mount(key, getOptions());
server.notify("InternalEncryptionServer::mount");