Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ripemd160 checksum is listed in the supported checksums but does not work #2516

Closed
odiferousmint opened this issue Aug 17, 2022 · 3 comments
Closed
Labels
Oldes.resolved Bugs/wishes with Oldes' fixes/features Test.written Type.bug

Comments

@odiferousmint
Copy link

odiferousmint commented Aug 17, 2022

Version:

REBOL/Bulk 3.9.1 (Oldes branch)
Platform   Linux | x64-pc-linux-elf | gcc
Build      17-Aug-2022/18:29

1st:

>> checksum form random/secure to-integer #{7fffffffffffffff} system/catalog/checksums/sha512

** Script error: invalid argument: ripemd160
** Where: checksum
** Near: checksum form random/secure to-integer #{7FFFFFFFFFFFFFFF} s...

2nd:

>> checksum #{FF} system/catalog/checksums/sha512 

** Script error: invalid argument: ripemd160
** Where: checksum
** Near: checksum #{FF} system/catalog/checksums/sha512

Before the regression (although the length does not seem to be correct even in this version):

Version:

REBOL/Bulk 3.7.2 (Oldes branch)
Platform   Linux | x64-pc-linux-elf | gcc
Build      11-May-2022/4:21
>> checksum form random/secure to-integer #{7fffffffffffffff} system/catalog/checksums/sha512
== #{795D5C4A39113C185FA7CAD948A43451E86E3B26}

That said, I get an error when the hash is ripemd160:

>> checksum #{FF} system/catalog/checksums/ripemd160 

** Script error: checksum does not allow none! for its method argument
@odiferousmint
Copy link
Author

odiferousmint commented Aug 17, 2022

I am not certain that the issue here is related to checksum per se, it might go deeper than that. Feel free to change the title.

>> system/catalog/checksums
== [adler32 crc24 crc32 tcp md4 md5 sha1 sha224 sha256 sha384 sha512 ripemd160]

I do not know why it would error out on the 2nd last element and the last element. Consider the following:

>> checksum #{FF} system/catalog/checksums/sha1
== #{E33F9D75E6AE1369DBABF81B96B4591AE46BBA30B591A6B6C62542B5}

>> checksum #{FF} system/catalog/checksums/sha384
== #{
6700DF6600B118AB0432715A7E8A68B0BF37CDF4ADAF0FB9E2B3EBE04AD19C70
32CBAD55E932792AF360BAFAA09962E2E690652BC075B2DAD0C30688BA2F31A3
}

>> checksum #{FF} system/catalog/checksums/sha512 

** Script error: invalid argument: ripemd160
** Where: checksum
** Near: checksum #{FF} system/catalog/checksums/sha512

>> checksum #{FF} system/catalog/checksums/ripemd160

** Script error: checksum does not allow none! for its method argument

I am not sure if I should create a separate issue for this, but it seems like that the returned digests are incorrect (in length as well, e.g. the returned digest for SHA-1 should be 40 characters long):

>> checksum to-binary "foobar" system/catalog/checksums/sha1 
== #{DE76C3E567FCA9D246F5F8D3B2E704A38C3C5E258988AB525F941DB8}

>> checksum to-binary "foobar" system/catalog/checksums/sha224
== #{C3AB8FF13720E8AD9047DD39466B3C8974E592C2FA383D4A3960714CAEF0C4F2}

>> checksum to-binary "foobar" system/catalog/checksums/sha256 
== #{
3C9C30D9F665E74D515C842960D4A451C83A0125FD3DE7392D7B37231AF10C72
EA58AEDFCDF89A5765BF902AF93ECF06
}

>> checksum to-binary "foobar" system/catalog/checksums/sha384 
== #{
0A50261EBD1A390FED2BF326F2673C145582A6342D523204973D0219337F8161
6A8069B012587CF5635F6925F1B56C360230C19B273500EE013E030601BF2425
}

>> checksum to-binary "foobar" system/catalog/checksums/sha512 
== #{A06E327EA7388C18E4740E350ED4E60F2E04FC41}

seems to be an issue as well (mind you, sha512 works with the older version only).

@Oldes
Copy link
Owner

Oldes commented Aug 18, 2022

You probably want to use just:

>> checksum to-binary "foobar" 'sha1
== #{8843D7F92416211DE9EBB963FF4CE28125932878}

>> checksum "foobar" 'sha1           
== #{8843D7F92416211DE9EBB963FF4CE28125932878}

The system/catalog/checksums is just a block with possible checksum names available.

But it looks that the ripemd160 is not working...

>> checksum "foobar" 'ripemd160  

** Script error: invalid argument: ripemd160
** Where: checksum
** Near: checksum "foobar" 'ripemd160

This is code to count all available checksums methods:

>> foreach method system/catalog/checksums [print [method tab mold/flat try [checksum "foo" method]]]
adler32 	 42074437
crc24 	 5804686
crc32 	 -1938594527
tcp 	 39201
md4 	 #{0AC6700C491D70FB8650940B1CA1E4B2}
md5 	 #{ACBD18DB4CC2F85CEDEF654FCCC4A4D8}
sha1 	 #{0BEEC7B5EA3F0FDBC95D0DD47F3C5BC275DA8A33}
sha224 	 #{0808F64E60D58979FCB676C96EC938270DEA42445AEEFCD3A4E6F8DB}
sha256 	 #{2C26B46B68FFC68FF99B453C1D30413413422D706483BFA0F98A5E886266E7AE}
sha384 	 #{98C11FFDFDD540676B1A137CB1A22B2A70350C9A44171D6B1180C6BE5CBB2EE3F79D532C8A1DD9EF2E8E08E752A3BABB}
sha512 	 #{F7FBBA6E0636F890E56FBBF3283E524C6FA3204AE298382D624741D0DC6638326E282C41BE5E4254D8820772C5518A2C5A8C0C7F7EDA19594A7EB539453E1ED7}
ripemd160 	 make error! [code: 309 type: 'Script id: 'invalid-arg arg1: 'ripemd160 arg2: none arg3: none near: [checksum "foo" method] where: [checksum try print foreach]]

@Oldes
Copy link
Owner

Oldes commented Aug 18, 2022

Note that what you are doing is probably not what you expect:

>> system/catalog/checksums/sha1
== sha224 ;<--- because it is next word after 'sha1

Which is like one use path on blocks.. similar to:

>> b: [a 1] b/a
== 1

@Oldes Oldes changed the title Possible regression in checksum ripemd160 checksum is listed in the supported checksums but does not work Aug 18, 2022
@Oldes Oldes added the Type.bug label Aug 18, 2022
@Oldes Oldes added Test.written Oldes.resolved Bugs/wishes with Oldes' fixes/features labels Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Oldes.resolved Bugs/wishes with Oldes' fixes/features Test.written Type.bug
Projects
None yet
Development

No branches or pull requests

2 participants