Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling openssl from x64 application
#6
(05-22-2019, 06:53 AM)info@a-dato.net Wrote:   ih.Key := IndyTextEncoding_8Bit.GetBytes(clean_key);

That will not work. Your clean_key contains a base64-encoded string, but the TIdHMAC.Key property expects actual bytes instead. You will have to decode the base64 string first.

(05-22-2019, 06:53 AM)info@a-dato.net Wrote:   indy_buf := ih.HashValue(IndyTextEncoding_8Bit.GetBytes(AData));

What does your AData actually look like? If it contains non-ASCII characters, 8Bit is likely to lose them. Typically, UTF8 is the preferred encoding when hashing string data.

(05-22-2019, 06:53 AM)info@a-dato.net Wrote:   indy_hash := TNetEncoding.Base64.EncodeBytesToString(indy_buf);

Like I said earlier, Indy has a base64 encoder:

Code:
indy_hash := TIdEncoderMIME.EncodeBytes(indy_buf);

(05-22-2019, 06:53 AM)info@a-dato.net Wrote: this hash value is calculated: 'SFYyolkv4nUPbzKoFOmHuPaDQE4='

The hash value should be: 
'jSXIuYXqNb23f0RHybCpYWlzNAfABN1ie2hGPA7Cj0svoXX2sLaTZdTt11nb8DieULXivftOzxKDPkWjGiJJQsxUaPpltsfYOCg/jSeNEo+clfRpIP3K4UGXDjCQNwV+WNCkggA9S87oEylUBPOdShibOAC1oMocAO/B9SOZm/o='

That is WAY TOO LONG for a valid HMAC-SHA1 hash, even when encoded in base64. SHA-1 produces a 20-byte hash, and HMAC-SHA1 simply invokes SHA-1 multiple times but the result is still 20 bytes. The "expected" base64 you have shown above decodes to 128 bytes. The "Indy" base64 you have shown above decodes to 20 bytes. Where are you getting this "expected" hash from exactly?

Reply


Messages In This Thread
Calling openssl from x64 application - by KeesVer - 05-16-2019, 12:13 PM
RE: Calling openssl from x64 application - by rlebeau - 05-22-2019, 08:00 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)