The CryptDestroyKey function releases the handle referenced by the hKey parameter. Once a key handle has been released, it becomes invalid and cannot be used again.
If the handle refers to a session key, or to a public key that has been imported into the CSP through CryptImportKey, this function destroys the key and frees the memory that the key occupied. Many CSPs will scrub the memory where the key was held before freeing it.
On the other hand, if the handle refers to a public/private key pair (obtained from CryptGetUserKey), the underlying key pair is not destroyed by this function. Only the handle is destroyed.
BOOL CRYPTFUNC CryptDestroyKey(
HCRYPTKEY hKey | |
); |
Keys take up memory in both the operating system’s memory space and the CSP’s memory space. Some CSPs will be implemented in hardware with very limited memory resources. For this reason, it is important that applications destroy all keys with the CryptDestroyKey function when they are finished with them.
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_KEY |
The hKey parameter does not contain a valid handle to a key. |
NTE_BAD_UID |
The CSP context that was specified when the key was created cannot be found. |
See the “Example” section in the CryptGenKey function.
CryptDeriveKey, CryptGenKey, CryptGetUserKey, CryptImportKey
file: /Techref/os/win/api/win32/func/src/f12_2.htm, 4KB, , updated: 2000/4/7 11:19, local time: 2024/12/24 18:21,
3.140.188.174: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? <A HREF="http://massmind.ecomorder.com/Techref/os/win/api/win32/func/src/f12_2.htm"> CryptDestroyKey Release 2]</A> |
Did you find what you needed? |
Welcome to ecomorder.com! |
Welcome to massmind.ecomorder.com! |
.