18180 Commits

Author SHA1 Message Date
Andreas Steffen
ec25c4d3a8 oqs: Added post-quantum KEM methods based on liboqs 2022-03-14 10:19:08 +01:00
Andreas Steffen
21257e0251 nist_kem_kat: Added script formating NIST KEM KAT records into ke_test vectors 2022-03-14 10:19:08 +01:00
Andreas Steffen
9e391cb934 test-vectors: Added NIST KEM test vectors 2022-03-14 10:19:08 +01:00
Andreas Steffen
e557629ba8 key-exchange: Joint ke_test_vector format for DH and KEM
Both Diffie-Hellman (DH) and Key Encapsulation Mechanism (KEM) based
key exchange methods use a common ke_test_vector format. The
set_seed() function is used to provide deterministic private key
material for the crypto tests.
2022-03-14 10:19:08 +01:00
Andreas Steffen
aa0bc52adb key-exchange: Added NIST round 2 submission KEM candidates 2022-03-14 10:19:08 +01:00
Tobias Brunner
29ccd78ed0 wip: ike-init: Indicate support for IKE_INTERMEDIATE
wip: Not strictly necessary. I guess we should also add some checks if
the notify was not received.
2022-03-14 10:19:08 +01:00
Tobias Brunner
91a667ddfc proposal: Prevent selection of duplicate key exchange methods
All additional (and the initial) key exchanges must use a different method.
2022-03-14 10:19:08 +01:00
Tobias Brunner
5cee4a9322 proposal: Add helper to check if additional key exchanges are contained 2022-03-14 10:19:08 +01:00
Tobias Brunner
e9a3a99f20 proposal: Accept NONE for additional key exchanges also for IKE proposals 2022-03-14 10:19:08 +01:00
Tobias Brunner
24131b0a63 unit-tests: Add tests for CHILD_SA rekeying with multiple key exchanges 2022-03-14 10:19:08 +01:00
Tobias Brunner
5ddb1715e8 unit-tests: Add tests for CHILD_SA creation with multiple key exchanges 2022-03-14 10:19:08 +01:00
Tobias Brunner
cf4780f5ac unit-tests: Tests for additional key exchanges 2022-03-14 10:19:08 +01:00
Tobias Brunner
596d18a352 unit-tests: Support multiple proposals in exchange tests 2022-03-14 10:19:08 +01:00
Tobias Brunner
a50be75323 unit-tests: Hand out an actual shared secret in mock KE implementation
Makes key derivation a bit more realistic.
2022-03-14 10:19:08 +01:00
Tobias Brunner
9d3908ca95 proposal: Add prefix for additional key exchanges when logging proposals 2022-03-14 10:19:08 +01:00
Tobias Brunner
c3b3be96af key-exchange: Add dynamic parser for additional key exchange methods 2022-03-14 10:19:08 +01:00
Tobias Brunner
2e36460d60 child-rekey: Support CHILD_SA rekeying with multiple key exchanges 2022-03-14 10:19:08 +01:00
Tobias Brunner
0cb8095032 child-sa: Cache and forward actual initiator flag for outbound SA
Kernel interfaces (e.g. TKM) might rely on this flag to be correct.
2022-03-14 10:19:08 +01:00
Tobias Brunner
3f72b47c10 unit-tests: Fix CHILD_SA rekey tests after INVALID_KE_PAYLOAD handling changes
The responder doesn't create a CHILD_SA and allocate an SPI anymore
when responding with an INVALID_KE_PAYLOAD notify.
2022-03-14 10:19:08 +01:00
Tobias Brunner
bb49d87b63 child-create: Add support for multiple key exchanges
It also changes that payloads are built before installing the CHILD_SA on
the responder, that is, the KE payload is generated before keys are derived,
so that key_exchange_t::get_public_key() is called before get_shared_secret(),
or it's internal equivalent, which could be relevant for KE implementations
that want to ensure that the key can't be used again after the key
derivation.
2022-03-14 10:19:08 +01:00
Tobias Brunner
38a848e089 ike-rekey: Support IKE_SA rekeying with multiple key exchanges 2022-03-14 10:19:08 +01:00
Tobias Brunner
42aee9945b ikev2: Send deletes also for rekeyed SAs
This way we can use the IKE_REKEYED state for both redundant and old SAs
to suppress ike_updown().

In the ike-delete task we don't suppress events in state IKE_REKEYING as
that's the case when we delete an SA the peer is currently rekeying with
multiple key exchanges.
2022-03-14 10:19:07 +01:00
Tobias Brunner
a53a3090b4 ikev2: Let ike/child-rekey tasks indicate if the passive task was adopted
This gives us more flexibility with tasks that return NEED_MORE (currently
none of the colliding tasks do, but that will change with multi-KE
rekeyings).  The active task has to check itself if the passive task is
done and should be removed from the task manager.
2022-03-14 10:19:07 +01:00
Tobias Brunner
623cf6ba83 ike-rekey: Remove collision task type checks
Since f67199378df9 ("ike-rekey: Handle undetected collisions also if
delete is delayed") we only ever track tasks of type TASK_IKE_REKEY, so
there is no need to check the type or use the generic task_t interface.

Also changed some of the comments to clarify collision handling.
2022-03-14 10:19:07 +01:00
Tobias Brunner
52c471906c ike-rekey: Don't actively rekey already rekeyed SAs
If the peer successfully rekeyed the SA it gets marked as IKE_REKEYED
and it remains until the peer deletes it (or a timeout).  There is no
point in rekeying such SAs again.

IKE_REKEYING will be relevant if we have multi-KE rekeyings and are
waiting for followup key exchanges for a passive rekeying.
2022-03-14 10:19:07 +01:00
Tobias Brunner
604336bf4c ike-init: Ignore COOKIE payloads during rekeying
This ensures that process_i() only returns NEED_MORE due to multiple
key exchanges or an INVALID_KE_PAYLOAD notify.
2022-03-14 10:19:07 +01:00
Tobias Brunner
0e6c490a07 ike-init: Add support for multiple key exchanges
Initially, this is handled with a key derivation for each
IKE_INTERMEDIATE exchange.  When rekeying the keys are derived only when
all IKE_FOLLOWUP_KE exchanges are done.
2022-03-14 10:19:07 +01:00
Tobias Brunner
ce389ec94b bus: Support multiple key exchanges in ike/child_keys() events 2022-03-14 10:19:07 +01:00
Tobias Brunner
4047aa2ec3 keymat_v2: Support key derivation with multiple key exchanges 2022-03-14 10:19:07 +01:00
Tobias Brunner
089fdcac1c key-exchange: Add helper to concatenate shared secrets of several key exchanges 2022-03-14 10:19:07 +01:00
Tobias Brunner
5aa4ba7f22 keymat_v2: Proper cleanup if derive_ike_keys() is called multiple times 2022-03-14 10:19:07 +01:00
Tobias Brunner
dbc411a772 ike-sa-manager: Log SPIs when checking in an IKE_SA 2022-03-14 10:19:07 +01:00
Tobias Brunner
d983d3de8b ikev2: Use hashes to detect retransmits
We avoid parsing messages with unexpected message IDs.  This allows us to
process and detect retransmits of messages for which we don't have the keys
anymore (i.e. IKE_INTERMEDIATE after IKE_SA_INIT and changing the keys).

This also changes how retransmits for fragmented messages are triggered,
previously we waited for all fragments and reconstructed the message
before retransmitting the response.  Now we only track the first
fragment and if we receive a retransmit of it respond immediately
without waiting for other fragments (which are now ignored).  This is in
compliance with RFC 7383, section 2.6.1.
2022-03-14 10:19:07 +01:00
Tobias Brunner
2518ff8e02 ike-auth: Calculate and collect IntAuth for IKE_INTERMEDIATE exchanges 2022-03-14 10:19:07 +01:00
Tobias Brunner
c830756f7d pubkey-authenticator: Handle IntAuth data 2022-03-14 10:19:07 +01:00
Tobias Brunner
fd2bc92201 psk-authenticator: Handle IntAuth data 2022-03-14 10:19:07 +01:00
Tobias Brunner
6ed497c4f5 eap-authenticator: Handle IntAuth data 2022-03-14 10:19:07 +01:00
Tobias Brunner
4a4cd569e5 keymat_v2: Include optional IntAuth in signed octets 2022-03-14 10:19:07 +01:00
Tobias Brunner
33fd1cc6a4 authenticator: Add optional method to set IntAuth data 2022-03-14 10:19:07 +01:00
Tobias Brunner
ebe2cd2958 message: Add method to generate data to authenticate IKE_INTERMEDIATE exchanges 2022-03-14 10:19:07 +01:00
Tobias Brunner
55ff82eb5a generator: Make pointer to length field optional
Only useful if we generate an IKE header.
2022-03-14 10:19:07 +01:00
Tobias Brunner
26f1544e21 message: Fix payload type in last unprotected payload of a fragmented message 2022-03-14 10:19:07 +01:00
Tobias Brunner
dfc7d18659 keymat_v2: Add method to calculate IntAuth for IKE_INTERMEDIATE exchanges 2022-03-14 10:19:07 +01:00
Tobias Brunner
f9fe0f4e9b ike-rekey: Reset IKE_SA after processing CREATE_CHILD_SA request
This probably didn't cause any problems, as there wasn't really anything
happening between the calls, but reset it anyway, just to be safe.
2022-03-14 10:19:07 +01:00
Tobias Brunner
8cd146d296 ikev2: Allow tasks to do work after processing requests/responses 2022-03-14 10:19:07 +01:00
Tobias Brunner
abafe33c68 task: Add optional post_process() method
This will allows tasks to do some work after a message has been
processed.
2022-03-14 10:19:07 +01:00
Tobias Brunner
5807d1d5df ikev2: Allow tasks to do work after generating requests/responses 2022-03-14 10:19:07 +01:00
Tobias Brunner
cba4cd90cc task: Add optional post_build() method
This will allow tasks to do some work after the message has been
generated.
2022-03-14 10:19:07 +01:00
Tobias Brunner
03467858f3 ike-auth: Support IKE_INTERMEDIATE exchange between IKE_SA_INIT and IKE_AUTH 2022-03-14 10:19:07 +01:00
Tobias Brunner
03d7d011b6 child-create: Support IKE_INTERMEDIATE exchange between IKE_SA_INIT and IKE_AUTH 2022-03-14 10:19:07 +01:00