The NCryptStreamOpenToProtect function opens a stream object that can be used to encrypt large amounts of data to a given protection descriptor. Call NCryptStreamUpdate to encrypt the content. To encrypt smaller messages such as keys and passwords, call NCryptProtectSecret.
SECURITY_STATUS NCryptStreamOpenToProtect( NCRYPT_DESCRIPTOR_HANDLE hDescriptor, DWORD dwFlags, HWND hWnd, NCRYPT_PROTECT_STREAM_INFO *pStreamInfo, NCRYPT_STREAM_HANDLE *phStream );
Handle of the protection descriptor. Create the handle by calling NCryptCreateProtectionDescriptor.
The flag can be zero or the following value.
||Requests that the key service provider not display a user interface.|
Handle to the parent window of the user interface, if any, to be displayed.
Pointer to an NCRYPT_PROTECT_STREAM_INFO structure that contains the address of a user defined callback function to receive the encrypted data and a pointer to user-defined context data.
Pointer to the stream object handle.
Returns a status code that indicates the success or failure of the function. Possible return codes include, but are not limited to, the following.
||The function was successful.|
||The dwFlags parameter must contain zero (0), NCRYPT_MACHINE_KEY_FLAG, or NCRYPT_SILENT_FLAG.|
||The handle specified by the hDescriptor parameter is not valid.|
The phStream and pStreamInfo parameters cannot be NULL.
The callback function pointed to by the pfnStreamOutput member of the NCRYPT_PROTECT_STREAM_INFO structure pointed to by the pStreamInfo parameter cannot be NULL.
||There was insufficient memory to allocate a data stream.|
The NCryptStreamOpenToProtect function creates an internal stream object that can be used to encrypt large messages. You cannot use the object directly. Instead, you must use the object handle returned by this function.
Call this function before calling the NCryptStreamUpdate function. If you are encrypting a large file, use NCryptStreamUpdate in a loop that advances through the file block by block, encrypting each block as it advances and notifying your callback when each block is finished. For more information, see NCryptStreamUpdate.
The NCryptStreamOpenToProtect function writes the unencrypted protection descriptor rule string to the stream object header so that NCryptStreamOpenToUnprotect will be able to start the decrypting the stream by using the same protector used during encryption.
|Minimum supported client||Windows 8 [desktop apps only]|
|Minimum supported server||Windows Server 2012 [desktop apps only]|