Commit 50d19cf3 authored by Longpeng(Mike)'s avatar Longpeng(Mike) Committed by Gonglei
Browse files

cryptodev: setiv only when really need



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: default avatarLongpeng(Mike) <longpeng2@huawei.com>
Signed-off-by: default avatarGonglei <arei.gonglei@huawei.com>
parent 55a19ad8
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -320,11 +320,13 @@ static int cryptodev_builtin_sym_operation(

    sess = builtin->sessions[op_info->session_id];

    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) {
        ret = qcrypto_cipher_encrypt(sess->cipher, op_info->src,