mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-18 02:44:03 -05:00
RADIUS: Share a single function for generating session IDs
There is no need to maintain three copies of this functionality even if it is currently implemented as a single function call. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
2cbc6ffb3a
commit
1fc63fe299
@ -379,12 +379,7 @@ void accounting_sta_stop(struct hostapd_data *hapd, struct sta_info *sta)
|
|||||||
|
|
||||||
int accounting_sta_get_id(struct hostapd_data *hapd, struct sta_info *sta)
|
int accounting_sta_get_id(struct hostapd_data *hapd, struct sta_info *sta)
|
||||||
{
|
{
|
||||||
/*
|
return radius_gen_session_id((u8 *) &sta->acct_session_id,
|
||||||
* Acct-Session-Id should be globally and temporarily unique.
|
|
||||||
* A high quality random number is required therefore.
|
|
||||||
* This could be be improved by switching to a GUID.
|
|
||||||
*/
|
|
||||||
return os_get_random((u8 *) &sta->acct_session_id,
|
|
||||||
sizeof(sta->acct_session_id));
|
sizeof(sta->acct_session_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,12 +449,7 @@ static void accounting_report_state(struct hostapd_data *hapd, int on)
|
|||||||
*/
|
*/
|
||||||
int accounting_init(struct hostapd_data *hapd)
|
int accounting_init(struct hostapd_data *hapd)
|
||||||
{
|
{
|
||||||
/*
|
if (radius_gen_session_id((u8 *) &hapd->acct_session_id,
|
||||||
* Acct-Session-Id should be globally and temporarily unique.
|
|
||||||
* A high quality random number is required therefore.
|
|
||||||
* This could be be improved by switching to a GUID.
|
|
||||||
*/
|
|
||||||
if (os_get_random((u8 *) &hapd->acct_session_id,
|
|
||||||
sizeof(hapd->acct_session_id)) < 0)
|
sizeof(hapd->acct_session_id)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -866,16 +866,13 @@ eapol_auth_alloc(struct eapol_authenticator *eapol, const u8 *addr,
|
|||||||
sm->radius_cui = wpabuf_alloc_copy(radius_cui,
|
sm->radius_cui = wpabuf_alloc_copy(radius_cui,
|
||||||
os_strlen(radius_cui));
|
os_strlen(radius_cui));
|
||||||
|
|
||||||
/*
|
#ifndef CONFIG_NO_RADIUS
|
||||||
* Acct-Multi-Session-Id should be globally and temporarily unique.
|
if (radius_gen_session_id((u8 *) &sm->acct_multi_session_id,
|
||||||
* A high quality random number is required therefore.
|
|
||||||
* This could be be improved by switching to a GUID.
|
|
||||||
*/
|
|
||||||
if (os_get_random((u8 *) &sm->acct_multi_session_id,
|
|
||||||
sizeof(sm->acct_multi_session_id)) < 0) {
|
sizeof(sm->acct_multi_session_id)) < 0) {
|
||||||
eapol_auth_free(sm);
|
eapol_auth_free(sm);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_NO_RADIUS */
|
||||||
|
|
||||||
return sm;
|
return sm;
|
||||||
}
|
}
|
||||||
|
@ -1656,3 +1656,14 @@ u8 radius_msg_find_unlisted_attr(struct radius_msg *msg, u8 *attrs)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int radius_gen_session_id(u8 *id, size_t len)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Acct-Session-Id and Acct-Multi-Session-Id should be globally and
|
||||||
|
* temporarily unique. A high quality random number is required
|
||||||
|
* therefore. This could be be improved by switching to a GUID.
|
||||||
|
*/
|
||||||
|
return os_get_random(id, len);
|
||||||
|
}
|
||||||
|
@ -319,4 +319,6 @@ int radius_copy_class(struct radius_class_data *dst,
|
|||||||
|
|
||||||
u8 radius_msg_find_unlisted_attr(struct radius_msg *msg, u8 *attrs);
|
u8 radius_msg_find_unlisted_attr(struct radius_msg *msg, u8 *attrs);
|
||||||
|
|
||||||
|
int radius_gen_session_id(u8 *id, size_t len);
|
||||||
|
|
||||||
#endif /* RADIUS_H */
|
#endif /* RADIUS_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user