Re: [TLS] HMAC context of ClientFinished in TLS 1.3

Kazuho Oku <kazuhooku@gmail.com> Fri, 07 October 2016 11:56 UTC

Return-Path: <kazuhooku@gmail.com>
X-Original-To: tls@ietfa.amsl.com
Delivered-To: tls@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 97E07129537 for <tls@ietfa.amsl.com>; Fri, 7 Oct 2016 04:56:35 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.7
X-Spam-Level:
X-Spam-Status: No, score=-2.7 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.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 8ZvNCaEsb2vz for <tls@ietfa.amsl.com>; Fri, 7 Oct 2016 04:56:34 -0700 (PDT)
Received: from mail-pf0-x230.google.com (mail-pf0-x230.google.com [IPv6:2607:f8b0:400e:c00::230]) (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 48EB0129510 for <tls@ietf.org>; Fri, 7 Oct 2016 04:56:34 -0700 (PDT)
Received: by mail-pf0-x230.google.com with SMTP id 128so3988135pfz.2 for <tls@ietf.org>; Fri, 07 Oct 2016 04:56:34 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:mime-version:subject:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=lCgtFdNNlmLW9O/pO1To6BeWOepelb2Ho/4rOqtujtc=; b=xgIYXriVjAJCcMqkWYmlrCyJL5vGWLt9bpc+M32J5lmA1I4gy6LJiRqeWISYC2LIAC 5I/bKlWR/6xRiuNRAmekCZZx8OPtL0sK9k+JWCxXZnptWofslwjegkVx42lbEdAMJ6tf n7CP+PLOSpkqVwloyraTIT+RG4sg9bZHtaoJdonpPxg0dg1O61iRLUsG3JfSnFfRtEq1 GFrQYM93hlcfX0uGJFVWNbj9uSnxioCAtqW4srLin6MkIYNvyIrVv42q/wM3U48io07o r2ZRztIAbZWSC9ButljvZsvJ5xNa9XiJpwmyeY8EY4WT6jCKJaoxXYdA0wAGEmlyH9s3 BqkQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:subject:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=lCgtFdNNlmLW9O/pO1To6BeWOepelb2Ho/4rOqtujtc=; b=Be0CTEVQ9jJQQ/6hPNn/HmPh0Rb5OLS3zHu/+eqBEiSawZ8ybZQhSo4PXUh96B59+D fEyvqob+sQuMQYzWCKI3ySAOl54flfk/GAKhHownD6rpQUZ3hCEnwz74b66lit9i+AkZ LOJ8SGnt4gylIMTJyoh+YMtiD2hT+ZLYJlTrpM/XFg463lsFxlHSACfLFtrHo6rBjCER T2PMWknBxs4wktCIben1Qjsl8NMVm2LNDCDy4qeHP22Px3NONBdGPgyNQZ+nIWh4er8c RlnAdrD4n+t0grksdxLKqHDWtSVbfn7/gCpir7i1F2qL4m/ZlkcxYKFJ4lMcWyGpqm1q 1mgA==
X-Gm-Message-State: AA6/9RkWAm9WRh15yLCXKB0/t6hJrCcEQvdEs7EVZsB3OM1uSXXOsSr1swrpI7/ybTUmhA==
X-Received: by 10.98.34.212 with SMTP id p81mr35963471pfj.18.1475841393594; Fri, 07 Oct 2016 04:56:33 -0700 (PDT)
Received: from [192.168.0.4] (p1679242-ipngn15801marunouchi.tokyo.ocn.ne.jp. [153.204.204.242]) by smtp.gmail.com with ESMTPSA id b197sm13465194pfb.52.2016.10.07.04.56.31 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Oct 2016 04:56:32 -0700 (PDT)
From: Kazuho Oku <kazuhooku@gmail.com>
X-Google-Original-From: Kazuho Oku <KAZUHOOKU@gmail.com>
Content-Type: text/plain; charset="iso-2022-jp"
Mime-Version: 1.0 (1.0)
X-Mailer: iPhone Mail (13G36)
In-Reply-To: <20161007101436.GA8774@LK-Perkele-V2.elisa-laajakaista.fi>
Date: Fri, 07 Oct 2016 20:56:29 +0900
Content-Transfer-Encoding: quoted-printable
Message-Id: <14A4B8BA-31FC-4C2A-BC6D-3C0F6F1A5FDD@gmail.com>
References: <CANatvzySkbddprp_mN3Hb4joscUPGANC4KwSz04K7hwRSSL48Q@mail.gmail.com> <20161007101436.GA8774@LK-Perkele-V2.elisa-laajakaista.fi>
To: Ilari Liusvaara <ilariliusvaara@welho.com>
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/2-YmiorvHtxqo0EvCdg4JmFdDms>
Cc: tls@ietf.org
Subject: Re: [TLS] HMAC context of ClientFinished in TLS 1.3
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.17
Precedence: list
List-Id: "This is the mailing list for the Transport Layer Security working group of the IETF." <tls.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/tls>, <mailto:tls-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/tls/>
List-Post: <mailto:tls@ietf.org>
List-Help: <mailto:tls-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/tls>, <mailto:tls-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 07 Oct 2016 11:56:35 -0000

Hi,

Thank you very much for the clarification and the advise.

I had indeed forgotten to consider the client certificate and its verify message.

iPhoneから送信

2016/10/07 19:14、Ilari Liusvaara <ilariliusvaara@welho.com> のメッセージ:

>> On Fri, Oct 07, 2016 at 06:41:35PM +0900, Kazuho Oku wrote:
>> Hi,
>> 
>> Recently I have started writing a TLS 1.3 implementation. While
>> working on it, I have noticed the following.
>> 
>> In section 4.4.3, the hash value used for building the HMAC is defined
>> as: Hash(Handshake Context + Certificate* + CertificateVerify*).
>> 
>> For ServerFinished, this corresponds to the statement following the
>> formula that states, quote:
>> 
>>    the HMAC input can generally be implemented by a running hash,
>> i.e., just the handshake hash at this point.
>> 
>> since Handshake Context for 1-RTT server is (as defined in section
>> 4.4): ClientHello … later of EncryptedExtensions/CertificateRequest.
>> 
>> However, for ClientFinished, the two descriptions do not match, since
>> Handshake Context for 1RTT client is: ClientHello … ServerFinished.
>> 
>> If we follow the way it is defined in the formula, then Certificate
>> and CertificateVerify needs to be applied to the hash after
>> ServerFinished, which is in discordance with the statement that it
>> could be implemented using a running hash.
> 
> Nope, it is a running hash:
> 
> The server Finished includes the following messages, in this order:
> 
> - ClientHello
> - HelloRetryRequest (if sent)
> - Clienthello (another, if HRR was sent)
> - ServerHello
> - EncryptedExtensions
> - CertificateRequest (if sent)
> - Certificate (server's)
> - CertificateVerify (server's)
> 
> And this exactly corresponds to the send/receive order.
> 
> 
> The client finished includes, in this order:
> 
> - ClientHello
> - HelloRetryRequest (if sent)
> - Clienthello (another, if HRR was sent)
> - ServerHello
> - EncryptedExtensions
> - CertificateRequest (if sent)
> - Certificate (server's)
> - CertificateVerify (server's)
> - Finished (server's)
> - Certificate (client's, if CR was sent).
> - CertificateVerify (client's, if non-empty client cert was sent)
> 
> And this exactly corresponds to the send/receive order.
> 
> 
> One place to be careful of is client application keys: The hash used
> for those is taken immediately after ServerFinished, but the keys are
> only commissioned after ClientFinished (whereas server keys have the
> hash taken in the same time as those are commissioned in).
> 
> 
> 
> -Ilari