Skip to content

Commit 7a71f44

Browse files
authored
RDK-55149 : Added Cryptography plugin. (rdkcentral#6305)
* RDK-57366 : Added Cryptography plugin. * Added VaultId(). Code cleanup. * Renamed plugin. * RDK-57366 : Used Svalbard plugin sources from R4_4 branch. * Added changelog.
1 parent 857eff8 commit 7a71f44

11 files changed

+537
-0
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,10 @@ if(PLUGIN_PERFORMANCEMETRICS)
377377
add_subdirectory(PerformanceMetrics)
378378
endif()
379379

380+
if(PLUGIN_CRYPTOGRAPHY)
381+
add_subdirectory(Cryptography)
382+
endif()
383+
380384
if(PLUGIN_UNIFIEDCASMANAGEMENT)
381385
add_subdirectory(UnifiedCASManagement)
382386
endif()

Cryptography/CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Changelog
2+
3+
All notable changes to this RDK Service will be documented in this file.
4+
5+
* Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG.
6+
7+
* Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels:
8+
* **Added** for new features.
9+
* **Changed** for changes in existing functionality.
10+
* **Deprecated** for soon-to-be removed features.
11+
* **Removed** for now removed features.
12+
* **Fixed** for any bug fixes.
13+
* **Security** in case of vulnerabilities.
14+
15+
* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development.
16+
17+
* For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README.
18+
19+
## [1.0.0] - 2025-06-27
20+
### Added
21+
- Add CHANGELOG
22+
23+
### Change
24+
- Reset API version to 1.0.0
25+
- Change README to inform how to update changelog and API version

Cryptography/CMakeLists.txt

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# If not stated otherwise in this file or this component's LICENSE file the
2+
# following copyright and licenses apply:
3+
#
4+
# Copyright 2020 Metrological
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
project(CryptographyExtAccess)
19+
20+
cmake_minimum_required(VERSION 3.3)
21+
22+
find_package(WPEFramework)
23+
24+
project_version(1.0.0)
25+
26+
set(MODULE_NAME ${NAMESPACE}${PROJECT_NAME})
27+
28+
message("Setup ${MODULE_NAME} v${PROJECT_VERSION}")
29+
30+
set(PLUGIN_CRYPTOGRAPHYEXTACCESS_AUTOSTART "true" CACHE STRING "Automatically start CryptographyExtAccess plugin")
31+
set(PLUGIN_CRYPTOGRAPHYEXTACCESS_MODE "Off" CACHE STRING "Controls if the plugin should run in its own process, in process or remote.")
32+
33+
# deprecated/legacy flags support
34+
if(PLUGIN_CRYPTOGRAPHYEXTACCESS_OUTOFPROCESS STREQUAL "true")
35+
set(PLUGIN_CRYPTOGRAPHYEXTACCESS_MODE "Local" CACHE STRING "Process mode" FORCE)
36+
unset(PLUGIN_CRYPTOGRAPHYEXTACCESS_OUTOFPROCESS CACHE)
37+
endif()
38+
39+
find_package(${NAMESPACE}Plugins REQUIRED)
40+
find_package(${NAMESPACE}Definitions REQUIRED)
41+
find_package(CompileSettingsDebug CONFIG REQUIRED)
42+
find_package(${NAMESPACE}Cryptography CONFIG REQUIRED)
43+
44+
find_package(${NAMESPACE}Definitions REQUIRED)
45+
46+
add_library(${MODULE_NAME} SHARED
47+
Module.cpp
48+
CryptographyExtAccess.cpp
49+
CryptographyRPC.cpp
50+
)
51+
52+
set_target_properties(${MODULE_NAME} PROPERTIES
53+
CXX_STANDARD 11
54+
CXX_STANDARD_REQUIRED YES)
55+
56+
target_link_libraries(${MODULE_NAME}
57+
PRIVATE
58+
CompileSettingsDebug::CompileSettingsDebug
59+
${NAMESPACE}Plugins::${NAMESPACE}Plugins
60+
${NAMESPACE}Definitions::${NAMESPACE}Definitions
61+
${NAMESPACE}Cryptography::${NAMESPACE}Cryptography
62+
)
63+
64+
install(TARGETS ${MODULE_NAME}
65+
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)
66+
67+
write_config()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
autostart = "@PLUGIN_CRYPTOGRAPHYEXTACCESS_AUTOSTART@"
2+
3+
callsign = "org.rdk.Cryptography"
4+
5+
configuration = JSON()
6+
7+
rootobject = JSON()
8+
rootobject.add("mode", "@PLUGIN_CRYPTOGRAPHYEXTACCESS_MODE@")
9+
rootobject.add("user", "@PLUGIN_CRYPTOGRAPHYEXTACCESS_USER@")
10+
rootobject.add("group", "@PLUGIN_CRYPTOGRAPHYEXTACCESS_GROUP@")
11+
12+
configuration.add("root", rootobject)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
set(autostart ${PLUGIN_CRYPTOGRAPHYEXTACCESS_AUTOSTART})
2+
3+
map()
4+
kv(mode ${PLUGIN_CRYPTOGRAPHYEXTACCESS_MODE})
5+
if(PLUGIN_CRYPTOGRAPHYEXTACCESS_USER)
6+
kv(user ${PLUGIN_CRYPTOGRAPHYEXTACCESS_USER})
7+
endif()
8+
if(PLUGIN_CRYPTOGRAPHYEXTACCESS_GROUP)
9+
kv(group ${PLUGIN_CRYPTOGRAPHYEXTACCESS_GROUP})
10+
endif()
11+
end()
12+
ans(rootobject)
13+
map_append(${configuration} root ${rootobject})
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* If not stated otherwise in this file or this component's LICENSE file the
3+
* following copyright and licenses apply:
4+
*
5+
* Copyright 2020 Metrological
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
#include "CryptographyExtAccess.h"
21+
22+
#define API_VERSION_NUMBER_MAJOR 1
23+
#define API_VERSION_NUMBER_MINOR 0
24+
#define API_VERSION_NUMBER_PATCH 0
25+
26+
namespace WPEFramework {
27+
namespace Plugin {
28+
29+
namespace {
30+
31+
static Metadata<CryptographyExtAccess> metadata(
32+
// Version
33+
API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH,
34+
// Preconditions
35+
{ subsystem::PLATFORM },
36+
// Terminations
37+
{},
38+
// Controls
39+
{}
40+
);
41+
}
42+
43+
44+
const string CryptographyExtAccess::Initialize(PluginHost::IShell* service) /* override */
45+
{
46+
string message;
47+
48+
ASSERT(service != nullptr);
49+
ASSERT(_service == nullptr);
50+
ASSERT(_implementation == nullptr);
51+
ASSERT(_connectionId == 0);
52+
53+
_service = service;
54+
_service->AddRef();
55+
56+
_service->Register(&_notification);
57+
_implementation = _service->Root<Exchange::IConfiguration>(_connectionId, Core::infinite, _T("CryptographyImplementation"));
58+
59+
if (_implementation == nullptr) {
60+
message = _T("CryptographyExtAccess could not be instantiated.");
61+
} else {
62+
printf("CryptographyExtAccess - Connection Id - %u\n",_connectionId);
63+
_implementation->Configure(_service);
64+
}
65+
66+
return message;
67+
}
68+
69+
void CryptographyExtAccess::Deinitialize(PluginHost::IShell* service) /* override */
70+
{
71+
if (_service != nullptr) {
72+
ASSERT(_service == service);
73+
74+
_service->Unregister(&_notification);
75+
76+
if (_implementation != nullptr) {
77+
78+
RPC::IRemoteConnection* connection(_service->RemoteConnection(_connectionId));
79+
printf("CryptographyExtAccess - Remote Connection - %p\n",connection);
80+
81+
VARIABLE_IS_NOT_USED uint32_t result = _implementation->Release();
82+
_implementation = nullptr;
83+
ASSERT(result == Core::ERROR_DESTRUCTION_SUCCEEDED);
84+
85+
if (connection != nullptr) {
86+
TRACE(Trace::Error, (_T("CryptographyExtAccess is not properly destructed. %d"), _connectionId));
87+
88+
connection->Terminate();
89+
connection->Release();
90+
}
91+
}
92+
93+
_connectionId = 0;
94+
_service->Release();
95+
_service = nullptr;
96+
}
97+
98+
}
99+
100+
string CryptographyExtAccess::Information() const /* override */
101+
{
102+
return string();
103+
}
104+
105+
void CryptographyExtAccess::Deactivated(RPC::IRemoteConnection* connection)
106+
{
107+
if (connection->Id() == _connectionId) {
108+
109+
ASSERT(_service != nullptr);
110+
111+
Core::IWorkerPool::Instance().Submit(PluginHost::IShell::Job::Create(_service,
112+
PluginHost::IShell::DEACTIVATED,
113+
PluginHost::IShell::FAILURE));
114+
}
115+
}
116+
} // namespace Plugin
117+
} // namespace WPEFramework
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* If not stated otherwise in this file or this component's LICENSE file the
3+
* following copyright and licenses apply:
4+
*
5+
* Copyright 2020 Metrological
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
#pragma once
21+
22+
#include "Module.h"
23+
#include <cryptography/cryptography.h>
24+
#include <interfaces/IConfiguration.h>
25+
26+
namespace WPEFramework {
27+
namespace Plugin {
28+
29+
class CryptographyExtAccess : public PluginHost::IPlugin {
30+
private:
31+
class Notification : public RPC::IRemoteConnection::INotification {
32+
public:
33+
Notification() = delete;
34+
Notification(const Notification&) = delete;
35+
Notification& operator=(const Notification&) = delete;
36+
37+
explicit Notification(CryptographyExtAccess& parent)
38+
: _parent(parent) {
39+
}
40+
~Notification() override = default;
41+
42+
public:
43+
void Activated(RPC::IRemoteConnection* /* connection */) override {
44+
}
45+
virtual void Deactivated(RPC::IRemoteConnection* connection) override {
46+
_parent.Deactivated(connection);
47+
}
48+
void Terminated(RPC::IRemoteConnection* /* connection */) override {
49+
}
50+
51+
BEGIN_INTERFACE_MAP(Notification)
52+
INTERFACE_ENTRY(RPC::IRemoteConnection::INotification)
53+
END_INTERFACE_MAP
54+
55+
private:
56+
CryptographyExtAccess& _parent;
57+
};
58+
59+
public:
60+
CryptographyExtAccess(const CryptographyExtAccess&) = delete;
61+
CryptographyExtAccess& operator=(const CryptographyExtAccess&) = delete;
62+
63+
PUSH_WARNING(DISABLE_WARNING_THIS_IN_MEMBER_INITIALIZER_LIST)
64+
CryptographyExtAccess()
65+
: _connectionId(0)
66+
, _service(nullptr)
67+
, _implementation(nullptr)
68+
, _notification(*this) {
69+
}
70+
POP_WARNING()
71+
~CryptographyExtAccess() override = default;
72+
73+
BEGIN_INTERFACE_MAP(CryptographyExtAccess)
74+
INTERFACE_ENTRY(PluginHost::IPlugin)
75+
END_INTERFACE_MAP
76+
77+
public:
78+
// IPlugin methods
79+
// -------------------------------------------------------------------------------------------------------
80+
const string Initialize(PluginHost::IShell* service) override;
81+
void Deinitialize(PluginHost::IShell* service) override;
82+
string Information() const override;
83+
84+
private:
85+
void Deactivated(RPC::IRemoteConnection* connection);
86+
87+
private:
88+
uint32_t _connectionId;
89+
PluginHost::IShell* _service;
90+
Exchange::IConfiguration* _implementation;
91+
Core::Sink<Notification> _notification;
92+
};
93+
94+
} // Namespace Plugin.
95+
}

0 commit comments

Comments
 (0)