From 3922ab9dad99a971deeaf3c62d527df8c5b11b24 Mon Sep 17 00:00:00 2001 From: yasuoka Date: Thu, 25 Jul 2024 07:24:40 +0000 Subject: [PATCH] Fix test23. It assumed the place of the attribute is unchanged. But now, the message-authenticator is located at first always. found anton --- regress/lib/libradius/test23.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/regress/lib/libradius/test23.c b/regress/lib/libradius/test23.c index 628c2f3b7e8..9b5e35b0866 100644 --- a/regress/lib/libradius/test23.c +++ b/regress/lib/libradius/test23.c @@ -15,14 +15,14 @@ void test23(void) uint8_t packetdata[] = { RADIUS_CODE_ACCESS_REQUEST, 0x7f, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* auth */ - 10, 10, 'h', 'o', 'g', 'e', 'f', 'u', 'g', 'a', RADIUS_TYPE_MESSAGE_AUTHENTICATOR, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 10, 10, 'h', 'o', 'g', 'e', 'f', 'u', 'g', 'a', }; uint8_t responsedata[] = { RADIUS_CODE_ACCESS_ACCEPT, 0x7f, 0, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* auth */ - 10, 11, 'f', 'o', 'o', 'b', 'a', 'r', 'b', 'a', 'z', RADIUS_TYPE_MESSAGE_AUTHENTICATOR, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 10, 11, 'f', 'o', 'o', 'b', 'a', 'r', 'b', 'a', 'z', }; packet = radius_new_request_packet(RADIUS_CODE_ACCESS_REQUEST); @@ -31,7 +31,7 @@ void test23(void) radius_put_message_authenticator(packet, "sharedsecret"); radius_get_authenticator(packet, packetdata + 4); - HMAC(EVP_md5(), "sharedsecret", 12, packetdata, sizeof(packetdata), packetdata + sizeof(packetdata) - 16, NULL); + HMAC(EVP_md5(), "sharedsecret", 12, packetdata, sizeof(packetdata), packetdata + 22, NULL); CHECK(radius_get_length(packet) == sizeof(packetdata)); CHECK(memcmp(radius_get_data(packet), packetdata, sizeof(packetdata)) == 0); @@ -47,7 +47,7 @@ void test23(void) HMAC_Update(ctx, responsedata, 4); HMAC_Update(ctx, packetdata + 4, 16); HMAC_Update(ctx, responsedata + 20, sizeof(responsedata) - 20); - HMAC_Final(ctx, responsedata + sizeof(responsedata) - 16, NULL); + HMAC_Final(ctx, responsedata + 22, NULL); HMAC_CTX_free(ctx); CHECK(radius_get_length(response) == sizeof(responsedata)); @@ -63,8 +63,8 @@ void test23(void) radius_set_id(packet, 0xff); radius_set_message_authenticator(packet, "sharedsecret"); packetdata[1] = 0xff; - memset(packetdata + sizeof(packetdata) - 16, 0, 16); - HMAC(EVP_md5(), "sharedsecret", 12, packetdata, sizeof(packetdata), packetdata + sizeof(packetdata) - 16, NULL); + memset(packetdata + 22, 0, 16); + HMAC(EVP_md5(), "sharedsecret", 12, packetdata, sizeof(packetdata), packetdata + 22, NULL); CHECK(memcmp(radius_get_data(packet), packetdata, sizeof(packetdata)) == 0); } -- 2.20.1