Code域有一个字节长度,用来标示RADIUS通信包的类型。当收到一个非法的包类型,将被丢弃。
Code可代表如下类型(十进制):
1
Access-Request
2
Access-Accept
3
Access-Reject
4
Accounting-Request
5
Accounting-Response
11
Access-Challenge
12
Status-Server (experimental)
13
Status-Client (experimental)
255
Reserved
Identifier
Identifier有一个字节长度,用来匹配RADIUS的请求和应答。
Length
Length有2个字节长度,它标明整个RADIUS数据包的长度,包括:Code, Identifier, Length, Authenticator
和Attributes。Length的最小值为20,最大值为4096。RADIUS的应用程序将丢弃小于20的包;对大于4096的包将把超出部分丢弃,只处理有效部分(超出部分被认为是填充域)。
Authenticator
Authenticator域有16个字节。这个域用来完成安全性检查,所以是非常重要的。Authenticator的作用有两个,一个是验证从RADIUS服务器返回的应答;另一个是为对口令部分加密算法做参数。
有两种Authenticator:
1)
Request Authenticator
出现在通信包“Access-Request”中,是长度为16字节的随机二进制串。格式为:
0
1
2
3
0 1 2 3
4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
Code
| Identifier
|
Length
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
Request
Authenticator
|
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
Attributes ...
+-+-+-+-+-+-+-+-+-+-+-+-+-
RADIUS协议建议Request
Authenticator应该是不可预测和在整个生命期内是唯一的。这是为了防止攻击者伪装成通信的一方的措施。RADIUS请求方(NAS)用Request
Authenticatior加密用户密码;相反,RADIUS服务器则用它来对用户密码,并生成应答包的Authenticator(Response Authenticatior)。如果Request
Authenticator不是唯一的话,网络窃听者将可以伪造RADIUS服务器的应答,因为此时Response
Authenticator的加密算法有相同的参数(详见下文)。
用户密码部分的加密算法是:
enpassword
= password XOR MD5(secret + Request Authenticator)
2)
Response Authenticator
出现在通信包“Access-Accept”、“Access-Reject”、“Access-Challenge”和“Accounting-Response”中。格式为:
0
1
2
3
0 1 2 3
4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
Code
| Identifier
|
Length
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
Response
Authenticator
|
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
Attributes ...
+-+-+-+-+-+-+-+-+-+-+-+-+-
Response
Authenticator产生的算法:
Response Authenticator
=
MD5(Code + Id
+ Length + Req-Authenticator + Attributes +
Secret)
Attributes
RADIUS通信包装载了验证、授权、统计等信息。这些信息都是用Attribute数据结构来表示的。Attributes域包含了0到数个属性描述(Attribute)。
Attributes域包含了0到数个属性描述(Attribute)。Attribute的基本格式在请求包和应答包中是一样的,各域(Fields)的先后次序是从左到右。
0
1
2
0 1 2 3
4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
Type
|
Length
| Value ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Type
Type域长度为一个字节。数值192-223被保留作实验使用;数值224-240被保留作特殊的应用;数值241-255被不建议使用。RADIUS服务器和客户机将可能忽略未知的Type值。被定义的值如下所列:
#
attribute
value-type
-------
---------------------------
-----------------
1
User-Name
string
2
User-Password
string
3
CHAP-Password
string
4
NAS-IP-Address
address
5
NAS-Port
string
6
Service-Type
integer
7
Framed-Protocol integer
8
Framed-IP-Address
address
9
Framed-IP-Netmask
address
10
Framed-Routing
integer
11
Filter-Id
string
12
Framed-MTU
integer
13
Framed-Compression
integer
14
Login-IP-Host
address
15
Login-Service
integer
16
Login-TCP-Port
integer
17
(unassigned)
18
Reply-Message
string
19
Callback-Number string
20
Callback-Id string
21
(unassigned)
22
Framed-Route
integer
23
Framed-IPX-Network
integer
24
State
string
25
Class
string
26
Vendor-Specific string
27
Session-Timeout integer
28
Idle-Timeout
integer
29
Termination-Action
integer
30
Called-Station-Id
string
31
Calling-Station-Id
string
32
NAS-Identifier
string
33
Proxy-State string
34
Login-LAT-Service
string
35
Login-LAT-Node
string
36
Login-LAT-Group string
37
Framed-AppleTalk-Link
integer
38
Framed-AppleTalk-Network
integer
39
Framed-AppleTalk-Zone
string
40
Acct-Status-Type integer
41
Acct-Delay-Time integer
42
Acct-Input-Octets
integer
43
Acct-Output-Octets
integer
44
Acct-Session-Id string
45
Acct-Authentic
integer
46
Acct-Session-Time
integer
47
Acct-Input-Packets
integer
48
Acct-Output-Packets integer
49
Acct-Terminate-Cause
integer
50
Acct-Multi-Session-Id
string
51
Acct-Link-Count integer
52-59
(unassigned)
60
CHAP-Challenge
string
61
NAS-Port-Type
integer
62
Port-Limit
integer
63
Login-LAT-Port
string
60
CHAP-Challenge
string
61
NAS-Port-Type
integer
62
Port-Limit
integer
63
Login-LAT-Port
string
70 ARAP-Password
string
71
ARAP-Features string
72
ARAP-Zone-Access
integer
73
ARAP-Security
integer
74
ARAP-Security-Data string
75
Password-Retry
integer
76
Prompt
integer
77
Connect-Info
string
78
Configuration-Token
string
79
EAP-Message
string
80
Message-Authenticator
string # 18 octets
84
ARAP-Challenge-Response
string # 10 octets
85
Acct-Interim-Interval
integer
87
NAS-Port-Id
string
88
Framed-Pool
string
Length
Length域长度为一个字节,标示Attribute的总长度,包括Type、Length和Value域。
Value
Value域长度可以是0到若干个字节,它包含了Attribte规定的值。Value的格式和长度由Type和Length域来决定。
Value有如下四种数据格式:
string 0-253
octets,does not require termination by an ASCII
null.
address 32 bit value, most
significant octet first.
integer 32 bit value, most
significant octet first.
time
32 bit value, most significant octet first --
seconds
since 00:00:00 GMT, January 1, 1970. The
standard
Attributes do not use this data type but it is
presented
here for possible use within Vendor-Specific
attributes.