[This is preliminary documentation and subject to change.]
CryptUnprotectData performs a decryption and integrity check of the data in a DATA_BLOB. Normally, only a user with the same login credential as the encrypter can decrypt the data. In addition, the encryption and decryption must be done on the same computer. See "Remarks" in CryptProtectData for information about exceptions.
BOOL WINAPI CryptUnprotectData(
DATA_BLOB *DataIn, // in
LPWSTR *ppszDataDescr, // out optional
DATA_BLOB *pOptionalEntropy, // in optional
PVOID *pvReserved, // reserved
CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, // in optional
DWORD dwFlags // in
DATA_BLOB *pDataOut; // out
);
The function returns TRUE if the function succeeded, FALSE if it failed. GetLastError returns the code for the cause of any failure. The pbData of the DATA_BLOB allocated and a non NULL ppszDataDescr must be freed using LocalFree.
The CryptProtectData function creates a session key when the data is encrypted. That key is re-derived and used to decrypt the data blob.
The MAC hash added to the encrypted data can be used to determine whether the encrypted data was altered in any way. Any tampering results in a ERROR_INVALID_DATA return.
See example using CryptProtectData.
Windows NT: Requires version 5.0 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in wincrypt.h.
Import Library: Use crypt32.lib.