PCRYPT_DECRYPT_PRIVATE_KEY_FUNC callback function (wincrypt.h)

[The PCRYPT_DECRYPT_PRIVATE_KEY_FUNC function is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.]

The PCRYPT_DECRYPT_PRIVATE_KEY_FUNC function decrypts the private key and returns the decrypted key in the pbClearTextKey parameter. PCRYPT_DECRYPT_PRIVATE_KEY_FUNC is a callback function specified in a CRYPT_PKCS8_IMPORT_PARAMS structure. It is used when a CRYPT_ENCRYPTED_PRIVATE_KEY_INFO structure contains a private key that needs to be decrypted. The CryptImportPKCS8 function uses this function. The function must be implemented by the developer to suit each application.



BOOL PcryptDecryptPrivateKeyFunc(
  [in]      CRYPT_DATA_BLOB EncryptedPrivateKey,
  [out]     BYTE *pbClearTextKey,
  [in, out] DWORD *pcbClearTextKey,
  [in]      LPVOID pVoidDecryptFunc


[in] Algorithm

A CRYPT_ALGORITHM_IDENTIFIER structure that identifies the algorithm used to encrypt the PrivateKeyInfo ASN.1 type found in the PKCS #8 standard.

[in] EncryptedPrivateKey

A CRYPT_DATA_BLOB value that identifies the encrypted private key BLOB.

[out] pbClearTextKey

A pointer to a BYTE buffer to receive the plaintext. This parameter can be NULL. For more information, see Retrieving Data of Unknown Length.

[in, out] pcbClearTextKey

A pointer to a DWORD value that identifies the size, in bytes, of the pbClearTextKey buffer. If the size is zero, then pcbClearTextKey should be filled with the size, in bytes, required to decrypt the key, and pbClearTextKey should be ignored.

[in] pVoidDecryptFunc

An LPVOID value that provides data used in decryption, such as key, initialization vector, and password.

Return value

If the function succeeds, the function returns nonzero (TRUE).

If the function fails, it returns zero (FALSE).


Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header wincrypt.h

See also