From: Jarkko Sakkinen <jarkko@kernel.org>
To: Stefan Berger <stefanb@linux.vnet.ibm.com>,
dhowells@redhat.com, keyrings@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, herbert@gondor.apana.org.au,
davem@davemloft.net, linux-crypto@vger.kernel.org,
patrick@puiterwijk.org, Stefan Berger <stefanb@linux.ibm.com>
Subject: Re: [PATCH v3 1/3] x509: Detect sm2 keys by their parameters OID
Date: Sat, 30 Jan 2021 23:26:35 +0200 [thread overview]
Message-ID: <689c44925d60238181390e775b52809e89e0b26a.camel@kernel.org> (raw)
In-Reply-To: <20210127123350.817593-2-stefanb@linux.vnet.ibm.com>
On Wed, 2021-01-27 at 07:33 -0500, Stefan Berger wrote:
> From: Stefan Berger <stefanb@linux.ibm.com>
>
> Detect whether a key is an sm2 type of key by its OID in the parameters
> array rather than assuming that everything under OID_id_ecPublicKey
> is sm2, which is not the case.
>
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
> ---
> crypto/asymmetric_keys/x509_cert_parser.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
> index 52c9b455fc7d..4643fe5ed69a 100644
> --- a/crypto/asymmetric_keys/x509_cert_parser.c
> +++ b/crypto/asymmetric_keys/x509_cert_parser.c
> @@ -459,6 +459,7 @@ int x509_extract_key_data(void *context, size_t hdrlen,
> const void *value, size_t vlen)
> {
> struct x509_parse_context *ctx = context;
> + enum OID oid;
>
> ctx->key_algo = ctx->last_oid;
> switch (ctx->last_oid) {
> @@ -470,7 +471,17 @@ int x509_extract_key_data(void *context, size_t hdrlen,
> ctx->cert->pub->pkey_algo = "ecrdsa";
> break;
> case OID_id_ecPublicKey:
> - ctx->cert->pub->pkey_algo = "sm2";
> + if (ctx->params_size < 2)
Either a named constant, or at least a comment instead of just '2'.
> + return -ENOPKG;
> +
> + oid = look_up_OID(ctx->params + 2, ctx->params_size - 2);
> + switch (oid) {
> + case OID_sm2:
> + ctx->cert->pub->pkey_algo = "sm2";
> + break;
> + default:
> + return -ENOPKG;
> + }
> break;
> default:
> return -ENOPKG;
/Jarkko
next prev parent reply other threads:[~2021-01-30 21:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-27 12:33 [PATCH v3 0/3] Add support for x509 certs with NIST p256 and p192 keys Stefan Berger
2021-01-27 12:33 ` [PATCH v3 1/3] x509: Detect sm2 keys by their parameters OID Stefan Berger
2021-01-30 21:26 ` Jarkko Sakkinen [this message]
2021-01-31 2:57 ` Stefan Berger
2021-02-02 15:16 ` Jarkko Sakkinen
2021-01-27 12:33 ` [PATCH v3 2/3] x509: Add support for parsing x509 certs with NIST p256 keys Stefan Berger
2021-01-27 19:31 ` Herbert Xu
2021-01-27 22:39 ` Stefan Berger
2021-01-27 12:33 ` [PATCH v3 3/3] x509: Add support for NIST p192 keys in certificates and akcipher Stefan Berger
2021-01-27 13:05 ` [PATCH v3 0/3] Add support for x509 certs with NIST p256 and p192 keys David Howells
2021-01-27 14:22 ` David Howells
2021-01-27 19:32 ` Herbert Xu
2021-01-27 21:08 ` David Howells
2021-01-27 16:12 ` Nym Seddon
2021-01-27 22:42 ` Stefan Berger
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=689c44925d60238181390e775b52809e89e0b26a.camel@kernel.org \
--to=jarkko@kernel.org \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=herbert@gondor.apana.org.au \
--cc=keyrings@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patrick@puiterwijk.org \
--cc=stefanb@linux.ibm.com \
--cc=stefanb@linux.vnet.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 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).