mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexander Holler <holler@ahsoftware.de>
To: linux-kernel@vger.kernel.org
Cc: linux-crypto@vger.kernel.org,
	Herbert Xu <herbert@gondor.hengli.com.au>,
	"David S. Miller" <davem@davemloft.net>,
	Rusty Russell <rusty@rustcorp.com.au>,
	David Howells <dhowells@redhat.com>,
	Alexander Holler <holler@ahsoftware.de>
Subject: [PATCH] crypto: Ignore validity dates of X.509 certificates by default
Date: Mon, 25 Feb 2013 18:40:26 +0100	[thread overview]
Message-ID: <1361814026-4734-1-git-send-email-holler@ahsoftware.de> (raw)

I don't see any real use case where checking the validity dates of X.509
certificates at parsing time adds any security gain. In contrast, doing so
makes MODSIGN unusable on systems without a RTC (or systems with a possible
wrong date in a existing RTC or systems where the RTC is read after the keys
got loaded).

So just disable checking the dates in the parser by default.

(In fact I even think the check in the parser should be deleted at all,
because those dates should be checked at the time of usage and not at
parsing time, if someone really cares about these dates.)

Signed-off-by: Alexander Holler <holler@ahsoftware.de>
---
 crypto/asymmetric_keys/Kconfig           | 10 ++++++++++
 crypto/asymmetric_keys/x509_public_key.c |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/crypto/asymmetric_keys/Kconfig b/crypto/asymmetric_keys/Kconfig
index 6d2c2ea..333976f 100644
--- a/crypto/asymmetric_keys/Kconfig
+++ b/crypto/asymmetric_keys/Kconfig
@@ -35,4 +35,14 @@ config X509_CERTIFICATE_PARSER
 	  data and provides the ability to instantiate a crypto key from a
 	  public key packet found inside the certificate.
 
+config X509_CERTIFICATE_PARSER_IGNORE_DATES
+	bool "Ignore validity dates of X.509 certificates in the parser"
+	depends on X509_CERTIFICATE_PARSER
+	default y
+	help
+	  Ignore the validity dates in X.509 certificates (Not Before
+	  and Not After) when they get parsed. Otherwise loading them will
+	  fail when the time is set wrong (which is e.g. a problem at startup
+	  on systems without a RTC).
+
 endif # ASYMMETRIC_KEY_TYPE
diff --git a/crypto/asymmetric_keys/x509_public_key.c b/crypto/asymmetric_keys/x509_public_key.c
index 06007f0..c9a73e2 100644
--- a/crypto/asymmetric_keys/x509_public_key.c
+++ b/crypto/asymmetric_keys/x509_public_key.c
@@ -106,7 +106,9 @@ error_no_sig:
 static int x509_key_preparse(struct key_preparsed_payload *prep)
 {
 	struct x509_certificate *cert;
+#if !defined(CONFIG_X509_CERTIFICATE_PARSER_IGNORE_DATES)
 	struct tm now;
+#endif
 	size_t srlen, sulen;
 	char *desc = NULL;
 	int ret;
@@ -137,6 +139,7 @@ static int x509_key_preparse(struct key_preparsed_payload *prep)
 		goto error_free_cert;
 	}
 
+#if !defined(CONFIG_X509_CERTIFICATE_PARSER_IGNORE_DATES)
 	time_to_tm(CURRENT_TIME.tv_sec, 0, &now);
 	pr_devel("Now: %04ld-%02d-%02d %02d:%02d:%02d\n",
 		 now.tm_year + 1900, now.tm_mon + 1, now.tm_mday,
@@ -173,6 +176,7 @@ static int x509_key_preparse(struct key_preparsed_payload *prep)
 		ret = -EKEYEXPIRED;
 		goto error_free_cert;
 	}
+#endif
 
 	cert->pub->algo = x509_public_key_algorithms[cert->pkey_algo];
 	cert->pub->id_type = PKEY_ID_X509;
-- 
1.8.1.2


                 reply	other threads:[~2013-02-25 17:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1361814026-4734-1-git-send-email-holler@ahsoftware.de \
    --to=holler@ahsoftware.de \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=herbert@gondor.hengli.com.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    /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

all inboxes | Powered by JetHome®