please dont rip this site Prev Next

CryptDecrypt info  Overview  Group

The CryptDecrypt function is used to decrypt data that was previously encrypted via the CryptEncrypt function.

BOOL CRYPTFUNC CryptDecrypt(

    HCRYPTKEY hKey,

    HCRYPTHASH hHash,

    BOOL Final,

    DWORD dwFlags,

    BYTE *pbData,

    DWORD *pdwDataLen

   );

Parameters

hKey
[in] A handle to the key to use for the decryption. An application obtains this handle by using either the CryptGenKey or CryptImportKey function.

This key specifies the decryption algorithm that is used.

hHash
[in] A handle to a hash object. This parameter is only used if a hash of the data is to be computed. See the “Remarks” section for more information.

If no hash is to be done, this parameter must be zero.

Final
[in] The Boolean value that specifies whether this is the last section in a series being decrypted. This will be TRUE if this is the last or only block. If it is not, then it will be FALSE. See the “Remarks” section for more information.
dwFlags
[in] The flag values. This parameter is reserved for future use and should always be zero.
pbData
[in/out] The buffer holding the data to be decrypted. Once that decryption has been performed, the plaintext is placed back in this same buffer.

The number of encrypted bytes in this buffer is specified by pdwDataLen.

pdwDataLen
[in/out] The address of the data length. Before calling this function, the caller should set this parameter to the number of bytes to be decrypted. Upon return, this address will contain the number of bytes of plaintext generated.

When a block cipher is used, this data length must be a multiple of the block size, unless this is the final section of data to be decrypted and the Final flag is TRUE.

Remarks

If data is to be decrypted and hashed simultaneously, a handle to a hash object can be passed in the hHash parameter. The hash value will be updated with the decrypted plaintext. This option is useful when simultaneously decrypting and verifying a signature.

Prior to calling CryptDecrypt, the application should obtain a handle to the hash object by calling the CryptCreateHash function. Once the decryption is complete, the hash value can be obtained (through CryptGetHashParam) or it can be signed (through CryptSignHash), or it can be used to verify a digital signature (through CryptVerifySignature).

When a large amount of data needs to be decrypted, it can be done in sections. This is done by calling CryptDecrypt repeatedly. The Final parameter should be set to TRUE only on the last invocation of CryptDecrypt, so the decryption engine can properly finish the decryption process. The following extra actions are performed when Final is TRUE:

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 hKey session key specifies an algorithm that this CSP does not support.

NTE_BAD_DATA

The data to be decrypted is invalid. For example, when a block cipher is used and the Final flag FALSE, the value specified by pdwDataLen must be a multiple of the block size. This error can also be returned when the padding is found to be invalid.

NTE_BAD_FLAGS

The dwFlags parameter is nonzero.

NTE_BAD_HASH

The hHash parameter contains an invalid handle.

NTE_BAD_KEY

The hKey parameter does not contain a valid handle to a key.

NTE_BAD_LEN

The size of the output buffer is too small to hold the generated plaintext.

NTE_BAD_UID

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

NTE_DOUBLE_ENCRYPT

The application attempted to decrypt the same data twice.

NTE_FAIL

The function failed in some unexpected way.

Example

See “Decryption Example” in the section Encrypting and Decrypting Data.

See Also

CryptCreateHash, CryptEncrypt, CryptGenKey, CryptGetKeyParam, CryptGetHashParam, CryptImportKey, CryptSignHash, CryptVerifySignature

 


file: /Techref/os/win/api/win32/func/src/f11_19.htm, 9KB, , updated: 2000/4/7 11:19, local time: 2024/12/25 17:52,
TOP NEW HELP FIND: 
3.148.105.127: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://massmind.ecomorder.com/Techref/os/win/api/win32/func/src/f11_19.htm"> CryptDecrypt 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 massmind.ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .