Tk Library Source Code

View Ticket
Login
Ticket UUID: 2986744
Title: issue with tcllib sha256 on 64bit systems
Type: Bug Version: None
Submitter: zdia Created on: 2010-04-13 20:46:23
Subsystem: sha1 Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2010-07-22 09:20:09
Resolution: Fixed Closed By: sf-robot
    Closed on: 2010-07-22 02:20:09
Description:
Having compiled Tcltk on a 64bit system I could not open databases which were encrypted with the sha256 algorithm. Before I used only 32bit versions of ActiveState binaries. Debugging the sha256.tcl file I found the reason:

In line 303-308 there was one expression which was not ANDed by 0xffffffff. The patched line looks now like:

for {set t 16} {$t < 64} {incr t} {
            lappend W [expr {([sigma1 [lindex $W [incr t2]]] \
                                 + [lindex $W [incr t7]] \
                                 + [sigma0 [lindex $W [incr t15]]] \
                                 + [lindex $W [incr t16]]) & 0xffffffff}]
        }

Now everything works fine. 

Zbigniew Diaczyszyn
User Comments: sf-robot added on 2010-07-22 09:20:09:

allow_comments - 1

sf-robot added on 2010-07-22 09:20:08:
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).

zdia added on 2010-07-08 17:56:12:
>What is the input to this code, i.e. the values of salt, password,iterations
> where it fails ?

Gorilla Password is working like this. Salt and the sha256 encoded password are saved in the database with the password.

Access to the database is granted if  the password taken from a dialog box and encoded with sha256 and the saved salt equals to the db saved password.

Because the saved 32bit (AS 8.5.8 on Linux) Xi result is not equal to a generated Xi on a 64 bit system (here: Mac Snow Leopard 10.6.2 compiled with 8.5 Tcl/TK Cocoa sources from Daniel Steffens github page) you have no access to the 32bit database.

Standard iteration is 3000
SALT is a 256 bit random value
The password is an integer string like "mypassword"

After iteration 16 there will be different Xi values.

Example for the salt:

pwsafe::int::randomString 15
proc pwsafe::int::randomString {length} {
    set randomOctets [list]
    
for {set i 0} {$i < $length} {incr i} {
    lappend randomOctets [expr {127-int(rand()*256.)}]
}
    }
    return [binary format c* $randomOctets]
}

I would be thankful If you could give me a hint on how to check in a script if the system is working on 64bit system

Regards

Zbigniew Diaczyszyn

andreas_kupries added on 2010-07-08 03:43:44:
Thank you for the code.
What is the input to this code, i.e. the values of salt, password, iterations
where it fails ?

andreas_kupries added on 2010-07-07 03:17:06:
Fixed as proposed, committed to CVS head. Package version bumped to 1.0.3.
One issue left: Can you provide us with a small snippet of code which demonstrates the failure ? I would really like to extend the testsuite as well, to catch this in the future.