I tried different ways to calculate a correct HMAC SHA1 hash and had no success. I shortened the code more and more to find out where the issue might be. The result was that some ASCII characters generated a bad result when used as key.
I have also asked here for help, but got no solution:
https://www.purebasic.fr/english/viewtopic.php?t=84677
Code: Select all
UseSHA1Fingerprint()
For i = 125 To 165
Debug "ascii: "+ Str(i) + " hash: " + StringFingerprint("test", #PB_Cipher_SHA1|#PB_Cipher_HMAC, #PB_Ignore, #PB_Ascii, Chr(i), #PB_Ascii)
Next
As can be seen the key is different for every loop but the hash output is the same for much of them (bad hash result: bcc96068c1cc6ecc361a9a26e8a9282b8204cd3a).
The problem only happens when "HmacKeyFormat" is using #PB_Ascii mode.