diff options
author | Gonglei <arei.gonglei@huawei.com> | 2016-09-26 17:23:21 +0800 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2016-10-19 10:09:24 +0100 |
commit | f844836ddccf3dbcba142128da5dd8ee618f3e91 (patch) | |
tree | 91556d3ea8b8236cf10d16681dacf2d95dfb4232 /crypto/cipher-builtin.c | |
parent | e8ddc2eae5ccc41f0815e5c43e70cb04a7e67e2e (diff) |
crypto: extend mode as a parameter in qcrypto_cipher_supports()
It can't guarantee all cipher modes are supported
if one cipher algorithm is supported by a backend.
Let's extend qcrypto_cipher_supports() to take both
the algorithm and mode as parameters.
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'crypto/cipher-builtin.c')
-rw-r--r-- | crypto/cipher-builtin.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c index 9d258428b0..fd59a9e461 100644 --- a/crypto/cipher-builtin.c +++ b/crypto/cipher-builtin.c @@ -400,14 +400,26 @@ static int qcrypto_cipher_init_des_rfb(QCryptoCipher *cipher, } -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg) +bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, + QCryptoCipherMode mode) { switch (alg) { case QCRYPTO_CIPHER_ALG_DES_RFB: case QCRYPTO_CIPHER_ALG_AES_128: case QCRYPTO_CIPHER_ALG_AES_192: case QCRYPTO_CIPHER_ALG_AES_256: + break; + default: + return false; + } + + switch (mode) { + case QCRYPTO_CIPHER_MODE_ECB: + case QCRYPTO_CIPHER_MODE_CBC: + case QCRYPTO_CIPHER_MODE_XTS: return true; + case QCRYPTO_CIPHER_MODE_CTR: + return false; default: return false; } |