How do I use AES-NI acceleration for IPSEC to pfSense?

Started by breakaway, June 04, 2022, 06:27:18 AM

Previous topic - Next topic
Long time pfSense user, I have many pfsense systems I look after but I am looking to make a switch.

I now have OPNsense 22.1.8_1-amd64 running in my lab. I am trying to connect IPSEC to a pfSense running 2.6.0 (latest) by using AES-NI acceleration.

I tried setting the same settings on both sides:
OpnSense:
Phase 1
->  Encryption algorithm 128 bit AES-GCM with 128 bit icv
->  Hash algorithm AES-XCBC
->  DH Group: 14

pfSense:
Phase 1
-> Algorithm: AES128-GCM
-> Key Length: 128 bit
-> Hash: AES-XCBC
-> DH Group: 14

But if I apply this, the IPSEC phase 1 won't connect. pfSense side shows timeout, and OpnSense side shows "key derivation failed".

If I set the "Hash" to SHA i.e. SHA512 on both sides (P1 & P2) it will connect. Why won't it connect with AES-XCBC on both sides?


Some log output below. Any ideas?


2022-06-04T16:08:22 Informational charon 09[NET] <108> sending packet: from 122.23.25.86[500] to 126.33.25.61[500] (36 bytes)
2022-06-04T16:08:22 Informational charon 09[ENC] <108> generating IKE_SA_INIT response 0 [ N(NO_PROP) ]
2022-06-04T16:08:22 Informational charon 09[IKE] <108> key derivation failed
2022-06-04T16:08:22 Informational charon 09[IKE] <108> KDF_PRF with PRF_UNDEFINED not supported
2022-06-04T16:08:22 Informational charon 09[CFG] <108> selected proposal: IKE:AES_GCM_16_128/PRF_AES128_XCBC/MODP_2048
2022-06-04T16:08:22 Informational charon 09[IKE] <108> 126.33.25.61 is initiating an IKE_SA
2022-06-04T16:08:22 Informational charon 09[ENC] <108> parsed IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(FRAG_SUP) N(HASH_ALG) N(REDIR_SUP) ]
2022-06-04T16:08:22 Informational charon 09[NET] <108> received packet: from 126.33.25.61[500] to 122.23.25.86[500] (456 bytes)
2022-06-04T16:08:18 Informational charon 09[CFG] ignoring acquire for reqid 1, connection attempt pending
2022-06-04T16:08:18 Informational charon 09[KNL] creating acquire job for policy 122.23.25.86/32 === 126.33.25.61/32 with reqid {1}
2022-06-04T16:08:18 Informational charon 09[NET] <107> sending packet: from 122.23.25.86[500] to 126.33.25.61[500] (36 bytes)
2022-06-04T16:08:18 Informational charon 09[ENC] <107> generating IKE_SA_INIT response 0 [ N(NO_PROP) ]
2022-06-04T16:08:18 Informational charon 09[IKE] <107> key derivation failed
2022-06-04T16:08:18 Informational charon 09[IKE] <107> KDF_PRF with PRF_UNDEFINED not supported
2022-06-04T16:08:18 Informational charon 09[CFG] <107> selected proposal: IKE:AES_GCM_16_128/PRF_AES128_XCBC/MODP_2048
2022-06-04T16:08:18 Informational charon 09[IKE] <107> 126.33.25.61 is initiating an IKE_SA
2022-06-04T16:08:18 Informational charon 09[ENC] <107> parsed IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(FRAG_SUP) N(HASH_ALG) N(REDIR_SUP) ]
2022-06-04T16:08:18 Informational charon 09[NET] <107> received packet: from 126.33.25.61[500] to 122.23.25.86[500] (456 bytes)
2022-06-04T16:08:16 Informational charon 09[NET] <106> sending packet: from 122.23.25.86[500] to 126.33.25.61[500] (36 bytes)
2022-06-04T16:08:16 Informational charon 09[ENC] <106> generating IKE_SA_INIT response 0 [ N(NO_PROP) ]
2022-06-04T16:08:16 Informational charon 09[IKE] <106> key derivation failed
2022-06-04T16:08:16 Informational charon 09[IKE] <106> KDF_PRF with PRF_UNDEFINED not supported
2022-06-04T16:08:16 Informational charon 09[CFG] <106> selected proposal: IKE:AES_GCM_16_128/PRF_AES128_XCBC/MODP_2048
2022-06-04T16:08:16 Informational charon 09[IKE] <106> 126.33.25.61 is initiating an IKE_SA
2022-06-04T16:08:16 Informational charon 09[ENC] <106> parsed IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(FRAG_SUP) N(HASH_ALG) N(REDIR_SUP) ]
2022-06-04T16:08:16 Informational charon 09[NET] <106> received packet: from 126.33.25.61[500] to 122.23.25.86[500] (456 bytes)
2022-06-04T16:08:15 Informational charon 13[CFG] ignoring acquire for reqid 1, connection attempt pending
2022-06-04T16:08:15 Informational charon 13[KNL] creating acquire job for policy 122.23.25.86/32 === 126.33.25.61/32 with reqid {1}
2022-06-04T16:08:14 Informational charon 13[NET] <105> sending packet: from 122.23.25.86[500] to 126.33.25.61[500] (36 bytes)
2022-06-04T16:08:14 Informational charon 13[ENC] <105> generating IKE_SA_INIT response 0 [ N(NO_PROP) ]
2022-06-04T16:08:14 Informational charon 13[IKE] <105> key derivation failed
2022-06-04T16:08:14 Informational charon 13[IKE] <105> KDF_PRF with PRF_UNDEFINED not supported
2022-06-04T16:08:14 Informational charon 13[CFG] <105> selected proposal: IKE:AES_GCM_16_128/PRF_AES128_XCBC/MODP_2048
2022-06-04T16:08:14 Informational charon 13[IKE] <105> 126.33.25.61 is initiating an IKE_SA
2022-06-04T16:08:14 Informational charon 13[ENC] <105> parsed IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(FRAG_SUP) N(HASH_ALG) N(REDIR_SUP) ]
2022-06-04T16:08:14 Informational charon 13[NET] <105> received packet: from 126.33.25.61[500] to 122.23.25.86[500] (456 bytes)
2022-06-04T16:08:12 Informational charon 13[CFG] ignoring acquire for reqid 1, connection attempt pending
2022-06-04T16:08:12 Informational charon 13[KNL] creating acquire job for policy 122.23.25.86/32 === 126.33.25.61/32 with reqid {1}
2022-06-04T16:08:12 Informational charon 13[NET] <104> sending packet: from 122.23.25.86[500] to 126.33.25.61[500] (36 bytes)
2022-06-04T16:08:12 Informational charon 13[ENC] <104> generating IKE_SA_INIT response 0 [ N(NO_PROP) ]
2022-06-04T16:08:12 Informational charon 13[IKE] <104> key derivation failed
2022-06-04T16:08:12 Informational charon 13[IKE] <104> KDF_PRF with PRF_UNDEFINED not supported
2022-06-04T16:08:12 Informational charon 13[CFG] <104> selected proposal: IKE:AES_GCM_16_128/PRF_AES128_XCBC/MODP_2048
2022-06-04T16:08:12 Informational charon 13[IKE] <104> 126.33.25.61 is initiating an IKE_SA
2022-06-04T16:08:12 Informational charon 13[ENC] <104> parsed IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(FRAG_SUP) N(HASH_ALG) N(REDIR_SUP) ]
2022-06-04T16:08:12 Informational charon 13[NET] <104> received packet: from 126.33.25.61[500] to 122.23.25.86[500] (456 bytes)
2022-06-04T16:08:11 Informational charon 09[CFG] ignoring acquire for reqid 1, connection attempt pending
2022-06-04T16:08:11 Informational charon 09[KNL] creating acquire job for policy 122.23.25.86/32 === 126.33.25.61/32 with reqid {1}
2022-06-04T16:08:10 Informational charon 09[NET] <103> sending packet: from 122.23.25.86[500] to 126.33.25.61[500] (36 bytes)
2022-06-04T16:08:10 Informational charon 09[ENC] <103> generating IKE_SA_INIT response 0 [ N(NO_PROP) ]




Also thought I'd add my "hardware - This OpnSense is running as a qemu VM on proxmox.

Also I did some testing for ipsec performance by copying a file from the remote side of the tunnel to my side (smb file transfer). The remote side has 500 mbps upload.

I found I couldn't get more than 4 MB/sec (~30 mbps). I tried adjusting the encryption to AES (128 bits) + SHA256 + DH Group 14 (for both P1 and P2) and found absolutely no change either - same sort of speed.

I've verified that aes-ni is available by checking dmesg as well.

I also did a speed test to internet - I have a 300 mbps down and 100 mbps up connection. That works perfectly, download comes out at 330 mbps, upload at 90 mbps.

Obviously something is wrong here. The Ubiquiti ERL (edge router lite) would do easily 100 mbps smb file transfer on ipsec until CPU bottlenecking.




KDF_PRF with PRF_UNDEFINED not supported

maybe this is due to AES-Ni or running in vm. I would try this on real hardware to test.

Please refer to https://forum.opnsense.org/index.php?topic=28654.msg139322#msg139322 as it looks to be a recent StrongSwan regression and we are trying to pin it down.


Thanks,
Franco

@franco - I see, I have hit that very same bug. I obviously missed that thread and it didn't come up on the googles when I searched.

Anyway this command (along with a reboot for good measure) and I am now connected with  AES_GCM_16 (128) PRF_AES128_XCBC MODP_2048

pkg add -f https://pkg.opnsense.org/FreeBSD:13:amd64/snapshots/misc/strongswan-kdf.pkg