Commit Graph

200 Commits

Author SHA1 Message Date
Tobias Brunner a6e0f14fd2 kernel-interface: Pass the same data to del_policy() that was passed to add_policy()
The additional data can be helpful to identify the exact policy to
delete.
2015-11-10 16:42:52 +01:00
Tobias Brunner 3195650180 Fix typo in error handling for sigwaitinfo() in charon-systemd and charon-tkm
Fixes 858148092d ("Replace usages of sigwait(3) with sigwaitinfo(2)")
2015-10-29 17:40:31 +01:00
Tobias Brunner 858148092d Replace usages of sigwait(3) with sigwaitinfo(2)
This is basically the same call, but it has the advantage of being
supported by FreeBSD's valgrind, which sigwait() is not.

References #1106.
2015-10-29 15:38:37 +01:00
Martin Willi ee9f691915 unit-tests: Forward variable argument list in TEST_SUITE_DEPEND
For some plugin features, such as crypters or AEADs, we have some additional
feature arguments, such as the key size.
2015-07-12 13:25:50 +02:00
Adrian-Ken Rueegsegger 38b65d7186 charon-tkm: Also store local SPI in SAD 2015-05-04 18:07:52 +02:00
Reto Buerki 8cdc563258 charon-tkm: Reset stale nonce contexts
If the nonce generator detects a stale nonce upon destroy(), it resets
the context in the TKM and releases associated resources in the ID
manager and chunk map.

Also, do not acquire the nonce context ID in tkm_nonceg_create function
but rather when the nonce is actually created by get_nonce().

The nonces created with get_nonce must also be registered in the chunk map.
2015-05-04 18:07:51 +02:00
Reto Buerki a8ca50e635 charon-tkm: Drop unneeded nonceg get_id function 2015-05-04 18:07:51 +02:00
Adrian-Ken Rueegsegger 5460098cce charon-tkm: Remove ESA nonce mappings from chunk map 2015-05-04 18:07:51 +02:00
Reto Buerki a0cf92a650 charon-tkm: Drop obsolete TKM_LIMIT define 2015-05-04 18:07:51 +02:00
Adrian-Ken Rueegsegger 2783bd17a4 charon-tkm: Select other ESA if any is present upon deletion
In the case that multiple ESAs exist (e.g. rekey collision) for a
security policy, make sure to select one of the remaining ESAs.
2015-05-04 18:07:51 +02:00
Adrian-Ken Rueegsegger c7ce0d96cd charon-tkm: Add get_other_esa_id function to TKM kernel SAD
The function gets the ESA id for another entry associated with the same
security policy as the specified ESA.
2015-05-04 18:07:50 +02:00
Adrian-Ken Rueegsegger ded14df603 charon-tkm: Only skip creation of first child SA
Use the new is_first boolean parameter of the
ALERT_KEEP_ON_CHILD_SA_FAILURE alert to determine if the failure was
caused by the first CHILD SA.
2015-05-04 18:07:50 +02:00
Adrian-Ken Rueegsegger 9ae6b507b9 charon-tkm: Fix SAD insertion when adding ESA
Commit f5fc592 added the reqid to the SAD. The insert call swapped the
order of the esa_id and reqid parameters.
2015-05-04 17:23:51 +02:00
Martin Willi 3c81cb6fc3 aead: Create AEAD using traditional transforms with an explicit IV generator
Real AEADs directly provide a suitable IV generator, but traditional crypters
do not. For some (stream) ciphers, we should use sequential IVs, for which
we pass an appropriate generator to the AEAD wrapper.
2015-04-13 15:06:15 +02:00
Martin Willi a777155ffe diffie-hellman: Add a bool return value to set_other_public_value() 2015-03-23 17:54:03 +01:00
Martin Willi 42431690e0 diffie-hellman: Add a bool return value to get_my_public_value() 2015-03-23 17:54:03 +01:00
Martin Willi bace1d6479 diffie-hellman: Use bool instead of status_t as get_shared_secret() return value
While such a change is not unproblematic, keeping status_t makes the API
inconsistent once we introduce return values for the public value operations.
2015-03-23 17:54:02 +01:00
Martin Willi 942797a5b5 kernel-interface: Add a separate "update" flag to add_sa()
The current "inbound" flag is used for two purposes: To define the actual
direction of the SA, but also to determine the operation used for SA
installation. If an SPI has been allocated, an update operation is required
instead of an add.

While the inbound flag normally defines the kind of operation required, this
is not necessarily true in all cases. On the HA passive node, we install inbound
SAs without prior SPI allocation.
2015-03-09 18:18:20 +01:00
Martin Willi 68e5ada005 tkm: Use the inbound flag do determine peer role in CHILD_SA exchange
This was not available during initial implementation, but fits just fine to
avoid reconstructing the peer role.
2015-03-09 18:18:20 +01:00
Tobias Brunner ab65a3e8fc tkm: Disable RFC 7427 signature authentication
TKM can't verify such signatures so we'd fail in the authorize hook.
Skipping the algorithm identifier doesn't help if the peer uses
anything other than SHA-1, so config changes would be required.
2015-03-09 16:59:07 +01:00
Tobias Brunner 1cbd34b9d4 tkm: Implement hash algorithm storage methods of keymat_v2_t interface 2015-03-04 13:54:11 +01:00
Reto Buerki 3fb42bc87f charon-tkm: Use get_dst_host getter in EES callback
Use the new get_dst_host getter to retrieve the destination host from
the SAD using the reqid, spi and protocol values received from the
xfrm-proxy.
2015-02-20 13:34:54 +01:00
Reto Buerki e12ff07c96 charon-tkm: Add get_dst_host getter to SAD
This function returns the destination host of an SAD entry for given
reqid, spi and protocol arguments or NULL if not found.
2015-02-20 13:34:53 +01:00
Reto Buerki ba8aefd5f2 charon-tkm: Improve SAD get_esa_id log messages 2015-02-20 13:34:53 +01:00
Reto Buerki f5fc592ae1 charon-tkm: Store reqid in SAD 2015-02-20 13:34:53 +01:00
Reto Buerki e1e854bd0c charon-tkm: Store remote SPI in SAD
Store the remote instead of the local SPI in the SAD when adding a new
entry in the kernel plugin's add_sa() function.

Since only one ESA context must be destroyed for an inbound/outbound
CHILD SA pair, it does not matter which SPI is used to retrieve it in
the del_sa function.
2015-02-20 13:34:53 +01:00
Reto Buerki fa4f66cba3 charon-tkm: Make CHILD/ESP SA database public
Make the CHILD/ESP SA database a public member of the global tkm_t
struct.
2015-02-20 13:34:53 +01:00
Reto Buerki e63cbb367c charon-tkm: Fix logger entity name in tests.c
Change 'test_runner' to 'test-runner'.
2015-02-20 13:34:52 +01:00
Reto Buerki 84e391e08e charon-tkm: Fix compilation of ees_callback.c
Update the call to hydra->kernel_interface->expire to make
ees_callback.c compile again. The required destination host argument is
set to NULL for now.
2015-02-20 13:34:51 +01:00
Martin Willi d05d85fe65 kernel-interface: Pass full list of traffic selectors to add_sa()
While we can handle the first selector only in BEET mode in kernel-netlink,
passing the full list gives the backend more flexibility how to handle this
information.
2015-02-20 13:34:47 +01:00
Martin Willi 2a1c9e20bd kernel-interface: Remove reqid parameter from get_spi/get_cpi() methods
The reqid is not strictly required, as we set the reqid with the update
call when installing the negotiated SA.

If we don't need a reqid at this stage, we can later allocate the reqid in
the kernel backend once the SA parameters have been fully negotaited. This
allows us to assign the same reqid for the same selectors to avoid conflicts
on backends this is necessary.
2015-02-20 13:34:32 +01:00
Tobias Brunner e13ef5c434 crypto: Define MODP_CUSTOM outside of IKE DH range
Before this fix it was possible to crash charon with an IKE_SA_INIT
message containing a KE payload with DH group MODP_CUSTOM(1025).
Defining MODP_CUSTOM outside of the two byte IKE DH identifier range
prevents it from getting negotiated.

Fixes CVE-2014-9221.
2014-12-23 15:40:01 +01:00
Reto Buerki 1ec7ee65c5 charon-tkm: Properly reset CC context in listener
Make sure that the acquired CC context is correctly reset and the
associated ID released in the authorize() function of the TKM bus
listener.
2014-10-31 13:49:40 +01:00
Reto Buerki a62d03d36b charon-tkm: Add missing comma to enum
Add missing comma to tkm_context_kind_names enum definition.
2014-10-31 13:49:33 +01:00
Martin Willi 5421092b75 plugin-loader: Support a reload() callback for static features 2014-09-22 13:55:12 +02:00
Martin Willi 30c009c2fe kernel-interface: Add a replay_window parameter to add_sa() 2014-06-17 16:41:30 +02:00
Martin Willi 3ecfc83c6b payload: Use common prefixes for all payload type identifiers
The old identifiers did not use a proper namespace and often clashed with
other defines.
2014-06-04 15:53:03 +02:00
Tobias Brunner 1c306c0ee9 libcharon: Remove unused charon->name 2014-02-12 14:34:33 +01:00
Tobias Brunner 9222bfc695 charon-tkm: Use lib->ns instead of charon->name 2014-02-12 14:34:32 +01:00
Tobias Brunner 10c4f4e1fd libhydra: Remove unused hydra->daemon 2014-02-12 14:34:32 +01:00
Tobias Brunner 34d3bfcf14 lib: Add global config namespace 2014-02-12 14:34:31 +01:00
Martin Willi b034131555 unit-tests: Pass a test suite collection name to print during test execution
As we except to get more and more test runners for the different components,
we add a name to easily identify them on the test output.
2014-01-22 15:34:53 +01:00
Adrian-Ken Rueegsegger 6db7feacf6 charon-tkm: Implement IANA DH Id to TKM Id mapping
The TKM Diffie-Hellman plugin now maps IANA DH identifiers to TKM DH
algorithm identifiers. The mapping is specified in the daemon's
'dh_mapping' section in the strongswan.conf file:

dh_mapping {
	iana_id1 = tkm_id1
	iana_id2 = tkm_id2
	iana_id3 = tkm_id3
	...
}

Only the mapped IANA IDs are registered as supported DH groups.
2013-12-03 11:58:53 +01:00
Adrian-Ken Rueegsegger 9e8a52003a charon-tkm: Drop unnecessary include 2013-12-03 11:58:53 +01:00
Tobias Brunner f5feeb04f3 charon-tkm: Don't run tests automatically during 'make check'
Due to the external dependencies these tests are quite inconvenient.
They can be run from the charon-tkm directory with 'make check-tkm'.
2013-11-27 18:35:44 +01:00
Reto Buerki 5221a16391 charon-tkm: Add Binder switches to test project to enable exception backtraces 2013-11-27 18:35:44 +01:00
Tobias Brunner d6032bff8b charon-tkm: Migrate tests to our own test runner
Due to problems with the external libraries tkm_init/deinit can't be
called for each test case.  Because of this leak detective has to be
disabled for these tests.
2013-11-27 18:35:44 +01:00
Tobias Brunner 70f4461359 charon-tkm: Support for out-of-tree build added 2013-11-27 18:35:44 +01: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
Tobias Brunner 82b1a38601 tkm: Properly refer to includes now that AM_CPPFLAGS is used 2013-07-19 09:02:04 +02:00
Martin Willi 19cb07b890 automake: replace INCLUDES by AM_CPPFLAGS
INCLUDES are now deprecated and throw warnings when using automake 1.13.
We now also differentiate AM_CPPFLAGS and AM_CFLAGS, where includes and
defines are passed to AM_CPPFLAGS only.
2013-07-18 14:59:19 +02:00
Tobias Brunner a2eb581781 capabilities: Move global capabilities_t instance to libstrongswan 2013-06-25 17:16:32 +02:00
Tobias Brunner 607f8e9906 plugin-loader: Add method to print loaded plugins on a given log level 2013-06-21 15:17:53 +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
Tobias Brunner cf95d2926c Fixed some typos, courtesy of codespell 2013-03-25 10:59:37 +01: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
Adrian-Ken Rueegsegger e2928a3e8c Provide MODP-2048 through TKM DH plugin 2013-03-19 15:23:51 +01:00
Adrian-Ken Rueegsegger 7f21523abd Add charon-tkm API documentation 2013-03-19 15:23:51 +01:00
Reto Buerki 0063e03325 Do not hardwire keys to KEY_RSA
Make the TKM private and public keys more easily extendable by
determining the associated key type dynamically.
2013-03-19 15:23:51 +01:00
Reto Buerki 38c1fd3cb1 Provide TKM credential encoder
The TKM credential encoder creates fingerprints of type
KEYID_PUBKEY_INFO_SHA1 and KEYID_PUBKEY_SHA1 using
CRED_PART_RSA_PUB_ASN1_DER.

This makes the pkcs1 plugin unnecessary.
2013-03-19 15:23:51 +01:00
Reto Buerki 1b22565ba5 Switch to openssl plugin 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 32b2ea9edb Move stroke plugin to the end of PLUGINS list
This fixes the problem of stroke being unable to load the ca
certificates 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 89b1d5f32c Call isa_skip_create_first when keeping IKE SA
An ALERT_KEEP_ON_CHILD_SA_FAILURE alert is issued when child SA establishment
fails but the corresponding IKE SA is not destroyed. To allow later creation
of child SAs the ISA context must be signaled that the implicity first child SA
creation was skipped.
2013-03-19 15:23:50 +01:00
Adrian-Ken Rueegsegger 140a6b7b34 Make IKE and EES sockets configurable
The IKE and EES sockets are now read from strongswan.conf. They can be
specified like this:

charon-tkm {
	ike_socket = /tmp/tkm.rpc.ike
	ees_socket = /tmp/tkm.rpc.ees
}

The socket names given above are used by default if none are configured.
2013-03-19 15:23:50 +01:00
Reto Buerki f47ea969f8 Implement TKM-specific credential set
The TKM credential set extends the in-memory credential set. It
provides a private key enumerator which is used to instantiate private
key proxy objects on-demand. This allows the usage of private keys with
arbitrary identifiers.
2013-03-19 15:23:50 +01:00
Reto Buerki ec169572a0 Initialize libstrongswan in test_runner main() 2013-03-19 15:23:50 +01:00
Adrian-Ken Rueegsegger 9099d2ba0b Set ri_id to reqid when setting user certificate
Pass the reqid (of the first child config of an IKE SA) as remote identity id
when calling cc_set_user_certificate. May lead to the usage of the wrong id in
case an IKE SA has multiple child configurations/reqids.

This must be replaced with a proper lookup once the configuration backend is
implemented and provides remote identity ids to charon-tkm.
2013-03-19 15:23:49 +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 d2371b728c Check that chunk fits into sequence when converting 2013-03-19 15:23:49 +01:00
Reto Buerki 3360bad910 Remove result out parameter from EES Init
Error processing is done by the registered exception handler.
2013-03-19 15:23:49 +01:00
Adrian-Ken Rueegsegger 0f5e57fe26 Drop support for pre-shared key authentication 2013-03-19 15:23:49 +01:00
Reto Buerki c457128ab6 charon-tkm: Register TKM private key on startup 2013-03-19 15:23:49 +01:00
Reto Buerki 08d199fa3d Add TKM private key implementation
The key currently imitates the private key of alice@strongswan.org by
returning it's fingerprint in the get_fingerprint function.

This associates the private key with alice's X.509 cert and charon will
use it to create a signature over the local AUTH octets of the test
connection.

The private key serves as a proxy to the TKM ike_isa_sign operation and
extracts the required information from the auth octets chunk passed on
by the keymat.
2013-03-19 15:23:49 +01:00
Reto Buerki fe504b745d keymat: Store signature info in auth octets
Store the ISA context id and the initial message in the auth octets
chunk using the sign_info_t struct. Charon will pass on this information
to the TKM private key sign operation where it is extracted.
2013-03-19 15:23:49 +01:00
Reto Buerki a2f97ff860 Add AUTH signature info data structure
The sign_info_t type is used to transfer an ISA context id and the
initial message from the keymat to the TKM private key sign operation.
2013-03-19 15:23:49 +01:00
Adrian-Ken Rueegsegger ac90fcee2f charon-tkm: Register TKM public key on startup 2013-03-19 15:23:49 +01:00
Adrian-Ken Rueegsegger 9a5c51c44f Add TKM public key implementation
The key unconditionally returns TRUE for the verify operation if it is called
with a supported signature algorithm. All such verification operations are
performed by the TKM (e.g. trustchain or auth octets verification) anyway, so
this is safe.
2013-03-19 15:23:49 +01:00
Adrian-Ken Rueegsegger 832488b14a Authenticate ISA using certificates
The authentication of the ISA is now done using the certificate provided
by the peer.
2013-03-19 15:23:49 +01:00
Adrian-Ken Rueegsegger 49b1fdb24a Store peer IKE init message
The IKE init message sent to us by the peer is needed for authentication
in the authorization hook. Store the message as chunk in the keymat and
provide a getter to make it available.
2013-03-19 15:23:49 +01:00
Adrian-Ken Rueegsegger 351bd59de2 Build cc context in tkm listener authorize hook
Extract peer certificate information and build a TKM certificate chain
context in the authorize hook of the tkm_listener_t. The cc context will
be used for ISA authentication using certificates.
2013-03-19 15:23:49 +01:00
Adrian-Ken Rueegsegger 464eb54ba4 Add TKM_CTX_CC (Certificate chain context id) 2013-03-19 15:23:48 +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
Reto Buerki 270b321e97 Implement Ada exception processing
Register a global exception action with the Ada runtime to log uncaught
exceptions to the daemon log and terminate.
2013-03-19 15:23:48 +01:00
Reto Buerki e0cb01f44d Implement Esa Event Service (EES)
The Esa Event Service can be used to trigger ESP SA (ESA) events such as
acquire or expire. The incoming events are forwarded to the hydra kernel
interface for processing.
2013-03-19 15:23:48 +01:00
Adrian-Ken Rueegsegger d9c6480688 Conditionally reset AE context in keymat destroy
The responsibility to reset an authenticated endpoint context is passed
from a parent IKE SA keymat to the new keymat by including it in the ISA
info data contained in the skd chunk. The last IKE SA to be destroyed
will also reset the associated AE context.
2013-03-19 15:23:48 +01:00
Adrian-Ken Rueegsegger 62b625430e Let tkm_keymat_t extend keymat_v2_t 2013-03-19 15:23:48 +01:00
Adrian-Ken Rueegsegger 2ac988bf4b Implement IKE SA rekeying
Use the TKM ike_isa_create_child exchange to rekey an IKE SA. The isa context id
is passed on (ab)using the rekey_skd chunk.
2013-03-19 15:23:48 +01:00
Adrian-Ken Rueegsegger e472129aa3 Add test for keymat derive_child_keys operation 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 1e13904f45 Implement TKM kernel SA database (SAD)
The TKM kernel SAD (security association database) stores information
about CHILD SAs.
2013-03-19 15:23:48 +01:00
Adrian-Ken Rueegsegger d1c0822759 Add TKM_CTX_ESA (ESP SA context id) 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