All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Zhuoying Cai <zycai@linux.ibm.com>
Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
	jrossi@linux.ibm.com, cohuck@redhat.com,
	richard.henderson@linaro.org, pierrick.bouvier@linaro.org,
	david@kernel.org, walling@linux.ibm.com, jjherne@linux.ibm.com,
	pasic@linux.ibm.com, borntraeger@linux.ibm.com,
	farman@linux.ibm.com, mjrosato@linux.ibm.com, iii@linux.ibm.com,
	eblake@redhat.com, armbru@redhat.com, alifm@linux.ibm.com,
	brueckner@linux.ibm.com, jdaley@linux.ibm.com
Subject: Re: [PATCH v10 03/30] crypto/x509-utils: Add helper functions for certificate store
Date: Tue, 7 Apr 2026 16:56:10 +0100	[thread overview]
Message-ID: <adUpGiQHAi2yoLmt@redhat.com> (raw)
In-Reply-To: <20260402221453.1602899-4-zycai@linux.ibm.com>

On Thu, Apr 02, 2026 at 06:14:25PM -0400, Zhuoying Cai wrote:
> Introduce new helper functions for x509 certificate, which will be used
> by the certificate store:
> 
> qcrypto_x509_convert_cert_der() - converts a certificate from PEM to DER format
> 
> These functions provide support for certificate format conversion.
> 
> Signed-off-by: Zhuoying Cai <zycai@linux.ibm.com>
> Acked-by: Daniel P. Berrangé <berrange@redhat.com>
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> Reviewed-by: Farhan Ali <alifm@linux.ibm.com>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> ---
>  crypto/x509-utils.c         | 49 +++++++++++++++++++++++++++++++++++++
>  include/crypto/x509-utils.h | 21 ++++++++++++++++
>  2 files changed, 70 insertions(+)
> 
> diff --git a/crypto/x509-utils.c b/crypto/x509-utils.c
> index 6176a88653..2696d48155 100644
> --- a/crypto/x509-utils.c
> +++ b/crypto/x509-utils.c
> @@ -81,6 +81,46 @@ int qcrypto_get_x509_cert_fingerprint(uint8_t *cert, size_t size,
>      return ret;
>  }
>  
> +int qcrypto_x509_convert_cert_der(uint8_t *cert, size_t size,
> +                                  uint8_t **result, size_t *resultlen,
> +                                  Error **errp)
> +{
> +    int ret = -1;
> +    int rc;
> +    gnutls_x509_crt_t crt;
> +    gnutls_datum_t datum = {.data = cert, .size = size};
> +    gnutls_datum_t datum_der = {.data = NULL, .size = 0};
> +
> +    rc = gnutls_x509_crt_init(&crt);
> +    if (rc < 0) {
> +        error_setg(errp, "Failed to initialize certificate: %s", gnutls_strerror(rc));
> +        return ret;
> +    }
> +
> +    rc = gnutls_x509_crt_import(crt, &datum, GNUTLS_X509_FMT_PEM);
> +    if (rc != 0) {
> +        error_setg(errp, "Failed to import certificate: %s", gnutls_strerror(rc));
> +        goto cleanup;
> +    }
> +
> +    rc = gnutls_x509_crt_export2(crt, GNUTLS_X509_FMT_DER, &datum_der);
> +    if (rc != 0) {
> +        error_setg(errp, "Failed to convert certificate to DER format: %s",
> +                   gnutls_strerror(rc));
> +        goto cleanup;
> +    }
> +
> +    *resultlen = datum_der.size;
> +    *result = g_memdup2(datum_der.data, datum_der.size);
> +
> +    ret = 0;
> +
> +cleanup:
> +    gnutls_x509_crt_deinit(crt);
> +    gnutls_free(datum_der.data);

Please use "g_free" here.

gnutls_free does nothing since gnutls deprecated gnutls_global_set_mem_functions
and turned its impl into a no-op, but the use of gnutls_free will break builds
with CFI enabled.

Same comment for the later patches to x509-utils.c that use gnutls_free.

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



  reply	other threads:[~2026-04-07 19:15 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02 22:14 [PATCH v10 00/30] Secure IPL Support for SCSI Scheme of virtio-blk/virtio-scsi Devices Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 01/30] Add boot-certs to s390-ccw-virtio machine type option Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 02/30] crypto/x509-utils: Refactor with GNUTLS fallback Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 03/30] crypto/x509-utils: Add helper functions for certificate store Zhuoying Cai
2026-04-07 15:56   ` Daniel P. Berrangé [this message]
2026-04-15 18:34     ` Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 04/30] hw/s390x/ipl: Create " Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 05/30] s390x/diag: Introduce DIAG 320 for Certificate Store Facility Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 06/30] s390x/diag: Refactor address validation check from diag308_parm_check Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 07/30] s390x/diag: Implement DIAG 320 subcode 1 Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 08/30] crypto/x509-utils: Add helper functions for DIAG 320 subcode 2 Zhuoying Cai
2026-04-07 16:06   ` Daniel P. Berrangé
2026-04-02 22:14 ` [PATCH v10 09/30] s390x/diag: Implement " Zhuoying Cai
2026-04-09 19:08   ` Collin Walling
2026-04-02 22:14 ` [PATCH v10 10/30] s390x/diag: Introduce DIAG 508 for secure IPL operations Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 11/30] crypto/x509-utils: Add helper functions for DIAG 508 subcode 1 Zhuoying Cai
2026-04-07 16:37   ` Daniel P. Berrangé
2026-04-02 22:14 ` [PATCH v10 12/30] s390x/diag: Implement DIAG 508 subcode 1 for signature verification Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 13/30] s390x/ipl: Introduce IPL Information Report Block (IIRB) Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 14/30] pc-bios/s390-ccw: Define memory for IPLB and convert IPLB to pointers Zhuoying Cai
2026-04-10 18:40   ` Farhan Ali
2026-04-02 22:14 ` [PATCH v10 15/30] hw/s390x/ipl: Add IPIB flags to IPL Parameter Block Zhuoying Cai
2026-04-09 19:43   ` Collin Walling
2026-04-10 19:16   ` Jared Rossi
2026-04-15 18:38     ` Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 16/30] s390x: Guest support for Secure-IPL Facility Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 17/30] pc-bios/s390-ccw: Refactor zipl_run() Zhuoying Cai
2026-04-10 19:24   ` Jared Rossi
2026-04-02 22:14 ` [PATCH v10 18/30] pc-bios/s390-ccw: Rework zipl_load_segment function Zhuoying Cai
2026-04-14 13:25   ` Jared Rossi
2026-04-02 22:14 ` [PATCH v10 19/30] pc-bios/s390-ccw: Add signature verification for secure IPL in audit mode Zhuoying Cai
2026-04-10 19:37   ` Collin Walling
2026-04-20 18:22     ` Zhuoying Cai
2026-04-13 19:59   ` Jared Rossi
2026-04-13 22:05     ` Joshua Daley
2026-04-13 23:07   ` Joshua Daley
2026-04-02 22:14 ` [PATCH v10 20/30] pc-bios/s390-ccw: Add signed component address overlap checks Zhuoying Cai
2026-04-10 19:54   ` Collin Walling
2026-04-28 18:41     ` Zhuoying Cai
2026-04-15 16:36   ` Jared Rossi
2026-04-28 18:42     ` Zhuoying Cai
2026-04-29 14:16       ` Jared Rossi
2026-04-02 22:14 ` [PATCH v10 21/30] s390x: Guest support for Secure-IPL Code Loading Attributes Facility (SCLAF) Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 22/30] pc-bios/s390-ccw: Add additional security checks for secure boot Zhuoying Cai
2026-04-10 20:51   ` Collin Walling
2026-04-10 20:58     ` Collin Walling
2026-04-15 19:09   ` Jared Rossi
2026-04-02 22:14 ` [PATCH v10 23/30] Add secure-boot to s390-ccw-virtio machine type option Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 24/30] hw/s390x/ipl: Set IPIB flags for secure IPL Zhuoying Cai
2026-04-10 20:13   ` Collin Walling
2026-04-02 22:14 ` [PATCH v10 25/30] pc-bios/s390-ccw: Handle true secure IPL mode Zhuoying Cai
2026-04-10 20:11   ` Collin Walling
2026-04-30 21:17     ` Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 26/30] hw/s390x/ipl: Handle secure boot with multiple boot devices Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 27/30] hw/s390x/ipl: Handle secure boot without specifying a boot device Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 28/30] tests/functional/s390x: Add secure IPL functional test Zhuoying Cai
2026-04-02 22:14 ` [PATCH v10 29/30] docs/specs: Add secure IPL documentation Zhuoying Cai
2026-04-13 22:53   ` Joshua Daley
2026-04-02 22:14 ` [PATCH v10 30/30] docs/system/s390x: " Zhuoying Cai
2026-04-13 23:03   ` Joshua Daley

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=adUpGiQHAi2yoLmt@redhat.com \
    --to=berrange@redhat.com \
    --cc=alifm@linux.ibm.com \
    --cc=armbru@redhat.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=brueckner@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@kernel.org \
    --cc=eblake@redhat.com \
    --cc=farman@linux.ibm.com \
    --cc=iii@linux.ibm.com \
    --cc=jdaley@linux.ibm.com \
    --cc=jjherne@linux.ibm.com \
    --cc=jrossi@linux.ibm.com \
    --cc=mjrosato@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=walling@linux.ibm.com \
    --cc=zycai@linux.ibm.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.