I have this code
.....
const EVP_CIPHER * cipher = EVP_des_ecb();
uint8_t ot_byte,st_byte;
EVP_CIPHER_CTX ctx;
int trash;
EVP_EncryptInit(&ctx,cipher, key, iv);
cout << size - offset << endl;
int i=0;
for (; i < size - offset ;i++){
check = read(input_fd,&ot_byte,1);
cout << (i < size - offset) << " " << i << endl;
EVP_EncryptUpdate(&ctx, &st_byte, &trash, &ot_byte, 1);
check = write(output_fd,&st_byte,1);
}
cout << (i < size - offset) << " " << i << endl;
close(output_fd);
close(output_fd);
the output is
702000
1 0
1 1
1 2
1 3
1 4
1 5
1 6
1 7
0 5019693
When I "comment off" the EVP update function, the loop goes through all 702000 iterations. Where is the mistake? Is there a possibility, that EVP somehow goes behind its buffer and corrupts stack data?
uint8_t type will be small, these functions return at least 8 bytes