summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2015-07-28 14:19:16 +0100
committerPeter Maydell <peter.maydell@linaro.org>2015-07-28 14:19:16 +0100
commit5e868d2e5e4aff76bdef787e44bc2d1eca18901f (patch)
tree3b9ece4b8018a1f302fa7604bad6e3d4bc8dd820 /tests
parent9f8c5b69c2b9ca8b9c3e569b0f41bd60a0b9e9fe (diff)
parent52c91dac6bd891656f297dab76da51fc8bc61309 (diff)
downloadqemu-5e868d2e5e4aff76bdef787e44bc2d1eca18901f.tar.gz
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* crypto fixes * megasas SIGSEGV fix * memory refcount change to fix virtio hot-unplug # gpg: Signature made Tue Jul 28 08:29:07 2015 BST using RSA key ID 78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini/tags/for-upstream: memory: do not add a reference to the owner of aliased regions megasas: Add write function to handle write access to PCI BAR 3 crypto: extend unit tests to cover decryption too crypto: fix built-in AES decrypt function Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/test-crypto-cipher.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/tests/test-crypto-cipher.c b/tests/test-crypto-cipher.c
index f9b1a03a02..9d38d2640a 100644
--- a/tests/test-crypto-cipher.c
+++ b/tests/test-crypto-cipher.c
@@ -226,12 +226,10 @@ static void test_cipher(const void *opaque)
const QCryptoCipherTestData *data = opaque;
QCryptoCipher *cipher;
- Error *err = NULL;
uint8_t *key, *iv, *ciphertext, *plaintext, *outtext;
size_t nkey, niv, nciphertext, nplaintext;
char *outtexthex;
- g_test_message("foo");
nkey = unhex_string(data->key, &key);
niv = unhex_string(data->iv, &iv);
nciphertext = unhex_string(data->ciphertext, &ciphertext);
@@ -244,28 +242,42 @@ static void test_cipher(const void *opaque)
cipher = qcrypto_cipher_new(
data->alg, data->mode,
key, nkey,
- &err);
+ &error_abort);
g_assert(cipher != NULL);
- g_assert(err == NULL);
if (iv) {
g_assert(qcrypto_cipher_setiv(cipher,
iv, niv,
- &err) == 0);
- g_assert(err == NULL);
+ &error_abort) == 0);
}
g_assert(qcrypto_cipher_encrypt(cipher,
plaintext,
outtext,
nplaintext,
- &err) == 0);
- g_assert(err == NULL);
+ &error_abort) == 0);
outtexthex = hex_string(outtext, nciphertext);
g_assert_cmpstr(outtexthex, ==, data->ciphertext);
+ g_free(outtexthex);
+
+ if (iv) {
+ g_assert(qcrypto_cipher_setiv(cipher,
+ iv, niv,
+ &error_abort) == 0);
+ }
+ g_assert(qcrypto_cipher_decrypt(cipher,
+ ciphertext,
+ outtext,
+ nplaintext,
+ &error_abort) == 0);
+
+ outtexthex = hex_string(outtext, nplaintext);
+
+ g_assert_cmpstr(outtexthex, ==, data->plaintext);
+
g_free(outtext);
g_free(outtexthex);
g_free(key);