IPsec key management

Every edge gets its tunnel keys through the controller, so can the controller read the traffic? In the traditional model, the default, each router generates an AES key per TLOC and sends it to the controller in OMP. In the pairwise model the controller passes only Diffie-Hellman public values. Keys live 86400 seconds by default and can be rekeyed by hand. Anti-replay keeps a sliding window.

In Daveth Pro (Network)5 min video · lab: SD-WAN, step by step

By , founder of Daveth · Updated

Opening frame of the video walkthrough of IPsec key management

Watch this lesson

5 min · Video walkthrough

In Daveth Pro (Network)

The full 5 min walkthrough is in Daveth Pro (Network). See what the plan opens

Upcoming practical lab

Lab C18: SD-WAN, step by step

What the lab covers

What this page answers

What is the difference between SD-WAN traditional and pairwise keys?

In the traditional model the controller sends each edge's IPsec encryption keys to the others. In the pairwise model it sends only Diffie-Hellman public values, and the edges derive the keys. Pairwise keying is off by default. Read it in “What an edge hands the controller”

How often are SD-WAN IPsec keys regenerated?

By default a key is valid for 86400 seconds, 24 hours, and changing keys drops no data traffic. request platform software sdwan security ipsec-rekey rekeys at once. Read it in “Rekeying by hand”

What is the SD-WAN anti-replay window?

A sliding window of sequence numbers the destination accepts, because packets arrive out of order. Packets to the left of the window are treated as old or duplicates and dropped. Read it in “The replay window”

The question a security team will ask

Every edge gets its tunnel keys through the controller. Can VSMART-1 read the traffic?

It is the first thing a security review asks about this design, and the reassuring answer is that only public values cross the controller. That answer is true of one of two key models. The Security Overview names both:

In the traditional key exchange model, the Cisco Catalyst SD-WAN Controller sends IPsec encryption keys to each edge device. In the pairwise keys model, the Cisco SD-WAN Controller sends Diffie-Hellman public values to the edge devices, and they generate pairwise IPsec encryption keys using Elliptic-curve Diffie-Hellman (ECDH) and a P-384 curve.

2.2.a.iii said OMP carries security information as well as routes. Which of these two models is that, on an overlay nobody has tuned? The reassuring answer stands or falls on it.

What an edge hands the controller

Nobody has changed the security settings on this overlay. What does EDGE-A hand to VSMART-1 for its data path?

Pairwise keying is turned off by default, as the Security feature template says in the section on pairwise keys below. So an edge nobody has tuned runs the traditional model, and the overview says what that sends:

Each router periodically generates an AES key for its data path (specifically, one key per TLOC) and transmits this key to the Cisco SD-WAN Controller in OMP route packets, which are similar to IP route updates. The Cisco SD-WAN Controller then places these OMP route packets into reachability advertisements that it sends to the other routers in the network. In this way, the AES keys for all the routers are distributed across the network.
Cisco Catalyst SD-WAN devices exchange not only the encryption key (which is symmetric), but also the authentication key that is used to generate the digest. Both are distributed as part of the TLOC properties for a router.

Computed from the state: what EDGE-A holds under the default model, and what it sends. No command prints it.

default model: EDGE-A holds                                       secret   sent
the AES encryption key for its mpls TLOC                          yes      yes
the authentication key in its mpls TLOC's properties              yes      yes
the AES encryption key for its biz-internet TLOC                  yes      yes
the authentication key in its biz-internet TLOC's properties      yes      yes

Read the last two columns together. Every row is secret and every row is sent: 2 TLOCs, so 4 keys from one edge. Document 218164 calls the same arrangement a group key:

In this model, an SD-WAN edge device periodically generates data plane inbound SA per TLOC (Transport Locator) and sends these SAs to the SD-WAN controller, which in turn propagates the SA to the rest of the edge devices in the SD-WAN fabric.

Is anything protecting them on the way? The control plane they ride on:

Keys are generated and refreshed locally, and key exchange is performed over a secure control plane.

And does every edge learn every key? Only the ones policy lets it use.

So, a router learns the keys only for those routers that they are allowed to communicate with.

Computed from the state: control policy does not allow EDGE-B to talk to EDGE-A. No command prints it.

policy allows EDGE-B to talk to EDGE-A      no
EDGE-B learns from EDGE-A                   nothing

Notice that nothing about EDGE-A's keys changed. Only who receives them did.

Why build it this way at all? Scale, and the overview says so directly:

Because only n +1 keypaths are required rather than the n2 required by IKE, the Cisco Catalyst SD-WAN solution scales better as the network grows large.

Rekeying by hand

How long does a key live, and what do you do the day you think EDGE-A's has leaked?

By default, a key is valid for 86400 seconds (24 hours) routers regenerate their AES keys aggressively (by default, every 24 hours). Also, the key regeneration mechanism ensures that no data traffic is dropped when keys change.

The timer is one line, which the guide prints as Device(config)# security ipsec rekey seconds. For a suspected leak, request platform software sdwan security ipsec-rekey does not wait for it, and every key has its own SPI:

A unique key is associated with each SPI.

Output from elsewhere: the local SA before a rekey. The values in it come from elsewhere, not from this scenario.

Device# show sdwan ipsec local-sa

                                          SOURCE           SOURCE
TLOC ADDRESS     TLOC COLOR       SPI     IP               PORT    KEY HASH
------------------------------------------------------------------------------
172.16.255.15    lte              256     10.1.15.15       12346   *****b93a

Output from elsewhere: after request platform software sdwan security ipsec-rekey. The values in it come from elsewhere, not from this scenario.

Device# request platform software sdwan security ipsec-rekey
Device# show sdwan ipsec local-sa
                                          SOURCE           SOURCE
TLOC ADDRESS     TLOC COLOR       SPI     IP               PORT    KEY HASH
------------------------------------------------------------------------------
172.16.255.15    lte              257     10.1.15.15       12346   *****b93a
After the new key is generated, the router sends it immediately to the Cisco SD-WAN Controllers using DTLS or TLS. The Cisco SD-WAN Controllers send the key to the peer routers. The routers begin using it as soon as they receive it. Note that the key associated with the old SPI (256) will continue to be used for a short period of time, until it times out.

Look where the new key goes: to the controllers, then to the peers. The rekey page describes the default model as plainly as the overview does.

Computed from the state: EDGE-A after one rekey. No command prints it.

SPI in use                                  257
older SPIs whose keys are still used        256
some packets dropped until peers learn it   no
new key sent to                             VSMART-1, which sends it to the peers

And if the old key must stop at once?

To stop using the old key immediately, issue the request platform software sdwan security ipsec-rekey command twice, in quick succession. Note, however, that some packets will be dropped for a short period of time, until all the remote routers learn the new key.

Output from elsewhere: after two rekeys in quick succession. The values in it come from elsewhere, not from this scenario.

Device# request platform software sdwan security ipsec-rekey
Device# request platform software sdwan security ipsec-rekey
Device# show sdwan ipsec local-sa
                                          SOURCE           SOURCE
TLOC ADDRESS     TLOC COLOR       SPI     IP               PORT    KEY HASH
------------------------------------------------------------------------------
172.16.255.15    lte              258     10.1.15.15       12346   *****b93a

Computed from the state: EDGE-A after two. No command prints it.

SPI in use                                  258
older SPIs whose keys are still used        none
some packets dropped until peers learn it   yes
new key sent to                             VSMART-1, which sends it to the peers

Look at row three before you run it twice on a live overlay. The drop is published, and brief, and real.

So read the SPI for what it is: a marker that the key state moved, and nothing else. It is not a version number worth being high, and it is not a score. It went up because you asked for a new key, and the only question it answers is whether the change you requested actually happened.

And compare it against the right thing. Each security association keeps its own numbering, so two of them carrying the same value are not duplicates any more than two queues both holding a ticket numbered 42. Before you call anything a collision, check you are comparing two entries from the same place.

Proves: the SPI this edge is using for each TLOC now, so whether a rekey has happened. Does not prove: that the remote routers have learned the new key, or that the key for an older SPI has stopped being used.

One more change replaces the key without anybody asking for a rekey:

Which is the kind of thing to know before a maintenance window rather than during one. You went in to adjust a setting. The key was replaced as a consequence, and a consequence that arrives without being requested is exactly what an audit trail makes awkward to explain afterwards.

When the IPsec authentication type is changed, the AES key for the data path is changed.

The replay window

What does anti-replay stop, and why does it sometimes drop packets nobody replayed?

Because packets often do not arrive in order, the destination maintains a sliding window of sequence numbers that it will accept. Packets with sequence numbers that fall to the left of the sliding window range are considered old or duplicates, and the destination drops them. The destination tracks the highest sequence number it has received, and adjusts the sliding window when it receives a packet with a higher value.
By default, the sliding window is set to 512 packets. To help with QoS, separate replay windows are maintained for each of the first eight traffic channels. The configured replay window size is divided by eight for each channel.

Eight windows, so eight highest numbers. Can an edge show you them? Document 218164 reads them from the data-plane output of show crypto ipsec sa peer x.x.x.x platform, for one inbound SA:

Output from elsewhere: the sequence number spaces of one inbound SA. The values in it come from elsewhere, not from this scenario.

 anti-replay enabled
 esn enabled
 Inbound SA
 Total SNS: 8
 Space                highest ar number
 ----------------------------------------
   0                               39444
   1                                   0
   2                                1355
   3                                   0
   4                                   0
   5                                   0
   6                                   0
   7                                   0

Look at spaces 0 and 2. They are the only two whose highest number is above zero, so they are the only two that have received anything on this SA.

A packet numbered 1100 reaches EDGE-B. Is it a replay?

Computed from the state: EDGE-B's windows at 64 per space, and packet 1100 in spaces 0 and 2. No command prints it.

packet 1100, arriving in      verdict
space 0                       dropped: old or duplicate
  it falls to the left of the window
space 2                       accepted
  it is higher than anything received, so the window moves up to it