ECB mode cipher doesn't need IV, if we setiv for it then qemu
crypto API would report "Expected IV size 0 not **", so we should
setiv only when the cipher algos really need.
Signed-off-by: Longpeng(Mike) <[email protected]>
Signed-off-by: Gonglei <[email protected]>
sess = builtin->sessions[op_info->session_id];
- ret = qcrypto_cipher_setiv(sess->cipher, op_info->iv,
- op_info->iv_len, errp);
- if (ret < 0) {
- return -VIRTIO_CRYPTO_ERR;
+ if (op_info->iv_len > 0) {
+ ret = qcrypto_cipher_setiv(sess->cipher, op_info->iv,
+ op_info->iv_len, errp);
+ if (ret < 0) {
+ return -VIRTIO_CRYPTO_ERR;
+ }
}
if (sess->direction == VIRTIO_CRYPTO_OP_ENCRYPT) {