Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2013-04-03
06:32 • Closed ticket [3609575fff]: sha256 output is wrong on 32bit Linux plus 7 ot... artifact: e7c5e3bf6d user: anonymous
2013-04-01
23:44 • Ticket [3609575fff]: 4 changes artifact: a56868eaef user: andreas_kupries
15:25 • Ticket [3609575fff]: 4 changes artifact: 710397e72a user: ferrieux
04:51 • Open ticket [3609575fff]. artifact: 4a240300f4 user: anonymous
03:58 • Ticket [3609575fff]: 4 changes artifact: 77d59600aa user: ferrieux
2013-03-31
23:32 • Pending ticket [3609575fff]. artifact: c5e7eeccbb user: dkf
2013-03-30
23:20 • New ticket [3609575fff]. artifact: 3c401e56f0 user: anonymous

sha256 output is wrong on 32bit Linux

Closed / Duplicate3609575fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 14 years ago
Descriptionplain2013-03-30 23:20:07
I am using ActiveState Tcl for 32bit and 64bit Linux. 
The command is:
sha2::sha256 -hex tk

The output is:
32bit Linux:
0b9422c2ca451b24fea81114412fb2c61e2ced68889466119b72d36c4ec3c337

64bit Linux:
1ec22d56dbbc91e849b00643bc4f10eb764441c93bde5c6090fe81db55cf6932

When using any web based sha256 generators the output is:
1ec22d56dbbc91e849b00643bc4f10eb764441c93bde5c6090fe81db55cf6932

Therefore, 32bit sha256 output seems to be incorrect.
dkfplain2013-03-31 23:32:39
That's probably a bug in the sha256 code, which is part of tcllib (and not part of tcl properly). Assigning to the master of tcllib for confirmation...
ferrieuxplain2013-04-01 03:58:08
A cursory look at the code reveals the use of constants like this:

    expr {int(0xc1059ed8)}

But since int() is the tricky, platform-dependent "truncate to machine word" operator, its result (and sign extension thereof, in this specific case) will suffer when moving from 32 to 64 bits architectures.
I'd risk that using wide() instead of int() throughout the package should make it robustly behave like the 64-bit version (which is supposed to be the good one according to this report).
plain2013-04-01 04:51:13
The sha256 package uses the accelerated compiled code from the tcllibc package. When forced to plain Tcl, the output is correct, changing int() to wide() does not make any difference. So, the problem is within the tcllibc package.
ferrieuxplain2013-04-01 15:25:58
Thanks for this critical precision, will dig ;)
Also note that both the pure-Tcl and the accelerated variants are part of the tcllib package.
andreas_kupriesplain2013-04-01 23:44:56
Alexandre, thanks for looking into this.
And thanks to the OS for clearing up that tcllibc is involved.
If possible please shift this bug over to the Tcllib Tracker.
(I.e. create a bug there with all the info, then close this one).
plain2013-04-03 06:32:34
allow_comments - 1

Moved the ticket over to tcllib tracker: ID: 3609843
https://sourceforge.net/tracker/?func=detail&aid=3609843&group_id=12883&atid=112883
Log in (anonymous is fine) to add a comment.