Re: [Curdle] FW: New Version Notification for draft-ietf-curdle-pkix-04.txt

Brian Smith <brian@briansmith.org> Mon, 01 May 2017 00:17 UTC

Return-Path: <brian@briansmith.org>
X-Original-To: curdle@ietfa.amsl.com
Delivered-To: curdle@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 537971279EB for <curdle@ietfa.amsl.com>; Sun, 30 Apr 2017 17:17:43 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.702
X-Spam-Level:
X-Spam-Status: No, score=-0.702 tagged_above=-999 required=5 tests=[BAYES_40=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=briansmith-org.20150623.gappssmtp.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C4_aWRNOXDxQ for <curdle@ietfa.amsl.com>; Sun, 30 Apr 2017 17:17:41 -0700 (PDT)
Received: from mail-io0-x22d.google.com (mail-io0-x22d.google.com [IPv6:2607:f8b0:4001:c06::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id E33FF129488 for <curdle@ietf.org>; Sun, 30 Apr 2017 17:15:57 -0700 (PDT)
Received: by mail-io0-x22d.google.com with SMTP id k87so102494780ioi.0 for <curdle@ietf.org>; Sun, 30 Apr 2017 17:15:57 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=briansmith-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=omBajCcS/67teSbtHkKKa/1YAU6n7oGdd/U8sFZBlvQ=; b=myrcUWlRI4zB2RKZnKhhRbiglS6C9q6d4qs7C02g9GLPA0YTZUZ+Z7tkRtsDZbidLo P6/UTVfRF0poihpvGo4P0davWHHwRBAQIThDv5V5FT8j/PpWDMyD3mEEK8gI5Od05QSU jbJrfu71z3ahBg+riqudh2z9ClUs3lI+BFFimR5wlBNNfrBZhCmfEF+XbIcoXTf7zMtV 4bmJVdWJfPlz1uwGrlv5WeRqYwlkOT3I7n2B+j67+DhaM0hL2EjRMHkA4CuKd5NhbbfX SDtLd+Isvwzc/cwvcSV4/4TV2jqKfwpZzS5IzPgav8zp3e57CoEqUiAtRB3Pqrp7khED CpiA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=omBajCcS/67teSbtHkKKa/1YAU6n7oGdd/U8sFZBlvQ=; b=T58PburRcgAtAphpZ1EgnljA/hX6TOHuxUXJxzbOXpEA1rae9fQFRcTm6bGAbVNLB/ v9JSA7KKdUGh5DjwBgkJSjt5r1bOhFWR76PVzJ4niMf6UUwW6vO2JvYO0JgqA7mXtDDW unr3TTo0rwtEkMFo9XBOV/RF55dnO1Kkcq8vSh4hjCreb2KNaGFL5y+44F/CBRPL/ZST WTMzvBAL3torRfWBL4Q4azaPGu1d82d76pI4cJ8lFLwo4e07CGBA6EINgJCWx8YdAtgl Bj++1/1SaAjLUO5g5TuXOlzl25P+ibm2VYy+bVIeYS8gSB6gVXRlyiF5Dyd1uHnP32gp n+Ww==
X-Gm-Message-State: AN3rC/51ti3NHdZuDJ4L+T6ucNByRj89HwtzaTvFBen1hfw1fIrhAiaD R11nzL3ESrttugs7G1QZM8ISdgd26Tx9oho=
X-Received: by 10.107.50.136 with SMTP id y130mr24520929ioy.152.1493597757131; Sun, 30 Apr 2017 17:15:57 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.36.77.84 with HTTP; Sun, 30 Apr 2017 17:15:56 -0700 (PDT)
In-Reply-To: <006d01d2c194$0e99b280$2bcd1780$@augustcellars.com>
References: <149073663013.1172.4888065212435317707.idtracker@ietfa.amsl.com> <051401d2a80b$e9bdea90$bd39bfb0$@augustcellars.com> <CAFewVt6-0WSqmwD7xVvKWDg3P9vNpFZDqB-n61hiU9qQp1c2cw@mail.gmail.com> <006d01d2c194$0e99b280$2bcd1780$@augustcellars.com>
From: Brian Smith <brian@briansmith.org>
Date: Sun, 30 Apr 2017 14:15:56 -1000
Message-ID: <CAFewVt4Lj7DMuVszGD6eht-3CJY6twaOao4J6KBTq4mTnYVFUQ@mail.gmail.com>
To: Jim Schaad <ietf@augustcellars.com>
Cc: curdle <curdle@ietf.org>
Content-Type: text/plain; charset="UTF-8"
Archived-At: <https://mailarchive.ietf.org/arch/msg/curdle/tt-svDWSIIY1546VjgYtVTA54Cc>
Subject: Re: [Curdle] FW: New Version Notification for draft-ietf-curdle-pkix-04.txt
X-BeenThere: curdle@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: "List for discussion of potential new security area wg." <curdle.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/curdle>, <mailto:curdle-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/curdle/>
List-Post: <mailto:curdle@ietf.org>
List-Help: <mailto:curdle-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/curdle>, <mailto:curdle-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 01 May 2017 00:17:43 -0000

Jim Schaad <ietf@augustcellars.com> wrote:
> Brian Smith wrote:
> > I started implementing this this weekend and I noticed that this is
> > the only private key format for which it is impossible to implement
> > a useful pairwise consistency check. In one sense, a consistency
> > check isn't necessary because the public key is computed from
> > the private key, so there's no room for inconsistency. On the
> > other hand, there's no way to detect corruption of the private key
> > like you can with RSA and ecPublicKey keys, when the key is
> > stored in the unencrypted form. I think this is really unfortunate.
>
> [JLS] It is true that RSA has this as a built in feature, however it
> is not true for all of the key formats that are in common use today.
> The same structure is used here as is used for traditional DH keys.

It seems to me that traditional DH keys are exceptional in this
respect. ECPrivateKey (for ECDSA and ECDH) is required to contain the
public key. RSAPrivateKey contains everything needed to validate it.

>  The ability to do check that the public and private keys match is something that is possible, but is frequently not done even for RSA keys.  Additionally, there are cases where it is less expensive to re-compute the public key than to transport it.

Doing the consistency check vs. saving space is a safety trade-off.

> It is not always possible to detect corruption when you store in an unencrypted form.

What kind of corruption would we not be able to detect? It is possible
that somehow the private key could get corrupted and that there could
be a corresponding corruption to the public key such that they match
again, but this seems extremely unlikely unless somebody simply
replaced the key pair with another key pair.

> It would also not be possible to know if it was the private key or the public key that has been corrupted, just that the two values do not match.

This is the case with any kind of cryptographic check, including HMAC
or whatnot.

> > However, unless this is documented in the draft one way or
> another as a MUST accept or a MUST NOT generate, I think
> it will be an interop nightmare. In particular, we should avoid
> the situation where some implementations produce v2 keys
> so they can add the publicKey field, and where other
> implementations reject v2 keys because they only parse v1,
> where the publicKey field isn't allowed.
>
> I have not heard that this is an issue today with DH keys.  This
> makes me think that this is not going to be a big issue.  I expect
> that most implementations would all for parsing v2 keys even if
> they then ignore the public key field.

If that's the expectation then let's enshrine that in the spec by
saying that implementations MUST accept v2 keys for these types of
keys.

In particular, I have seen PKCS#8 implementations that reject any v2
PKCS#8 file instead of ignoring the extra fields.

> > In particular, it is important for the spec to include v2 PKCS#8
> > examples with the publicKey field, if such encoding is allowed.
>
> This is a reasonable request.  I will look at adding this as part of the IETF last call comments.

Thanks.

> I also found that, if the publicKey field is included, and one tries to
> do pairwise validation of the private key and public key, there are
> a few special cases that should be documented as test vectors.

> [JLS] Please be more explicit on what you believe are the special
> cases that need to be highlighted.  The cases that immediately
> come to mind for me are the question of correct form for the values,
> but that is not an encoding problem but an issue with the library
> being used.  Are there others that you have in mind?

I'll use X25519 as an example.

RFC 7748 says:
> When receiving such an array, implementations of X25519 (but
> not X448) MUST mask the most significant bit in the final byte."

Thus for every X25519 key, there will be at least two possible
encodings of the public key. We should have test vectors such
that both encodings of the same public key (for the same private
key) are included as separate vectors, to ensure that any
implementation that does do a pairwise consistency check
includes the masking step in the comparison.

Similarly, for ~19 X25519 keys, there are twice as many (4)
possible encodings of the public key:

1. High bit is 0, fully reduced.
2. High bit is 1, not fully reduced.
3. High bit is 0, fully reduced.
4. High bit is 0, not fully reduced.

We should have test vectors for all four cases, to ensure that any
implementation that does the pairwise consistency check does the
comparison on the fully-reduced value of the given and calculated
public key, instead of just doing a bytewise comparison. (Though, do
we know any of the these 19 private keys that could use to produce a
test vector?)

Cheers,
Brian
-- 
https://briansmith.org/