0

我尝试使用 Crypto++ 为 AES 实现 CBC 方案。我的问题来自这里:当我尝试“异或”2个字符字符串时,当我尝试与自己异或一个字符时,我遇到了一些问题。

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;
}

来电:

unsigned char * encryptedXOR = xorOp(plainTextBlock.c_str(),iv);

其中 plainTextBlock 是纯文本的 16 字节块,iv 是初始化向量(16 字节)。之后,假设我的纯文本长度为130,填充144后,加密后必须为288。因此,由于异或,无法达到该维度。请帮忙!谢谢!

4

0 回答 0