C++ EVP_EncriptUpdate 重写堆栈?
C++ EVP_EncriptUpdate rewriting stack?
我有这个代码
.....
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);
输出是
702000
1 0
1 1
1 2
1 3
1 4
1 5
1 6
1 7
0 5019693
当我"comment off" EVP 更新函数时,循环会经历所有 702000 次迭代。错误在哪里? EVP 是否有可能以某种方式落后于其缓冲区并损坏堆栈数据?
uint8_t类型会小,这些函数return至少8个字节
我有这个代码
.....
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);
输出是
702000
1 0
1 1
1 2
1 3
1 4
1 5
1 6
1 7
0 5019693
当我"comment off" EVP 更新函数时,循环会经历所有 702000 次迭代。错误在哪里? EVP 是否有可能以某种方式落后于其缓冲区并损坏堆栈数据?
uint8_t类型会小,这些函数return至少8个字节