summaryrefslogtreecommitdiffstats
path: root/src/tests/keywords/sha1
blob: 0d577a94a985f07adb1ab71ea8f0dfc5159a254e (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 {
       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"
}

update reply {
	Filter-Id := 'filter'
}

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

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

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

if ("%{sha1:%{Tmp-String-0}}" != 'cc7edf1ccc4bdf1e0ec8f72b95388b65218ecf0c') {
	update reply {
		Filter-Id += 'fail 4'
	}
}

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

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