Re: [Cfrg] draft-irtf-cfrg-eddsa -- one final proposal for domain separation (context labels) for ed25519

"Dang, Quynh (Fed)" <quynh.dang@nist.gov> Sat, 21 May 2016 10:18 UTC

Return-Path: <quynh.dang@nist.gov>
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 193D312D0FD; Sat, 21 May 2016 03:18:58 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.902
X-Spam-Level:
X-Spam-Status: No, score=-1.902 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=nistgov.onmicrosoft.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 S8aLV9H_49oF; Sat, 21 May 2016 03:18:56 -0700 (PDT)
Received: from gcc01-CY1-obe.outbound.protection.outlook.com (mail-cy1gcc01on0095.outbound.protection.outlook.com [23.103.200.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 1377B12D117; Sat, 21 May 2016 03:18:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nistgov.onmicrosoft.com; s=selector1-nist-gov; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=muEJ485BvboRLm//rYyl9csX1sthx3CPYbVSVOh5XFw=; b=c0txWuIrANqRyGg0RoFZr4j0nkKAX4pfa5gsbNnKj4mWBSbSea1M03x5WzM5+MlghlN6HUXqfalc984rSg014CkmztIyaWQhgH8dGZ995sjvs5YftOWaH+BWMAvm/Zi9J7lTaaMdvvWQm1xBWghzDcuRxzrVlI7YOczJcNG40Yk=
Received: from BY2PR09MB126.namprd09.prod.outlook.com (10.242.37.156) by BY2PR09MB128.namprd09.prod.outlook.com (10.242.37.28) with Microsoft SMTP Server (TLS) id 15.1.497.12; Sat, 21 May 2016 10:18:53 +0000
Received: from BY2PR09MB126.namprd09.prod.outlook.com ([10.242.37.156]) by BY2PR09MB126.namprd09.prod.outlook.com ([10.242.37.156]) with mapi id 15.01.0497.019; Sat, 21 May 2016 10:18:53 +0000
From: "Dang, Quynh (Fed)" <quynh.dang@nist.gov>
To: Bryan Ford <brynosaurus@gmail.com>, Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Thread-Topic: [Cfrg] draft-irtf-cfrg-eddsa -- one final proposal for domain separation (context labels) for ed25519
Thread-Index: AQHRms3FPUFKlN9LcUqDT2qenJ6a2Z/DVN6AgAAJZrY=
Date: Sat, 21 May 2016 10:18:52 +0000
Message-ID: <BY2PR09MB126C138CF1136B3DC2F732DF34C0@BY2PR09MB126.namprd09.prod.outlook.com>
References: <87bn543id1.fsf@alice.fifthhorseman.net>, <56CB4525-5392-4749-A5D1-0A9B54D5C8FB@gmail.com>
In-Reply-To: <56CB4525-5392-4749-A5D1-0A9B54D5C8FB@gmail.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: debian.org; dkim=none (message not signed) header.d=none;debian.org; dmarc=none action=none header.from=nist.gov;
x-ms-exchange-messagesentrepresentingtype: 1
x-originating-ip: [129.6.218.166]
x-ms-office365-filtering-correlation-id: 0b8de710-7616-456f-2fdf-08d381614fa8
x-microsoft-exchange-diagnostics: 1; BY2PR09MB128; 5:18bkUMMfKVX6lfXsSliV1X6XfZlDYCd5Q/wFo7FUxpyfBRBW1uBMcP0Lh5kakzrBsBJOfD7jRO8Rxmw++dtxCFiZNsSqKtB+weZZkGrF+2lW2/pM+v6BYZB3gfebUrEP0F9V1q/UzPp95I5ptM9i9A==; 24:hXDJGMiDaFLKI1yyRTGhIq58ZhtBCYR/YyI2w1KLtoth3JwLBqgH3OMU2X69ax6OvmBiejw3a4N3LuoxOLkN1qUHSPncngHR2EPscXm8vt8=; 7:O1I2l18nXKHOleHfNl/ltPKaq5QfyvFGHKGrmNOnL1D4Udvuq/EuZpxe7+tZrozrRg0qJljRJQwcTbgGWVxhcDokxGE3gzBdPHMLTVzYHHNlZtCiega2UmkcrbNMGdXNfHWzOPm3fe8cgYOTpTgpe9W1ei9VVUSbTItoGIy7/HkWkPwj5g6O9QaczHD0AkZv
x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR09MB128;
x-microsoft-antispam-prvs: <BY2PR09MB12829BB0840FA0D9794899FF34C0@BY2PR09MB128.namprd09.prod.outlook.com>
x-exchange-antispam-report-test: UriScan:;
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:BY2PR09MB128; BCL:0; PCL:0; RULEID:; SRVR:BY2PR09MB128;
x-forefront-prvs: 09497C15EB
x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(377454003)(92566002)(561944003)(2950100001)(5003600100002)(5004730100002)(87936001)(77096005)(74316001)(33656002)(5002640100001)(3846002)(86362001)(66066001)(54356999)(76176999)(50986999)(106116001)(230783001)(8676002)(8936002)(11100500001)(81166006)(5008740100001)(99286002)(189998001)(586003)(2906002)(5001770100001)(76576001)(102836003)(4326007)(19580395003)(9686002)(3660700001)(6116002)(122556002)(3280700002)(10400500002)(1220700001)(3900700001)(19580405001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR09MB128; H:BY2PR09MB126.namprd09.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en;
spamdiagnosticoutput: 1:23
spamdiagnosticmetadata: NSPM
Content-Type: text/plain; charset="windows-1250"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: nist.gov
X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2016 10:18:52.8229 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 2ab5d82f-d8fa-4797-a93e-054655c61dec
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR09MB128
Archived-At: <http://mailarchive.ietf.org/arch/msg/cfrg/DKTKIB1yj-8j7UewvCI9q0v0gl8>
Resent-From: alias-bounces@ietf.org
Resent-To: <>
Cc: Ondřej Surý <ondrej@sury.org>, Robert Edmonds <edmonds@debian.org>, Benjamin Kaduk <bkaduk@akamai.com>, "cfrg@ietf.org" <cfrg@ietf.org>, "draft-irtf-cfrg-eddsa.all@ietf.org" <draft-irtf-cfrg-eddsa.all@ietf.org>
Subject: Re: [Cfrg] draft-irtf-cfrg-eddsa -- one final proposal for domain separation (context labels) for ed25519
X-BeenThere: cfrg@irtf.org
X-Mailman-Version: 2.1.17
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: Sat, 21 May 2016 10:18:58 -0000

#3 is a clever idea.

Regards,
Quynh. 

________________________________________
From: Cfrg <cfrg-bounces@irtf.org> on behalf of Bryan Ford <brynosaurus@gmail.com>
Sent: Saturday, May 21, 2016 5:43 AM
To: Daniel Kahn Gillmor
Cc: Robert Edmonds; draft-irtf-cfrg-eddsa.all@ietf.org; cfrg@ietf.org; Ondřej Surý; Benjamin Kaduk
Subject: Re: [Cfrg] draft-irtf-cfrg-eddsa -- one final proposal for domain separation (context labels) for ed25519

I see after a long absence that I missed a new flare-up of the Great Context Debate (tm). :)

When I originally proposed the hashing scheme that included contexts for Ed448, I brought up this Ed25519 backward-compatibility issue, and suggested a few alternatives, at least one of which as I recall was similar to DKG’s suggestion.

At any rate, I agree with DKG and others that it would be nice for the RFC to specify a way to deal with an *optional* context parameter for Ed25519 - for consistency with Ed448 if nothing else - while preserving Ed25519 backward compatibility when the context parameter is missing/empty.  No one is forced to use it, but having it in the RFC - and in the APIs of implementations that choose to support it - both makes the RFC more self-consistent and offer a small robustness benefit to new protocols that decide to use contexts.

While the same domain-separation benefit can always be achieved by just prefixing the message, having an explicit context parameter in an API forces the software developer who’s calling that API to see it, and think “do I need to pass something there? what? should I ask a colleague?”  Whereas it’s much easier (essentially trivial) to “forget” to decide to prefix a signed message with something, especially if you’re not a crypto-geek and never heard that you were supposed to.  TLS won’t use contexts, and that’s fine, bit TLS isn’t the relevant “customer” here.  The “customer” is all the possible users of Ed25519 that are *not* nearly so widely-analyzed as TLS.

Yes, key-separation practices are good too, but do not substitute for the domain-separation that contexts can provide, because relying on key-separation exposes message-confusion risks at much higher levels of the “protocol stack” where key management occurs.  If an IETF protocol or proprietary application protocol is designed to use of a context, then any properly-functioning software implementing that protocol will enforce that domain-separation independently of how well or badly users or administrators might manage their keys.  Contexts provide a way for the protocol and software developer to enforce domain separation, whereas key-separation in many environments is something users and administrators have to do.  As others have stated, it’s about redundancy: no one is saying key-separation is bad, but encouraging the use of both reduces the chance of something going critically wrong at *both* levels (protocol design/implementation and key management).

In terms of how exactly to specify a backward-compatible context mechanism for Ed25519, I would certainly support DKG’s specific proposal where context may be empty) as offering a reasonable balance between simplicity and domain-separation goals.  But just to explore a couple slightly different variants with slightly different tradeoffs:

1. DKG’s proposal (baseline): mainly just change H(x) in Table 1 to H(context || x), where context may be empty for backward-compatibility.

2. Change the H(x) line in Table 1 to:

   |    H(x)   | SHA-512(x) [RFC4634] if ctx is empty               |
   |    H(x    | SHA-512(len(ctx) || ctx || x) if ctx is nonempty   |

Advantage: stronger domain separation, ensuring any use that specifies a context is domain-separated from any use that does not.
Downside: slightly more complex specification and code (one ‘if’ statement), though this bit of complexity is hidden from callers of the Ed25519 API.

3. Change the H(x) line in Table 1 to:

   |    H(x)   | SHA-512(len(context)^len(context) || context || x) [RFC4634]    |
…that is, the prefix is L consecutive bytes having value L, where L is the length of the context string, followed by the context and x.  So:

- empty context: H(x) is SHA-512(x)
- context = “foo”: H(x) is SHA-512(“\3\3\3foo” || x)
- context = “blah”: H(x) is SHA-512(“\4\4\4\4blah” || x)

Advantage: eliminates the need for a special-case (the ‘if’ statement) for backward compatibility, while providing the same stronger domain-separation of alternative #2 above.
Downside: doubles the effective size of the context-prefix to process.  But I can’t imagine this mattering in any practical scenario, especially since contexts are expected to be short strings.

Cheers
Bryan