Results 1 to 13 of 13

Thread: [RESOLVED] Conversion Problem

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,668

    Resolved [RESOLVED] Conversion Problem

    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
    Last edited by Siddharth Rout; May 19th, 2013 at 09:29 PM. Reason: Added Code Tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width