RADIUS: Use more likely unique accounting Acct-{,Multi-}Session-Id
Rework the Acct-Session-Id and Acct-Multi-Session-Id implementation to give better global and temporal uniqueness. Previously, only 32-bits of the Acct-Session-Id would contain random data, the other 32-bits would be incremented. Previously, the Acct-Multi-Session-Id would not use random data. Switch from two u32 variables to a single u64 for the Acct-Session-Id and Acct-Multi-Session-Id. Do not increment, this serves no legitimate purpose. Exclusively use os_get_random() to get quality random numbers, do not use or mix in the time. Inherently take a dependency on /dev/urandom working properly therefore. Remove the global Acct-Session-Id and Acct-Multi-Session-Id values that serve no legitimate purpose. Signed-off-by: Nick Lowe <nick.lowe@lugatech.com>
This commit is contained in:
parent
d689317ddb
commit
d72a00539c
11 changed files with 62 additions and 81 deletions
|
@ -438,9 +438,9 @@ static int add_common_radius_sta_attr(struct hostapd_data *hapd,
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (sta->acct_session_id_hi || sta->acct_session_id_lo) {
|
||||
os_snprintf(buf, sizeof(buf), "%08X-%08X",
|
||||
sta->acct_session_id_hi, sta->acct_session_id_lo);
|
||||
if (sta->acct_session_id) {
|
||||
os_snprintf(buf, sizeof(buf), "%016lX",
|
||||
(long unsigned int) sta->acct_session_id);
|
||||
if (!radius_msg_add_attr(msg, RADIUS_ATTR_ACCT_SESSION_ID,
|
||||
(u8 *) buf, os_strlen(buf))) {
|
||||
wpa_printf(MSG_ERROR, "Could not add Acct-Session-Id");
|
||||
|
@ -2493,12 +2493,12 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
|||
/* TODO: dot1xAuthSessionOctetsTx */
|
||||
/* TODO: dot1xAuthSessionFramesRx */
|
||||
/* TODO: dot1xAuthSessionFramesTx */
|
||||
"dot1xAuthSessionId=%08X-%08X\n"
|
||||
"dot1xAuthSessionId=%016lX\n"
|
||||
"dot1xAuthSessionAuthenticMethod=%d\n"
|
||||
"dot1xAuthSessionTime=%u\n"
|
||||
"dot1xAuthSessionTerminateCause=999\n"
|
||||
"dot1xAuthSessionUserName=%s\n",
|
||||
sta->acct_session_id_hi, sta->acct_session_id_lo,
|
||||
(long unsigned int) sta->acct_session_id,
|
||||
(wpa_key_mgmt_wpa_ieee8021x(
|
||||
wpa_auth_sta_key_mgmt(sta->wpa_sm))) ?
|
||||
1 : 2,
|
||||
|
@ -2508,11 +2508,11 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
|||
return len;
|
||||
len += ret;
|
||||
|
||||
if (sm->acct_multi_session_id_hi) {
|
||||
if (sm->acct_multi_session_id) {
|
||||
ret = os_snprintf(buf + len, buflen - len,
|
||||
"authMultiSessionId=%08X+%08X\n",
|
||||
sm->acct_multi_session_id_hi,
|
||||
sm->acct_multi_session_id_lo);
|
||||
"authMultiSessionId=%016lX\n",
|
||||
(long unsigned int)
|
||||
sm->acct_multi_session_id);
|
||||
if (os_snprintf_error(buflen - len, ret))
|
||||
return len;
|
||||
len += ret;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue