Commit Graph

20 Commits

Author SHA1 Message Date
Martin Willi 30c009c2fe kernel-interface: Add a replay_window parameter to add_sa() 2014-06-17 16:41:30 +02:00
Martin Willi d7083b6541 kernel: Use a time_t to report use time in query_policy() 2013-10-11 10:23:17 +02:00
Martin Willi c99458e94e kernel: Use a time_t to report use time in query_sa() 2013-10-11 10:23:17 +02:00
Martin Willi a8c9454423 kernel-interface: add an exchange initiator parameter to add_sa()
This new flag gives the kernel-interface a hint how it should priorize the
use of newly installed SAs during rekeying.

Consider the following rekey procedure in IKEv2:

Initiator  ---    Responder

I1 -------CREATE-------> R1
I2 <------CREATE--------
   -------DELETE-------> R2
I3 <------DELETE--------

SAs are always handled as pairs, the following happens at the SA level:

  * Initiator starts the exchange at I1
  * Responder installs new SA pair at R1
  * Initiator installs new SA pair at I2
  * Responder removes old SA pair at R2
  * Initiator removes old SA pair at I3

This makes sure SAs get installed/removed overlapping during rekeying. However,
to avoid any packet loss, it is crucial that the new outbound SA gets
activated at the correct position:

  * as exchange initiator, in I2
  * as exchange responder, in R2

This should guarantee that we don't use the new outbound SA before the peer
could install its corresponding inbound SA.

The new parameter allows the kernel backend to install the new SA with
appropriate priorities, i.e. it should:

  * as exchange inititator, have the new outbound SA installed with higher
    priority than the old SA
  * as exchange responder, have the new outbound SA installed with lower
    priority than the old SA

While we could split up the SA installation at the responder, this approach
has another advantage: it allows the kernel backend to switch SAs based on
other criteria, for example when receiving traffic on the new inbound SA.
2013-06-11 15:58:48 +02:00
Martin Willi 5c12700f9a kernel-interface: query SAD for last use time if SPD query didn't yield one 2013-05-06 17:01:13 +02:00
Adrian-Ken Rueegsegger 7cc6fa1a98 Various stylistic fixes 2013-03-19 15:24:36 +01:00
Adrian-Ken Rueegsegger c57b7a66c3 Use network byte order for ESA SPIs 2013-03-19 15:23:51 +01:00
Reto Buerki ae6f4ee39f Don't manually register kernel_netlink_net
Load complete kernel_netlink plugin instead. Registering the TKM
specific plugins first still ensures that the correct ipsec plugin
is used.

Lazy initialize the RNG_WEAK plugin to avoid the unsatisfiable
soft dependency on startup.
2013-03-19 15:23:50 +01:00
Reto Buerki 41eaaef79b Make sure IP_XFRM_POLICY is defined 2013-03-19 15:23:50 +01:00
Adrian-Ken Rueegsegger 722d68803e Set sp_id to reqid when creating ESA
The reqid corresponds to the sp_id (security policy id) on the TKM side.
2013-03-19 15:23:49 +01:00
Adrian-Ken Rueegsegger 1c1400f007 Call Esa_Select after creation of child SA
This tells the TKM which child SA is the currently active SA.
2013-03-19 15:23:49 +01:00
Adrian-Ken Rueegsegger 0f0165c81f Add typelen parameter to chunk_to_sequence function
The parameter is used to initialize the given sequence to zero.
2013-03-19 15:23:48 +01:00
Adrian-Ken Rueegsegger 4a1529203b Implement ESA rekeying with and without PFS
A child SA is being rekeyed if the esa information passed to the add_sa
function contains nonces. If it also contains a valid Diffie-Hellman
context id PFS is used.

The fact that the encr_r encryption key is passed to add_sa in the
inbound case can be used to determine if we are initiator or not by
inspecting the is_encr_r flag of the esa information struct.
2013-03-19 15:23:48 +01:00
Adrian-Ken Rueegsegger d303221c0b Extend esa_info_t struct
Add additional fields to the esa_info_t struct so the necessary data can
be passed from the keymat to the kernel ipsec interface, where ESA
creation and key generation using the TKM takes place.

The information is used during the inbound add_sa call to create an ESP
SA. This makes the hack of storing the local SPI in a kernel interface
variable between subsequent add_sa calls unnecessary.
2013-03-19 15:23:48 +01:00
Adrian-Ken Rueegsegger de20230111 Use SAD to manage TKM ESA context information
An SAD entry is added after successfull creation of a TKM ESA context
in the add_sa() function. The corresponding entry is removed in
del_sa() using the SAD, src, dst, spi and protocol parameters.
2013-03-19 15:23:48 +01:00
Adrian-Ken Rueegsegger d0ab667c99 Use rng to generate local ESP SPIs 2013-03-19 15:23:48 +01:00
Reto Buerki 6c237edb9a Remove netlink proxy from TKM kernel interface
The TKM is now able to manage simple child SAs, so there is no need for
the netlink proxy anymore.
2013-03-19 15:23:47 +01:00
Reto Buerki a642e3ba27 Avoid proxy for bypass_socket, enable_udp_decap
This is in preparation for the removal of the netlink kernel proxy. The
code is copied as-is from the kernel_netlink_ipsec plugin.
2013-03-19 15:23:47 +01:00
Adrian-Ken Rueegsegger b94a0befaf Implement CHILD SA key derivation using TKM
ESP SAs are created when adding CHILD SAs via the kernel ipsec
interface.

The encr_i key is used to transfer the context id of the parent IKE SA
from the keymat to the TKM kernel ipsec interface.
2013-03-19 15:23:47 +01:00
Adrian-Ken Rueegsegger 8a780242e2 Add TKM kernel ipsec skeleton
The existing kernel netlink ipsec interface is currently used as proxy
to perform the actual work. It will be gradually removed as the TKM
implements the needed features.
2013-03-19 15:23:47 +01:00