blob: 75364d7e027841cde619e3fccb3f3b7b7d05be7e (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# scram.test - Copyright (c) 2013 Sergei Golovan <sgolovan@nes.ru>
#
# Tests for the Tcllib SASL::SCRAM package
#
# -------------------------------------------------------------------------
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# -------------------------------------------------------------------------
source [file join \
[file dirname [file dirname [file join [pwd] [info script]]]] \
devtools testutilities.tcl]
#package require tcltest
#source [file join devtools testutilities.tcl]
testsNeedTcl 8.4
testsNeedTcltest 2
support {
useLocal sasl.tcl SASL
}
testing {
useLocal scram.tcl SASL::SCRAM
}
# -------------------------------------------------------------------------
# Tests
# -------------------------------------------------------------------------
proc SASLCallback {clientblob context command args} {
upvar #0 $context ctx
switch -exact -- $command {
login { return "" }
username { return "tester" }
password { return "secret" }
realm { return "tcllib.sourceforge.net" }
hostname { return [info host] }
default {
return -code error "oops: client needs to write $command"
}
}
}
# -------------------------------------------------------------------------
test SASL-SCRAM-6.0 {Check basic SCRAM-SHA-1 operation} -setup {
set result {}
} -body {
set stx [SASL::new -type server -service xmpp -mechanism SCRAM-SHA-1 -callback {SASLCallback 0}]
set ctx [SASL::new -type client -service xmpp -mechanism SCRAM-SHA-1 -callback {SASLCallback 0}]
set sv ""
while {1} {
set res [SASL::step $ctx $sv]
lappend result $res
if {!$res} break
set cl [SASL::response $ctx]
set res [SASL::step $stx $cl]
lappend result $res
set sv [SASL::response $stx]
}
SASL::cleanup $ctx
SASL::cleanup $stx
set result
} -cleanup {
unset result sv res stx ctx cl
} -result {1 1 1 0 0}
test SASL-SCRAM-6.1 {Check main SCRAM-SHA-1 algorithm} -setup {
} -body {
# Data is taken from http://www.ietf.org/mail-archive/web/xmpp/current/msg00887.html
foreach {p v} [SASL::SCRAM::Algo SASL::SCRAM::SHA-1:hash SASL::SCRAM::SHA-1:hmac \
r0m30myr0m30 [base64::decode NjhkYTM0MDgtNGY0Zi00NjdmLTkxMmUtNDlmNTNmNDNkMDMz] 4096 \
[join {n=juliet
r=oMsTAAwAAAAMAAAANP0TAAAAAABPU0AA
r=oMsTAAwAAAAMAAAANP0TAAAAAABPU0AAe124695b-69a9-4de6-9c30-b51b3808c59e
s=NjhkYTM0MDgtNGY0Zi00NjdmLTkxMmUtNDlmNTNmNDNkMDMz
i=4096
c=biws
r=oMsTAAwAAAAMAAAANP0TAAAAAABPU0AAe124695b-69a9-4de6-9c30-b51b3808c59e} ,]] break
list [base64::encode $p] [base64::encode $v]
} -cleanup {
unset p
unset v
} -result {UA57tM/SvpATBkH2FXs0WDXvJYw= pNNDFVEQxuXxCoSEiW8GEZ+1RSo=}
# -------------------------------------------------------------------------
testsuiteCleanup
# Local Variables:
# mode: tcl
# indent-tabs-mode: nil
# End:
# vim:ts=8:sw=4:sts=4:et
|