From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: Zhuoying Cai <zycai@linux.ibm.com>,
richard.henderson@linaro.org, david@redhat.com,
jrossi@linux.ibm.com, qemu-s390x@nongnu.org,
qemu-devel@nongnu.org, brueckner@linux.ibm.com,
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
Subject: Re: [PATCH v7 08/29] crypto/x509-utils: Add helper functions for DIAG 320 subcode 2
Date: Fri, 9 Jan 2026 11:38:38 +0000 [thread overview]
Message-ID: <aWDovtQX2IEwg-NA@redhat.com> (raw)
In-Reply-To: <53a6f846-2a65-49d4-aabb-021e9c2f590f@redhat.com>
On Fri, Jan 09, 2026 at 12:24:32PM +0100, Thomas Huth wrote:
> On 09/01/2026 12.13, Daniel P. Berrangé wrote:
> > On Fri, Jan 09, 2026 at 12:06:25PM +0100, Thomas Huth wrote:
> > > On 08/12/2025 22.32, Zhuoying Cai wrote:
> > > > Introduce new helper functions to extract certificate metadata:
> > > >
> > > > qcrypto_x509_check_cert_times() - validates the certificate's validity period against the current time
> > > > qcrypto_x509_get_pk_algorithm() - returns the public key algorithm used in the certificate
> > > > qcrypto_x509_get_cert_key_id() - extracts the key ID from the certificate
> > > > qcrypto_x509_is_ecc_curve_p521() - determines the ECC public key algorithm uses P-521 curve
> > > >
> > > > These functions provide support for metadata extraction and validity checking
> > > > for X.509 certificates.
> > > >
> > > > Signed-off-by: Zhuoying Cai <zycai@linux.ibm.com>
> > > > ---
> > > > crypto/x509-utils.c | 248 ++++++++++++++++++++++++++++++++++++
> > > > include/crypto/x509-utils.h | 73 +++++++++++
> > > > 2 files changed, 321 insertions(+)
> > > >
> > > > diff --git a/crypto/x509-utils.c b/crypto/x509-utils.c
> > > > index 2696d48155..f91fa56563 100644
> > > > --- a/crypto/x509-utils.c
> > > > +++ b/crypto/x509-utils.c
> > > > @@ -27,6 +27,25 @@ static const int qcrypto_to_gnutls_hash_alg_map[QCRYPTO_HASH_ALGO__MAX] = {
> > > > [QCRYPTO_HASH_ALGO_RIPEMD160] = GNUTLS_DIG_RMD160,
> > > > };
> > > > +static const int gnutls_to_qcrypto_pk_alg_map[] = {
> > >
> > > Could you do me a favour and add a line like this at the beginning of this
> > > array:
> > >
> > > [GNUTLS_PK_UNKNOWN] = QCRYPTO_PK_ALGO_UNKNOWN,
> > >
> > > and then also set QCRYPTO_PK_ALGO_UNKNOWN = 0 in the enum in the header?
> > > That way we can be sure that zero values are not accidentally mapped to a
> > > valid algorithm.
> >
> > That would be special casing just one enum type in the crypto subsystem
> > to have this special unknown value. We've got 1000's of enums across
> > QEMU and don't generally add such a special zeroth constant, so I don't
> > find this suggested change to be desirable.
>
> I came up with this idea when reviewing the qcrypto_x509_get_pk_algorithm()
> function in this patch which is basically doing:
>
> ret = gnutls_to_qcrypto_pk_alg_map[rc];
>
> My concern is that if someone ever extends the QCryptoPkAlgo in the header,
> but forgets to fill in as much entries to gnutls_to_qcrypto_pk_alg_map as
> there are entries in the enum, we're in trouble, since the wholes in the
> array will be padded with zeros that then get mapped to QCRYPTO_PK_ALGO_RSA.
> Having a clearly invalid meaning of 0 would help in such cases.
Hmm, looking at the usage of qcrypto_x509_get_pk_algorithm(), I think
the method and the QCryptoPkAlgo enums should be deleted entirely.
In the next patch, the caller does
/* public key algorithm */
algo = qcrypto_x509_get_pk_algorithm(cert.raw, cert.size, &err);
if (algo < 0) {
error_report_err(err);
return -1;
}
if (algo == QCRYPTO_PK_ALGO_ECDSA) {
rc = qcrypto_x509_check_ecc_curve_p521(cert.raw, cert.size, &err);
if (rc == -1) {
error_report_err(err);
return -1;
}
return (rc == 1) ? DIAG_320_VCE_KEYTYPE_ECDSA_P521 :
DIAG_320_VCE_KEYTYPE_SELF_DESCRIBING;
}
return DIAG_320_VCE_KEYTYPE_SELF_DESCRIBING;
so the caller doesn't actually care about anything other than
PK_ALGO_ECDSA, so IMHO going to the trouble of defining an enum
and mapping gnutls enums is pointless.
This caller should unconditionally call
qcrypto_x509_check_ecc_curve_p521()
and then then qcrypto_x509_check_ecc_curve_p521() method should
check whether the pk algorithm is GNUTLS_PK_ECDSA internally
and just return 0 if not.
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 :|
next prev parent reply other threads:[~2026-01-09 11:39 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-08 21:32 [PATCH v7 00/29] Secure IPL Support for SCSI Scheme of virtio-blk/virtio-scsi Devices Zhuoying Cai
2025-12-08 21:32 ` [PATCH v7 01/29] Add boot-certs to s390-ccw-virtio machine type option Zhuoying Cai
2026-01-08 10:45 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 02/29] crypto/x509-utils: Refactor with GNUTLS fallback Zhuoying Cai
2026-01-08 11:19 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 03/29] crypto/x509-utils: Add helper functions for certificate store Zhuoying Cai
2026-01-08 12:06 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 04/29] hw/s390x/ipl: Create " Zhuoying Cai
2026-01-07 22:18 ` Collin Walling
2026-01-09 18:57 ` Collin Walling
2026-01-08 12:28 ` Thomas Huth
2026-01-08 21:26 ` Zhuoying Cai
2026-01-08 16:01 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 05/29] s390x/diag: Introduce DIAG 320 for Certificate Store Facility Zhuoying Cai
2026-01-07 22:40 ` Collin Walling
2026-01-08 15:27 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 06/29] s390x/diag: Refactor address validation check from diag308_parm_check Zhuoying Cai
2026-01-07 22:19 ` Collin Walling
2026-01-09 13:30 ` Hendrik Brueckner
2025-12-08 21:32 ` [PATCH v7 07/29] s390x/diag: Implement DIAG 320 subcode 1 Zhuoying Cai
2026-01-07 22:31 ` Collin Walling
2026-01-08 15:53 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 08/29] crypto/x509-utils: Add helper functions for DIAG 320 subcode 2 Zhuoying Cai
2026-01-08 19:32 ` Farhan Ali
2026-01-08 21:25 ` Zhuoying Cai
2026-01-09 11:06 ` Thomas Huth
2026-01-09 11:13 ` Daniel P. Berrangé
2026-01-09 11:24 ` Thomas Huth
2026-01-09 11:38 ` Daniel P. Berrangé [this message]
2026-01-12 21:43 ` Zhuoying Cai
2025-12-08 21:32 ` [PATCH v7 09/29] s390x/diag: Implement " Zhuoying Cai
2026-01-08 22:22 ` Collin Walling
2026-01-14 21:42 ` Zhuoying Cai
2026-01-08 22:54 ` Farhan Ali
2026-01-14 21:54 ` Zhuoying Cai
2026-01-14 23:06 ` Farhan Ali
2026-01-15 21:00 ` Collin Walling
2026-01-09 12:41 ` Thomas Huth
2026-01-14 22:05 ` Zhuoying Cai
2025-12-08 21:32 ` [PATCH v7 10/29] s390x/diag: Introduce DIAG 508 for secure IPL operations Zhuoying Cai
2026-01-12 10:21 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 11/29] crypto/x509-utils: Add helper functions for DIAG 508 subcode 1 Zhuoying Cai
2026-01-09 12:51 ` Thomas Huth
2026-01-09 20:03 ` Farhan Ali
2025-12-08 21:32 ` [PATCH v7 12/29] s390x/diag: Implement DIAG 508 subcode 1 for signature verification Zhuoying Cai
2026-01-09 13:00 ` Thomas Huth
2026-01-09 20:23 ` Farhan Ali
2025-12-08 21:32 ` [PATCH v7 13/29] pc-bios/s390-ccw: Introduce IPL Information Report Block (IIRB) Zhuoying Cai
2026-01-15 21:34 ` Collin Walling
2026-01-21 21:29 ` Zhuoying Cai
2026-01-22 19:55 ` Zhuoying Cai
2025-12-08 21:32 ` [PATCH v7 14/29] pc-bios/s390-ccw: Define memory for IPLB and convert IPLB to pointers Zhuoying Cai
2026-01-09 18:02 ` Thomas Huth
2026-01-21 21:48 ` Zhuoying Cai
2025-12-08 21:32 ` [PATCH v7 15/29] hw/s390x/ipl: Add IPIB flags to IPL Parameter Block Zhuoying Cai
2026-01-12 13:58 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 16/29] s390x: Guest support for Secure-IPL Facility Zhuoying Cai
2026-01-09 18:15 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 17/29] pc-bios/s390-ccw: Refactor zipl_run() Zhuoying Cai
2026-01-09 18:26 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 18/29] pc-bios/s390-ccw: Rework zipl_load_segment function Zhuoying Cai
2025-12-08 21:32 ` [PATCH v7 19/29] pc-bios/s390-ccw: Add signature verification for secure IPL in audit mode Zhuoying Cai
2026-01-09 18:46 ` Thomas Huth
2026-01-24 18:13 ` Collin Walling
2026-01-29 19:19 ` Zhuoying Cai
2026-01-29 20:24 ` Collin Walling
2025-12-08 21:32 ` [PATCH v7 20/29] s390x: Guest support for Secure-IPL Code Loading Attributes Facility (SCLAF) Zhuoying Cai
2025-12-08 21:32 ` [PATCH v7 21/29] pc-bios/s390-ccw: Add additional security checks for secure boot Zhuoying Cai
2026-01-09 7:13 ` Thomas Huth
2026-01-26 22:11 ` Collin Walling
2026-01-30 21:09 ` Zhuoying Cai
2025-12-08 21:32 ` [PATCH v7 22/29] Add secure-boot to s390-ccw-virtio machine type option Zhuoying Cai
2026-01-12 14:45 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 23/29] hw/s390x/ipl: Set IPIB flags for secure IPL Zhuoying Cai
2026-01-12 14:49 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 24/29] pc-bios/s390-ccw: Handle true secure IPL mode Zhuoying Cai
2026-01-09 7:32 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 25/29] pc-bios/s390-ccw: Handle secure boot with multiple boot devices Zhuoying Cai
2026-01-13 8:36 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 26/29] hw/s390x/ipl: Handle secure boot without specifying a boot device Zhuoying Cai
2026-01-13 9:13 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 27/29] tests/functional/s390x: Add secure IPL functional test Zhuoying Cai
2026-01-13 9:37 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 28/29] docs/specs: Add secure IPL documentation Zhuoying Cai
2026-01-13 9:43 ` Thomas Huth
2025-12-08 21:32 ` [PATCH v7 29/29] docs/system/s390x: " Zhuoying Cai
2026-01-13 10:13 ` Thomas Huth
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=aWDovtQX2IEwg-NA@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=david@redhat.com \
--cc=eblake@redhat.com \
--cc=farman@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=jjherne@linux.ibm.com \
--cc=jrossi@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
--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.