qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] crypto: extend unit tests to cover decryption too
Date: Mon, 20 Jul 2015 14:57:47 -0600	[thread overview]
Message-ID: <55AD60CB.1020405@redhat.com> (raw)
In-Reply-To: <1437413322-14808-1-git-send-email-berrange@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1779 bytes --]

On 07/20/2015 11:28 AM, Daniel P. Berrange wrote:
> The current unit test only verify the encryption API, which

grammatical mismatch; you want either:
tests only verify
test only verifies

> resulted in us missing a recently introduced bug in the
> decryption API from commit d3462e3. It was fortunately
> later discovered & fixed by commit bd0959 thanks to the

Is a 6-byte SHA going to stay unambiguous long enough? git defaults to
7-byte to reduce chances of collisions by 16.

> QEMU I/O tests for qcow2 encryption, but we should really
> detect this directly in the crypto unit tests.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  tests/test-crypto-cipher.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 

> @@ -266,6 +265,25 @@ static void test_cipher(const void *opaque)
>  
>      g_assert_cmpstr(outtexthex, ==, data->ciphertext);
>  
> +    g_free(outtexthex);
> +
> +    if (iv) {
> +        g_assert(qcrypto_cipher_setiv(cipher,
> +                                      iv, niv,
> +                                      &err) == 0);
> +        g_assert(err == NULL);

g_assert(qcrypto_cipher_setiv(cipher, iv, niv, &error_abort);

saves you a call to g_assert().

> +    }
> +    g_assert(qcrypto_cipher_decrypt(cipher,
> +                                    ciphertext,
> +                                    outtext,
> +                                    nplaintext,
> +                                    &err) == 0);
> +    g_assert(err == NULL);

and again

But that's style, not correctness, so:
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2015-07-20 20:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-20 17:28 [Qemu-devel] [PATCH] crypto: extend unit tests to cover decryption too Daniel P. Berrange
2015-07-20 20:57 ` Eric Blake [this message]
2015-07-20 21:37   ` Peter Maydell
2015-07-20 22:16     ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55AD60CB.1020405@redhat.com \
    --to=eblake@redhat.com \
    --cc=berrange@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).