Issue with crypto HMAC Hash


I have an issue with calculating the HMAC Hash on a virtual machine. It gives me a different result then OpenSSL, which is not the case on my personal computer:

# swipl -version
Welcome to SWI-Prolog (threaded, 64 bits, version 8.0.3)
root@h2181216:# swipl  -g go

root@h2181216:# echo -n test | openssl dgst -sha256 -hmac "test"
(stdin)= 88cd2108b5347d973cf39cdf9053d7dd42704876d8c9a9bd8e2d168259d3ddf7

root@h2181216:# cat 
:- use_module(library(ssl)).


root@h2181216:# uname -a
Linux 4.4.0-042stab141.3 #1 SMP Fri Nov 15 22:45:34 MSK 2019 x86_64 x86_64 x86_64 GNU/Linux

On my PC I get the correct value:

wolfram@kardo:$ swipl -g go bin/ 

wolfram@kardo:$ uname -a
Linux kardo 4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

What may be wrong?

Meanwhile I found out a bit more. This is also returning the right hash:

    hash_atom(HMac,Hex), writeln(Hex).

Furthermore using crypto_data_hash the result does not depend of the key given as hmac(Key). As I use in both cases swi-prolog 8.0.3 I suppose there is a bug in an underlying crypto-lib preventing the hmac key to be used to calculate the hash.

Anyway, so I could use the hmac_sha predicate as a workaround at least.

Strange. I would suggest to try a couple of things.

  1. Check to see if the openssl version is the same in the PC and the VM.
  2. Try with a development version of SWI-Prolog, there were some ssl changes lately.

Yes, I see, you hit the point - RTFM. On the server it is Ubuntu 16.04 with OpenSSL1.0.2g whereas the SWI docu says OpenSSL 1.1.0 is required for the hmac option:

openssl/xenial-updates,xenial-security,now 1.0.2g-1ubuntu4.15 amd64 [installed]