Re: [Cfrg] draft-irtf-cfrg-randomness-improvements-00 vs currently-deployed alternatives

Brian Smith <brian@briansmith.org> Thu, 14 June 2018 03:07 UTC

Return-Path: <brian@briansmith.org>
X-Original-To: cfrg@ietfa.amsl.com
Delivered-To: cfrg@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 5A81E131002 for <cfrg@ietfa.amsl.com>; Wed, 13 Jun 2018 20:07:47 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.611
X-Spam-Level:
X-Spam-Status: No, score=-2.611 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, T_DKIMWL_WL_MED=-0.01] 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 Y_wJnHgHQHg9 for <cfrg@ietfa.amsl.com>; Wed, 13 Jun 2018 20:07:45 -0700 (PDT)
Received: from mail-lf0-x242.google.com (mail-lf0-x242.google.com [IPv6:2a00:1450:4010:c07::242]) (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 014B4130E95 for <cfrg@irtf.org>; Wed, 13 Jun 2018 20:07:44 -0700 (PDT)
Received: by mail-lf0-x242.google.com with SMTP id d24-v6so7037140lfa.8 for <cfrg@irtf.org>; Wed, 13 Jun 2018 20:07:44 -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:content-transfer-encoding; bh=Crorz+1VwsoME1n9G6oCvhoUpfOF8ksJUbOTH4pOZnU=; b=zPS9d/BOpHFosCzHe1FOWF3J2TvL8pbAY6+mlggxM34kBYMng0XfEtkZjuowA8KFGp 8+0eKPfT0JAy1scVAZ0Arqg0wbwSUVH98hiWZAIo6QFu7pAsttLYUkSjNz7ZpxpFzsBO j/zaQaPKjqcgfprWcTCiZiThG+VFEl3WrYQxixxI8OE3DgzUuH5DoQ/uirqwBY0N9AmD fqGGnwDn5Guc7XrbjhcoNTz20ZAvWMjoDqolj1M0sUaL8cGRbNH607kl2wVIymW8R2vh dL5nmprrzWReCP2zxdnv9mWRCVSY1JCBjWBvQnjbxmPFI8o7SPT7OF27U1Pv7M331Eg4 PbdQ==
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:content-transfer-encoding; bh=Crorz+1VwsoME1n9G6oCvhoUpfOF8ksJUbOTH4pOZnU=; b=ctjLW0bMJvApUCeNz+RAo3CFK/wInblhjnx8VEQ2jAoGU3C8tyEHqSY8CE8j8tds69 DFcC+oFUfT7J2TVBAP/NK6iKeAL0zji0aJB+iYDT8cw3RLWNMNuJu8HnnqXeEV2HuYun cYUw+XF+jY/z4YVhqb7GP/6NxkeOB9Shl+r4jbX81+fp7y2o4NYyg8gtuzmIzqes69sH 3VAuWQ7FR27YW5dCiRFAqAcJlTqkaz9G31bqlkM0UytfKipo4tAbSX5rgJ3/B/5lXDKX 2bEqTqVoDebO1SJPXYQwc6A4E4sCQ+wLr2+vtcDzhM6/Wv7NPEqdncCUSSgzvJ4tdS9v 6/Vw==
X-Gm-Message-State: APt69E0FR22zyJDS9We7fY9qCtfCYhm34CxlYvHYBxIZYflp1piuoUBu HDuD8EDRWKj/wdw8EJbq/dbB6JlELCIMpPfeNfhv3g==
X-Google-Smtp-Source: ADUXVKKACVTEbgwzZ7mXYl7EcxWU2WH+vLh3Hipt3sBu/xQ6mZr0qFO2PIqBfdr59Vyig04vs70MkR71EHskC4K7sJ0=
X-Received: by 2002:a19:dbc3:: with SMTP id t64-v6mr4422537lfi.123.1528945663089; Wed, 13 Jun 2018 20:07:43 -0700 (PDT)
MIME-Version: 1.0
Received: by 2002:a19:41c7:0:0:0:0:0 with HTTP; Wed, 13 Jun 2018 20:07:42 -0700 (PDT)
In-Reply-To: <CAMr0u6=1WBmo_qHSOzT6HRQ1N3Qfsf49rN-F2uk9m9wSrYOi+w@mail.gmail.com>
References: <CAFewVt6E8Ft3vRKEs3vdvOhNr8JmOEDwQH8SU5rm_SkDdsi89A@mail.gmail.com> <CAMr0u6=1WBmo_qHSOzT6HRQ1N3Qfsf49rN-F2uk9m9wSrYOi+w@mail.gmail.com>
From: Brian Smith <brian@briansmith.org>
Date: Wed, 13 Jun 2018 17:07:42 -1000
Message-ID: <CAFewVt5mq4MRHKMrjB-eFtsguBy6+8tv7J9J4nX3MYONKXqSQw@mail.gmail.com>
To: "Stanislav V. Smyshlyaev" <smyshsv@gmail.com>
Cc: cfrg@irtf.org, Luke Garratt <luke.garratt@wolfson.ox.ac.uk>, Cas Cremers <cas.cremers@gmail.com>, Cas Cremers <cas.cremers@cs.ox.ac.uk>, Christopher Wood <christopherwood07@gmail.com>, Nick Sullivan <nick@cloudflare.com>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/cfrg/hL-6ZVi5QTqnxqOlwERud5gIqpU>
Subject: Re: [Cfrg] draft-irtf-cfrg-randomness-improvements-00 vs currently-deployed alternatives
X-BeenThere: cfrg@irtf.org
X-Mailman-Version: 2.1.26
Precedence: list
List-Id: Crypto Forum Research Group <cfrg.irtf.org>
List-Unsubscribe: <https://www.irtf.org/mailman/options/cfrg>, <mailto:cfrg-request@irtf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cfrg/>
List-Post: <mailto:cfrg@irtf.org>
List-Help: <mailto:cfrg-request@irtf.org?subject=help>
List-Subscribe: <https://www.irtf.org/mailman/listinfo/cfrg>, <mailto:cfrg-request@irtf.org?subject=subscribe>
X-List-Received-Date: Thu, 14 Jun 2018 03:07:48 -0000

Stanislav V. Smyshlyaev <smyshsv@gmail.com> wrote:
> About deterministic signature functions.
>
> Actually the worst case scenario we are defending against is a complete
> breakdown of all existing entropy sources (say, because of failure of
> hardware RNG) on a certain computer.

The draft says "In the NAXOS key exchange protocol, raw entropy output
x is replaced by H(x, sk), where sk is the sender's private key.
Unfortunately, as private keys are often isolated in HSMs, direct
access to compute H(x, sk) is impossible. An alternate yet
functionally equivalent construction is needed. [...] Implementations
SHOULD apply this technique when indirect access to a private key is
available and CSPRNG randomness guarantees are dubious"

If the private key `sk` is available to the user then one could use
NAXOS or a variant of it.

If the private key `sk` is not available but the HSM lets the user
choose the nonce then the user can extract `sk` from the HSM by using
the standard ECDSA attack, and then use NAXOS or a variant of it.

If the private key `sk` is not available and the HSM rightly doesn't
let the user choose the nonce then the only way one can follow the
recommendation to use a deterministic signature function is if the HSM
implements deterministic ECDSA itself. But it is really uncommon for
an HSM to implement deterministic ECDSA, especially because
deterministic ECDSA is non-compliant with all specifications for
ECDSA. Note: I'm not saying this is good or bad.

The main consequence of this is that, practically speaking, it seems
like one can't really use deterministic ECDSA except in cases where
one could also use NAXOS or a similar thing. Thus the "e.g.,
deterministic ECDSA [RFC6979]" seems to contradict "direct access to
compute H(x, sk) is impossible."

Similarly, APIs for HSMs generally don't let one choose the salt for
PSS signature generation, though in some implementations one can set
the salt length to zero to get a deterministic PSS signature. However,
other work on PSS in TLS has already tried to make it so an
implementation (e.g. mine and a few other new implementations) need
only support specific non-zero lengths of salts. Thus one probably
can't rely on deterministic PSS being available either.

Similarly, TLS 1.3 says that we must use PSS instead of PKCS#1
signatures so a TLS 1.3 implementation wouldn't need to implement
PKCS#1 signing. Further, everybody knows that we shouldn't use the
same private key for two different algorithms, so if we have an RSA
private key for use with TLS 1.3 then we shouldn't use it to make
PKCS#1 signatures; ideally the HSM would enforce that.

Thus, the requirement that "Sig MUST be a deterministic signature
function" seems unrealistic except in cases where a new mechanism may
not even be useful since NAXOS or similar would work fine.

> The problem
> occurs in another case  - when a random value used in ECDSA/EC-RDSA is
> obtained from the same potentially broken entropy source.

Right. One the one hand you don't want to trust the ECDSA's
implementation's RNG. On the other hand, ECDSA implementations don't
generally expose APIs that let you replace their RNG unless they also
give you the raw private key, in which case we wouldn't need to use
ECDSA to derive the initial key.

> Of course it would be better to mix-in entropy, but we'd like to stress that
> the main reason of using the techniques described in our draft is to address
> the possible worst-case scenarios of having no working entropy sources –
> when we cannot rely on any mixed-in entropy at all.

The point I'm trying to make is subtle:
1. Obviously, we don't want to rely on having any entropy.
2. Less obviously, if there is entropy available then it seems silly
to ignore it.

> In fact the
> problem we're trying to address here is the following. If we do not have any
> actual entropy, then, in case of using our techniques, we'll leverage the
> security of such worst-case scenarios – but – if we also have two equivalent
> environments (two cloned virtual machines, for example) and two tags are
> equivalent, then we can do nothing at all: no entropy and no differences
> between two environments would lead to completely equivalent outputs.

There are four cases to consider:
1. A working entropy source is available, and the two tags are the same.
2. A working entropy source is available, and the two tags are different.
3. The entropy source is broken, and the two tags are the same.
4. The entropy source is broken, and the two tags are different.

In your paragraph above, you are describing case #3. But what about case #1?

BTW, I think that you and I may be thinking of different use cases for
draft-irtf-cfrg-randomness-improvements-00. The question I original
set out to answer is "Would it be better to use
draft-irtf-cfrg-randomness-improvements-00 instead of RFC 6979 when
implementing ECDSA?" From re-reading the draft I think that target use
case might have been more about "How can we strengthen key agreement
(e.g. ECDH)?"

Since I posted my question I actually came up a few with more
questions, but the general question I think is still unanswered is
"Why is this mechanism better than using other established
mechanisms?" In particular, why is this mechanism better than a
variant of NAXOS or better than using the HMAC DRBG? Speaking from my
own experience and motivation for reading thedocument, that's the main
question that I think is left unanswered in the draft.

Cheers,
Brian