Re: [openpgp] Catch 22 in ECC support of OpenPGP?

Jon Callas <jon@callas.org> Sat, 01 February 2014 21:05 UTC

Return-Path: <jon@callas.org>
X-Original-To: openpgp@ietfa.amsl.com
Delivered-To: openpgp@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 898401A1F7A for <openpgp@ietfa.amsl.com>; Sat, 1 Feb 2014 13:05:40 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.358
X-Spam-Level:
X-Spam-Status: No, score=-0.358 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DATE_IN_PAST_06_12=1.543, SPF_PASS=-0.001] autolearn=no
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 qbxb5mBLIln2 for <openpgp@ietfa.amsl.com>; Sat, 1 Feb 2014 13:05:39 -0800 (PST)
Received: from mail.merrymeet.com (merrymeet.com [173.164.244.100]) by ietfa.amsl.com (Postfix) with ESMTP id F18F81A1F76 for <openpgp@ietf.org>; Sat, 1 Feb 2014 13:05:38 -0800 (PST)
Received: from localhost (localhost [127.0.0.1]) by mail.merrymeet.com (Postfix) with ESMTP id B32FA4C53C22; Sat, 1 Feb 2014 13:05:34 -0800 (PST)
X-Virus-Scanned: amavisd-new at merrymeet.com
Received: from mail.merrymeet.com ([127.0.0.1]) by localhost (merrymeet.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GBASkhkHalMo; Sat, 1 Feb 2014 13:05:33 -0800 (PST)
Received: from keys.merrymeet.com (keys.merrymeet.com [173.164.244.97]) by mail.merrymeet.com (Postfix) with ESMTPSA id 57EC04C53BFF; Sat, 1 Feb 2014 13:05:31 -0800 (PST)
Received: from [192.168.10.248] ([64.134.147.132]) by keys.merrymeet.com (PGP Universal service); Sat, 01 Feb 2014 13:05:33 -0800
X-PGP-Universal: processed; by keys.merrymeet.com on Sat, 01 Feb 2014 13:05:33 -0800
Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\))
From: Jon Callas <jon@callas.org>
In-Reply-To: <874n4kxqop.fsf@vigenere.g10code.de>
Date: Sat, 01 Feb 2014 04:57:29 -0800
Message-Id: <E77E59A7-05D9-480A-939F-E1198CFC8246@callas.org>
References: <87iot0y1su.fsf@vigenere.g10code.de> <E238B88A-6259-4D1F-A432-AD0D20652392@callas.org> <874n4kxqop.fsf@vigenere.g10code.de>
To: Werner Koch <wk@gnupg.org>
X-Mailer: Apple Mail (2.1827)
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Cc: "openpgp@ietf.org OpenPGP" <openpgp@ietf.org>, Jon Callas <jon@callas.org>
Subject: Re: [openpgp] Catch 22 in ECC support of OpenPGP?
X-BeenThere: openpgp@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: "Ongoing discussion of OpenPGP issues." <openpgp.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/openpgp>, <mailto:openpgp-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/openpgp/>
List-Post: <mailto:openpgp@ietf.org>
List-Help: <mailto:openpgp-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/openpgp>, <mailto:openpgp-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 01 Feb 2014 21:05:40 -0000

On Jan 31, 2014, at 4:48 AM, Werner Koch <wk@gnupg.org> wrote:

> Sure.  We already use one from the GNU arc in Libgcrypt:
> 
>  1.3.6.1.4.1.11591.15 ellipticCurve
>    1.3.6.1.4.1.11591.15.1 Ed25519
> 
> This is a different OID than Peter Gutman's for Curve25519.

Who cares? It's just a bitstring that is added into the hash to make it unique for the signature algorithm. Think of it as a form of salted hash where that is for the algorithm. The only thing that matters is uniqueness, and even if there's an OID collision, it's not the end of the world. Do it!

> 
>> As you've noted, in RFC 6637, Andrey codes an EC point into an MPI,
>> which I think is clever, and works fine. Why not just do it?
> 
> I explained it below.  RFC-6637 requires the use of SEC encoding which
> is nice because you will never have the problems with leading zeroes.
> However, EdDSA uses a different compression format without any
> identifier (which makes up nice 32 bytes).  A leading zero may however
> happen.  RFC-4880 does not allow that and thus one would need to check
> whether to left pad a read MPI before using it with Ed25519 code.  As I
> said, not a real problem but it would be possible to save 2 lines of
> code if we could use a raw octet string.

I can think of two ways to deal with it:

1) Ignore it. It's not *really* an MPI. It's a point in MPI format, and just throw it in there.

The reason for the rule is so that a given integer doesn't have subtle problems from different encodings with leading zeroes.

But these aren't integers, they're points of a known length. Just use the length and don't worry.

2) Consider this a primitive form of compression and roll with it.

Of those two, I vote for (1). There's no real value in the compression, it's an observation. And the reason there's little value in compression is the same reason that there's little harm in just putting the point there and don't worry about leading zeroes.

Let me take the case of the curve 414-19, and let's imagine that there's two leading zeroes in a point and thus the debate is whether we code it as a 412 or 414 bit field.

Either of those is kinda meh. It would be *better* even to make the field be 416, as that's an even multiple of 32. That gives you fast unpacking. If you're not going to do 416, it seems not worth worrying about the MPI rules, as you already have to have in your library a way to slosh zero high bits around anyway.

For a curve like one of the 255-bit ones, it's easy to stress over that extra bit, and why *not* just pack it into 256 bits for efficiency? Don't stress. 

 

> I have not yet seen the specs for Curve41417 and thus I do not know
> whether it also defines EdDSA for signatures.  EdDSA according to the
> paper requires the use of SHA512 but it also tells that other hash
> algorithms are possible.  Hopefully Watson Ladd's I-D can eventually be
> used as a reference.

Well, 414-19 is an Edwards curve so you can do EdDSA on it. It's 30 bits larger than 384, so you could use a 384-bit hash, or a variable-length hash function like Skein or SHA-512/z.

	Jon