Skip to content

Commit f7725bf

Browse files
committed
support esp sha256 with diff truncated lengths.
1 parent 4c74fb9 commit f7725bf

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

scripts/ip-xfrm/esp_sa.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# This file is automatically generated, DO NOT MODIFY.
2-
"IPv4","10.10.10.2","10.10.10.1","0xf6e9b80d","NULL","","HMAC-MD5-96 [RFC2403]","0x02020202020202020202020202020202","32-bit","0"
3-
"IPv4","10.10.10.1","10.10.10.2","0x2fa9d8c8","NULL","","HMAC-MD5-96 [RFC2403]","0x01010101010101010101010101010101","32-bit","0"
2+
"IPv4","10.10.10.2","10.10.10.1","0xf6e9b80d","NULL","","HMAC-SHA-256-128 [RFC4868]","0x02020202020202020202020202020202","32-bit","0"
3+
"IPv4","10.10.10.1","10.10.10.2","0x2fa9d8c8","NULL","","HMAC-SHA-256-128 [RFC4868]","0x01010101010101010101010101010101","32-bit","0"

scripts/ip-xfrm/hmac_auth

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ print_usage_and_die() {
1212

1313
alg=sha1
1414
ip_proto=tcp
15+
len=96
1516

1617
if [ $# -eq 0 ]; then
1718
print_usage_and_die
@@ -23,7 +24,7 @@ fi
2324

2425
if [ $# -eq 2 ]; then
2526
alg=$1
26-
ip_proto=$2
27+
len=$2
2728
fi
2829

2930
# State
@@ -34,7 +35,7 @@ sudo ip xfrm state add \
3435
spi 0x2fa9d8c8 \
3536
mode transport \
3637
replay-window 64 \
37-
auth $alg 0x01010101010101010101010101010101 \
38+
auth-trunc $alg 0x01010101010101010101010101010101 $len \
3839
enc cipher_null "" \
3940
sel src 10.10.10.1 dst 10.10.10.2
4041

@@ -44,7 +45,7 @@ sudo ip xfrm state add \
4445
spi 0xf6e9b80d \
4546
mode transport \
4647
replay-window 64 \
47-
auth $alg 0x02020202020202020202020202020202 \
48+
auth-trunc $alg 0x02020202020202020202020202020202 $len \
4849
enc cipher_null "" \
4950
sel src 10.10.10.2 dst 10.10.10.1
5051

src/wolfesp.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
#define ESP_ICV_ALIGNMENT 4
99
/* hmac-[sha256, sha1, md5]-96*/
1010
#define ESP_ICVLEN_HMAC_96 12
11+
#define ESP_ICVLEN_HMAC_128 16
1112
#define WOLFIP_ESP_NUM_SA 1
1213

1314
typedef enum {
1415
ESP_AUTH_NONE = 0,
1516
ESP_AUTH_MD5_RFC2403, /* hmac(md5)-96 */
1617
ESP_AUTH_SHA1_RFC2404, /* hmac(sha1)-96 */
17-
ESP_AUTH_SHA256_RFC4868, /* hmac(sha256)-96 */
18+
ESP_AUTH_SHA256_RFC4868, /* hmac(sha256)-N, N=96,128 */
1819
ESP_AUTH_GCM_RFC4106, /* placeholder to indicate gcm auth. */
1920
ESP_AUTH_GCM_RFC4543 /* rfc4543 gmac */
2021
} esp_auth_t;
@@ -49,7 +50,7 @@ struct wolfIP_esp_sa in_sa_list[WOLFIP_ESP_NUM_SA] =
4950
{0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
5051
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
5152
16,
52-
ESP_ICVLEN_HMAC_96
53+
ESP_ICVLEN_HMAC_128
5354
},
5455
};
5556

@@ -65,7 +66,7 @@ struct wolfIP_esp_sa out_sa_list[WOLFIP_ESP_NUM_SA] =
6566
{0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
6667
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02},
6768
16,
68-
ESP_ICVLEN_HMAC_96
69+
ESP_ICVLEN_HMAC_128
6970
},
7071
};
7172

0 commit comments

Comments
 (0)