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. Actually it
change in the CSP dll but pbData which is in the cryptencrypt function
didn't change. how could i write the value on pbData? when i used
"strcpy((char* )pbData,(char *)tempData);" the progmram send
error.(tempdata is carrying ciphertext value)
Mycode(smaple program which is using my own CSP) is below.
thanks.
if (RCRYPT_FAILED(CryptAcquireContext(&hProv, "selami",
"MyCSP ", PROV_RSA_FULL, CRYPT_NEWKEYSET)))
{
printf("FAILED CryptAcquireConext returned error %x\n",
GetLastError());
return(TRUE);
}
else
printf("\n CryptAcquireContext SUCCEED\n");
.
.
.
.
if(!CryptGenKey(hProv, CALG_RC2, CRYPT_EXPORTABLE|0x00400000, &hKey))
printf("Error %x during CryptGenKey!\n", GetLastError());
else printf("CryptGenKey succeed\n");
BYTE *outdata;
outdata=(BYTE *)malloc(100);
outdata=(unsigned char *)"selami uekae tubitak\0";
DWORD len = strlen((const char *)outdata);
if(!CryptEncrypt(hKey, 0,TRUE,0,outdata,&len,(DWORD)100 ))
//if(!CryptEncrypt(hKey, phHash,TRUE,0,outdata,(DWORD
*)40,(DWORD)40)) // HASH kisminin testi icin yazilan bolum
printf("Error %x during CryptEncrypt!\n", GetLastError());
else printf("CryptEncrypt succeed\n");
if(!CryptReleaseContext(hProv,0)) {
errnum = GetLastError();
return false;
}
}
if i used below code instead of "outdata=(BYTE *)malloc(100)" and
encrypted the hash value the program work properly.
BYTE outdata[100];
outdata[0]=(char)"s";
outdata[1]=(char)"e";
outdata[2]=(char)"l";
outdata[3]=(char)"a";
outdata[4]=(char)"m";
outdata[5]=(char)"i";
outdata[6]=(char)"h";
outdata[7]=(char)"o";
outdata[8]=(char)"z";
outdata[9]=(char)"b";
outdata[10]=(char)"e";
outdata[11]=(char)"f";
outdata[12]=(char)"b";
outdata[13]=(char)"y";
outdata[14]='\0';
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. Actually it
change in the CSP dll but pbData which is in the cryptencrypt function
didn't change. how could i write the value on pbData? when i used
"strcpy((char* )pbData,(char *)tempData);" the progmram send
error.(tempdata is carrying ciphertext value)
Mycode(smaple program which is using my own CSP) is below.
thanks.
if (RCRYPT_FAILED(CryptAcquireContext(&hProv, "selami",
"MyCSP ", PROV_RSA_FULL, CRYPT_NEWKEYSET)))
{
printf("FAILED CryptAcquireConext returned error %x\n",
GetLastError());
return(TRUE);
}
else
printf("\n CryptAcquireContext SUCCEED\n");
.
.
.
.
if(!CryptGenKey(hProv, CALG_RC2, CRYPT_EXPORTABLE|0x00400000, &hKey))
printf("Error %x during CryptGenKey!\n", GetLastError());
else printf("CryptGenKey succeed\n");
BYTE *outdata;
outdata=(BYTE *)malloc(100);
outdata=(unsigned char *)"selami uekae tubitak\0";
DWORD len = strlen((const char *)outdata);
if(!CryptEncrypt(hKey, 0,TRUE,0,outdata,&len,(DWORD)100 ))
//if(!CryptEncrypt(hKey, phHash,TRUE,0,outdata,(DWORD
*)40,(DWORD)40)) // HASH kisminin testi icin yazilan bolum
printf("Error %x during CryptEncrypt!\n", GetLastError());
else printf("CryptEncrypt succeed\n");
if(!CryptReleaseContext(hProv,0)) {
errnum = GetLastError();
return false;
}
}
if i used below code instead of "outdata=(BYTE *)malloc(100)" and
encrypted the hash value the program work properly.
BYTE outdata[100];
outdata[0]=(char)"s";
outdata[1]=(char)"e";
outdata[2]=(char)"l";
outdata[3]=(char)"a";
outdata[4]=(char)"m";
outdata[5]=(char)"i";
outdata[6]=(char)"h";
outdata[7]=(char)"o";
outdata[8]=(char)"z";
outdata[9]=(char)"b";
outdata[10]=(char)"e";
outdata[11]=(char)"f";
outdata[12]=(char)"b";
outdata[13]=(char)"y";
outdata[14]='\0';