Commit graph

677 commits

Author SHA1 Message Date
martinbremmer
66c0d87886 Encoding preparations (#329)
* Payload encoding/decoding preparations.

Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>

* Sub-message encoding/decoding preparations.

Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>

* RTPS message encoding/decoding preparations.

Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>

* Removed redundant destination acquiring.

Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>

* Refactored secure writing of RTPS messages slightly.

Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-12-06 17:50:31 +02:00
Dennis Potman
30bd6e4c1c DDS Security built-in Cryptographic plugin (#306)
* DDS Security built-in Cryptographic plugin

This commit adds the built-in Cryptographic plugin that is part of the
DDS Security implementation for Cyclone.

The Cryptographic plugin defines the types and operations necessary
to support encryption, digest, message authentication codes, and key
exchange for DDS DomainParticipants, DataWriters and DDS DataReaders.

Similar to other builtin plugins, the DDS Security cryptographic plugin
is built as a shared library to allow dynamic library loading on runtime.
This enables DDS participants to use specific plugin implementations
with different configurations.

Although I think this initial version is a reasonable starting point to be
merged in the security branch, some parts of the code will need refactoring:

* crypto_key_factory.c: crypto_factory_get_endpoint_relation returns
arbitrary local-remote relation if no specific key for remote is found,
which will not work in Cyclone because participants can have different
security settings

* performance of encoding data can be improved by not copying
plain_rtps_message to a new buffer (to enable this, crypto_cipher_encrypt_data
should allow encrypting parts of a message)

* when decoding a message the message is split in several parts (header, body,
footer, etc) and for this memory is allocated which is probably not necessary.
Performance should be improved by removing these allocations and use pointers
to the data instead.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* WIP processing crypto plugin review comments

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* WIP more refactoring based on review comments

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* WIP fixing crypto plugin support for 128 bit key size

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* WIP refactored master key storage to reduce memory usage when using 128 bit keys

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* WIP fixing windows build linker issue

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* WIP refactored crypto key types, avoid returning pointers to released ref-counted object

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* Fixed bug in test decode_datareader_submessage.invalid_data

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* Fixed issues from review: use correct constant for hashing and handle different src/dst keysize correctly

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2019-12-05 11:30:35 +02:00
Dennis Potman
37c64e0965 Add string functions used by security plugins to ddsrt (#334)
* String functions required by DDS Security Access Control plugin

The implementation for the DDS Security Access Control plugin
requires two additional string functions. This commit adds the
ddsrt_str_replace function (including tests) and exports the
existing function ddsrt_todigit.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* Suppress strcpy warnings in Windows builds for ddsrt_str_replace

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* Minor nitpicks on ddsrt_str_replace

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-12-04 11:22:40 +02:00
Martin Bremmer
e2afccf4a0 Fixed security build.
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-11-14 12:08:13 +01:00
eboasson
e53920031f
Merge pull request #251 from kurtuluso/authentication_plugin
Builtin authentication plugin for DDS Security
2019-10-30 12:20:16 +01:00
Kurtulus Oksuztepe
2c1d3010d0 Builtin authentication plugin for DDS Security
Builtin authentication plugin of DDS Security implementation was added.
This plugin is the first implementation and it also contains the functions that are used initially in the secure communication sequence.

The builtin authentication plugin implements authentication using a trusted Certificate Authority (CA). It performs mutual authentication between discovered participants using the RSA or ECDSA Digital Signature Algorithms and establishes a shared secret using Diffie-Hellman (DH) or Elliptic Curve Diffie-Hellman (ECDH) Key Agreement Methods.

DDS Security core component is introduced with this commit. DDSI and other builtin plugins will also use the security core.

Like all builtin plugins, dds security authentication plugin is a shared library for providing dynamic library loading on runtime. So that, dds participants can use different plugin implementations with different configurations.

Authentication plugin uses ddsrt functions. ddsrt is not expected to be a shared library and statically adding ddsrt objects to authentication library produces linkage errors in windows. So, dynamically linking authentication plugin to ddc library is decided. Another decision should be taken for the platforms that are not supporting dynamic libraries later.

Signed-off-by: Kurtulus Oksuztepe <kurtulus.oksuztepe@adlinktech.com>
2019-10-30 11:41:00 +01:00
Martin Bremmer
d0035cfdbd Protected discovery preparation.
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-10-30 10:57:13 +01:00
Kurtulus Oksuztepe
aa3b95ee7f Merge branch 'master' into security
Signed-off-by: Kurtulus Oksuztepe <kurtulus.oksuztepe@adlinktech.com>

Conflicts:
	.travis.yml
2019-10-29 17:40:33 +01:00
dennis-adlink
7f59a46ff8 Add PropertyPolicy to QoS API for Security settings (#278)
* Add PropertyPolicy to QoS API for Security settings

This commit adds the public API for PropertyQosPolicy including
tests. This policy can be used to set the parameters for the DDS security
implementation, as an alternative for using the xml configuration.
Tests are also inlcuded for setting security properties and conflict
resolving when both security configuration and qos properties are present.
Finally, the pubsub tool is updated so that is handles this qos correctly.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* Init binary_value.props to fix failing qos merge and moved init code in qset_prop functions

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* Add additional test and some validation improvements based on review comments

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* Refactoring of qos property

Refactored the qos property handling based on review comments. Setting
and unsettings functions are simplified and now use helper functions
for lookup, property initialisation is simplified. Added an additional
check for required security properties when creating participant using
security settings from qos, and added a test-case for this code.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* Check for qos flag before getting property index from qos

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* Participant creation should fail on inconsistent security qos properties, and some minor code improvements in property qos api functions

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* Update log message in test security_config_qos

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* Fixed unused label compiler error in q_entity.c when security is disabled

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* Refactored qprop functions with macros to avoid code duplicate code

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2019-10-29 16:56:12 +01:00
Marcel Jordense
43ee3f87ca use ddsrt_malloc for allocating iov array
Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
2019-10-28 21:45:41 +01:00
dennis-adlink
c8aa6fee5a Moved bswap functions to ddsrt (#297)
* Moved bswap functions to ddsrt

Moved the byte swapping functions from ddsi to ddsrt so that
these can be re-used in e.g. the security plugins and tests.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* Moved  decarations for bswap functions to ddsrt

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2019-10-28 15:03:46 +01:00
Dan Rose
76fa688086 CMAKE_SOURCE_DIR -> CMAKE_CURRENT_SOURCE_DIR
Signed-off-by: Dan Rose <dan@digilabs.io>
2019-10-23 09:36:38 +02:00
Scott K Logan
860a6aadae Drop IDLC when building with colcon
This will eliminate two large dependencies when building CycloneDDS with
colcon for ROS 2, which doesn't appear to need the IDLC.

Signed-off-by: Scott K Logan <logans@cottsay.net>
2019-10-22 22:37:40 +02:00
Scott K Logan
1cc6caff14 First check the CMake Package Registry for CUnit
This is useful when building CycloneDDS on platforms that provide CMake
configuration for CUnit outside of Conan.

If no configuration is found in the system CMake registry the module
continues as before.

Co-authored-by: Steven! Ragnarök <steven@nuclearsandwich.com>
Signed-off-by: Scott K Logan <logans@cottsay.net>
2019-10-22 22:33:10 +02:00
eboasson
5399e5103c
Merge pull request #279 from martinbremmer/merge4
Merge master into security
2019-10-22 20:31:12 +02:00
Martin Bremmer
41d36d59b2 Removed duplicate build from travis
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-10-22 20:28:34 +02:00
Thijs Sassen
36b1b9da3d Adjusted mpt qos test includes to be in line with other tests
Signed-off-by: Thijs Sassen <thijs.sassen@adlinktech.com>
2019-10-22 16:27:15 +02:00
Scott K Logan
a3b35a2aa4 Fix some unreliable STREQUAL calls in CMakeLists.txt
These conditionals may fail if the variable they're checking isn't
defined at all. Adding quotes makes the comparison against an empty
string in this case, which avoids the syntax error.

Signed-off-by: Scott K Logan <logans@cottsay.net>
2019-10-22 15:22:56 +02:00
Scott K Logan
94e4c0915d Skip some tests when BUILD_IDLC=OFF
These tests use `idlc_generate`, which is not available when
`BUILD_IDLC` is not `ON`.

Signed-off-by: Scott K Logan <logans@cottsay.net>
2019-10-22 15:20:30 +02:00
Dan Rose
98ce7d1971 Stylistic CMake changes
No functional impact intended
Signed-off-by: Dan Rose <dan@digilabs.io>
2019-10-22 15:18:26 +02:00
Dan Rose
418a70e7c3 Fix CI not finding pip3
Signed-off-by: Dan Rose <dan@digilabs.io>
2019-10-20 03:32:18 -07:00
Dan Rose
960d4f7358 Use PROJECT_NAME instead of CMAKE_PROJECT_NAME
CMAKE_PROJECT_NAME refers to the top-level project name, not the most recent project. So any CMake project that pulls this in as a dependency was in for a nasty surprise.
https://cmake.org/cmake/help/latest/variable/CMAKE_PROJECT_NAME.html

Signed-off-by: Dan Rose <dan@digilabs.io>
2019-10-20 03:28:15 -07:00
martinbremmer
64cc631137 Participant generic message (#273)
* Extended DDSI (de)serializer.

Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>

* Added security Participant Generic Message.

Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>

* Updated Participant Generic Message.

Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>

* Updated generic ddsi (de)serializer.

Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>

* Changed macros for functions.

Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-10-18 10:05:13 -07:00
Martin Bremmer
a28a5ae23d Merge branch 'master' into merge4
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-10-17 11:05:49 +02:00
Erik Boasson
8ec68e1d7d No printing of null pointers in config errors
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-10-16 03:08:31 +02:00
Erik Boasson
a71be9dcec Remove all occurrences of strncpy
Too many compilers warn about correct use of strncpy these days ...

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-10-16 03:08:31 +02:00
Erik Boasson
f8bff97736 Fix off-by-one error in dds_strretcode (#270)
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-10-16 03:08:31 +02:00
Erik Boasson
5a746cad81 Always abort on DDS_FATAL variants + test (#270)
The test only works on Linux and macOS because of the system
dependencies in catching an abort.  The logging code is platform
independent so testing only on these platforms still gives a good sanity
check.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-10-16 03:08:31 +02:00
Erik Boasson
50e63b3324 Correct ddsrt_gnuc, ddsrt_clang definitions (#270)
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-10-16 03:08:31 +02:00
Erik Boasson
14ffab2705 Always use atomic64 for writer seq_xmit (#270)
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-10-16 03:08:31 +02:00
Erik Boasson
8ce389dd85 IID generator: init and atomic64 ops (#270)
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-10-16 03:08:31 +02:00
Dennis Potman
cbc6dc5aa0 Increase thread test timeout to check if this caused the failing tests on travis win32
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2019-10-15 19:29:18 +02:00
martinbremmer
7c1e47218d Added DDS Security XML configuration elements. (#268)
* Added DDS Security XML configuration elements.

Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>

* Extended security configuration tests.

Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>

* Updated security conf to qos conversion.

Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-10-11 15:43:30 +02:00
Erik Boasson
aa5236dea4 Prefix matching for config XML in CYCLONEDDS_URI
Allow unique prefix matches for elements and attributes specified in
directly in CYCLONEDDS_URI.  That mode already has a few niceties for
quickly specifying some configuration overrides, this is simply one
more.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-10-10 17:44:39 +02:00
Erik Boasson
a25b69be7d Exclude network channels from documentation
They are not supported yet.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-10-10 17:44:39 +02:00
Erik Boasson
d429045255 Add option documentation and add XSD
The ``docs/makernc.pl`` perl script can extract the options from the
source code for the configuration processing and turn these into a
GitHub MarkDown document and a RELAX NG Compact form (RNC) description
of the options.  Standard conversion tools can be used to turn the RNC
file into an XSD.

Although they are generated by a mechanical transformation, it is not
(yet) part of the build process, in no small part because there no
proper generation and publishing system has yet been set up for the
documentation.

Now that there is an XSD and a Markdown file for discovering the
options, there is no need to retain the configuration editing tool.  Any
decent editor will do a better job.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-10-10 17:44:39 +02:00
Erik Boasson
fde05810c6 Drop broken protection against casual eavesdroppers
From a distant past came code to encrypt data on the wire, but it hasn't
been functional in Cyclone for a long time and it only ever provided
protection against casual eavesdroppers.  It is better to delete it.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-10-10 17:44:39 +02:00
Thijs Sassen
0b57b74b93 Fix compile error when using rusage functionality on FreeRTOS
Signed-off-by: Thijs Sassen <thijs.sassen@adlinktech.com>
2019-10-07 14:12:27 +02:00
Jeroen Koekkoek
378b4b19d7 Add macOS 10.12 / Xcode 9 build on Travis CI
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2019-10-02 14:17:38 +02:00
Erik Boasson
0098cfcab7 Fix macOS 10.12 version check
Xcode 9 doesn't yet define MAC_OS_X_VERSION_10_13.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-10-02 08:52:06 +02:00
martinbremmer
ef90c11e8d Added DDS Security msg parameters. (#263)
* Added DDS Security msg parameters.

Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>

* Added ENABLE_SECURITY cmake option and DDSI_INCLUDE_SECURITY compile switch.

Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-10-01 12:43:33 +02:00
eboasson
50b0611ad1
macOS pre-10.13 support (#264)
* macOS < 10.13: skip log tests for want of fmemopen

There is a dependency on fmemopen in the tests for the logging
functions, which macOS introduced only in version 10.13.  There should
be no other obstacle to building/running/testing on older versions of
macOS.  This commit does the pragmatic thing: remove the dependency and
turns the tests into no-ops in this one case.

Signed-off-by: Erik Boasson <eb@ilities.com>

* Fix macOS clock_gettime_nsec_np availability test

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-09-30 09:13:49 +02:00
eboasson
992d2b6e55
Merge pull request #261 from martinbremmer/merge
Merge master into security
2019-09-27 15:16:50 +02:00
Martin Bremmer
919850232c Merge branch 'master' into merge
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-09-27 14:45:16 +02:00
eboasson
78fc9c2e85
Merge pull request #260 from eboasson/plist-update
parameter list update: properties, fixes, unit tests
2019-09-27 13:32:46 +02:00
Erik Boasson
2289428991 Support optional tail in plist deserialisation
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-09-27 13:12:54 +02:00
Martin Bremmer
bc6ece0bfb Fixed missing-field-initializers clang-4 warnings.
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-09-27 10:07:54 +02:00
Erik Boasson
bf8bc87a87 Fixes for table-driven plist ser/deser
* GUID, keyhash compare (currently no reliance on this comparison, so
  not causing trouble in Cyclone for applications)

* comparing "propagate" boolean in plist (newly added for security,
  not yet used)

* fix memory leak in plist_unalias (currently only used in duplicating
  them, in which case the memory leak doesn't occur)

* add unit tests for plist handling

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-09-26 15:58:50 +02:00
Martin Bremmer
8f46889f74 Improved property policy handling.
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-09-26 15:54:05 +02:00
Martin Bremmer
9f1ddb0b38 Added property policy.
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-09-26 15:54:00 +02:00