SHA1 hash on OS X incorrect

I was just stunned by the fact that the SHA1 hash in Ruby on OS X
(Jaguar) produces incorrect results.

I use SHA1 in the jabber4r (Ruby Jabber) library for digest
authentication. This effectively prevents jabber4r from working on the
stock Ruby that ships with OS X.

test.rb…
require 'digest/sha1’
puts Digest::SHA1.new(“test”).hexdigest

And then a few tests:

/usr/bin/ruby -v
ruby 1.6.7 (2002-03-01) [powerpc-darwin6.0]
/usr/bin/ruby test.rb
94266438e06c02e522256b64ed8c833aef0270d0
^ ^ ^
This number is incorrect.
Under 1.6.7 on Win32 and Linux it produces the correct result.

/usr/local/bin/ruby -v
ruby 1.8.0 (2003-01-31) [powerpc-darwin6.3]
/usr/local/bin/ruby test.rb
a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
^ ^ ^
This is correct.

Anyone want to corroborate?

-rich

$ ruby -v
ruby 1.6.8 (2002-12-24) [i386-freebsd4]
$ ruby -r digest/sha1 -e ‘puts
Digest::SHA1.new(“test”).hexdigest’
a94a8fe5ccb19ba61c4c0873d391e987982fbbd3

$ ruby18 -v
ruby 1.8.0 (2003-01-11) [i386-freebsd4]
$ ruby18 -r digest/sha1 -e ‘puts
Digest::SHA1.new(“test”).hexdigest’
a94a8fe5ccb19ba61c4c0873d391e987982fbbd3

$ uname -a
FreeBSD uriel.jijo.segment7.net 4.7-STABLE FreeBSD 4.7-STABLE #2: Wed
Jan 22 18:02:24 PST 2003
root@uriel.jijo.segment7.net:/usr/obj/disks/src/stable/sys/URIEL i386

···

Richard Kilmer (rich@infoether.com) wrote:

I was just stunned by the fact that the SHA1 hash in Ruby on OS X
(Jaguar) produces incorrect results.

I use SHA1 in the jabber4r (Ruby Jabber) library for digest
authentication. This effectively prevents jabber4r from working on the
stock Ruby that ships with OS X.

test.rb…
require ‘digest/sha1’
puts Digest::SHA1.new(“test”).hexdigest

And then a few tests:

/usr/bin/ruby -v
ruby 1.6.7 (2002-03-01) [powerpc-darwin6.0]
/usr/bin/ruby test.rb
94266438e06c02e522256b64ed8c833aef0270d0
^ ^ ^
This number is incorrect.
Under 1.6.7 on Win32 and Linux it produces the correct result.

/usr/local/bin/ruby -v
ruby 1.8.0 (2003-01-31) [powerpc-darwin6.3]
/usr/local/bin/ruby test.rb
a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
^ ^ ^
This is correct.

Anyone want to corroborate?


Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04