* See the License for the specific language governing permissions and
* limitations under the License
*/
-#include "rmi/extension-encryption.h"
+#include "extension-encryption.h"
namespace ode {
-ExtensionEncryption::ExtensionEncryption(ODEControlContext& ctx) :
- context(ctx),
- currentReq(Request::NONE)
+ExtensionEncryptionClient::ExtensionEncryptionClient(ODEControlContext& ctx) :
+ context(ctx)
{
}
-ExtensionEncryption::~ExtensionEncryption()
+ExtensionEncryptionClient::~ExtensionEncryptionClient()
{
}
-int ExtensionEncryption::setMountPassword(const std::string& password)
+int ExtensionEncryptionClient::setMountPassword(const std::string& password)
{
try {
- return context->methodCall<int>("ExtensionEncryption::setMountPassword", password);
+ return context->methodCall<int>("ExtensionEncryptionServer::setMountPassword", password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExtensionEncryption::mount()
+int ExtensionEncryptionClient::mount()
{
try {
- return context->methodCall<int>("ExtensionEncryption::mount");
+ return context->methodCall<int>("ExtensionEncryptionServer::mount");
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExtensionEncryption::umount()
+int ExtensionEncryptionClient::umount()
{
try {
- return context->methodCall<int>("ExtensionEncryption::umount");
+ return context->methodCall<int>("ExtensionEncryptionServer::umount");
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExtensionEncryption::format(const std::string& password)
+int ExtensionEncryptionClient::format(const std::string& password)
{
try {
- return context->methodCall<int>("ExtensionEncryption::format", password);
+ return context->methodCall<int>("ExtensionEncryptionServer::format", password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExtensionEncryption::isPasswordInitialized()
+int ExtensionEncryptionClient::isPasswordInitialized()
{
try {
- return context->methodCall<int>("ExtensionEncryption::isPasswordInitialized");
+ return context->methodCall<int>("ExtensionEncryptionServer::isPasswordInitialized");
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExtensionEncryption::initPassword(const std::string& password)
+int ExtensionEncryptionClient::initPassword(const std::string& password)
{
try {
- return context->methodCall<int>("ExtensionEncryption::initPassword",
+ return context->methodCall<int>("ExtensionEncryptionServer::initPassword",
password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExtensionEncryption::cleanPassword(const std::string& password)
+int ExtensionEncryptionClient::cleanPassword(const std::string& password)
{
try {
- return context->methodCall<int>("ExtensionEncryption::cleanPassword",
+ return context->methodCall<int>("ExtensionEncryptionServer::cleanPassword",
password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExtensionEncryption::changePassword(const std::string& oldPassword,
+int ExtensionEncryptionClient::changePassword(const std::string& oldPassword,
const std::string& newPassword)
{
try {
- return context->methodCall<int>("ExtensionEncryption::changePassword",
+ return context->methodCall<int>("ExtensionEncryptionServer::changePassword",
oldPassword, newPassword);
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExtensionEncryption::verifyPassword(const std::string& password)
+int ExtensionEncryptionClient::verifyPassword(const std::string& password)
{
try {
- return context->methodCall<int>("ExtensionEncryption::verifyPassword",
+ return context->methodCall<int>("ExtensionEncryptionServer::verifyPassword",
password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExtensionEncryption::getState()
+int ExtensionEncryptionClient::getState()
{
try {
- return context->methodCall<int>("ExtensionEncryption::getState");
+ return context->methodCall<int>("ExtensionEncryptionServer::getState");
} catch (runtime::Exception& e) {
return -1;
}
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+#ifndef __EXTENSION_ENCRYPTION_CLIENT_H__
+#define __EXTENSION_ENCRYPTION_CLIENT_H__
+
+#include <string>
+
+#include "rmi/extension-encryption.h"
+#include "context.h"
+
+namespace ode {
+
+class ExtensionEncryptionClient final: public ExtensionEncryption {
+public:
+ ExtensionEncryptionClient(ODEControlContext& ctxt);
+ ~ExtensionEncryptionClient();
+
+ int setMountPassword(const std::string& password);
+
+ int mount();
+ int umount();
+
+ int format(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 getState();
+
+private:
+ ODEControlContext& context;
+};
+
+} // namespace ode
+
+#endif // __EXTENSION_ENCRYPTION_CLIENT_H__
* See the License for the specific language governing permissions and
* limitations under the License
*/
-#include "rmi/external-encryption.h"
+#include "external-encryption.h"
namespace ode {
-ExternalEncryption::ExternalEncryption(ODEControlContext& ctx) :
+ExternalEncryptionClient::ExternalEncryptionClient(ODEControlContext& ctx) :
context(ctx)
{
}
-ExternalEncryption::~ExternalEncryption()
+ExternalEncryptionClient::~ExternalEncryptionClient()
{
}
-int ExternalEncryption::setMountPassword(const std::string& password)
+int ExternalEncryptionClient::setMountPassword(const std::string& password)
{
try {
- return context->methodCall<int>("ExternalEncryption::setMountPassword", password);
+ return context->methodCall<int>("ExternalEncryptionServer::setMountPassword", password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExternalEncryption::mount()
+int ExternalEncryptionClient::mount()
{
try {
- return context->methodCall<int>("ExternalEncryption::mount");
+ return context->methodCall<int>("ExternalEncryptionServer::mount");
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExternalEncryption::umount()
+int ExternalEncryptionClient::umount()
{
try {
- return context->methodCall<int>("ExternalEncryption::umount");
+ return context->methodCall<int>("ExternalEncryptionServer::umount");
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExternalEncryption::encrypt(const std::string& password, unsigned int options)
+int ExternalEncryptionClient::encrypt(const std::string& password, unsigned int options)
{
try {
- return context->methodCall<int>("ExternalEncryption::encrypt", password, options);
+ return context->methodCall<int>("ExternalEncryptionServer::encrypt", password, options);
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExternalEncryption::decrypt(const std::string& password)
+int ExternalEncryptionClient::decrypt(const std::string& password)
{
try {
- return context->methodCall<int>("ExternalEncryption::decrypt", password);
+ return context->methodCall<int>("ExternalEncryptionServer::decrypt", password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExternalEncryption::recovery()
+int ExternalEncryptionClient::recovery()
{
try {
- return context->methodCall<int>("ExternalEncryption::recovery");
+ return context->methodCall<int>("ExternalEncryptionServer::recovery");
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExternalEncryption::isPasswordInitialized()
+int ExternalEncryptionClient::isPasswordInitialized()
{
try {
- return context->methodCall<int>("ExternalEncryption::isPasswordInitialized");
+ return context->methodCall<int>("ExternalEncryptionServer::isPasswordInitialized");
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExternalEncryption::initPassword(const std::string& password)
+int ExternalEncryptionClient::initPassword(const std::string& password)
{
try {
- return context->methodCall<int>("ExternalEncryption::initPassword",
+ return context->methodCall<int>("ExternalEncryptionServer::initPassword",
password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExternalEncryption::cleanPassword(const std::string& password)
+int ExternalEncryptionClient::cleanPassword(const std::string& password)
{
try {
- return context->methodCall<int>("ExternalEncryption::cleanPassword",
+ return context->methodCall<int>("ExternalEncryptionServer::cleanPassword",
password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExternalEncryption::changePassword(const std::string& oldPassword,
+int ExternalEncryptionClient::changePassword(const std::string& oldPassword,
const std::string& newPassword)
{
try {
- return context->methodCall<int>("ExternalEncryption::changePassword",
+ return context->methodCall<int>("ExternalEncryptionServer::changePassword",
oldPassword, newPassword);
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExternalEncryption::verifyPassword(const std::string& password)
+int ExternalEncryptionClient::verifyPassword(const std::string& password)
{
try {
- return context->methodCall<int>("ExternalEncryption::verifyPassword",
+ return context->methodCall<int>("ExternalEncryptionServer::verifyPassword",
password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int ExternalEncryption::getState()
+int ExternalEncryptionClient::getState()
{
try {
- return context->methodCall<int>("ExternalEncryption::getState");
+ return context->methodCall<int>("ExternalEncryptionServer::getState");
} catch (runtime::Exception& e) {
return -1;
}
}
-unsigned int ExternalEncryption::getSupportedOptions()
+unsigned int ExternalEncryptionClient::getSupportedOptions()
{
try {
- return context->methodCall<unsigned int>("ExternalEncryption::getSupportedOptions");
+ return context->methodCall<unsigned int>("ExternalEncryptionServer::getSupportedOptions");
} catch (runtime::Exception& e) {
return -1;
}
--- /dev/null
+/*
+ * Copyright (c) 2015-2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+#ifndef __EXTERNAL_ENCRYPTION_CLIENT_H__
+#define __EXTERNAL_ENCRYPTION_CLIENT_H__
+
+#include <string>
+
+#include "rmi/extension-encryption.h"
+#include "context.h"
+
+namespace ode {
+
+class ExternalEncryptionClient {
+public:
+ ExternalEncryptionClient(ODEControlContext& ctxt);
+ ~ExternalEncryptionClient();
+
+ int setMountPassword(const std::string& password);
+
+ int mount();
+ int umount();
+
+ int encrypt(const std::string& password, unsigned int options);
+ int decrypt(const std::string& password);
+
+ int recovery();
+
+ 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 getState();
+
+ unsigned int getSupportedOptions();
+
+private:
+ ODEControlContext& context;
+};
+
+} // namespace ode
+
+#endif // __EXTERNAL_ENCRYPTION_CLIENT_H__
* See the License for the specific language governing permissions and
* limitations under the License
*/
-#include "rmi/internal-encryption.h"
+#include "internal-encryption.h"
namespace ode {
-InternalEncryption::InternalEncryption(ODEControlContext& ctx) :
+InternalEncryptionClient::InternalEncryptionClient(ODEControlContext& ctx) :
context(ctx)
{
}
-InternalEncryption::~InternalEncryption()
+InternalEncryptionClient::~InternalEncryptionClient()
{
}
-int InternalEncryption::setMountPassword(const std::string& password)
+int InternalEncryptionClient::setMountPassword(const std::string& password)
{
try {
- return context->methodCall<int>("InternalEncryption::setMountPassword", password);
+ return context->methodCall<int>("InternalEncryptionServer::setMountPassword", password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int InternalEncryption::mount()
+int InternalEncryptionClient::mount()
{
try {
- return context->methodCall<int>("InternalEncryption::mount");
+ return context->methodCall<int>("InternalEncryptionServer::mount");
} catch (runtime::Exception& e) {
return -1;
}
}
-int InternalEncryption::umount()
+int InternalEncryptionClient::umount()
{
try {
- return context->methodCall<int>("InternalEncryption::umount");
+ return context->methodCall<int>("InternalEncryptionServer::umount");
} catch (runtime::Exception& e) {
return -1;
}
}
-int InternalEncryption::encrypt(const std::string& password, unsigned int options)
+int InternalEncryptionClient::encrypt(const std::string& password, unsigned int options)
{
try {
- return context->methodCall<int>("InternalEncryption::encrypt", password, options);
+ return context->methodCall<int>("InternalEncryptionServer::encrypt", password, options);
} catch (runtime::Exception& e) {
return -1;
}
}
-int InternalEncryption::decrypt(const std::string& password)
+int InternalEncryptionClient::decrypt(const std::string& password)
{
try {
- return context->methodCall<int>("InternalEncryption::decrypt", password);
+ return context->methodCall<int>("InternalEncryptionServer::decrypt", password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int InternalEncryption::recovery()
+int InternalEncryptionClient::recovery()
{
try {
- return context->methodCall<int>("InternalEncryption::recovery");
+ return context->methodCall<int>("InternalEncryptionServer::recovery");
} catch (runtime::Exception& e) {
return -1;
}
}
-int InternalEncryption::isPasswordInitialized()
+int InternalEncryptionClient::isPasswordInitialized()
{
try {
- return context->methodCall<int>("InternalEncryption::isPasswordInitialized");
+ return context->methodCall<int>("InternalEncryptionServer::isPasswordInitialized");
} catch (runtime::Exception& e) {
return -1;
}
}
-int InternalEncryption::initPassword(const std::string& password)
+int InternalEncryptionClient::initPassword(const std::string& password)
{
try {
- return context->methodCall<int>("InternalEncryption::initPassword",
+ return context->methodCall<int>("InternalEncryptionServer::initPassword",
password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int InternalEncryption::cleanPassword(const std::string& password)
+int InternalEncryptionClient::cleanPassword(const std::string& password)
{
try {
- return context->methodCall<int>("InternalEncryption::cleanPassword",
+ return context->methodCall<int>("InternalEncryptionServer::cleanPassword",
password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int InternalEncryption::changePassword(const std::string& oldPassword,
+int InternalEncryptionClient::changePassword(const std::string& oldPassword,
const std::string& newPassword)
{
try {
- return context->methodCall<int>("InternalEncryption::changePassword",
+ return context->methodCall<int>("InternalEncryptionServer::changePassword",
oldPassword, newPassword);
} catch (runtime::Exception& e) {
return -1;
}
}
-int InternalEncryption::verifyPassword(const std::string& password)
+int InternalEncryptionClient::verifyPassword(const std::string& password)
{
try {
- return context->methodCall<int>("InternalEncryption::verifyPassword",
+ return context->methodCall<int>("InternalEncryptionServer::verifyPassword",
password);
} catch (runtime::Exception& e) {
return -1;
}
}
-int InternalEncryption::getState()
+int InternalEncryptionClient::getState()
{
try {
- return context->methodCall<int>("InternalEncryption::getState");
+ return context->methodCall<int>("InternalEncryptionServer::getState");
} catch (runtime::Exception& e) {
return -1;
}
}
-unsigned int InternalEncryption::getSupportedOptions()
+unsigned int InternalEncryptionClient::getSupportedOptions()
{
try {
- return context->methodCall<unsigned int>("InternalEncryption::getSupportedOptions");
+ return context->methodCall<unsigned int>("InternalEncryptionServer::getSupportedOptions");
} catch (runtime::Exception& e) {
return -1;
}
--- /dev/null
+/*
+ * Copyright (c) 2015-2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+#ifndef __INTERNAL_ENCRYPTION_CLIENT_H__
+#define __INTERNAL_ENCRYPTION_CLIENT_H__
+
+#include <string>
+
+#include "rmi/internal-encryption.h"
+#include "context.h"
+
+namespace ode {
+
+class InternalEncryptionClient final: public InternalEncryption {
+public:
+ InternalEncryptionClient(ODEControlContext& ctxt);
+ ~InternalEncryptionClient();
+
+ int setMountPassword(const std::string& password);
+
+ int mount();
+ int umount();
+
+ int encrypt(const std::string& password, unsigned int options);
+ int decrypt(const std::string& password);
+
+ int recovery();
+
+ 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 getState();
+
+ unsigned int getSupportedOptions();
+
+private:
+ ODEControlContext& context;
+};
+
+} // namespace ode
+
+#endif // __INTERNAL_ENCRYPTION_CLIENT_H__
#include "extension-encryption.h"
#include "client.h"
-#include "rmi/extension-encryption.h"
+#include "lib/extension-encryption.h"
using namespace ode;
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExtensionEncryption extension = client.createInterface<ExtensionEncryption>();
+ ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
return extension.setMountPassword(password);
}
{
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExtensionEncryption extension = client.createInterface<ExtensionEncryption>();
+ ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
return extension.mount();
}
{
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExtensionEncryption extension = client.createInterface<ExtensionEncryption>();
+ ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
return extension.umount();
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExtensionEncryption extension = client.createInterface<ExtensionEncryption>();
+ ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
return extension.format(password);
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExtensionEncryption extension = client.createInterface<ExtensionEncryption>();
+ ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
int ret = extension.isPasswordInitialized();
RET_ON_FAILURE(ret >= 0, ODE_ERROR_INVALID_PARAMETER);
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExtensionEncryption extension = client.createInterface<ExtensionEncryption>();
+ ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
return extension.initPassword(password);
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExtensionEncryption extension = client.createInterface<ExtensionEncryption>();
+ ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
return extension.cleanPassword(password);
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExtensionEncryption extension = client.createInterface<ExtensionEncryption>();
+ ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
return extension.changePassword(old_password, new_password);
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExtensionEncryption extension = client.createInterface<ExtensionEncryption>();
+ ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
int ret = extension.verifyPassword(password);
RET_ON_FAILURE(ret >= 0, ODE_ERROR_INVALID_PARAMETER);
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExtensionEncryption extension = client.createInterface<ExtensionEncryption>();
+ ExtensionEncryptionClient extension = client.createInterface<ExtensionEncryptionClient>();
int ret = extension.getState();
RET_ON_FAILURE(ret >= 0, ODE_ERROR_INVALID_PARAMETER);
#include "external-encryption.h"
#include "client.h"
-#include "rmi/external-encryption.h"
+#include "lib/external-encryption.h"
using namespace ode;
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExternalEncryption external = client.createInterface<ExternalEncryption>();
+ ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
return external.setMountPassword(password);
}
{
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExternalEncryption external = client.createInterface<ExternalEncryption>();
+ ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
return external.mount();
}
{
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExternalEncryption external = client.createInterface<ExternalEncryption>();
+ ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
return external.umount();
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExternalEncryption external = client.createInterface<ExternalEncryption>();
+ ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
return external.encrypt(password, options);
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExternalEncryption external = client.createInterface<ExternalEncryption>();
+ ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
return external.decrypt(password);
}
{
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExternalEncryption external = client.createInterface<ExternalEncryption>();
+ ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
return external.recovery();
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExternalEncryption external = client.createInterface<ExternalEncryption>();
+ ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
int ret = external.isPasswordInitialized();
RET_ON_FAILURE(ret >= 0, ODE_ERROR_INVALID_PARAMETER);
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExternalEncryption external = client.createInterface<ExternalEncryption>();
+ ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
return external.initPassword(password);
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExternalEncryption external = client.createInterface<ExternalEncryption>();
+ ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
return external.cleanPassword(password);
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExternalEncryption external = client.createInterface<ExternalEncryption>();
+ ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
return external.changePassword(old_password, new_password);
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExternalEncryption external = client.createInterface<ExternalEncryption>();
+ ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
int ret = external.verifyPassword(password);
RET_ON_FAILURE(ret >= 0, ODE_ERROR_INVALID_PARAMETER);
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExternalEncryption external = client.createInterface<ExternalEncryption>();
+ ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
int ret = external.getState();
RET_ON_FAILURE(ret >= 0, ODE_ERROR_INVALID_PARAMETER);
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- ExternalEncryption external = client.createInterface<ExternalEncryption>();
+ ExternalEncryptionClient external = client.createInterface<ExternalEncryptionClient>();
*options = external.getSupportedOptions();
return ODE_ERROR_NONE;
}
#include "internal-encryption.h"
#include "client.h"
-#include "rmi/internal-encryption.h"
+#include "lib/internal-encryption.h"
using namespace ode;
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- InternalEncryption internal = client.createInterface<InternalEncryption>();
+ InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
return internal.setMountPassword(password);
}
{
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- InternalEncryption internal = client.createInterface<InternalEncryption>();
+ InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
return internal.mount();
}
{
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- InternalEncryption internal = client.createInterface<InternalEncryption>();
+ InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
return internal.umount();
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- InternalEncryption internal = client.createInterface<InternalEncryption>();
+ InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
return internal.encrypt(password, options);
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- InternalEncryption internal = client.createInterface<InternalEncryption>();
+ InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
return internal.decrypt(password);
}
{
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- InternalEncryption internal = client.createInterface<InternalEncryption>();
+ InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
return internal.recovery();
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- InternalEncryption internal = client.createInterface<InternalEncryption>();
+ InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
int ret = internal.isPasswordInitialized();
RET_ON_FAILURE(ret >= 0, ODE_ERROR_INVALID_PARAMETER);
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- InternalEncryption internal = client.createInterface<InternalEncryption>();
+ InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
return internal.initPassword(password);
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- InternalEncryption internal = client.createInterface<InternalEncryption>();
+ InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
return internal.cleanPassword(password);
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- InternalEncryption internal = client.createInterface<InternalEncryption>();
+ InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
return internal.changePassword(old_password, new_password);
}
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- InternalEncryption internal = client.createInterface<InternalEncryption>();
+ InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
int ret = internal.verifyPassword(password);
RET_ON_FAILURE(ret >= 0, ODE_ERROR_INVALID_PARAMETER);
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- InternalEncryption internal = client.createInterface<InternalEncryption>();
+ InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
int ret = internal.getState();
RET_ON_FAILURE(ret >= 0, ODE_ERROR_INVALID_PARAMETER);
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- InternalEncryption internal = client.createInterface<InternalEncryption>();
+ InternalEncryptionClient internal = client.createInterface<InternalEncryptionClient>();
*options = internal.getSupportedOptions();
return ODE_ERROR_NONE;
}
mountEventCallbackContext.reset(new ODEContext);
RET_ON_FAILURE(mountEventCallbackContext->connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- int ret = mountEventCallbackContext->subscribeSignal("InternalEncryption::mount", callback, user_data);
+ int ret = mountEventCallbackContext->subscribeSignal("InternalEncryptionServer::mount", callback, user_data);
RET_ON_FAILURE(ret >= 0, ODE_ERROR_INVALID_PARAMETER);
return ODE_ERROR_NONE;
#include "secure-erase.h"
#include "client.h"
-#include "rmi/secure-erase.h"
+#include "lib/secure-erase.h"
using namespace ode;
ODEContext client;
RET_ON_FAILURE(client.connect() == 0, ODE_ERROR_CONNECTION_REFUSED);
- SecureErase secure = client.createInterface<SecureErase>();
+ SecureEraseClient secure = client.createInterface<SecureEraseClient>();
return secure.clean(name);
}
* See the License for the specific language governing permissions and
* limitations under the License
*/
-#include "rmi/secure-erase.h"
+#include "secure-erase.h"
namespace ode {
-SecureErase::SecureErase(ODEControlContext& ctx) :
+SecureEraseClient::SecureEraseClient(ODEControlContext& ctx) :
context(ctx)
{
}
-SecureErase::~SecureErase()
+SecureEraseClient::~SecureEraseClient()
{
}
-int SecureErase::clean(const std::string& name)
+int SecureEraseClient::clean(const std::string& name)
{
try {
- return context->methodCall<int>("SecureErase::clean", name);
+ return context->methodCall<int>("SecureEraseServer::clean", name);
} catch (runtime::Exception& e) {
return -1;
}
--- /dev/null
+/*
+ * Copyright (c) 2015-2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+#ifndef __SECURE_ERASE_CLIENT_H__
+#define __SECURE_ERASE_CLIENT_H__
+
+#include <string>
+
+#include "rmi/secure-erase.h"
+#include "context.h"
+
+namespace ode {
+
+class SecureEraseClient final: public SecureErase {
+public:
+ SecureEraseClient(ODEControlContext& ctxt);
+ ~SecureEraseClient();
+
+ int clean(const std::string& name);
+
+private:
+ ODEControlContext& context;
+};
+
+} // namespace ode
+#endif // __SECURE_ERASE_CLIENT_H__
#define __EXTENSION_ENCRYPTION_H__
#include <string>
-#include <mutex>
-
-#include <klay/dbus/connection.h>
-
-#include "context.h"
namespace ode {
* such as SD card, used as an extension of the internal memory.
*/
-class ExtensionEncryption final {
+class ExtensionEncryption {
public:
- ExtensionEncryption(ODEControlContext& ctxt);
- ~ExtensionEncryption();
-
- int setMountPassword(const std::string& password);
+ virtual int setMountPassword(const std::string& password) = 0;
- int mount();
- int umount();
+ virtual int mount() = 0;
+ virtual int umount() = 0;
- int format(const std::string& password);
+ virtual int format(const std::string& password) = 0;
- 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);
+ virtual int isPasswordInitialized() = 0;
+ virtual int initPassword(const std::string& password) = 0;
+ virtual int cleanPassword(const std::string& password) = 0;
+ virtual int changePassword(const std::string& oldPW, const std::string& newPW) = 0;
+ virtual int verifyPassword(const std::string& password) = 0;
enum State {
Encrypted = 0x01,
Corrupted = 0x02,
};
- int getState();
-
-private:
- enum Operation {
- ADDED = 0,
- CHANGED,
- REMOVED,
-
- OPERATION_MAX
- };
-
- enum Device {
- MMC = 0,
- MAP,
-
- DEVICE_MAX
- };
-
- enum Request {
- NONE = 0,
- MOUNT,
- UMOUNT
- };
-
- struct DevInfo {
- std::string mntPath;
- std::string fsType;
- std::string sysPath;
- bool mounted;
- int storagedId;
-
- DevInfo() : mounted(false), storagedId(-1) {}
- ~DevInfo() {}
-
- void clear() {
- mntPath.clear();
- fsType.clear();
- sysPath.clear();
- mounted = false;
- storagedId = -1;
- }
- };
-
- void logStoragedEvent(Operation op, Device d);
- void handleDevice(Operation op,
- const std::vector<int> &intparams,
- const std::vector<char*> &strparams);
- void parseVariant(Operation op, dbus::Variant parameters);
- void queryStoraged();
- void subscribeToStoraged();
- void unsubscribeFromStoraged();
-
- bool storagedMount(std::unique_lock<std::mutex> &lock);
- bool storagedUnmount(std::unique_lock<std::mutex> &lock);
-
- int getStatePriv() const;
- bool isInserted() const;
- bool isOpened() const;
- bool isMounted() const;
-
- ODEControlContext& context;
-
- // currently inserted card information, empty if no card:
- DevInfo info[DEVICE_MAX];
-
- dbus::Connection::SubscriptionId subId[OPERATION_MAX];
-
- Request currentReq;
+ virtual int getState() = 0;
};
} // namespace ode
#ifndef __EXTERNAL_ENCRYPTION_H__
#define __EXTERNAL_ENCRYPTION_H__
-#include "context.h"
+#include <string>
namespace ode {
* such as SD card.
*/
-class ExternalEncryption final {
+class ExternalEncryption {
public:
- ExternalEncryption(ODEControlContext& ctxt);
- ~ExternalEncryption();
+ virtual int setMountPassword(const std::string& password) = 0;
- int setMountPassword(const std::string& password);
+ virtual int mount() = 0;
+ virtual int umount() = 0;
- int mount();
- int umount();
+ virtual int encrypt(const std::string& password, unsigned int options) = 0;
+ virtual int decrypt(const std::string& password) = 0;
- int encrypt(const std::string& password, unsigned int options);
- int decrypt(const std::string& password);
+ virtual int recovery() = 0;
- int recovery();
-
- 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);
+ virtual int isPasswordInitialized() = 0;
+ virtual int initPassword(const std::string& password) = 0;
+ virtual int cleanPassword(const std::string& password) = 0;
+ virtual int changePassword(const std::string& oldPW, const std::string& newPW) = 0;
+ virtual int verifyPassword(const std::string& password) = 0;
enum State {
Unencrypted = 0x00,
Corrupted = 0x02,
};
- int getState();
+ virtual int getState() = 0;
enum Option {
OnlyNewFile = 1 << 0,
ExceptForMediaFile = 1 << 1,
};
- unsigned int getSupportedOptions();
-
-private:
- ODEControlContext& context;
+ virtual unsigned int getSupportedOptions() = 0;
};
} // namespace ode
+
#endif // __EXTERNAL_ENCRYPTION_H__
#ifndef __INTERNAL_ENCRYPTION_H__
#define __INTERNAL_ENCRYPTION_H__
-#include "context.h"
+#include <string>
namespace ode {
* This class provides APIs to manage the encryption of internal stroage.
*/
-class InternalEncryption final {
+class InternalEncryption {
public:
- InternalEncryption(ODEControlContext& ctxt);
- ~InternalEncryption();
+ virtual int setMountPassword(const std::string& password) = 0;
- int setMountPassword(const std::string& password);
+ virtual int mount() = 0;
+ virtual int umount() = 0;
- int mount();
- int umount();
+ virtual int encrypt(const std::string& password, unsigned int options) = 0;
+ virtual int decrypt(const std::string& password) = 0;
- int encrypt(const std::string& password, unsigned int options);
- int decrypt(const std::string& password);
+ virtual int recovery() = 0;
- int recovery();
-
- 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);
+ virtual int isPasswordInitialized() = 0;
+ virtual int initPassword(const std::string& password) = 0;
+ virtual int cleanPassword(const std::string& password) = 0;
+ virtual int changePassword(const std::string& oldPW, const std::string& newPW) = 0;
+ virtual int verifyPassword(const std::string& password) = 0;
enum State {
Unencrypted = 0x00,
Corrupted = 0x02,
};
- int getState();
+ virtual int getState() = 0;
enum Option {
IncludeUnusedRegion = 1 << 0,
};
- unsigned int getSupportedOptions();
-
-private:
- ODEControlContext& context;
+ virtual unsigned int getSupportedOptions() = 0;
};
} // namespace ode
+
#endif // __INTERNAL_ENCRYPTION_H__
#ifndef __SECURE_ERASE_H__
#define __SECURE_ERASE_H__
-#include "context.h"
-
namespace ode {
/**
* This class provides APIs to secure actions(erase/clean).
*/
-class SecureErase final {
+class SecureErase {
public:
- SecureErase(ODEControlContext& ctxt);
- ~SecureErase();
-
- int clean(const std::string& name);
-
-private:
- ODEControlContext& context;
+ virtual int clean(const std::string& name) = 0;
};
} // namespace ode
* See the License for the specific language governing permissions and
* limitations under the License
*/
-#include <mutex>
-
#include <unistd.h>
#include <sys/mount.h>
#include "misc.h"
#include "logger.h"
#include "ext4-tool.h"
-#include "engine/encryption/cryptsetup-engine.h"
-#include "key-manager/key-manager.h"
-#include "rmi/extension-encryption.h"
+#include "extension-encryption.h"
#define EXTENSION_NAME_DEF "extension"
namespace {
-typedef CryptsetupEngine EXTENSION_ENGINE;
-
const size_t DEFAULT_KEY_SIZE = 64;
const char *EXTENSION_DEV_PATH = "/dev/mmcblk1p1";
const char *STORAGED_DBUS_OBJECT = "/Org/Tizen/System/Storage/Block/Manager";
const char *STORAGED_DBUS_INTERFACE = "org.tizen.system.storage.BlockManager";
-std::unique_ptr<EXTENSION_ENGINE> engine;
-KeyManager::data mountKey;
-
-std::mutex apiGuard;
-std::mutex stateGuard;
-std::condition_variable storagedCv;
-
bool findKillAndUmount(const std::string &devPath)
{
for(;;) {
} // namsepace
-ExtensionEncryption::ExtensionEncryption(ODEControlContext &ctx) :
+ExtensionEncryptionServer::ExtensionEncryptionServer(ODEControlContext &ctx) :
context(ctx),
currentReq(Request::NONE)
{
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryption::setMountPassword)(std::string));
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryption::mount)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryption::umount)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryption::format)(std::string));
- context.expose(this, "", (int)(ExtensionEncryption::isPasswordInitialized)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryption::initPassword)(std::string));
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryption::cleanPassword)(std::string));
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryption::changePassword)(std::string, std::string));
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryption::verifyPassword)(std::string));
- context.expose(this, "", (int)(ExtensionEncryption::getState)());
-
- context.createNotification("ExtensionEncryption::mount");
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::setMountPassword)(std::string));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::mount)());
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::umount)());
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::format)(std::string));
+ context.expose(this, "", (int)(ExtensionEncryptionServer::isPasswordInitialized)());
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::initPassword)(std::string));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::cleanPassword)(std::string));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::changePassword)(std::string, std::string));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExtensionEncryptionServer::verifyPassword)(std::string));
+ context.expose(this, "", (int)(ExtensionEncryptionServer::getState)());
+
+ context.createNotification("ExtensionEncryptionServer::mount");
// TODO: think about handling more than one card / more than one engine
// it would require global API change to select which card is handled atm
subscribeToStoraged();
}
-ExtensionEncryption::~ExtensionEncryption()
+ExtensionEncryptionServer::~ExtensionEncryptionServer()
{
unsubscribeFromStoraged();
}
-int ExtensionEncryption::setMountPassword(const std::string& password)
+int ExtensionEncryptionServer::setMountPassword(const std::string& password)
{
std::lock_guard<std::mutex> guardLock(apiGuard);
return 0;
}
-int ExtensionEncryption::mount()
+int ExtensionEncryptionServer::mount()
{
std::lock_guard<std::mutex> guardLock(apiGuard);
std::unique_lock<std::mutex> stateLock(stateGuard);
}
}
- context.notify("ExtensionEncryption::mount");
+ context.notify("ExtensionEncryptionServer::mount");
return 0;
}
-int ExtensionEncryption::umount()
+int ExtensionEncryptionServer::umount()
{
std::lock_guard<std::mutex> guardLock(apiGuard);
std::unique_lock<std::mutex> stateLock(stateGuard);
return 0;
}
-int ExtensionEncryption::format(const std::string &password)
+int ExtensionEncryptionServer::format(const std::string &password)
{
int status = 0;
std::condition_variable workerCv;
return 0;
}
-int ExtensionEncryption::isPasswordInitialized()
+int ExtensionEncryptionServer::isPasswordInitialized()
{
std::lock_guard<std::mutex> guardLock(apiGuard);
return 0;
}
-int ExtensionEncryption::initPassword(const std::string& password)
+int ExtensionEncryptionServer::initPassword(const std::string& password)
{
std::lock_guard<std::mutex> guardLock(apiGuard);
return 0;
}
-int ExtensionEncryption::cleanPassword(const std::string& password)
+int ExtensionEncryptionServer::cleanPassword(const std::string& password)
{
std::lock_guard<std::mutex> guardLock(apiGuard);
return 0;
}
-int ExtensionEncryption::changePassword(const std::string &oldPassword,
+int ExtensionEncryptionServer::changePassword(const std::string &oldPassword,
const std::string &newPassword)
{
std::lock_guard<std::mutex> guardLock(apiGuard);
return 0;
}
-int ExtensionEncryption::verifyPassword(const std::string& password)
+int ExtensionEncryptionServer::verifyPassword(const std::string& password)
{
std::lock_guard<std::mutex> guardLock(apiGuard);
return 0;
}
-int ExtensionEncryption::getState()
+int ExtensionEncryptionServer::getState()
{
std::lock_guard<std::mutex> guardLock(apiGuard);
std::unique_lock<std::mutex> stateLock(stateGuard);
return getStatePriv();
}
-void ExtensionEncryption::logStoragedEvent(Operation op, Device d)
+void ExtensionEncryptionServer::logStoragedEvent(Operation op, Device d)
{
DEBUG(SINK, "Storaged event:");
DEBUG(SINK, " ID: " + std::to_string(info[d].storagedId));
}
-void ExtensionEncryption::handleDevice(Operation op,
- const std::vector<int> &intparams,
- const std::vector<char*> &strparams)
+void ExtensionEncryptionServer::handleDevice(Operation op,
+ const std::vector<int> &intparams,
+ const std::vector<char*> &strparams)
{
Device d;
}
}
-void ExtensionEncryption::parseVariant(Operation op, dbus::Variant parameters)
+void ExtensionEncryptionServer::parseVariant(Operation op, dbus::Variant parameters)
{
std::vector<int> intparams(6);
std::vector<char*> strparams(7);
handleDevice(op, intparams, strparams);
}
-void ExtensionEncryption::queryStoraged()
+void ExtensionEncryptionServer::queryStoraged()
{
INFO(SINK, "Querying the storaged for devices...");
}
}
-void ExtensionEncryption::subscribeToStoraged()
+void ExtensionEncryptionServer::subscribeToStoraged()
{
dbus::Connection &systemDBus = dbus::Connection::getSystem();
auto subscribe = [&systemDBus, this](Operation op, const std::string &method) {
dbus::Connection::SignalCallback callback =
- std::bind(&ExtensionEncryption::parseVariant,
+ std::bind(&ExtensionEncryptionServer::parseVariant,
this,
op,
std::placeholders::_1);
subscribe(Operation::REMOVED, "DeviceRemoved");
}
-void ExtensionEncryption::unsubscribeFromStoraged()
+void ExtensionEncryptionServer::unsubscribeFromStoraged()
{
dbus::Connection &systemDBus = dbus::Connection::getSystem();
systemDBus.unsubscribeSignal(subId[Operation::REMOVED]);
}
-bool ExtensionEncryption::storagedMount(std::unique_lock<std::mutex> &lock)
+bool ExtensionEncryptionServer::storagedMount(std::unique_lock<std::mutex> &lock)
{
currentReq = Request::MOUNT;
return true;
}
-bool ExtensionEncryption::storagedUnmount(std::unique_lock<std::mutex> &lock)
+bool ExtensionEncryptionServer::storagedUnmount(std::unique_lock<std::mutex> &lock)
{
currentReq = Request::UMOUNT;
return true;
}
-int ExtensionEncryption::getStatePriv() const
+int ExtensionEncryptionServer::getStatePriv() const
{
if (!isInserted()) {
ERROR(SINK, "Cannot check state, card not inserted");
return State::Corrupted;
}
-bool ExtensionEncryption::isInserted() const
+bool ExtensionEncryptionServer::isInserted() const
{
return info[Device::MMC].storagedId >= 0;
}
-bool ExtensionEncryption::isOpened() const
+bool ExtensionEncryptionServer::isOpened() const
{
return info[Device::MAP].storagedId >= 0;
}
-bool ExtensionEncryption::isMounted() const
+bool ExtensionEncryptionServer::isMounted() const
{
return info[Device::MAP].mounted;
}
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+#ifndef __EXTENSION_ENCRYPTION_SERVER_H__
+#define __EXTENSION_ENCRYPTION_SERVER_H__
+
+#include <string>
+#include <mutex>
+#include <memory>
+#include <condition_variable>
+
+#include "context.h"
+#include "rmi/extension-encryption.h"
+#include "key-manager/key-manager.h"
+#include "engine/encryption/cryptsetup-engine.h"
+
+namespace ode {
+
+typedef CryptsetupEngine EXTENSION_ENGINE;
+
+class ExtensionEncryptionServer final: public ExtensionEncryption {
+public:
+ ExtensionEncryptionServer(ODEControlContext& ctxt);
+ ~ExtensionEncryptionServer();
+
+ int setMountPassword(const std::string& password);
+
+ int mount();
+ int umount();
+
+ int format(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 getState();
+
+private:
+ enum Operation {
+ ADDED = 0,
+ CHANGED,
+ REMOVED,
+
+ OPERATION_MAX
+ };
+
+ enum Device {
+ MMC = 0,
+ MAP,
+
+ DEVICE_MAX
+ };
+
+ enum Request {
+ NONE = 0,
+ MOUNT,
+ UMOUNT
+ };
+
+ struct DevInfo {
+ std::string mntPath;
+ std::string fsType;
+ std::string sysPath;
+ bool mounted;
+ int storagedId;
+
+ DevInfo() : mounted(false), storagedId(-1) {}
+ ~DevInfo() {}
+
+ void clear() {
+ mntPath.clear();
+ fsType.clear();
+ sysPath.clear();
+ mounted = false;
+ storagedId = -1;
+ }
+ };
+
+ void logStoragedEvent(Operation op, Device d);
+ void handleDevice(Operation op,
+ const std::vector<int> &intparams,
+ const std::vector<char*> &strparams);
+
+ void parseVariant(Operation op, dbus::Variant parameters);
+ void queryStoraged();
+ void subscribeToStoraged();
+ void unsubscribeFromStoraged();
+
+ bool storagedMount(std::unique_lock<std::mutex> &lock);
+ bool storagedUnmount(std::unique_lock<std::mutex> &lock);
+
+ int getStatePriv() const;
+ bool isInserted() const;
+ bool isOpened() const;
+ bool isMounted() const;
+
+ ODEControlContext& context;
+
+ // currently inserted card information, empty if no card:
+ DevInfo info[DEVICE_MAX];
+
+ dbus::Connection::SubscriptionId subId[OPERATION_MAX];
+
+ Request currentReq;
+
+ std::unique_ptr<EXTENSION_ENGINE> engine;
+ KeyManager::data mountKey;
+
+ std::mutex apiGuard;
+ std::mutex stateGuard;
+ std::condition_variable storagedCv;
+};
+
+} // namespace ode
+
+#endif // __EXTENSION_ENCRYPTION_SERVER_H__
#include "launchpad.h"
#include "app-bundle.h"
#include "progress-bar.h"
-#include "engine/encryption/ecryptfs-engine.h"
-#include "key-manager/key-manager.h"
-#include "rmi/external-encryption.h"
+#include "external-encryption.h"
#define EXTERNAL_PATH "/opt/media/SDCardA1"
#define EXTERNAL_STATE_VCONF_KEY VCONFKEY_SDE_CRYPTO_STATE
namespace {
-typedef EcryptfsEngine EXTERNAL_ENGINE;
-
-std::unique_ptr<EXTERNAL_ENGINE> engine;
-KeyManager::data mountKey;
bool isBootCompleted = false;
void externalCallback(dbus::Variant parameters)
} // namsepace
-ExternalEncryption::ExternalEncryption(ODEControlContext &ctx) :
+ExternalEncryptionServer::ExternalEncryptionServer(ODEControlContext &ctx) :
context(ctx)
{
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryption::setMountPassword)(std::string));
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryption::mount)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryption::umount)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryption::encrypt)(std::string, unsigned int));
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryption::decrypt)(std::string));
- context.expose(this, "", (int)(ExternalEncryption::isPasswordInitialized)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryption::initPassword)(std::string));
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryption::cleanPassword)(std::string));
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryption::changePassword)(std::string, std::string));
- context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryption::verifyPassword)(std::string));
- context.expose(this, "", (int)(ExternalEncryption::getState)());
- context.expose(this, "", (unsigned int)(ExternalEncryption::getSupportedOptions)());
-
- context.createNotification("ExternalEncryption::mount");
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::setMountPassword)(std::string));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::mount)());
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::umount)());
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::encrypt)(std::string, unsigned int));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::decrypt)(std::string));
+ context.expose(this, "", (int)(ExternalEncryptionServer::isPasswordInitialized)());
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::initPassword)(std::string));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::cleanPassword)(std::string));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::changePassword)(std::string, std::string));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(ExternalEncryptionServer::verifyPassword)(std::string));
+ context.expose(this, "", (int)(ExternalEncryptionServer::getState)());
+ context.expose(this, "", (unsigned int)(ExternalEncryptionServer::getSupportedOptions)());
+
+ context.createNotification("ExternalEncryptionServer::mount");
engine.reset(new EXTERNAL_ENGINE(
EXTERNAL_PATH, EXTERNAL_PATH,
externalAddEventReceiver();
}
-ExternalEncryption::~ExternalEncryption()
+ExternalEncryptionServer::~ExternalEncryptionServer()
{
}
-
-int ExternalEncryption::setMountPassword(const std::string& password)
+int ExternalEncryptionServer::setMountPassword(const std::string& password)
{
KeyManager::data pwData(password.begin(), password.end());
KeyManager keyManager(engine->getKeyMeta());
return -2;
}
- ode::mountKey = keyManager.getMasterKey(pwData);
+ mountKey = keyManager.getMasterKey(pwData);
return 0;
}
-int ExternalEncryption::mount()
+int ExternalEncryptionServer::mount()
{
if (getState() != State::Encrypted) {
return -1;
engine->mount(mountKey, getOptions());
mountKey.clear();
- context.notify("ExternalEncryption::mount");
+ context.notify("ExternalEncryptionServer::mount");
return 0;
}
-int ExternalEncryption::umount()
+int ExternalEncryptionServer::umount()
{
if (getState() != State::Encrypted) {
return -1;
return 0;
}
-int ExternalEncryption::encrypt(const std::string &password, unsigned int options)
+int ExternalEncryptionServer::encrypt(const std::string &password, unsigned int options)
{
if (getState() != State::Unencrypted) {
return -1;
setOptions(options & getSupportedOptions());
INFO(SINK, "Encryption completed");
::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "encrypted");
- context.notify("ExternalEncryption::mount");
+ context.notify("ExternalEncryptionServer::mount");
INFO(SINK, "Sync disk...");
sync();
} catch (runtime::Exception &e) {
return 0;
}
-int ExternalEncryption::decrypt(const std::string &password)
+int ExternalEncryptionServer::decrypt(const std::string &password)
{
if (getState() != State::Encrypted) {
return -1;
return 0;
}
-int ExternalEncryption::recovery()
+int ExternalEncryptionServer::recovery()
{
if (getState() == State::Unencrypted) {
return -1;
return 0;
}
-int ExternalEncryption::isPasswordInitialized()
+int ExternalEncryptionServer::isPasswordInitialized()
{
if (engine->isKeyMetaSet()) {
return 1;
return 0;
}
-int ExternalEncryption::initPassword(const std::string& password)
+int ExternalEncryptionServer::initPassword(const std::string& password)
{
KeyManager::data pwData(password.begin(), password.end());
KeyManager keyManager;
return 0;
}
-int ExternalEncryption::cleanPassword(const std::string& password)
+int ExternalEncryptionServer::cleanPassword(const std::string& password)
{
KeyManager::data pwData(password.begin(), password.end());
KeyManager keyManager(engine->getKeyMeta());
return 0;
}
-int ExternalEncryption::changePassword(const std::string &oldPassword,
+int ExternalEncryptionServer::changePassword(const std::string &oldPassword,
const std::string &newPassword)
{
KeyManager::data oldPwData(oldPassword.begin(), oldPassword.end());
return 0;
}
-int ExternalEncryption::verifyPassword(const std::string& password)
+int ExternalEncryptionServer::verifyPassword(const std::string& password)
{
KeyManager::data pwData(password.begin(), password.end());
KeyManager keyManager(engine->getKeyMeta());
return 0;
}
-int ExternalEncryption::getState()
+int ExternalEncryptionServer::getState()
{
char *value = ::vconf_get_str(EXTERNAL_STATE_VCONF_KEY);
if (value == NULL) {
return 0;
}
-unsigned int ExternalEncryption::getSupportedOptions()
+unsigned int ExternalEncryptionServer::getSupportedOptions()
{
return engine->getSupportedOptions();
}
--- /dev/null
+/*
+ * Copyright (c) 2015-2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+#ifndef __EXTERNAL_ENCRYPTION_SERVER_H__
+#define __EXTERNAL_ENCRYPTION_SERVER_H__
+
+#include <string>
+#include <mutex>
+#include <memory>
+
+#include <klay/dbus/connection.h>
+
+#include "context.h"
+#include "rmi/external-encryption.h"
+#include "key-manager/key-manager.h"
+#include "engine/encryption/ecryptfs-engine.h"
+
+namespace ode {
+
+typedef EcryptfsEngine EXTERNAL_ENGINE;
+
+class ExternalEncryptionServer final: public ExternalEncryption {
+public:
+ ExternalEncryptionServer(ODEControlContext& ctxt);
+ ~ExternalEncryptionServer();
+
+ int setMountPassword(const std::string& password);
+
+ int mount();
+ int umount();
+
+ int encrypt(const std::string& password, unsigned int options);
+ int decrypt(const std::string& password);
+
+ int recovery();
+
+ 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 getState();
+
+ unsigned int getSupportedOptions();
+
+private:
+ ODEControlContext& context;
+
+ std::unique_ptr<EXTERNAL_ENGINE> engine;
+ KeyManager::data mountKey;
+};
+
+} // namespace ode
+
+#endif // __EXTERNAL_ENCRYPTION_SERVER_H__
#include "misc.h"
#include "logger.h"
#include "progress-bar.h"
-#include "engine/encryption/dmcrypt-engine.h"
-#include "key-manager/key-manager.h"
-#include "rmi/internal-encryption.h"
+#include "internal-encryption.h"
namespace ode {
namespace {
-typedef DMCryptEngine INTERNAL_ENGINE;
-
const char *INTERNAL_DEV_PATH = "/dev/disk/by-partlabel";
const char *INTERNAL_DEV_NAME = "USER";
const char *INTERNAL_PATH = "/opt/usr";
"com.samsung.factoryreset.start.setting"
};
-std::unique_ptr<INTERNAL_ENGINE> engine;
-KeyManager::data mountKey;
-
std::string findDevPath()
{
std::string source = INTERNAL_DEV_PATH + std::string("/") + INTERNAL_DEV_NAME;
}
-InternalEncryption::InternalEncryption(ODEControlContext& ctx) :
+InternalEncryptionServer::InternalEncryptionServer(ODEControlContext& ctx) :
context(ctx)
{
- context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryption::setMountPassword)(std::string));
- context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryption::mount)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryption::umount)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryption::encrypt)(std::string, unsigned int));
- context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryption::decrypt)(std::string));
- context.expose(this, "", (int)(InternalEncryption::isPasswordInitialized)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryption::initPassword)(std::string));
- context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryption::cleanPassword)(std::string));
- context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryption::changePassword)(std::string, std::string));
- context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryption::verifyPassword)(std::string));
- context.expose(this, "", (int)(InternalEncryption::getState)());
- context.expose(this, "", (unsigned int)(InternalEncryption::getSupportedOptions)());
-
- context.createNotification("InternalEncryption::mount");
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::setMountPassword)(std::string));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::mount)());
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::umount)());
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::encrypt)(std::string, unsigned int));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::decrypt)(std::string));
+ context.expose(this, "", (int)(InternalEncryptionServer::isPasswordInitialized)());
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::initPassword)(std::string));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::cleanPassword)(std::string));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::changePassword)(std::string, std::string));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(InternalEncryptionServer::verifyPassword)(std::string));
+ context.expose(this, "", (int)(InternalEncryptionServer::getState)());
+ context.expose(this, "", (unsigned int)(InternalEncryptionServer::getSupportedOptions)());
+
+ context.createNotification("InternalEncryptionServer::mount");
std::string source = findDevPath();
));
}
-InternalEncryption::~InternalEncryption()
+InternalEncryptionServer::~InternalEncryptionServer()
{
}
-int InternalEncryption::setMountPassword(const std::string& password)
+int InternalEncryptionServer::setMountPassword(const std::string& password)
{
KeyManager::data pwData(password.begin(), password.end());
KeyManager keyManager(engine->getKeyMeta());
return -2;
}
- ode::mountKey = keyManager.getMasterKey(pwData);
+ mountKey = keyManager.getMasterKey(pwData);
return 0;
}
-int InternalEncryption::mount()
+int InternalEncryptionServer::mount()
{
if (getState() != State::Encrypted) {
return -1;
engine->mount(mountKey, getOptions());
mountKey.clear();
- context.notify("InternalEncryption::mount");
+ context.notify("InternalEncryptionServer::mount");
runtime::File("/tmp/.lazy_mount").create(O_WRONLY);
runtime::File("/tmp/.unlock_mnt").create(O_WRONLY);
return 0;
}
-int InternalEncryption::umount()
+int InternalEncryptionServer::umount()
{
if (getState() != State::Encrypted) {
return -1;
return 0;
}
-int InternalEncryption::encrypt(const std::string& password, unsigned int options)
+int InternalEncryptionServer::encrypt(const std::string& password, unsigned int options)
{
if (getState() != State::Unencrypted) {
return -1;
INFO(SINK, "Encryption completed");
::vconf_set_str(VCONFKEY_ODE_CRYPTO_STATE, "encrypted");
- context.notify("InternalEncryption::mount");
+ context.notify("InternalEncryptionServer::mount");
INFO(SINK, "Syncing disk and rebooting...");
::sync();
return 0;
}
-int InternalEncryption::decrypt(const std::string& password)
+int InternalEncryptionServer::decrypt(const std::string& password)
{
if (getState() != State::Encrypted) {
return -1;
return 0;
}
-int InternalEncryption::recovery()
+int InternalEncryptionServer::recovery()
{
if (getState() != State::Unencrypted) {
return -1;
return 0;
}
-int InternalEncryption::isPasswordInitialized()
+int InternalEncryptionServer::isPasswordInitialized()
{
if (engine->isKeyMetaSet()) {
return 1;
return 0;
}
-int InternalEncryption::initPassword(const std::string& password)
+int InternalEncryptionServer::initPassword(const std::string& password)
{
KeyManager::data pwData(password.begin(), password.end());
KeyManager keyManager;
return 0;
}
-int InternalEncryption::cleanPassword(const std::string& password)
+int InternalEncryptionServer::cleanPassword(const std::string& password)
{
KeyManager::data pwData(password.begin(), password.end());
KeyManager keyManager(engine->getKeyMeta());
return 0;
}
-int InternalEncryption::changePassword(const std::string& oldPassword,
+int InternalEncryptionServer::changePassword(const std::string& oldPassword,
const std::string& newPassword)
{
KeyManager::data oldPwData(oldPassword.begin(), oldPassword.end());
return 0;
}
-int InternalEncryption::verifyPassword(const std::string& password)
+int InternalEncryptionServer::verifyPassword(const std::string& password)
{
KeyManager::data pwData(password.begin(), password.end());
KeyManager keyManager(engine->getKeyMeta());
return 0;
}
-int InternalEncryption::getState()
+int InternalEncryptionServer::getState()
{
char *value = ::vconf_get_str(VCONFKEY_ODE_CRYPTO_STATE);
if (value == NULL) {
return 0;
}
-unsigned int InternalEncryption::getSupportedOptions()
+unsigned int InternalEncryptionServer::getSupportedOptions()
{
return engine->getSupportedOptions();
}
--- /dev/null
+/*
+ * Copyright (c) 2015-2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+#ifndef __INTERNAL_ENCRYPTION_SERVER_H__
+#define __INTERNAL_ENCRYPTION_SERVER_H__
+
+#include <string>
+#include <memory>
+
+#include "context.h"
+#include "rmi/internal-encryption.h"
+#include "key-manager/key-manager.h"
+#include "engine/encryption/dmcrypt-engine.h"
+
+namespace ode {
+
+typedef DMCryptEngine INTERNAL_ENGINE;
+
+class InternalEncryptionServer final: public InternalEncryption {
+public:
+ InternalEncryptionServer(ODEControlContext& ctxt);
+ ~InternalEncryptionServer();
+
+ int setMountPassword(const std::string& password);
+
+ int mount();
+ int umount();
+
+ int encrypt(const std::string& password, unsigned int options);
+ int decrypt(const std::string& password);
+
+ int recovery();
+
+ 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 getState();
+
+ unsigned int getSupportedOptions();
+
+private:
+ ODEControlContext& context;
+
+ std::unique_ptr<INTERNAL_ENGINE> engine;
+ KeyManager::data mountKey;
+};
+
+} // namespace ode
+
+#endif // __INTERNAL_ENCRYPTION_SERVER_H__
#include <mntent.h>
#include "ext4-tool.h"
-#include "engine/erase/erase-engine.h"
-#include "rmi/secure-erase.h"
-#define ERASE_ENGINE EraseEngine
-#define PRIVILEGE_PLATFORM "http://tizen.org/privilege/internal/default/platform"
+#include "secure-erase.h"
namespace ode {
namespace {
typedef std::unordered_map<std::string, std::string> DeviceList;
-std::unique_ptr<ERASE_ENGINE> engine;
+const char *PRIVILEGE_PLATFORM = "http://tizen.org/privilege/internal/default/platform";
std::string findDevPath(const std::string &mntPath)
{
}
} /* namespace */
-SecureErase::SecureErase(ODEControlContext &ctx) :
+SecureEraseServer::SecureEraseServer(ODEControlContext &ctx) :
context(ctx)
{
- context.expose(this, PRIVILEGE_PLATFORM, (int)(SecureErase::clean)(std::string));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(SecureEraseServer::clean)(std::string));
engine.reset(new ERASE_ENGINE(ProgressBar([](int v) {
::vconf_set_str(VCONFKEY_ODE_ERASE_PROGRESS, std::to_string(v).c_str());
);
}
-SecureErase::~SecureErase()
+SecureEraseServer::~SecureEraseServer()
{
}
-int SecureErase::clean(const std::string &name)
+int SecureEraseServer::clean(const std::string &name)
{
auto cleanWorker = [name, this]() {
try {
--- /dev/null
+/*
+ * Copyright (c) 2015-2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+#ifndef __SECURE_ERASE_SERVER_H__
+#define __SECURE_ERASE_SERVER_H__
+
+#include <string>
+#include <memory>
+
+#include "context.h"
+#include "rmi/secure-erase.h"
+#include "engine/erase/mmc-engine.h"
+
+namespace ode {
+
+typedef MMCEraseEngine ERASE_ENGINE;
+
+class SecureEraseServer final: public SecureErase {
+public:
+ SecureEraseServer(ODEControlContext& ctxt);
+ ~SecureEraseServer();
+
+ int erase(const std::string& name);
+ int clean(const std::string& name);
+
+private:
+ ODEControlContext& context;
+
+ std::unique_ptr<ERASE_ENGINE> engine;
+};
+
+} // namespace ode
+#endif // __SECURE_ERASE_SERVER_H__
#include <klay/audit/dlog-sink.h>
#include "logger.h"
-#include "rmi/secure-erase.h"
-#include "rmi/internal-encryption.h"
-#include "rmi/external-encryption.h"
-#include "rmi/extension-encryption.h"
+#include "secure-erase.h"
+#include "internal-encryption.h"
+#include "external-encryption.h"
+#include "extension-encryption.h"
#include "key-manager/key-generator.h"
#include "server.h"
const std::string ODE_MANAGER_ADDRESS = "/tmp/.ode.sock";
-std::unique_ptr<ode::SecureErase> secureErase;
-std::unique_ptr<ode::InternalEncryption> internalEncryption;
-std::unique_ptr<ode::ExternalEncryption> externalEncryption;
-std::unique_ptr<ode::ExtensionEncryption> extensionEncryption;
+std::unique_ptr<ode::SecureEraseServer> secureErase;
+std::unique_ptr<ode::InternalEncryptionServer> internalEncryption;
+std::unique_ptr<ode::ExternalEncryptionServer> externalEncryption;
+std::unique_ptr<ode::ExtensionEncryptionServer> extensionEncryption;
std::unique_ptr<audit::DlogLogSink> _sink = nullptr;
} // namespace
service->expose(this, "", (runtime::FileDescriptor)(Server::registerNotificationSubscriber)(std::string));
service->expose(this, "", (int)(Server::unregisterNotificationSubscriber)(std::string, int));
- secureErase.reset(new ode::SecureErase(*this));
- internalEncryption.reset(new ode::InternalEncryption(*this));
- externalEncryption.reset(new ode::ExternalEncryption(*this));
- extensionEncryption.reset(new ode::ExtensionEncryption(*this));
+ secureErase.reset(new ode::SecureEraseServer(*this));
+ internalEncryption.reset(new ode::InternalEncryptionServer(*this));
+ externalEncryption.reset(new ode::ExternalEncryptionServer(*this));
+ extensionEncryption.reset(new ode::ExtensionEncryptionServer(*this));
ode::KeyGenerator::init();
}