Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21339

Conversion Problem

$
0
0
I need some help with a Crypto call. According to MSDN, the following C++ call sets the random string from the client:

Code:

Data.pbData = pClientRandom;
Data.cbData = cbClientRandom;
CryptSetKeyParam(
        hMasterKey,
        KP_CLIENT_RANDOM,
        (PBYTE)&Data,
        0);

Converting to VB, the function is declared as:

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
The call:

Code:

CryptSetKeyParam(hMasterKey, KP_CLIENT_RANDOM, hClientRandom, 0)
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.

I have tried every combination I can think of, but the call always returns an error. Any help would be appreciated.

J.A. Coutts

Viewing all articles
Browse latest Browse all 21339

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>