SHA512 HMAC support in Pharo

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

SHA512 HMAC support in Pharo

jvalteren@objectguild.com
Hi all,

For a client project we need support for SHA512 and SHA384 hashing and digital signatures with HMAC). Can anyone tell me if there is work (being) done on SHA512? We're on Pharo 7.0.3.

At first, it didn't look too hard to refactor the SHA256 class in the System-Hashing package. That is... until I saw the use of ThirtyTwoBitRegister and the SHA256NonPrimitive and SHA256WithPrimitive classes in the Cryptography-SHA256 package.

It seems to me that SHA512 will need a SixtyFourBitRegister class. 

Also, when I try to generate the constants on the fly with 64 bit values, the last 3 hexadecimal digits are zero (0). To me, this suggests that Pharo/Smalltalk might have issues working with 64 bit (float?) values.

"(Integer primesUpTo: 312) collect: [:x | (((x raisedTo: 1/3) fractionPart) * (2.0 raisedTo: 64)) truncated hex]"


Kind regards,

Jonathan van Alteren


Founding Member
+31622500930
Reply | Threaded
Open this post in threaded view
|

Re: SHA512 HMAC support in Pharo

Ben Coman


On Wed, 14 Aug 2019 at 20:25, Jonathan van Alteren <[hidden email]> wrote:
Hi all,

For a client project we need support for SHA512 and SHA384 hashing and digital signatures with HMAC). Can anyone tell me if there is work (being) done on SHA512? We're on Pharo 7.0.3.

At first, it didn't look too hard to refactor the SHA256 class in the System-Hashing package. That is... until I saw the use of ThirtyTwoBitRegister and the SHA256NonPrimitive and SHA256WithPrimitive classes in the Cryptography-SHA256 package.

It seems to me that SHA512 will need a SixtyFourBitRegister class. 

Also, when I try to generate the constants on the fly with 64 bit values, the last 3 hexadecimal digits are zero (0). To me, this suggests that Pharo/Smalltalk might have issues working with 64 bit (float?) values.

"(Integer primesUpTo: 312) collect: [:x | (((x raisedTo: 1/3) fractionPart) * (2.0 raisedTo: 64)) truncated hex]"


You can use LibSodium via FFI to do SHA512-HMAC...

Example...

And you may find some other options here...

cheers -ben