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);
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);
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));
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);
}