diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2015-10-23 16:13:50 +0100 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2015-12-23 11:02:20 +0000 |
commit | dd2bf9eb95f875f0ad6a15aecb48cfc8b739fcbc (patch) | |
tree | cbc8e4b7a4f1af17d438cf51f5c0a558bd5472f6 /tests | |
parent | 5dc42c186d63b7b338594fc071cf290805dcc5a5 (diff) |
crypto: add additional query accessors for cipher instances
Adds new methods to allow querying the length of the cipher
key, block size and initialization vectors.
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-crypto-cipher.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/test-crypto-cipher.c b/tests/test-crypto-cipher.c index f4946a0af0..c687307bcd 100644 --- a/tests/test-crypto-cipher.c +++ b/tests/test-crypto-cipher.c @@ -229,6 +229,7 @@ static void test_cipher(const void *opaque) uint8_t *key, *iv, *ciphertext, *plaintext, *outtext; size_t nkey, niv, nciphertext, nplaintext; char *outtexthex; + size_t ivsize, keysize, blocksize; nkey = unhex_string(data->key, &key); niv = unhex_string(data->iv, &iv); @@ -245,6 +246,15 @@ static void test_cipher(const void *opaque) &error_abort); g_assert(cipher != NULL); + keysize = qcrypto_cipher_get_key_len(data->alg); + blocksize = qcrypto_cipher_get_block_len(data->alg); + ivsize = qcrypto_cipher_get_iv_len(data->alg, data->mode); + + g_assert_cmpint(keysize, ==, nkey); + g_assert_cmpint(ivsize, ==, niv); + if (niv) { + g_assert_cmpint(blocksize, ==, niv); + } if (iv) { g_assert(qcrypto_cipher_setiv(cipher, |