please dont rip this site Prev Next

CryptHashSessionKey info  Overview  Group

The CryptHashSessionKey function is used to compute the cryptographic hash on a key object. This function can be called multiple times with the same hash handle to compute the hash on multiple keys. Calls to CryptHashSessionKey can be interspersed with calls to CryptHashData.

Before calling this function the CryptCreateHash function must be called to get a handle to a hash object.

BOOL CRYPTFUNC CryptHashSessionKey(

    HCRYPTHASH hHash,

    HCRYPTKEY hKey,

    DWORD dwFlags

   );

Parameters

hHash
[in] A handle to the hash object. An application obtains this handle using the CryptCreateHash function.
hKey
[in] A handle to the key object to be hashed.
dwFlags
[in] The flag values. This parameter is reserved for future use and should always be zero.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To retrieve extended error information, use the GetLastError function.

The following table lists the error codes most commonly returned by the GetLastError function. The error codes prefaced by “NTE” are generated by the particular CSP you are using.

Error

Description

ERROR_INVALID_HANDLE

One of the parameters specifies an invalid handle.

ERROR_INVALID_PARAMETER

One of the parameters contains an invalid value. This is most often an illegal pointer.

NTE_BAD_ALGID

The hHash handle specifies an algorithm that this CSP does not support.

NTE_BAD_FLAGS

The dwFlags parameter is nonzero.

NTE_BAD_HASH

The hash object specified by the hHash parameter is invalid.

NTE_BAD_HASH_STATE

An attempt was made to add data to a hash object that is already marked “finished.”

NTE_BAD_KEY

A keyed hash algorithm is being used, but the session key is no longer valid. This error will be generated if the session key is destroyed before the hashing operating is complete.

NTE_BAD_UID

The CSP context that was specified when the hash object was created cannot be found.

NTE_FAIL

The function failed in some unexpected way.

Example

#include <wincrypt.h>



HCRYPTPROV hProv = 0;

HCRYPTHASH hHash = 0;

HCRYPTKEY hKey   = 0;



// Get handle to the default provider.

if(!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, 0)) {

    printf("Error %x during CryptAcquireContext!\n", GetLastError());

    goto done;

}



// Create hash object.

if(!CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash)) {

    printf("Error %x during CryptBeginHash!\n", GetLastError());

    goto done;

}



// Create random session key.

if(!CryptGenKey(hProv, CALG_RC2, CRYPT_EXPORTABLE, &hKey)) {

    printf("Error %x during CryptGenKey!\n", GetLastError());

    goto done;

}



// Hash session key.

if(!CryptHashSessionKey(hHash, hKey, 0)) {

    printf("Error %x during CryptHashSessionKey!\n", GetLastError());

    goto done;

}



// Use the hash object for something.

...



done:



// Destroy hash object.

if(hHash) CryptDestroyHash(hHash);



// Destroy session key.

if(hKey) CryptDestroyKey(hKey);



// Release CSP handle.

if(hProv) CryptReleaseContext(hProv,0);

 

See Also

CryptCreateHash, CryptGenKey, CryptHashData 


file: /Techref/os/win/api/win32/func/src/f12_12.htm, 6KB, , updated: 2000/4/7 11:19, local time: 2024/11/27 20:48,
TOP NEW HELP FIND: 
18.117.145.67:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://ecomorder.com/techref/os/win/api/win32/func/src/f12_12.htm"> CryptHashSessionKey Service Release 2]</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to ecomorder.com!

 

Welcome to ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .