From cfc72fe901f20b30664bd16330631b1b93917090 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Tue, 16 Jun 2026 10:00:55 +0200 Subject: [PATCH] eap-aka-3gpp2: Fix SQN generation Same as the previous commit. Fixes: 424ddf801c21 ("Do not use monotonic time for AKA sequence numbers, it has an undefined starting point") --- .../plugins/eap_aka_3gpp2/eap_aka_3gpp2_provider.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libcharon/plugins/eap_aka_3gpp2/eap_aka_3gpp2_provider.c b/src/libcharon/plugins/eap_aka_3gpp2/eap_aka_3gpp2_provider.c index 9d057b468..61c35d4b5 100644 --- a/src/libcharon/plugins/eap_aka_3gpp2/eap_aka_3gpp2_provider.c +++ b/src/libcharon/plugins/eap_aka_3gpp2/eap_aka_3gpp2_provider.c @@ -71,14 +71,15 @@ bool eap_aka_3gpp2_get_k(identification_t *id, char k[AKA_K_LEN]) void eap_aka_3gpp2_get_sqn(char sqn[AKA_SQN_LEN], int offset) { timeval_t time; + uint32_t sec, usec; gettimeofday(&time, NULL); /* set sqn to an integer containing 4 bytes seconds + 2 bytes usecs */ - time.tv_sec = htonl(time.tv_sec + offset); + sec = htonl((uint32_t)(time.tv_sec + offset)); /* usec's are never larger than 0x000f423f, so we shift the 12 first bits */ - time.tv_usec = htonl(time.tv_usec << 12); - memcpy(sqn, (char*)&time.tv_sec + sizeof(time_t) - 4, 4); - memcpy(sqn + 4, &time.tv_usec, 2); + usec = htonl((uint32_t)time.tv_usec << 12); + memcpy(sqn, &sec, 4); + memcpy(sqn + 4, &usec, 2); } METHOD(simaka_provider_t, get_quintuplet, bool,