Re: Suggested changes for DSA2

hal@finney.org ("Hal Finney") Sun, 26 March 2006 18:24 UTC

Received: from [10.91.34.44] (helo=ietf-mx.ietf.org) by megatron.ietf.org with esmtp (Exim 4.43) id 1FNZuY-0008F3-W3 for openpgp-archive@lists.ietf.org; Sun, 26 Mar 2006 13:24:22 -0500
Received: from balder-227.proper.com ([192.245.12.227]) by ietf-mx.ietf.org with esmtp (Exim 4.43) id 1FNZuW-0002qM-Hn for openpgp-archive@lists.ietf.org; Sun, 26 Mar 2006 13:24:22 -0500
Received: from balder-227.proper.com (localhost [127.0.0.1]) by balder-227.proper.com (8.13.5/8.13.5) with ESMTP id k2QI44kw037256; Sun, 26 Mar 2006 11:04:04 -0700 (MST) (envelope-from owner-ietf-openpgp@mail.imc.org)
Received: (from majordom@localhost) by balder-227.proper.com (8.13.5/8.13.5/Submit) id k2QI44Aq037255; Sun, 26 Mar 2006 11:04:04 -0700 (MST) (envelope-from owner-ietf-openpgp@mail.imc.org)
X-Authentication-Warning: balder-227.proper.com: majordom set sender to owner-ietf-openpgp@mail.imc.org using -f
Received: from finney.org (226-132.adsl2.netlojix.net [207.71.226.132]) by balder-227.proper.com (8.13.5/8.13.5) with ESMTP id k2QI43t2037249 for <ietf-openpgp@imc.org>; Sun, 26 Mar 2006 11:04:03 -0700 (MST) (envelope-from hal@finney.org)
Received: by finney.org (Postfix, from userid 500) id 12C8057FAE; Sun, 26 Mar 2006 10:02:18 -0800 (PST)
To: dshaw@jabberwocky.com, hal@finney.org
Subject: Re: Suggested changes for DSA2
Cc: ietf-openpgp@imc.org
Message-Id: <20060326180218.12C8057FAE@finney.org>
Date: Sun, 26 Mar 2006 10:02:18 -0800
From: hal@finney.org
Sender: owner-ietf-openpgp@mail.imc.org
Precedence: bulk
List-Archive: <http://www.imc.org/ietf-openpgp/mail-archive/>
List-Unsubscribe: <mailto:ietf-openpgp-request@imc.org?body=unsubscribe>
List-ID: <ietf-openpgp.imc.org>
X-Spam-Score: 0.1 (/)
X-Scan-Signature: 32b73d73e8047ed17386f9799119ce43

David Shaw writes:
> On Fri, Mar 24, 2006 at 12:21:42PM -0800, "Hal Finney" wrote:
> > Aside from this I think David's wording is a little unclear about "the
> > appropriate number" of leftmost bits.  Maybe we could say:
> > 
> >     DSA signatures MUST use hashes that are equal to or larger than the
> >     size of q, the group generated by the DSA key's generator value.
> >     If the chosen hash is larger than the size of q, the hash result
> >     is truncated to fit by taking a number of leftmost bits equal to
> >     the number of bits in q.  This (possibly truncated) hash function
> >     result is treated as a number and used directly in the DSA signature
> >     algorithm.
> >
> > Note that this truncation (or non-truncation) could still leave the
> > hash as bigger than q, but that is OK as the signature and validation
> > algorithms will either explicitly or implicitly take it mod q as it
> > is used.  So I don't think we have to tell them to take it mod q.
>
> I agree with your suggested change, but I'm not sure I follow this
> comment.  How could the hash still be bigger than q if we're
> explicitly truncating it to be the same size as q?

For example, we have a 1024 bit key with a 160 bit q.  We truncate a
SHA-256 hash to 160 bits.  But q < 2^160, hence the truncated hash can
still be greater than q, i.e.  q < trunc(hash) < 2^160.

I see that my proposed text still has this somewhat ambiguous reference
to "the size of q".  It also refers to the size of the chosen hash when
it should say the output size.  If I fix those two it becomes:

    DSA signatures MUST use hashes whose output size is equal to or larger
    than the number of bits of q, the group generated by the DSA key's
    generator value.  If the output size of the chosen hash is larger
    than the number of bits of q, the hash result is truncated to fit by
    taking a number of leftmost bits equal to the number of bits of q.
    This (possibly truncated) hash function result is treated as a number
    and used directly in the DSA signature algorithm.

Regarding the question of whether to allow intermediate sizes:

> I wasn't so much thinking about which q to use for intermediate p
> sizes, but rather thinking more from the verification end: namely, we
> can't stop people from generating whatever key they like, sensible or
> not.  So rather than defining the set of valid p/q pairs, and
> presumably rejecting any p or q outside the defined set, I was
> thinking of just stepping back and saying, in effect, that this isn't
> our problem to solve.  Give SHOULD guidance on what to generate
> (i.e. the FIPS list), but don't make it a MUST to lock things down to
> that list.  Otherwise, a few years from now, FIPS-186-4 will come out
> and define a p/q pair not on the FIPS-186-3 list and break all of our
> implementations.
>
> The FIPS draft refers such questions to NIST publication SP800-57,
> which actually does mention two larger p/q pairs: p=7680 q=384 and
> p=15360 q=512 (see page 63).  Not that I think that a 15360-bit DSA
> key is useful in practice in 2006, but clearly there is already
> consideration of other key sizes.

It's always a tricky question, how much we should try to enforce
security standards in a data-format document.  We do put minimum length
restrictions on the moduli to try to protect users against making one
kind of mistake, using a too-short key.  In the same way, I don't think
we should allow them to use a 160-bit q for a 3072-bit p.  This is the
spirit behind my suggestion to just allow the NIST sizes.

Allowing the bigger sizes would also be consistent with this proposal
but I don't think everyone would want to support those.

> >      * The DSA algorithm will work with any hash, but it is
> >        sensitive to the quality of the hash algorithm.  An implementation
> >        should take care which hash algorithms are used with DSA.
> >        Verifiers should be aware that even if the signer used a strong
> >        hash, an attacker could have modified a signature to use a
> >        weak one.  Only signatures issued using acceptably strong hash
> >        algorithms should be accepted as valid.

On re-reading this I have two improvements.  The second sentence is
redundant.  And the last sentence cautions verifiers about what hash
was used when the sig was "issued", but the verifier doesn't know this
(that is the point), it only knows what it sees:

     * The DSA algorithm will work with any hash, but it is
       sensitive to the quality of the hash algorithm.  Verifiers
       should be aware that even if the signer used a strong hash,
       an attacker could have modified a signature to use a weak one.
       Only signatures using acceptably strong hash algorithms should
       be accepted as valid.

Hal Finney