0

I am trying to cipher and decipher in AES CBC mode, but I have errors.

My code:

BYTE initVec[16] = {0x00};
BYTE message[16];
BYTE cipher[16];

for(r = 0; r < 16; r++){
    int read2 =  fread(cipher, 1, 16, fpIn); // Read last block
    aes_decrypt(buffer, cipher, key); // Decrypt - buffer
    buffer[r] = buffer[r] ^ cipher[r];
}

After the first block, I need to XOR the previous block of ciphertext with the current block of decrypted data for other blocks. How can I achieve this?

4

1 に答える 1