On 11 December 2017 at 13:09, Ben Coman <b...@openinworld.com> wrote:

> 2017-12-10 6:01 GMT-03:00 Ben Coman <b...@openinworld.com>:
> > Can anyone recommend libraries (native Smalltalk or via FFI)
> > to do generate a HMAC-SHA512 ?
>
> On 11 December 2017 at 01:30, Hernán Morales Durand <
> hernan.mora...@gmail.com> wrote:
>
>> Hi Ben,
>>
>> I would use NaCl: http://cr.yp.to/highspeed/coolnacl-20120725.pdf
>> which you can install from the Pharo Project Catalog in Pharo 6.x
>
>
> Thanks Henry.  That looks like path of least resistance.
>

Whoops, I meant thanks Hernán.




>  I hit a stumbling block that took a short while to understand.
> The library binary downloaded specified by ConfigruationOfNacl>>
> platformLibraryUrl
> is  libsodium: ELF 32-bit LSB shared object
> whereas I'm using 64bit Linux.
>

btw, I discovered just now that FFILibrary>>unix64ModuleName
was introduced this year.  So presumably with the following
you could include both bit'ness libraries in the libsodium.so.gz
file specified in ConfigurationOfNacl >> platformLibraryUrl.

FFILbrary subclass: #Nacl
instanceVariableNames: ''
classVariableNames: ''
package: 'Crypto-Nacl'

Nacl >> unixModuleName
    ^ 'libsodium.so'

Nacl >> unix64ModuleName
    ^ 'libsodium64.so'

Nacl class >> apiXXX
^ self ffiCall: #(void XXX())
                 module: Nacl





>
> I have the following system library preinstalled...
> /usr/lib/x86_64-linux-gnu/libsodium.so.18.0.1: ELF 64-bit LSB shared
> object
>
> However its api is slightly different.  Pharo Nacl makes this call out...
>    crypto_hash_sha512_ref()
>
> but the system library provides...
>     56: 0000000000014dc0   175 FUNC    GLOBAL DEFAULT   11
> crypto_hash_sha512_final
>     81: 0000000000014c40   384 FUNC    GLOBAL DEFAULT   11
> crypto_hash_sha512_update
>    154: 0000000000014bd0   106 FUNC    GLOBAL DEFAULT   11
> crypto_hash_sha512_init
>    233: 0000000000014e70   114 FUNC    GLOBAL DEFAULT   11
> crypto_hash_sha512
>    342: 0000000000012330     6 FUNC    GLOBAL DEFAULT   11
> crypto_hash_sha512_bytes
>    351: 0000000000012340     6 FUNC    GLOBAL DEFAULT   11
> crypto_hash_sha512_statebytes
>
> The canonical source doesn't seem to have the function
> https://github.com/jedisct1/libsodium/search?utf8=%E2%9C%
> 93&q=+crypto_hash_sha512_ref
> so I'm curious where the "_ref" comes from.
>
> My options seem...
> * Compile a 64-bit libsodium from source which includes "_ref" functions.
> Where is such source?
>
* Use the system libsodium and define an FFI callout just for the one
> function I need.
>

btw, I'm doing the latter for now as the immediate path of least
resistance.
Thanks Hernan, for the tip on libsodium.

cheers -ben

Reply via email to