473,399 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

question about in out parameter

hi
I'm trying to write CPEncrypt function. but i don't change the
content's of the pbData. First it contained the plaintext. But after
encryption i did not write the ciphertext value on it.
thanks.
BOOL WINAPI
CPEncrypt(
IN HCRYPTPROV hProv,
IN HCRYPTKEY hKey,
IN HCRYPTHASH hHash,
IN BOOL fFinal,
IN DWORD dwFlags,
IN OUT LPBYTE pbData,
IN OUT LPDWORD pcbDataLen,
IN DWORD cbBufLen)
{
char *tempData;
tempData=(PBYTE)malloc(strlen(outData));
..
..//pbData (plaintext) is encrypted
..//and ciphertext is written on tempData
..
printf("tempdata degeri %s %d \n",tempData,strlen((char
*)tempData));//in mysample //program i can see these values
memcpy(pbData,tempData,strlen(tempData));//and in this line CSP send
error 0x57 but if i //use hashed data for encryption
//the program is working properly

return true;
}
my sample program code
..
..
..
BYTE *outdata;
outdata=(BYTE *)malloc(100);
size_t size;
size=_msize(outdata);
outdata=(unsigned char*)"selami uekae tubitak";
DWORD len = strlen((const char *)outdata);
if(!CryptEncrypt(hKey, 0,TRUE,0,outdata,&len,(DWORD)size ))
printf("Error %x during CryptEncrypt!\n", GetLastError());
else printf("CryptEncrypt succeed\n");
Jul 19 '05 #1
1 3141
On 17 Nov 2003 02:03:39 -0800, se****@uekae.tubitak.gov.tr (p_hose)
wrote in comp.lang.c++:

You didn't fix half the mistakes I pointed out when you posted this in
comp.lang.c hours ago.
BOOL WINAPI
There are no keywords BOOL or WINAPI in C++.
CPEncrypt(
IN HCRYPTPROV hProv,
IN HCRYPTKEY hKey,
IN HCRYPTHASH hHash,
IN BOOL fFinal,
IN DWORD dwFlags,
IN OUT LPBYTE pbData,
IN OUT LPDWORD pcbDataLen,
IN DWORD cbBufLen)
{
char *tempData;
tempData=(PBYTE)malloc(strlen(outData));
.
.//pbData (plaintext) is encrypted
.//and ciphertext is written on tempData
.
printf("tempdata degeri %s %d \n",tempData,strlen((char
*)tempData));//in mysample //program i can see these values
memcpy(pbData,tempData,strlen(tempData));//and in this line CSP send
error 0x57 but if i //use hashed data for encryption
//the program is working properly

return true;
}
my sample program code
.
.
.
BYTE *outdata;
outdata=(BYTE *)malloc(100);
You still don't check that the memory allocation succeeded, dipstick.
size_t size;
size=_msize(outdata);
outdata=(unsigned char*)"selami uekae tubitak";


You still create a memory leak by assigning a pointer to a string
literal into the pointer to memory that you allocated.

If you're not going to take advice when you ask for it, go the fsck
away.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: LG | last post by:
Just have a question with regards to the clipboard, and how to read what other applications (Adobe InDesignCS) place in the clipboard. I am currently in the process of creating a booklet from a...
7
by: Herman | last post by:
Hi everyone, I recently installed the Sun J2SE SDK on my machine, and I am having trouble running the java.exe interpreter for my Java compiled code. I remember that I had to set my environment...
3
by: thomas goodwin | last post by:
I have a query which asks for a parameter value to execute it. To see the results I have to: a) click on the query -- the "Enter Parameter Value" window pops up. b) enter the parameter value c)...
18
by: Kamen Yotov | last post by:
hi all, i first posted this on http://msdn.microsoft.com/vcsharp/team/language/ask/default.aspx (ask a c# language designer) a couple of days ago, but no response so far... therefore, i am...
6
by: hecsan07 | last post by:
I am writing some code that passes two parameters to a store procedure. One of the parameters is an output parameter. I am querying the DB using the input value and returning a field from the...
2
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row...
3
by: Henry | last post by:
I know it is possible to store dynamic propterties for applications in XML files. The app.config and the web.config files can be used to store AppSettings... I am just wondering how far one can...
33
by: jobo | last post by:
If I have the function: int f(int (*h)(int)) { return (*h)(13); } What exactly does (int (*h)(int)) do? So it's taking a pointer but what's with the two ints? Thanks.
6
by: damiensawyer | last post by:
Hi, Can someone please explain to me something about delegates? My understanding is as follows. A delegate is basically an object that can hold a reference to a "method" somewhere. That is,...
5
by: =?Utf-8?B?SmVzc2ljYQ==?= | last post by:
Hello, I have a pInvoke question. This is the C function that is exported from one of the C dll, extern __declspec(dllexport) IM_RET_CODE ST_import (IM_MODE mode, char *filename,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.