diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2015-12-23 13:53:32 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2015-12-23 13:53:32 +0000 |
commit | 38a762fec63fd5c035aae29ba9a77d357e21e4a7 (patch) | |
tree | 08b447dac347975d9a22215bdb57f80329b82354 /tests | |
parent | 8b4f90316a56dc370da94a04838a5c0a7d61d41f (diff) | |
parent | 50de6261510301d586f0411b3fdb11e4cd4fdb52 (diff) |
Merge remote-tracking branch 'remotes/berrange/tags/pull-crypto-fixes-2015-12-23-1' into staging
Merge misc crypto changes & fixes
# gpg: Signature made Wed 23 Dec 2015 11:11:54 GMT using RSA key ID 15104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>"
# gpg: aka "Daniel P. Berrange <berrange@redhat.com>"
* remotes/berrange/tags/pull-crypto-fixes-2015-12-23-1:
crypto: fix transposed arguments in cipher error message
crypto: ensure qapi/crypto.json is listed in qapi-modules
crypto: move QCryptoCipherAlgorithm/Mode enum definitions into QAPI
crypto: move QCryptoHashAlgorithm enum definition into QAPI
crypto: add ability to query hash digest len
crypto: add additional query accessors for cipher instances
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-crypto-cipher.c | 10 | ||||
-rw-r--r-- | tests/test-crypto-hash.c | 5 |
2 files changed, 15 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, diff --git a/tests/test-crypto-hash.c b/tests/test-crypto-hash.c index 911437e60d..3ec31dde7b 100644 --- a/tests/test-crypto-hash.c +++ b/tests/test-crypto-hash.c @@ -163,6 +163,11 @@ static void test_hash_digest(void) for (i = 0; i < G_N_ELEMENTS(expected_outputs) ; i++) { int ret; char *digest; + size_t digestsize; + + digestsize = qcrypto_hash_digest_len(i); + + g_assert_cmpint(digestsize * 2, ==, strlen(expected_outputs[i])); ret = qcrypto_hash_digest(i, INPUT_TEXT, |