P
p_hose
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");
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");