All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Dorjoy Chowdhury <dorjoychy111@gmail.com>
Cc: qemu-devel@nongnu.org, graf@amazon.com, agraf@csgraf.de,
	stefanha@redhat.com, pbonzini@redhat.com, slp@redhat.com,
	richard.henderson@linaro.org, eduardo@habkost.net,
	mst@redhat.com, marcel.apfelbaum@gmail.com, philmd@linaro.org
Subject: Re: [PATCH v5 6/8] hw/core: Add Enclave Image Format (EIF) related helpers
Date: Wed, 28 Aug 2024 16:42:57 +0100	[thread overview]
Message-ID: <Zs9Fgb-I__0TNok_@redhat.com> (raw)
In-Reply-To: <20240822150849.21759-7-dorjoychy111@gmail.com>

On Thu, Aug 22, 2024 at 09:08:47PM +0600, Dorjoy Chowdhury wrote:
> An EIF (Enclave Image Format)[1] file is used to boot an AWS nitro
> enclave[2] virtual machine. The EIF file contains the necessary kernel,
> cmdline, ramdisk(s) sections to boot.
> 
> Some helper functions have been introduced for extracting the necessary
> sections from an EIF file and then writing them to temporary files as
> well as computing SHA384 hashes from the section data. These will be
> used in the following commit to add support for nitro-enclave machine
> type in QEMU.
> 
> [1] https://github.com/aws/aws-nitro-enclaves-image-format
> [2] https://docs.aws.amazon.com/enclaves/latest/user/nitro-enclave.html
> 
> Signed-off-by: Dorjoy Chowdhury <dorjoychy111@gmail.com>
> ---
>  hw/core/eif.c | 719 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  hw/core/eif.h |  22 ++
>  2 files changed, 741 insertions(+)
>  create mode 100644 hw/core/eif.c
>  create mode 100644 hw/core/eif.h
> 
> diff --git a/hw/core/eif.c b/hw/core/eif.c
> new file mode 100644
> index 0000000000..2cfd5c911e
> --- /dev/null
> +++ b/hw/core/eif.c
> +static bool get_SHA384_digest(GList *list, uint8_t *digest, Error **errp)
> +{
> +    size_t digest_len = QCRYPTO_HASH_DIGEST_LEN_SHA384;
> +    size_t list_len = g_list_length(list);
> +    struct iovec *iovec_list = g_malloc(list_len * sizeof(struct iovec));

Even if probably harmless in this case, it is best practice to use

   g_new0(struct iovec, list_len)

because glib then checks for integer overflow when doing the
"count * sizeof()" multiplication on your behalf.

> +    bool ret = true;
> +    GList *l;
> +    int i;
> +
> +    for (i = 0, l = list; l != NULL; l = l->next, i++) {
> +        iovec_list[i] = *(struct iovec *) l->data;
> +    }
> +
> +    if (qcrypto_hash_bytesv(QCRYPTO_HASH_ALG_SHA384, iovec_list, list_len,
> +                            &digest, &digest_len, errp) < 0) {
> +        ret = false;
> +    }
> +
> +    g_free(iovec_list);
> +    return ret;
> +}
> +

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:[~2024-08-28 15:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-22 15:08 [PATCH v5 0/8] AWS Nitro Enclave emulation support Dorjoy Chowdhury
2024-08-22 15:08 ` [PATCH v5 1/8] crypto: Define macros for hash algorithm digest lengths Dorjoy Chowdhury
2024-08-28 15:33   ` Daniel P. Berrangé
2024-08-22 15:08 ` [PATCH v5 2/8] crypto: Support SHA384 hash when using glib Dorjoy Chowdhury
2024-08-22 15:08 ` [PATCH v5 3/8] crypto: Introduce x509 utils Dorjoy Chowdhury
2024-08-22 15:08 ` [PATCH v5 4/8] tests/lcitool: Update libvirt-ci and add libcbor dependency Dorjoy Chowdhury
2024-08-28 15:34   ` Daniel P. Berrangé
2024-08-22 15:08 ` [PATCH v5 5/8] device/virtio-nsm: Support for Nitro Secure Module device Dorjoy Chowdhury
2024-08-28 18:28   ` Michael S. Tsirkin
2024-08-28 19:04     ` Dorjoy Chowdhury
2024-08-28 19:11       ` Michael S. Tsirkin
2024-09-03 19:58         ` Dorjoy Chowdhury
2024-09-03 20:32           ` Michael S. Tsirkin
2024-09-03 20:47             ` Dorjoy Chowdhury
2024-09-04 18:30               ` Dorjoy Chowdhury
2024-09-04 20:27                 ` Michael S. Tsirkin
2024-09-04 20:45                   ` Dorjoy Chowdhury
2024-08-22 15:08 ` [PATCH v5 6/8] hw/core: Add Enclave Image Format (EIF) related helpers Dorjoy Chowdhury
2024-08-28 15:42   ` Daniel P. Berrangé [this message]
2024-08-22 15:08 ` [PATCH v5 7/8] machine/nitro-enclave: New machine type for AWS Nitro Enclaves Dorjoy Chowdhury
2024-08-28 15:39   ` Daniel P. Berrangé
2024-08-28 15:50     ` Dorjoy Chowdhury
2024-08-29  8:14       ` Daniel P. Berrangé
2024-09-05 20:00         ` Dorjoy Chowdhury
2024-08-22 15:08 ` [PATCH v5 8/8] docs/nitro-enclave: Documentation for nitro-enclave machine type Dorjoy Chowdhury
2024-09-05 20:03 ` [PATCH v5 0/8] AWS Nitro Enclave emulation support Dorjoy Chowdhury

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=Zs9Fgb-I__0TNok_@redhat.com \
    --to=berrange@redhat.com \
    --cc=agraf@csgraf.de \
    --cc=dorjoychy111@gmail.com \
    --cc=eduardo@habkost.net \
    --cc=graf@amazon.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=slp@redhat.com \
    --cc=stefanha@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.