Re: [Cfrg] hpke encoding of DH output

Stephen Farrell <stephen.farrell@cs.tcd.ie> Thu, 20 August 2020 18:47 UTC

Return-Path: <stephen.farrell@cs.tcd.ie>
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 9DC413A12D3 for <cfrg@ietfa.amsl.com>; Thu, 20 Aug 2020 11:47:57 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -5.248
X-Spam-Level:
X-Spam-Status: No, score=-5.248 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, NICE_REPLY_A=-0.949, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=cs.tcd.ie
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 xjzNRlaz2nZM for <cfrg@ietfa.amsl.com>; Thu, 20 Aug 2020 11:47:55 -0700 (PDT)
Received: from mercury.scss.tcd.ie (mercury.scss.tcd.ie [134.226.56.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 1D4563A12CB for <cfrg@irtf.org>; Thu, 20 Aug 2020 11:47:54 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1]) by mercury.scss.tcd.ie (Postfix) with ESMTP id 33C0EBE5D; Thu, 20 Aug 2020 19:47:53 +0100 (IST)
X-Virus-Scanned: Debian amavisd-new at scss.tcd.ie
Received: from mercury.scss.tcd.ie ([127.0.0.1]) by localhost (mercury.scss.tcd.ie [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4EBxCcP4qjtJ; Thu, 20 Aug 2020 19:47:50 +0100 (IST)
Received: from [10.244.2.119] (95-45-153-252-dynamic.agg2.phb.bdt-fng.eircom.net [95.45.153.252]) by mercury.scss.tcd.ie (Postfix) with ESMTPSA id BDD0ABE3E; Thu, 20 Aug 2020 19:47:50 +0100 (IST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cs.tcd.ie; s=mail; t=1597949270; bh=4mdbS+1qPLFNh1SdF5rArtB/p0ksjZE7gEsLnIYvNvE=; h=Subject:To:References:From:Date:In-Reply-To:From; b=Rkh4CK47P0ad1JhLphyIC9wR1dhKBMWTVardqtyCbNBiKTl+iVcf8OWklKyNYziEw Wv6YnjCLWMn/5bSNeSu/PyLN2fBl7NRskuO3mZ5HwhnXwfYLaON9opbyOvV7tP02NR NN13mVdok3hvt3bXUWrIboCVAqvnJfXP7wXcNKNY=
To: Christopher Wood <caw@heapingbits.net>, cfrg@irtf.org
References: <627dbf76-25c5-ae56-d602-d8cf2c63fb50@cs.tcd.ie> <CAL02cgQne5i-BDo_VbwFnUSkdMsRTJh0n19cVf+uEPnDL-kiWA@mail.gmail.com> <9fc1db17-3f9d-4d32-b4a6-1c4e807a8321@www.fastmail.com>
From: Stephen Farrell <stephen.farrell@cs.tcd.ie>
Autocrypt: addr=stephen.farrell@cs.tcd.ie; prefer-encrypt=mutual; keydata= mQINBFo9UDIBEADUH4ZPcUnX5WWRWO4kEkHea5Y5eEvZjSwe/YA+G0nrTuOU9nemCP5PMvmh 5Cg8gBTyWyN4Z2+O25p9Tja5zUb+vPMWYvOtokRrp46yhFZOmiS5b6kTq0IqYzsEv5HI58S+ QtaFq978CRa4xH9Gi9u4yzUmT03QNIGDXE37honcAM4MOEtEgvw4fVhVWJuyy3w//0F2tzKr EMjmL5VGuD/Q9+G/7abuXiYNNd9ZFjv4625AUWwy+pAh4EKzS1FE7BOZp9daMu9MUQmDqtZU bUv0Q+DnQAB/4tNncejJPz0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BZHzM3WGrL3S7ZmCYMdudhykxXXjq7M6Do1 oxM8JofrXGtwBTLv5wfvvygJouVCVe87Ge7mCeY5vey1eUi4zSSF1zPpR6gg64w2g4TXM5qt SwkZVOv1g475LsGlYWRuJV8TA67yp1zJI7HkNqCo8KyHX0DPOh9c+Sd9ZX4aqKfqH9HIpnCL AYEgj7vofeix7gM3kQQmwynqq32bQGQBrKJEYp2vfeO30VsVx4dzuuiC5lyjUccVmw5D72J0 FlGrfEm0kw6D1qwyBg0SAMqamKN6XDdjhNAtXIaoA2UMZK/vZGGUKbqTgDdk0fnzOyb2zvXK CiPFKqIPAqKaDHg0JHdGI3KpQdRNLLzgx083EqEc6IAwWA6jSz+6lZDV6XDgF0lYqAYIkg3+ 6OUXUv6plMlwSHquiOc/MQXHfgUP5//Ra5JuiuyCj954FD+MBKIj8eWROfnzyEnBplVHGSDI ZLzL3pvV14dcsoajdeIH45i8DxnVm64BvEFHtLNlnliMrLOrk4shfmWyUqNlzilXN2BTFVFH 4MrnagFdcFnWYp1JPh96ZKjiqBwMv/H0kw==
Message-ID: <04c0827d-6a94-77ef-a1f5-ad5f4ed93956@cs.tcd.ie>
Date: Thu, 20 Aug 2020 19:47:50 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <9fc1db17-3f9d-4d32-b4a6-1c4e807a8321@www.fastmail.com>
Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="UKCLrSIcIe4mtAV6Y8oVic7FO41itpTop"
Archived-At: <https://mailarchive.ietf.org/arch/msg/cfrg/7rIudmPJoK9Q7LIvZzK907Khw-c>
Subject: Re: [Cfrg] hpke encoding of DH output
X-BeenThere: cfrg@irtf.org
X-Mailman-Version: 2.1.29
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, 20 Aug 2020 18:47:58 -0000


On 20/08/2020 19:43, Christopher Wood wrote:
> On Thu, Aug 20, 2020, at 11:29 AM, Richard Barnes wrote:
>> Hi Stephen,
>>
>> I think you're right here.  I just re-checked both the NIST and SECG 
>> specifications for ECDH [1][2], and they're in agreement that the 
>> secret value is the X-coordinate.  I'll work with my coauthors to get 
>> this implemented.
> 
> A proposed fix is here:
> 
>    https://github.com/cfrg/draft-irtf-cfrg-hpke/pull/148

LGTM, thanks both.

S.


> 
> Thanks,
> Chris
> 
>>
>> --Richard
>>
>> [1] Section 5.7.1.2 of 
>> https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-186-draft.pdf
>> [2] Section 3.3.1 of https://www.secg.org/sec1-v2.pdf
>>
>>
>>
>> On Thu, Aug 20, 2020 at 2:04 PM Stephen Farrell 
>> <stephen.farrell@cs.tcd.ie> wrote:
>>>
>>> Hi,
>>>
>>> I ran into an interop problem with draft-05 that I think is
>>> worth bringing to the list.
>>>
>>> Draft-05 says:
>>>
>>> "For the variants of DHKEM defined in this document, the
>>> size Ndh of the Diffie-Hellman shared secret is equal to
>>> Npk, and the size Nsecret of the KEM shared secret is equal
>>> to the output length of the hash function underlying the
>>> KDF."
>>>
>>> What that means is that, for the NIST curves, the DH
>>> value (used to be zz I think) is represented as a public
>>> key in uncompressed form. My code uses the OpenSSL
>>> EVP_PKEY_derive() function (same as it did for draft-02)
>>> which only gives me the X co-ordinate, and OpenSSL doesn't
>>> seem to have an easy way to get the uncompressed version
>>> from that. I don't know, but I'd guess that other libraries
>>> might be similar. In draft-02 only the X co-ordinate was
>>> used btw, and I don't recall this change being brought
>>> up on the list.
>>>
>>> I don't think there's any security benefit in treating
>>> the output of the DH operation as a public key. If there
>>> were, then I'd be fine with changing to use lower level
>>> calls to do the DH operation. But that seems a bit wrong,
>>> so I'd argue that we'd be better to not treat the DH
>>> shared secret value as a public key when encoding that.
>>>
>>> Separately, it'd be good to add those values to the
>>> test vectors - took me a while to find this - in the
>>> end I had to add more tracing to the go implementation
>>> to spit out these values.
>>>
>>> Lastly, even if we don't make a change, it'd be good
>>> to add text to clarify this, but I think I'd prefer we
>>> make the change if there's no security downside.
>>>
>>> Cheers,
>>> S.
>>> _______________________________________________
>>> Cfrg mailing list
>>> Cfrg@irtf.org
>>> https://www.irtf.org/mailman/listinfo/cfrg
>> _______________________________________________
>> Cfrg mailing list
>> Cfrg@irtf.org
>> https://www.irtf.org/mailman/listinfo/cfrg
>>
> 
> _______________________________________________
> Cfrg mailing list
> Cfrg@irtf.org
> https://www.irtf.org/mailman/listinfo/cfrg
>