Menu

#8 Attaching md5 to channels doesn't work

open
Trf (15)
5
2003-05-30
2003-05-30
Pat Thoyts
No

From reading the documentation it seems I should be
able to attach an md5 filter to a channel like this:

set f [open ChangeLog r]
fconfigure $f -translation binary
::md5 -attach $f -mode transparent -read-destination ::R
read $f
close $f

now to examine the hash value:
hex -mode encode $::R

Sure enough there is a value in R and in fact it bears
_some_ resembance to the correct value:
Correct: 91A44FB 606D6D09 AEFA68DFE A018983B
Oops : 91A44FB 606D6 1 A 8DFE A018983B

So it's too short and appears to be missing bits from
values B and C. (I've lined things up a bit.)

Discussion

  • Andreas Kupries

    Andreas Kupries - 2004-02-07

    Logged In: YES
    user_id=75003

    aku Oh. God, I really have to work on Trf again. Can you
    add on which platform this happended ?
    patthoyts windows. Probably 2K
    patthoyts I'm just checking I can still repeat this.
    aku Ok, will add this as comment to the report.

     
  • Andreas Kupries

    Andreas Kupries - 2004-02-07

    Logged In: YES
    user_id=75003

    patthoyts Well it seems to be OK with Win2k, tcl
    8.4.2, trf 2.1p1
    patthoyts Interesting.
    patthoyts Maybe it was a tcl bug?

     
  • Pat Thoyts

    Pat Thoyts - 2004-02-07

    Logged In: YES
    user_id=202636

    Tests OK with OpenBSD 3.4, Tcl 8.4.5.1 Trf 2.1

     
  • Pat Thoyts

    Pat Thoyts - 2004-02-07

    Logged In: YES
    user_id=202636

    Tests OK with Windows 2K, Tcl 8.3.5, Trf 2.1p1

     
  • Pat Thoyts

    Pat Thoyts - 2004-02-11

    Logged In: YES
    user_id=202636

    This appears to be platform dependant and possibly data
    dependent. The sample given initially now doesn't error for
    me. However this does at least under Windows 2K

    proc md5trf {data} {
    set f [null]
    fconfigure $f -translation binary -buffering none
    ::md5 -attach $f -mode write \ -read-type variable -read-destination ::R \ -write-type variable -write-destination ::W
    puts -nonewline $f $data
    close $f
    return [hex -mode encode $::W]
    }

    The correct md5 hash for abc is:
    % md5::md5 -hex abc
    900150983CD24FB0D6963F7D28E17F72
    % md5trf abc
    900150983CD24FB0963F7D28E17F72

    As can be seen, we have lost a byte in the middle.
    This was with Tcl 8.4.5, Trf 2.1p1 and Memchan 2.2
    Under OpenBSD with the same versions of all packages we
    get the correct answer.

    As for data dependence:
    % md5trf [string repeat \x00 10000]
    B85D6FB9EF4260DCF1CE0A1B0BFF80D3
    % md5trf [string repeat \x00 1000]
    EDE3F685B4E137BA4CB2521329A75E
    % md5trf [string repeat \x00 5000]
    6BF95A48F366BDF8AF3A198C7B723C77
    % md5trf [string repeat \x00 2500]
    AF182E35CFE16AE393D2D228E789

    In the last one, we have lost 2 bytes.