CryptEncrypt() buffer limit?
From: Michael Prendergast (MichaelPrendergast_at_discussions.microsoft.com)
Date: 10/28/04
- Next message: Anand Abhyankar [MS]: "Re: handling asymmetric key that exists in a container"
- Previous message: lelteto: "RE: Writing SCP"
- Next in thread: Rob Teixeira: "Re: CryptEncrypt() buffer limit?"
- Reply: Rob Teixeira: "Re: CryptEncrypt() buffer limit?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 28 Oct 2004 12:29:01 -0700
Hello,
I have a strange little bug that keeps occurring whenever I make a call to
CryptEncrypt():
It seems that whenever I call CryptEncrypt() to encrypt a plaintext buffer
of greater than 53 bytes, it fails and returns NTE_BAD_LEN through
GetLastError(). This seems independent of the actual buffer size I pass in.
For example, I tried getting the size required to encrypt a 58 byte buffer,
and gave CryptEncrypt() a size of 1000 for the actual buffer length, and
received NTE_BAD_LEN in response.
Here's some sample code:
---------------------------------------------------------------------
ULONG ulEncryptedDataSizeInBytes = 58;
if (CryptEncrypt(m_hRemotePublicKey, 0, TRUE, 0, NULL,
&ulEncryptedDataSizeInBytes, 1000) == FALSE)
{
hrReturnValue = GetLastError();
}
}
---------------------------------------------------------------------
I'm using MS_DEF_PROV as the cryptographic provider name, with PROV_RSA_FULL
and CALG_RSA_KEYX as the encryption algorithm (I'm using this encryption for
a public key exchange sequence).
Does anyone have any idea what could be wrong? Is there something I need to
set with SetKeyParam() first?
Also, as a side note, this works if I make repeated calls to CryptEncrypt()
with temporary copy buffers of less 32 bytes each.
Any help would be greatly appreciated.
Thank you very much for your help.
Ciao,
Michael Prendergast
- Next message: Anand Abhyankar [MS]: "Re: handling asymmetric key that exists in a container"
- Previous message: lelteto: "RE: Writing SCP"
- Next in thread: Rob Teixeira: "Re: CryptEncrypt() buffer limit?"
- Reply: Rob Teixeira: "Re: CryptEncrypt() buffer limit?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|