I need some help with a Crypto call. According to MSDN, the following C++ call sets the random string from the client:
Converting to VB, the function is declared as:Code:Data.pbData = pClientRandom; Data.cbData = cbClientRandom; CryptSetKeyParam( hMasterKey, KP_CLIENT_RANDOM, (PBYTE)&Data, 0);
The call:Code:Private Declare Function CryptSetKeyParam Lib "advapi32.dll" (ByVal hKey As Long, ByVal dwParam As Long, ByVal pbData As Long, ByVal dwFlags As Long) As Long
returns an error. However, the call works when using KP_SCHANNEL_ALG (20) instead of KP_CLIENT_RANDOM (21) or KP_CLIENT_SERVER (22). According to Microsoft, the structure of "pbData" will vary, depending on the value of "dwParam". In the case of KP_CLIENT_RANDOM, "pbData" is a handle to a byte string containing 32 bytes of random data from the client followed by whatever cbClientRandom is. Some sources suggest that this is a BLOB structure, which means that cbClientRandom should be a 4 byte long integer (DWORD) containing the length of pClientRandom.Code:CryptSetKeyParam(hMasterKey, KP_CLIENT_RANDOM, hClientRandom, 0)
I have tried every combination I can think of, but the call always returns an error. Any help would be appreciated.
J.A. Coutts




Reply With Quote