You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Introduction


Internet Protocol Security (IPsec) is a set of protocols defined by the Internet Engineering Task Force (IETF) to secure packet exchange over unprotected IP/IPv6 networks such as the Internet.


IPsec protocol suite can be divided into the following groups:

  • Internet Key Exchange (IKE) protocols. Dynamically generates and distributes cryptographic keys for AH and ESP.
  • Authentication Header (AH) RFC 4302
  • Encapsulating Security Payload (ESP) RFC 4303

Internet Key Exchange Protocol (IKE)

The Internet Key Exchange (IKE) is a protocol that provides authenticated keying material for the Internet Security Association and Key Management Protocol (ISAKMP) framework. There are other key exchange schemes that work with ISAKMP, but IKE is the most widely used one. Together they provide means for authentication of hosts and automatic management of security associations (SA).

Most of the time IKE daemon is doing nothing. There are two possible situations when it is activated:

There is some traffic caught by a policy rule which needs to become encrypted or authenticated, but the policy doesn't have any SAs. The policy notifies IKE daemon about that, and IKE daemon initiates a connection to a remote host. IKE daemon responds to remote connection. In both cases, peers establish a connection and execute 2 phases:

  • Phase 1 - The peers agree upon algorithms they will use in the following IKE messages and authenticate. The keying material used to derive keys for all SAs and to protect following ISAKMP exchanges between hosts is generated also. This phase should match the following settings:
    • authentication method
    • DH group
    • encryption algorithm
    • exchange mode
    • hash algorithm
    • NAT-T
    • DPD and lifetime (optional)
  • Phase 2 - The peers establish one or more SAs that will be used by IPsec to encrypt data. All SAs established by IKE daemon will have lifetime values (either limiting time, after which SA will become invalid, or amount of data that can be encrypted by this SA, or both). This phase should match the following settings:
    • IPsec protocol
    • mode (tunnel or transport)
    • authentication method
    • PFS (DH) group
    • lifetime

There are two lifetime values - soft and hard. When SA reaches it's soft lifetime treshold, the IKE daemon receives a notice and starts another phase 2 exchange to replace this SA with fresh one. If SA reaches hard lifetime, it is discarded.

Phase 1 is not re-keyed if DPD is disabled when the lifetime expires, only phase 2 is re-keyed. To force phase 1 re-key, enable DPD.

PSK authentication was known to be vulnerable against Offline attacks in "aggressive" mode, however recent discoveries indicate that offline attack is possible also in case of "main" and "ike2" exchange modes. A general recommendation is to avoid using the PSK authentication method.

IKE can optionally provide a Perfect Forward Secrecy (PFS), which is a property of key exchanges, that, in turn, means for IKE that compromising the long term phase 1 key will not allow to easily gain access to all IPsec data that is protected by SAs established through this phase 1. It means an additional keying material is generated for each phase 2.

The generation of keying material is computationally very expensive. Exempli Gratia, the use of the modp8192 group can take several seconds even on a very fast computer. It usually takes place once per phase 1 exchange, which happens only once between any host pair and then is kept for a long time. PFS adds this expensive operation also to each phase 2 exchange.

Diffie-Hellman Groups

Diffie-Hellman (DH) key exchange protocol allows two parties without any initial shared secret to create one securely. The following Modular Exponential (MODP) and Elliptic Curve (EC2N) Diffie-Hellman (also known as "Oakley") Groups are supported:

Diffie-Hellman GroupNameReference
Group 1768 bit MODP groupRFC 2409
Group 21024 bits MODP groupRFC 2409
Group 3EC2N group on GP(2^155)RFC 2409
Group 4EC2N group on GP(2^185)RFC 2409
Group 51536 bits MODP groupRFC 3526
Group 142048 bits MODP groupRFC 3526
Group 153072 bits MODP groupRFC 3526
Group 164096 bits MODP groupRFC 3526
Group 176144 bits MODP groupRFC 3526
Group 188192 bits MODP groupRFC 3526
Group 19256 bits random ECP groupRFC 5903
Group 20384 bits random ECP groupRFC 5903
Group 21521 bits random ECP groupRFC 5903

More on standards can be found here.

IKE Traffic

To avoid problems with IKE packets hit some SPD rule and require to encrypt it with not yet established SA (that this packet perhaps is trying to establish), locally originated packets with UDP source port 500 are not processed with SPD. The same way packets with UDP destination port 500 that are to be delivered locally are not processed in incoming policy checks.

Setup Procedure

To get IPsec to work with automatic keying using IKE-ISAKMP you will have to configure policy, peer, and proposal (optional) entries.

IPsec is very sensitive to time changes. If both ends of the IPsec tunnel are not synchronizing time equally(for example, different NTP servers not updating time with the same timestamp), tunnels will break and will have to be established again.

EAP Authentication methods

Outer AuthInner Auth
EAP-GTC
EAP-MD5
EAP-MSCHAPv2
EAP-PEAPv0

EAP-MSCHAPv2
EAP-GPSK
EAP-GTC
EAP-MD5
EAP-TLS

EAP-SIM
EAP-TLS
EAP-TTLS

PAP
CHAP
MS-CHAP
MS-CHAPv2
EAP-MSCHAPv2
EAP-GTC
EAP-MD5
EAP-TLS

Authentication Header (AH)

AH is a protocol that provides authentication of either all or part of the contents of a datagram through the addition of a header that is calculated based on the values in the datagram. What parts of the datagram are used for the calculation, and the placement of the header depends on whether tunnel or transport mode is used.

The presence of the AH header allows to verify the integrity of the message but doesn't encrypt it. Thus, AH provides authentication but not privacy. Another protocol (ESP) is considered superior, it provides data privacy and also its own authentication method.

RouterOS supports the following authentication algorithms for AH:

  • SHA2 (256, 512)
  • SHA1
  • MD5

Transport mode

In transport mode, AH header is inserted after the IP header. IP data and header is used to calculate authentication value. IP fields that might change during transit, like TTL and hop count, are set to zero values before authentication.

Tunnel mode

In tunnel mode original IP packet is encapsulated within a new IP packet. All of the original IP packets is authenticated.


  • No labels