qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: zhenwei pi <pizhenwei@bytedance.com>
Cc: mst@redhat.com, arei.gonglei@huawei.com, qemu-devel@nongnu.org,
	virtualization@lists.linux-foundation.org,
	linux-crypto@vger.kernel.org, helei.sig11@bytedance.com,
	jasowang@redhat.com, cohuck@redhat.com
Subject: Re: [PATCH v6 5/9] crypto: Implement RSA algorithm by hogweed
Date: Mon, 23 May 2022 10:41:50 +0100	[thread overview]
Message-ID: <YotW3ikMeeXAvs8/@redhat.com> (raw)
In-Reply-To: <20220514005504.1042884-6-pizhenwei@bytedance.com>

On Sat, May 14, 2022 at 08:55:00AM +0800, zhenwei pi wrote:
> From: Lei He <helei.sig11@bytedance.com>
> 
> Implement RSA algorithm by hogweed from nettle. Thus QEMU supports
> a 'real' RSA backend to handle request from guest side. It's
> important to test RSA offload case without OS & hardware requirement.
> 
> Signed-off-by: lei he <helei.sig11@bytedance.com>
> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
> ---
>  crypto/akcipher-nettle.c.inc | 451 +++++++++++++++++++++++++++++++++++
>  crypto/akcipher.c            |   4 +
>  crypto/meson.build           |   4 +
>  crypto/rsakey-builtin.c.inc  | 200 ++++++++++++++++
>  crypto/rsakey-nettle.c.inc   | 158 ++++++++++++
>  crypto/rsakey.c              |  44 ++++
>  crypto/rsakey.h              |  94 ++++++++
>  meson.build                  |  11 +
>  8 files changed, 966 insertions(+)
>  create mode 100644 crypto/akcipher-nettle.c.inc
>  create mode 100644 crypto/rsakey-builtin.c.inc
>  create mode 100644 crypto/rsakey-nettle.c.inc
>  create mode 100644 crypto/rsakey.c
>  create mode 100644 crypto/rsakey.h
> 
> diff --git a/crypto/akcipher-nettle.c.inc b/crypto/akcipher-nettle.c.inc
> new file mode 100644
> index 0000000000..0796bddcaa
> --- /dev/null
> +++ b/crypto/akcipher-nettle.c.inc

> +static int qcrypto_nettle_rsa_encrypt(QCryptoAkCipher *akcipher,
> +                                      const void *data, size_t data_len,
> +                                      void *enc, size_t enc_len,
> +                                      Error **errp)
> +{
> +
> +    QCryptoNettleRSA *rsa = (QCryptoNettleRSA *)akcipher;
> +    mpz_t c;
> +    int ret = -1;
> +
> +    if (data_len > rsa->pub.size) {
> +        error_setg(errp, "Plaintext length should be less than key size: %lu",
> +                   rsa->pub.size);
> +        return ret;
> +    }

This needs to include both the good & bad values. I'm going to make
the following changes to error messages:

ie

+        error_setg(errp, "Plaintext length %zu is greater than key size: %lu"
+                   data_len, rsa->pub.size);
         return ret;
     }


But also the '%lu' needs to change to '%zu' because the rsa->pub.size
parameter is 'size_t'.  %lu doesn't match size_t on 32-bit hosts.

The same issues appear in several other error messages through this
file

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2022-05-23  9:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-14  0:54 [PATCH v6 0/9] Introduce akcipher service for virtio-crypto zhenwei pi
2022-05-14  0:54 ` [PATCH v6 1/9] virtio-crypto: header update zhenwei pi
2022-05-14  0:54 ` [PATCH v6 2/9] qapi: crypto-akcipher: Introduce akcipher types to qapi zhenwei pi
2022-05-14  0:54 ` [PATCH v6 3/9] crypto: Introduce akcipher crypto class zhenwei pi
2022-05-14  0:54 ` [PATCH v6 4/9] crypto: add ASN.1 DER decoder zhenwei pi
2022-05-23  9:46   ` Daniel P. Berrangé
2022-05-14  0:55 ` [PATCH v6 5/9] crypto: Implement RSA algorithm by hogweed zhenwei pi
2022-05-23  9:41   ` Daniel P. Berrangé [this message]
2022-05-23  9:43   ` Daniel P. Berrangé
2022-05-14  0:55 ` [PATCH v6 6/9] crypto: Implement RSA algorithm by gcrypt zhenwei pi
2022-05-23  9:40   ` Daniel P. Berrangé
2022-05-14  0:55 ` [PATCH v6 7/9] test/crypto: Add test suite for crypto akcipher zhenwei pi
2022-05-23  9:45   ` Daniel P. Berrangé
2022-05-14  0:55 ` [PATCH v6 8/9] tests/crypto: Add test suite for RSA keys zhenwei pi
2022-05-14  0:55 ` [PATCH v6 9/9] crypto: Introduce RSA algorithm zhenwei pi

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=YotW3ikMeeXAvs8/@redhat.com \
    --to=berrange@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=cohuck@redhat.com \
    --cc=helei.sig11@bytedance.com \
    --cc=jasowang@redhat.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=pizhenwei@bytedance.com \
    --cc=qemu-devel@nongnu.org \
    --cc=virtualization@lists.linux-foundation.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).