Hi,
As i have no idea how TMSCryptography-Pack works, also i can't find the documentation online (i remember saw them on their site in that past),
1) Are these commented lines from TMS on how to use ?
2) What is this ? and how this is working with salt declared like that ?
Zitat:
function getHKDFKey(echdSharedSecret,salt:String):String;
var hkdf: THKDFKeyDerivation;
ecdhSharedSecret,salt:String;
PRK: string;
3) This is definitely is wrong here
hkdf.Unicode:= TUnicode.yesUni;
if you are using raw bytes as source for HKDF then it can't be handled as string or UnicodeString as input, this only can be helpful if you are trying to get key HKDF generated from something like password
4) Main question now :
Delphi-Quellcode:
hkdf.OutputFormat:= hexa;
hkdf.hashFunction := hsha2;
hkdf.hashSizeBits := 256;
PRK:= hkdf.Extract(ecdhSharedSecret, salt);
result:= hkdf.Expand(PRK, '', 36);
This either your own algorithm, which is.... lets say OKAY, or you need some defined algorithm to follow, in case of HKDF these parameters will change the output for sure, so why PRK followed by Expand ? , why the output is hexa ?
if the commented lines are documentation then PRK is not needed here, it is something to get bit entropy from limited source like (again) password, so Expand following Extract make no sense.
I suggest to make your needs clear first then write the usage HKDF, because the mentioned code is making little sense and not logically clear.
On other hand:
DEC has examples and tests for HKDF and they do pass, means it should work, if you are familiar with it then stick to it, if you can't make it show some specific result then ask about that, and don't forget to provide the needed steps/algorithm/parameters for HKDF, in case there is specification for follow, if there is not and all what you want is HKDF, i mean your own, then again repeat (exact steps) any example from TMS or
DEC, both will do.