Skip to content

Commit

Permalink
crypto: add mode check in qcrypto_cipher_new() for cipher-builtin
Browse files Browse the repository at this point in the history
Signed-off-by: Gonglei <[email protected]>
Signed-off-by: Daniel P. Berrange <[email protected]>
  • Loading branch information
gongleiarei authored and berrange committed Oct 19, 2016
1 parent 3c28292 commit 77cf26c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crypto/cipher-builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 77cf26c

Please sign in to comment.