From fbd4dd9c5eba6f8f10bcc0db30a72ea3378c149b Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Mon, 11 Feb 2019 23:50:45 +0100 Subject: [HICN-51] Add static assert for ensuring correct struct size in libhicn definitions. Change-Id: Ib41e9cbdd2ea84a40eb4e7b01da131cbad9575c4 Signed-off-by: Mauro Sardara --- lib/src/protocol/ah.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/src/protocol/ah.h') diff --git a/lib/src/protocol/ah.h b/lib/src/protocol/ah.h index f8a05bf38..a59a5051a 100644 --- a/lib/src/protocol/ah.h +++ b/lib/src/protocol/ah.h @@ -20,12 +20,19 @@ #ifndef HICN_PROTOCOL_AH_H #define HICN_PROTOCOL_AH_H +#include "../common.h" + /* * The TCP PSH flag is set to indicate TCP payload in fact contains a AH header * with signature information for the packet */ #define AH_FLAG 0x10 +/* + * The length of the AH struct must be 44 bytes. + */ +#define EXPECTED_AH_HDRLEN 44 + typedef struct { u8 nh; // (to match with reserved in IPSEC AH) @@ -49,6 +56,8 @@ typedef struct }; // Unix timestamp indicating when the signature has been calculated u8 timestamp_as_u8[8]; + u16 timestamp_as_u16[4]; + u32 timestamp_as_u32[2]; }; // ICV would follow u8 keyId[32]; // Hash of the pub key @@ -57,6 +66,8 @@ typedef struct } _ah_header_t; #define AH_HDRLEN sizeof(_ah_header_t) +static_assert (EXPECTED_AH_HDRLEN == AH_HDRLEN, + "Size of AH Struct does not match its expected size."); #endif /* HICN_PROTOCOL_AH_H */ -- cgit 1.2.3-korg