aboutsummaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorGonglei <arei.gonglei@huawei.com>2016-09-26 17:23:23 +0800
committerDaniel P. Berrange <berrange@redhat.com>2016-10-19 10:09:24 +0100
commit77cf26cd89c6e6947fe856a079061cebaecd5435 (patch)
treeb3ccc0f106bf7934812d76ad7921e42ba34bd81a /crypto
parent3c28292f390f642bbb3dba0949ecf36aaf7be0d6 (diff)
downloadqemu-77cf26cd89c6e6947fe856a079061cebaecd5435.zip
qemu-77cf26cd89c6e6947fe856a079061cebaecd5435.tar.gz
qemu-77cf26cd89c6e6947fe856a079061cebaecd5435.tar.bz2
crypto: add mode check in qcrypto_cipher_new() for cipher-builtin
Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/cipher-builtin.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c
index fd59a9e..b4bc2b9 100644
--- a/crypto/cipher-builtin.c
+++ b/crypto/cipher-builtin.c
@@ -433,6 +433,17 @@ 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:
+ break;
+ default:
+ error_setg(errp, "Unsupported cipher mode %s",
+ QCryptoCipherMode_lookup[mode]);
+ return NULL;
+ }
+
cipher = g_new0(QCryptoCipher, 1);
cipher->alg = alg;
cipher->mode = mode;