Commit graph

63 commits

Author SHA1 Message Date
Dennis Potman
0348bb2741 Security liveliness protection tests
Add testing liveness protection to the existing discovery protection
test. The test checks if the P2P_BUILTIN_PARTICIPANT_MESSAGE_SECURE_WRITER
is using the encode_decode_submessage function of the crypto plugin
to secure liveliness messages.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-05-15 15:35:31 +02:00
Dennis Potman
231d820052 Add security encoding-mismatch test
A test that checks that the security handshake fails in case of non-matching
encoding settings in the governance xml. All combinations of values for
rtps, discovery and liveliness protection are checked. For meta-data and
payload encoding, this test checks that a reader and writer do not connect
in case of non-matching values.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-05-15 15:35:31 +02:00
Dennis Potman
9f261423e3 Add tests for discovery protection
Adding a test that checks the effects of using different configuration settings
for discovery protection. This test set uses the cryptography wrapper to count
the number of invocations of the encode and decode functions during a session
and checks the counts with the expected values.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-05-15 15:35:31 +02:00
Dennis Potman
fd27604a26 Add crypto token exchange test
Introduced a test that checks if all crypto tokens send by a node are
received correctly by the remote node. To support this test, the crypto
wrapper plugin is extended with a token_log mode, that stores all tokens
that are exchanged after the security handshake is finished.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-05-15 15:35:31 +02:00
Marcel Jordense
e1899df62d Fix incorrect type of include_optional_fields config parameter
Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
2020-05-11 15:03:20 +02:00
Marcel Jordense
860f261dc6 Correct generation of the crypto key
Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
2020-05-11 15:03:20 +02:00
Marcel Jordense
720c8f8fbf Correct security (de)serialization of QosProperty contained in c.data field of handshake token
Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
2020-05-11 15:03:20 +02:00
Marcel Jordense
623a5c02bd Correct handshake tokens verification w.r.t. optional fields
Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
2020-05-11 15:03:20 +02:00
Dennis Potman
e8c349f96d Fix condition for setting identity subject in remote rights
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-04-22 17:41:27 +02:00
Dennis Potman
19bc6f33cc Access control tests
Add test cases for the join_access_control governance setting and for
the access control plugin check_create_ and check_remote_ hooks,
using a wrapper plugin that simulates failure for each of these,
to test the DDSI integration with the access control plugin.
This commit also contains fixes for:
- an assert on DDS_RETCODE_OK in dds_create_reader and
dds_create_writer that cased the application to terminate in case
creation of a reader or writer is not allowed by security
- do not match a proxy reader that has the 'relay_only' set to
true, which is currently unsupported

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-04-22 17:41:27 +02:00
Dennis Potman
e8dfbabd0c Add locking when intializing remote key material
The initialization of remote participant's key material was not protected
by the remote_participant_crypto lock, which could result in using partially
initialized remote key material. This caused intermittent test failures
with assertions on key_size in crypto_cipher_decrypt_data. This commit fixes
this issue by adding locking for the remote key material.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-04-16 18:05:06 +02:00
Dennis Potman
dae562c602 Improve delays/timing in permissions_expiry_multiple test
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-04-16 15:30:08 +02:00
Dennis Potman
5e721c99e5 Change test timing and time-outs in access-control and authentication
expiry tests and add timestamps to test logging to get more stable
test results on Travis and enable analysing timeing issues.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-04-16 15:30:08 +02:00
Dennis Potman
e3056402fc Implement on_revoke_identity_cb
Impement the revoke identity callback in ddsi that is called when
the identity certificate of a participant expires. In case the
identity handle that expires is from a local participant, all
proxy pp connections will be dropped for this participant. In case
the identity that expires is from a remote participant, the
corresponding proxy participant is deleted.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-04-16 15:30:08 +02:00
Dennis Potman
736d0a027a Add access control tests for permissions expiry and move some reused test
functions to common utils file.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-04-16 15:30:08 +02:00
Dennis Potman
d53cdce8fe Access Control on_revoke_permissions implementation in DDSI
Implement handler for access control on_revoke_permissions. This callback
function disconnects and deletes all proxy participant that are using the
revoked permissions handle (in case of remote permissions expire) and
proxy participant that are connected with a participant for which the
permissions expire (local permissions expire).

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-04-16 15:30:08 +02:00
Dennis Potman
e6500b6528 Add domaingv pointer to security plugins, as a preparation for supporting the permissions_expiry callback (which needs the gv to enumerate participants.
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-04-16 15:30:08 +02:00
Dennis Potman
a6a9d1f7c1 Security core tests: new tests and refactoring
Refactoring security core tests and adding more tests:
- Dynamically generate ca and identity certificates in authentication tests, so that certificate expiry is tested.
Added writing/reading samples to these tests to ensure that nodes can (or cannot) communicate in a specific test case
- Secure communication tests: improved the validation of encryption in wrapper
- Added test for access control plugin settings
- Replaced the in-code test identities (and included ca private keys), added an additional identity

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-04-16 15:30:08 +02:00
Erik Boasson
1fd4ab290f Do not build security tests if BUILD_IDLC=NO
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-04-10 09:51:35 +02:00
Erik Boasson
eb7e5e3a87 Disallow junk after optional terminator in string/binprop compare
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-04-07 11:40:14 +02:00
Erik Boasson
9c09eca2e9 Do not assume string in algo binary property
Interpretation of the c.dsign_algo and c.kagree_algo properties must not
assume the binary property to be a null-terminated string.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-04-07 11:40:14 +02:00
Marcel Jordense
b6640d86b0 Correct length of encrypted submessage body
Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
2020-04-07 11:39:57 +02:00
Erik Boasson
99df0956e7 Crypto endpoint relation compare routines cleanup
* Trying not to assume an int is at least 32 bits.

* Technically speaking, comparing "unrelated" addresses is undefined
  behaviour which can be avoided by a cast to uintptr_t.

* The early out if either local_crypto == 0 does work in context,
  provided the nodes in tree never have local_crypto == 0.  That implies
  crypto_insert_endpoint_relation must never have a 0 in there, which I
  think the callers do respect.  Still I think it is better to not hide
  these assumptions in the compare function and address the problem in
  the lookup function instead.

These changes likely make the code fractionally slower, but I do think
they improve clarity.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-04-01 09:39:11 +02:00
Marcel Jordense
9175f44273 Send crypto tokens after handshake is completely finished
Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
2020-03-27 16:31:08 +01:00
Marcel Jordense
a77fe10a04 Add index on receiver specific key to improve verification of origin authentication signing
Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
2020-03-27 16:31:08 +01:00
Dennis Potman
d03587fcea Add identity bob to default test permissions xml
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-25 10:46:17 +01:00
Dennis Potman
bf23dee70a Fix in access control identity subject compare
Fixed a bug in the subject compare function for identity subjects, that
could cause using the incorrect permission grant in case multiple grants
are provided in the permissions configuration of the access control plugin.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-25 10:46:17 +01:00
Erik Boasson
cec8aea6c9 Compound literals go out of scope, too
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-03-23 14:15:38 +01:00
Dennis Potman
0768ad59ed
Remove duplicated code in authentication plugin (#442)
* Remove duplicated code in authentication plugin

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

* Fix build warnings

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

* Fix memory leak and call create_validate_asymmetrical_signature directly from create_validate_signature_impl

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

* Fix refcount issue (assert in openssl) for identity cert in hs remote info

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

* Refactoring of validate_handshake_token function

Co-authored-by: Erik Boasson <eb@ilities.com>
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-20 13:44:27 +01:00
Dennis Potman
3ea2cea318
Code formatting fixes and clean-up authentication plugin (#439)
* Fix code formatting, fix for memory leak in validate_handshake_reply_token and
make error handling and return values more consistent with the other two
plugins.

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

* Processed review comments: fixed memory leaks and more consistent error handling and function returns

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

* Fix trusted ca dir max exceeded

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-18 10:01:20 +01:00
Marcel Jordense
6507859f36 Correct handling of identity certificates with EC key
Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
2020-03-13 19:24:03 +01:00
Sid Faber
9fe51ef3fb Install security plugins
Security plugins are built but not installed.  Add target to CMakeLists.txt
for three security plugins.

Signed-off-by: Sid Faber <sid.faber@canonical.com>
2020-03-10 15:19:50 +01:00
Dennis Potman
0a9d391c64 Fixed logging in find_own_ip
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Marcel Jordense
8ca1780538 Correct problem with cleanup of security handshake
Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
b8537c0d09 Add test in secure_communication suite to validate that payload/submsg/rtps-msg does not contain secret when using encryption protection kind
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
9cc128c295 Remove setting the tracing verbosity in tests and make configs in security core tests more consistent
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
e7f5ae354c Fix security handshake test
Isolate domains by using unique tags when running tests that are using security handshake.
And updated coding style and some minor refactoring in fsm and timed_cb tests.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
ea10dbd8e1 Fixes in security core tests: add check that all provided vars are used in variable expansion for test configs, add note on concurrency in authentication wrapper, replace assert by cunit assert in crypto wrapper
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
8f464e0c99 Fix writer-reader sync in secure_communication tests
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
28aa06915e Fixed bug in handshake happy-day test
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
6c9e50cf3a Fix for empty trusted CA dir
Trusted CA dir in security configuration is optional, but participant
creation currently fails if no or empty dir is provided. This commit
fixes this issue and adds some tests for various trusted_ca_dir values.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
1cf472ea06 Refactored tests for security core: introduced generic wrappers for security plugins and
updated plugin loading tests to use these instead of specific wrappers per test. Added
test for securing communication ad handshake fail (using different identity CAs)

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
323de40cba Moved add_definitions in cmake files to /src/ so that all components and tests use the same definitions when compiling sources
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Erik Boasson
a0b4245600 Fix FSM timeout test race
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-03-03 13:32:38 +01:00
Marcel Jordense
4960fbf94c Add security authentication handshake and encoding and decoding
Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
2020-03-03 13:32:38 +01:00
Erik Boasson
1c77aad39c Fix Clang static analyzer warnings
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-24 15:59:00 +01:00
Erik Boasson
0d5a8bf461 Remove built-in crypto plugin unused variables
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-24 15:59:00 +01:00
Erik Boasson
e0a9beb3cb Fix condition for validating topic access rules
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-24 15:59:00 +01:00
Erik Boasson
0d3ca448ff Liveliness monitoring fixes for security FSM
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-12 20:15:49 +01:00
Erik Boasson
ad58db0721 Merge branch 'master' into security
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-12 17:30:38 +01:00