66#define ESP_PADDING_LEN 1
77#define ESP_NEXT_HEADER_LEN 1
88#define ESP_ICV_ALIGNMENT 4
9- /* hmac-[sha1, md5]-96*/
9+ /* hmac-[sha256, sha1, md5]-96*/
1010#define ESP_ICVLEN_HMAC_96 12
1111#define WOLFIP_ESP_NUM_SA 1
1212
1313typedef enum {
1414 ESP_AUTH_NONE = 0 ,
15- ESP_AUTH_SHA1 , /* hmac(sha1)-96 */
16- ESP_AUTH_MD5 , /* hmac(md5)-96 */
17- ESP_AUTH_GCM_RFC4106 , /* placeholder to indicate gcm auth. */
18- ESP_AUTH_GCM_RFC4543 /* rfc4543 gmac */
15+ ESP_AUTH_MD5_RFC2403 , /* hmac(md5)-96 */
16+ ESP_AUTH_SHA1_RFC2404 , /* hmac(sha1)-96 */
17+ ESP_AUTH_SHA256_RFC4868 , /* hmac(sha256)-96 */
18+ ESP_AUTH_GCM_RFC4106 , /* placeholder to indicate gcm auth. */
19+ ESP_AUTH_GCM_RFC4543 /* rfc4543 gmac */
1920} esp_auth_t ;
2021
2122/* Minimal ESP Security Association structure.
@@ -44,7 +45,7 @@ struct wolfIP_esp_sa in_sa_list[WOLFIP_ESP_NUM_SA] =
4445 0x020A0A0A , /* dst */
4546 0 ,0 , /* oseq, seq */
4647 0 , /* iv len */
47- ESP_AUTH_MD5 ,
48+ ESP_AUTH_SHA256_RFC4868 ,
4849 {0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
4950 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 },
5051 16 ,
@@ -60,7 +61,7 @@ struct wolfIP_esp_sa out_sa_list[WOLFIP_ESP_NUM_SA] =
6061 0x010A0A0A , /* dst */
6162 0 ,0 , /* oseq, seq */
6263 0 , /* iv len */
63- ESP_AUTH_MD5 ,
64+ ESP_AUTH_SHA256_RFC4868 ,
6465 {0x02 , 0x02 , 0x02 , 0x02 , 0x02 , 0x02 , 0x02 , 0x02 ,
6566 0x02 , 0x02 , 0x02 , 0x02 , 0x02 , 0x02 , 0x02 , 0x02 },
6667 16 ,
@@ -223,11 +224,14 @@ esp_calc_icv_hmac(uint8_t * hash, const struct wolfIP_esp_sa * esp_sa,
223224 uint32_t auth_len = esp_len ;
224225
225226 switch (esp_sa -> auth ) {
226- case ESP_AUTH_SHA1 :
227+ case ESP_AUTH_MD5_RFC2403 :
228+ type = WC_MD5 ;
229+ break ;
230+ case ESP_AUTH_SHA1_RFC2404 :
227231 type = WC_SHA ;
228232 break ;
229- case ESP_AUTH_MD5 :
230- type = WC_MD5 ;
233+ case ESP_AUTH_SHA256_RFC4868 :
234+ type = WC_SHA256 ;
231235 break ;
232236 case ESP_AUTH_NONE :
233237 default :
@@ -295,12 +299,13 @@ esp_check_icv_hmac(const struct wolfIP_esp_sa * esp_sa, uint8_t * esp_data,
295299 uint32_t esp_len )
296300{
297301 /* SHA1 and MD5 have these digest sizes:
298- * - WC_SHA_DIGEST_SIZE 20 bytes
299- * - WC_MD5_DIGEST_SIZE 16 bytes
302+ * - WC_MD5_DIGEST_SIZE 16 bytes
303+ * - WC_SHA_DIGEST_SIZE 20 bytes
304+ * - WC_SHA256_DIGEST_SIZE 32 bytes
300305 * */
301306 int rc = 0 ;
302307 const uint8_t * icv = NULL ;
303- byte hash [WC_SHA_DIGEST_SIZE ];
308+ byte hash [WC_SHA256_DIGEST_SIZE ];
304309
305310 rc = esp_calc_icv_hmac (hash , esp_sa , esp_data , esp_len );
306311 if (rc ) {
0 commit comments