Commit Graph

25 Commits

Author SHA1 Message Date
Muddasir shakil
b457206d24
feat(pubsub): KeyStorage and SetSecurityKeys (#5243)
* Add UA_ENABLE_PUBSUB_SKS Cmake option

The SKS related features are enabled in open62541. The UA_ENABLE_PUBSUB_SKS
cmake option adds the support to enable/disable SKS related features.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Add securityGroupId parameter to PubSub Group Config

The PubSub groups (Reader/Writer) are associated to a security group by
securityGroupId. The securityGroupId parameter is added to UA_WriterGroupConfig
and UA_ReaderGroupConfig structs.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Add UA_PubSubKeyListItem struct

The Keystorage contains a linked list of KeyItems. The KeyItems holds the
information related to a key. The UA_PubSubKeyListItem struct forms the keyItems
of the keystorage KeyList.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Add UA_PubSubKeyStorage struct

A structured storage is required to store all the keys and related information,
such as which security group, what security policy, how many PubSub Groups, and
when to move to next keys. The UA_PubSubKeyStorage struct holds the list of keys
used to secure the pubsub message for a security group and related information.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Add PubSubKeyStorageList to the pubSubManager

The KeyStorage is managed by the pubSubManager object. There can be multiple key
storages managed by a pubSubManager for different Security Groups. An
UA_PubSubKeyStorage List is added to the pubSubManager, which contains the
pointers to all the key Storages managed by the pubSubManager for different
Security Groups.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Add KeyStorage pointer to ReaderGroup and WriterGroup struct

A reference to a Keystorage is created when a ReaderGroup or WriterGroup group
is created. This reference is used for the life cycle management of the
KeyStorage. A non-owning pointer is added to WriterGroup and ReaderGroup structs
to point to their associated keystorage in the server.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Add function to initialize a keyStorage

An empty keystorage list is created when a ReaderGroup or a WriterGroup is
created in server. The new KeyStorage is added to the server KeyList and
initialized for a securityGroup. If a KeyStorage already exists in the server
for a securityGroupId, then the referenceCount is incremented and the keyStorage
is added to the initializing ReaderGroup or WriterGroup. In case of failure,
the keystorage is cleaned and deleted.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Add storeSecurityKey function

After the keystorage is initialized and added to the server keyList, the
keys should be stored in the keystorage keylist. the storeSecurityKeys function
takes current key and future key list and add it a KeyStorage in the server.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Add Mechanism for key Rollover after KeyLifeTime expires

After the KeyLifeTime expires the Publisher and Subscriber are required to
move to the next key in the existing list. The addMoveToNextKeyCallback function
calculates the time to trigger the callback function and adds a timed server
callback. The importKeyToChannelContext function takes the key material,
divides the key into singing, encrypting and keyNonce part according to security
Policy assigned to KeyStorage and adds them to the channelcontext of the PubSub
Group. The moveToKeyCallback is the callback function to set the keys and
add next callback for key Rollover.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Add API function update the existing keyStorage

The existing KeyList is updated/replaced with the fetched list. If the
currentTokenId is unknown in the existing list, then the existing keylist is
replaced by the fetched KeyList. In othercases keystorage is updated and keylist
is extended with new future keys.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Add removeKeyStorage function

A keyStorage can be referenced by multiple PubSub Groups in a server. When a
keyStorage is removed with removeKeyStorage function, it checks the number of
of referenceCount parameter and decrements it by 1. If referenceCount was 1, then
the keyStorage pointer is freed and removed from the server.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Add keyStorage in Server with ReaderGroup

Each ReaderGroup is assocaited with a keyStorage. The keys are used in its
channel context to secure the messages. A keyStorage is added/updated when
a ReaderGroup is created in the server.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Add KeyStorage in server with WriterGroup

Each WriterGroup is assocaited with a keyStorage. The keys are used in its
channel context to secure the messages. A keyStorage is added/updated when
a WriterGroup is created in the server.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Remove KeyStorage from server with ReaderGroup

Each ReaderGroup is assocaited with a keyStorage. The keys are used in its
channel context to secure the messages. A keyStorage is removed/updated when
a ReaderGroup is removed from the server.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Remove KeyStorage from server with a WriterGroup

Each WriterGroup is assocaited with a keyStorage. The keys are used in its
channel context to secure the messages. A keyStorage is removed/updated when
a WriterGroup is removed in the server.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Delete All KeyStorages from Server

When PubSub Configuration is deleted, all the nested configuration and members
are deleted from the server. The KeyStorages are also deleted when a
PubSubManager is deleted, because KeyStorages does not serve the purpose anymore.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Add KeyStorage Test setup and unit tests

A test suite is added for the keystorage and the following using tests are added
to it
	- Initialization of empty keystorage
	- Initialization of keystorage with invalid PubSub security policy
	- storing keys into empty keystorage
	- move to next key after keylifetime expire
	- Setting keys to the channel context
	- Adding keyStorage with Writer and ReaderGroup
	- Adding a Reader/WriterGroup to existing Keystorage
	- Removing keyStorage with a Writer/ReaderGroup

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Add setSecurityKeys Method Node Callback

The keys are pushed to the Publishers and Subscribers who do not have client
functionality using setSecurityKeys Method Node. The setSecurityKeys callback
implements the backend of the setSecurityKeys Method node exposed by the server.
Checking for user credentials against PubSub Security Group Object nodes
is unresolved becuase creation of Security Group Object is not implemented.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Add sks push test setup and unit tests

Setups the PubSub SKS Push test suite and helper methods. The test suite
includes a server with encryption and a client to connect with the server
with encrypted channel. The following unit tests are added
	- insufficient Security Mode
	- MissingSecurityGroup
	- Setting Security Keys
	- Update CurrentKey from exisiting list
	- Update CurrentKey and add new future keys
	- Replace existing keys with new keys

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Add PubSubKeyStorage description

The PubSubKeyStorage description is added to the header file. It also includes
the implemented workflow of the KeyStorage API to interact with KeyStorage.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

* Integrate PubSub SKS build and unit test in CI

The unit tests should be intergerated in the CI of open62541 pipeline to provide
proper testing and integration support of the new feature. The  build and unit
tests of PubSub SKS are integrated in the CI pipeline.

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>

Signed-off-by: Muddasir Shakil <muddasir.shakil@linutronix.de>
2022-10-17 20:55:11 +02:00
Andreas Ebner
e1ce62306c fix(ci) add ci mosquitto dependency 2022-05-03 19:52:53 +02:00
Julius Pfrommer
f550925698 feat(ci): Enable MQTT for the CI build 2022-05-03 19:51:27 +02:00
Götz Görisch
120831bc6e core(deps): Bumps LibreSSL to 3.4.3
Relnotes: https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.4.3-relnotes.txt
2022-03-19 09:48:29 +01:00
Julius Pfrommer
802cbb4e2c Merge remote-tracking branch 'origin/1.3' 2022-01-19 12:48:39 +01:00
Julius Pfrommer
1c447182c2 feat(ci): Add CI builds without Subscriptions and with Diagnostics enabled 2022-01-19 07:01:02 +01:00
Julius Pfrommer
5de6a2e7c3 Revert "Merge branch 'master' into 1.3"
This reverts commit 2f2b9fea7d, reversing
changes made to 271f3dcb01.
2021-12-18 14:34:34 +01:00
Julius Pfrommer
2f2b9fea7d
Merge branch 'master' into 1.3 2021-12-01 11:08:34 +01:00
Julius Pfrommer
73ffb85ea3 feat(ci): Enable 32bit builds in the CI 2021-12-01 01:36:51 +01:00
Götz Görisch
9685857c7a core(deps): Bumps LibreSSL to 3.4.2
* fixes CB-K21-1240
2021-11-29 01:27:52 +01:00
Götz Görisch
0d490ef052
core(deps): Bumps LibreSSL to 3.4.1 (#4782) 2021-11-19 10:40:22 +01:00
Julius Pfrommer
6e971e912f feat(ci): Build amalgamation in the CI with multithreading enabled
Prevent regression to the recent build fix.

Co-authored-by: kimim <kimi.im@outlook.com>
2021-11-04 19:33:51 +01:00
andreasebner
3b95d6278c ci(gihubaction) fixed build unit testing names and description (#4699) 2021-10-25 18:05:16 +02:00
Divya Prasanth Prabhakaran
379ee51171 feat(ex): Add client server example to use keys stored in TPM
- Encrypt the private key using the key stored in TPM
   and remove the unencrypted private key from the filesystem
 - Used the encrypted key intermittently for software-based
   encryption/decryption

Change-Id: I46fc24102365292d9af6b51c582e3a3f74b2af5e
2021-10-02 12:23:09 +02:00
Julius Pfrommer
cbc7d0dbfe feat(ci): Add valgrind-testing for OpenSSL encyrption 2021-08-09 16:38:57 +02:00
JanSurft
51962a36c4
feat(ci): Enable and fix PubSub Ethernet tests (#4579) 2021-08-06 14:03:08 +02:00
Julius Pfrommer
e5cf98c273 ci(server): Add CI build for Alarms&Conditions 2021-08-02 11:33:37 +02:00
Christian von Arnim
2010a02fed ci(plugin): Add LibreSSL 2021-07-14 09:20:29 +02:00
Christian von Arnim
e9bd0d988e ci(core): Use Github Action Matrix build 2021-07-14 09:20:29 +02:00
Jan Hermes
986227e99f ci: enable and use pubsub encryption tests
Currently there is at least one unit-test that uses
pubsub encryption that is never executed in the continous
integration. This ci extension enables the test of pubsub encryption.
2021-05-23 12:48:45 +02:00
Julius Pfrommer
5dbdd26c84 feat(ci): Add an amalgamation build for the CI 2021-04-06 22:24:51 +02:00
Julius Pfrommer
ae74dc0071 feat(ci): Add multithread-enabled build 2021-03-23 14:58:51 +01:00
Christian von Arnim
0f583db1ef fix(ci): Use clang 11 2021-02-02 11:35:33 +01:00
Christian von Arnim
5351338fba fix(ci): Use python3-sphinx instead of python-sphinx 2021-02-02 11:35:33 +01:00
Julius Pfrommer
dee5de0acf feat(ci): Add first Github actions for Linux builds 2021-01-04 11:20:23 +01:00