aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLongpeng(Mike) <longpeng2@huawei.com>2017-01-14 14:14:27 +0800
committerGonglei <arei.gonglei@huawei.com>2017-03-23 17:22:01 +0800
commit50d19cf3681059efc8d2efcc585d2a19b9ab37c3 (patch)
tree6d81c3368073cfc8508f3b2ac2edbc1ae1d265a9
parent55a19ad8b2d0797e3a8fe90ab99a9bb713824059 (diff)
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: Longpeng(Mike) <longpeng2@huawei.com> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
-rw-r--r--backends/cryptodev-builtin.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c
index 82a068e792..b24a299d9e 100644
--- a/backends/cryptodev-builtin.c
+++ b/backends/cryptodev-builtin.c
@@ -320,10 +320,12 @@ static int cryptodev_builtin_sym_operation(
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) {