Project

General

Profile

IKE keying daemon charon » History » Version 18

Tobias Brunner, 10.07.2014 15:19

1 18 Tobias Brunner
h1. IKE keying daemon charon
2 14 Tobias Brunner
3 1 Martin Willi
The _charon_ keying daemon was built from scratch to implement the IKEv2 protocol for strongSwan. 
4 18 Tobias Brunner
5 18 Tobias Brunner
Most of its code is located in the _libcharon_ library, making the IKE daemon core available to other programs such as [[charon-svc]], [[charon-cmd]] or the [[AndroidVPNClient|Android app]].
6 1 Martin Willi
7 14 Tobias Brunner
h2. Architecture
8 14 Tobias Brunner
9 1 Martin Willi
<pre>
10 1 Martin Willi
      +---------------------------------+       +----------------------------+
11 14 Tobias Brunner
      |          Credentials            |       |          Backends          |
12 15 Martin Willi
      +---------------------------------+       +----------------------------+
13 15 Martin Willi
14 1 Martin Willi
       +------------+    +-----------+        +------+            +----------+
15 1 Martin Willi
       |  receiver  |    |           |        |      |  +------+  | CHILD_SA |
16 1 Martin Willi
       +----+-------+    | Scheduler |        | IKE- |  | IKE- |--+----------+
17 1 Martin Willi
            |            |           |        | SA   |--| SA   |  | CHILD_SA |
18 1 Martin Willi
    +-------+--+         +-----------+        |      |  +------+  +----------+
19 1 Martin Willi
 <->|  socket  |               |              | Man- |
20 1 Martin Willi
    +-------+--+         +-----------+        | ager |  +------+  +----------+
21 1 Martin Willi
            |            |           |        |      |  | IKE- |--| CHILD_SA |
22 1 Martin Willi
       +----+-------+    | Processor |--------|      |--| SA   |  +----------+
23 15 Martin Willi
       |   sender   |    |           |        |      |  +------+
24 15 Martin Willi
       +------------+    +-----------+        +------+
25 15 Martin Willi
26 1 Martin Willi
      +---------------------------------+       +----------------------------+
27 1 Martin Willi
      |               Bus               |       |      Kernel Interface      |
28 15 Martin Willi
      +---------------------------------+       +----------------------------+
29 1 Martin Willi
             |                    |                           |
30 1 Martin Willi
      +-------------+     +-------------+                     V
31 1 Martin Willi
      | File-Logger |     |  Sys-Logger |                  //////
32 15 Martin Willi
      +-------------+     +-------------+
33 7 Martin Willi
</pre>
34 7 Martin Willi
35 13 Tobias Brunner
36 15 Martin Willi
|Processor        |The threading is realized with the help of a thread pool (called processor), which contains a fixed amount of precreated threads. All threads in the daemon originate from the processor. To delegate work to a thread, jobs are queued to the processor for asynchronous execution.|
37 15 Martin Willi
|Scheduler        |The scheduler is responsible to execute timed events. Jobs may be queued to the scheduler to get executed at a defined time (e.g. rekeying). The scheduler does not execute the jobs itself, it queues them to the processor.|
38 15 Martin Willi
|IKE_SA Manager   |The IKE_SA manager manages all IKE_SAs. It further handles the synchronization: Each IKE_SA must be checked out strictly and checked in again after use. The manager guarantees that only one thread may check out a single IKE_SA. This allows us to write the (complex) IKE_SAs routines non-threadsave.|
39 15 Martin Willi
|IKE_SA           |The IKE_SA contain the state and the logic of each IKE_SA and handle the messages.|
40 15 Martin Willi
|CHILD_SA         |The CHILD_SA contains state about an IPsec security association and manages them. An IKE_SA may have multiple CHILD_SAs. Communication to the kernel takes place here through the kernel interface.|
41 15 Martin Willi
|Kernel Interface |The kernel interface installs IPsec security associations, policies, routes and virtual addresses. It further provides methods to enumerate interfaces and may notify the daemon about state changes at lower layers.|
42 15 Martin Willi
|Bus              |The bus receives signals from the different threads and relays them to interested listeners. Debugging signals, but also important state changes or error messages are sent over the bus.|
43 15 Martin Willi
|Controller       |The controller provides a simple API for plugins to control the daemon (e.g. initiate IKE_SA, close IKE_SA, ...).|
44 15 Martin Willi
|Backends         |Backends are pluggable modules which provide configuration. They have to implement an API which the daemon core uses to get configuration.|
45 15 Martin Willi
|Credentials      |Provides trustchain verification and credential serving using registered plugins.|
46 14 Tobias Brunner
47 14 Tobias Brunner
h2. Plugins
48 14 Tobias Brunner
49 15 Martin Willi
The daemon loads plugins at startup. These implement the plugin_t interface (source:src/libstrongswan/plugins/plugin.h). Each plugin registers itself at the daemon to hook in functionality. 
50 1 Martin Willi
51 14 Tobias Brunner
<pre>
52 4 Martin Willi
  +-------------------------------------+
53 1 Martin Willi
  | charon                  +---+ +-----+------+
54 1 Martin Willi
  |                         |   | |   stroke   |
55 1 Martin Willi
  |                         |   | +-----+------+
56 1 Martin Willi
  | +-------------+         |   | +-----+------+
57 1 Martin Willi
  | | bus         |  ---->  | p | |    smp     |
58 1 Martin Willi
  | +-------------+         | l | +-----+------+
59 4 Martin Willi
  | +-------------+  <----  | u | +-----+------+
60 4 Martin Willi
  | | controller  |         | g | |    sql     |
61 4 Martin Willi
  | +-------------+  ---->  | i | +-----+------+
62 4 Martin Willi
  | +-------------+         | n | +-----+------+
63 4 Martin Willi
  | | credentials |  <----  |   | |  eap_aka   |
64 4 Martin Willi
  | +-------------+         | l | +-----+------+
65 4 Martin Willi
  | +-------------+  ---->  | o | +-----+------+
66 4 Martin Willi
  | | backends    |         | a | |  eap_sim   |
67 4 Martin Willi
  | +-------------+  <----  | d | +-----+------+
68 1 Martin Willi
  | +-------------+         | e | +-----+------+
69 1 Martin Willi
  | | eap         |  ---->  | r | |  eap_md5   |
70 1 Martin Willi
  | +-------------+         |   | +-----+------+
71 4 Martin Willi
  |                         |   | +-----+------+
72 4 Martin Willi
  |                         |   | |eap_identity|
73 4 Martin Willi
  |                         +---+ +-----+------+
74 4 Martin Willi
  +-------------------------------------+
75 1 Martin Willi
</pre>
76 14 Tobias Brunner
77 17 Martin Willi
There is a growing [[PluginList|list of available plugins]] (see source:src/libcharon/plugins).