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
|
package require tls
# Constraints
source common.tcl
# Helper functions - See common.tcl
proc digest_read_chan {cmd filename args} {
set ch [open $filename rb]
set bsize [fconfigure $ch -buffersize]
set new [$cmd {*}$args -chan $ch]
while {![eof $new]} {set md [read $new $bsize]}
close $new
return $md}
proc digest_write_chan {cmd filename data args} {
set ch [open $filename wb]
set new [$cmd {*}$args -chan $ch]
puts -nonewline $new $data
flush $new
close $new
set ch [open $filename rb]
set md [read $ch]
close $ch
return $md}
proc digest_accumulate {string args} {
set cmd [{*}$args -command dcmd]
$cmd update [string range $string 0 20]
$cmd update [string range $string 21 end]
return [$cmd finalize]}
set test_data "Example string for message digest tests.\n"
set test_file "md_data.dat"
set test_alt_file "md_alt_data.dat"
set test_key "Example key"
::tcltest::makeFile $test_data $test_file
|
|
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
|
<
<
<
<
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package require tls
# Constraints
source common.tcl
# Helper functions - See common.tcl
proc digest_read_chan {cmd filename args} {;set ch [open $filename rb];set bsize [fconfigure $ch -buffersize];set new [$cmd {*}$args -chan $ch];while {![eof $new]} {set md [read $new $bsize]};close $new;return $md}
proc digest_write_chan {cmd filename data args} {;set ch [open $filename wb];set new [$cmd {*}$args -chan $ch];puts -nonewline $new $data;flush $new;close $new;set ch [open $filename rb];set md [read $ch];close $ch;return $md}
proc digest_accumulate {string args} {;set cmd [{*}$args -command dcmd]; $cmd update [string range $string 0 20];$cmd update [string range $string 21 end];return [$cmd finalize]}
set test_data "Example string for message digest tests.\n"
set test_file "md_data.dat"
set test_alt_file "md_alt_data.dat"
set test_key "Example key"
::tcltest::makeFile $test_data $test_file
|