On Sat, May 14, 2022 at 08:55:00AM +0800, zhenwei pi wrote:
> From: Lei He <[email protected]>
>
> 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 <[email protected]>
> Signed-off-by: zhenwei pi <[email protected]>
> ---
> 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 :|
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization