summaryrefslogtreecommitdiffstats
path: root/src/tests/keywords/md5
blob: a97366002b8a2a688cc15c34339bc47f427b85c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#
# PRE: update if
#
update reply {
	Filter-Id := "filter"
}

update {
       control:Cleartext-Password := 'hello'
       request:Tmp-String-0 := "This is a string\n"
       request:Tmp-Octets-0 := 0x000504030201
       request:Tmp-String-1 := "what do ya want for nothing?"
       request:Tmp-String-2 := "Jefe"
}

#
#  Put "This is a string" into a file and call "md5sum" on it.
#  You should get this string.
#
if ("%{md5:This is a string\n}" != '9ac4dbbc3c0ad2429e61d0df5dc28add') {
	update reply {
		Filter-Id += 'fail 1'
	}
}

if ("%{md5:&Tmp-String-0}" != '9ac4dbbc3c0ad2429e61d0df5dc28add') {
	update reply {
		Filter-Id += 'fail 2'
	}
}

if ("%{md5:&request:Tmp-String-0}" != '9ac4dbbc3c0ad2429e61d0df5dc28add') {
	update reply {
		Filter-Id += 'fail 3'
	}
}

if ("%{md5:%{request:Tmp-String-0}}" != '9ac4dbbc3c0ad2429e61d0df5dc28add') {
	update reply {
		Filter-Id += 'fail 4'
	}
}

#
#  MD5 should also be able to cope with references to octet attributes
#
if ("%{md5:&request:Tmp-Octets-0}" != 'c1e7fa505b2fc1fd0da6cac3db6f6f44') {
	update reply {
		Filter-Id += 'fail 5'
	}
}

#
#  MD5 HMAC with attribute references
#
if ("%{hmacmd5:&Tmp-String-1 &Tmp-String-2}" != '750c783e6ab0b503eaa86e310a5db738') {
	update reply {
		Filter-Id += 'fail 6'
	}
}