I try to implement CBC scheme for AES ,using Crypto++. My problems come from here:When I try to "xor" 2 char strings,I have some problems in that case when I try to xor a character with himself.
unsigned char * xorOp(const char * s1,unsigned char * s2){
unsigned char *out = (unsigned char *) calloc(strlen(s1),sizeof(unsigned char));
for(int i=0; s1[i]!=0;i++)
{
out[i] = s1[i] ^ s2[i];
cout<<out[i]<<endl;
if(out[i] == '\0') cout<<"not ok "<<s1[i]<<" "<<s2[i]<<endl;
}
return out;
}
Calling:
unsigned char * encryptedXOR = xorOp(plainTextBlock.c_str(),iv);
where plainTextBlock is a block of 16 bytes from plain text and iv is an initialization vector(16 bytes). After that ,supposing that my plain text length is 130 ,after padding 144,after encryption must be 288.So ,that dimension can not be reached because of the xor. Please help! Thank you!