Page MenuHomeFreeBSD

Add ESP TFC padding support
Needs ReviewPublic

Authored by aurelien.cazuc.external_stormshield.eu on Nov 19 2019, 2:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 7 2024, 1:58 AM
Unknown Object (File)
Mar 7 2024, 1:58 AM
Unknown Object (File)
Mar 7 2024, 1:58 AM
Unknown Object (File)
Mar 7 2024, 1:58 AM
Unknown Object (File)
Mar 7 2024, 1:58 AM
Unknown Object (File)
Mar 7 2024, 1:58 AM
Unknown Object (File)
Mar 7 2024, 12:52 AM
Unknown Object (File)
Mar 7 2024, 12:00 AM
Subscribers

Details

Reviewers
ae
bz
mw
Group Reviewers
Contributor Reviews (src)
Summary

This patch provides support of TFC padding in ESP packets as specified by RFC 4303
Padding is added between payload and cipher padding to force packet size

To control TFC padding length, a new SADB extension structure is defined (struct sadb_x_sa_tfc_length, SADB_X_EXT_SA_TFC_LENGTH)
Received packets with TFC padding is already supported as it doesn't need any specific code

Sponsored by: Stormshield

Test Plan

When pinging through an IPsec tunnel, tcpdump reports that packets have the length set by tfc padding (modulo cipher padding length)

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

sys/net/pfkeyv2.h
304

Is there any reason not to make the length unsigned?

sys/netipsec/key.c
2958

sav is allocated with M_ZERO flag, there is no need to initialize tfc field explicitly. IMHO.

3415

I think we should not override specified value and just return error to the app here.

3572

It would be good move this adjustment into key_setnatt() and fix the style(9).

7412

Is this header really needed for SADB_EXPIRE message? Also wrong style.

sys/netipsec/keydb.h
189

the same question, why we use signed length here?

sys/net/pfkeyv2.h
304

I set it to signed because strongswan use -1 as magic value for "pad to MTU"
It could be set to unsigned but it would need checks for -1 instead of > 0

sys/netipsec/key.c
7412

Not really, I removed it

Padding is now done per block of MHLEN bytes to avoid buffer overflow due to m_pad allocating at most 1 mbuf