qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 3/3] crypto: add mode check in qcrypto_cipher_new


From: Gonglei
Subject: [Qemu-devel] [PATCH v2 3/3] crypto: add mode check in qcrypto_cipher_new() for cipher-builtin
Date: Sat, 24 Sep 2016 10:10:00 +0800

Signed-off-by: Gonglei <address@hidden>
---
 crypto/cipher-builtin.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c
index fd59a9e..d710608 100644
--- a/crypto/cipher-builtin.c
+++ b/crypto/cipher-builtin.c
@@ -433,6 +433,16 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm 
alg,
 {
     QCryptoCipher *cipher;
 
+    switch (mode) {
+    case QCRYPTO_CIPHER_MODE_ECB:
+    case QCRYPTO_CIPHER_MODE_CBC:
+    case QCRYPTO_CIPHER_MODE_XTS:
+    default:
+        error_setg(errp, "Unsupported cipher mode %s",
+                   QCryptoCipherMode_lookup[mode]);
+        return NULL;
+    }
+
     cipher = g_new0(QCryptoCipher, 1);
     cipher->alg = alg;
     cipher->mode = mode;
-- 
1.7.12.4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]