RE: Problems verifying sample packet protection in appendix A of Using TLS to Secure QUIC

tim.jebb@bt.com Wed, 29 July 2020 12:36 UTC

Return-Path: <tim.jebb@bt.com>
X-Original-To: quic@ietfa.amsl.com
Delivered-To: quic@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 869DF3A0A4D for <quic@ietfa.amsl.com>; Wed, 29 Jul 2020 05:36:15 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.098
X-Spam-Level:
X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, MISSING_HEADERS=1.021, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=no autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=bt.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 gpMkqRiHQqzW for <quic@ietfa.amsl.com>; Wed, 29 Jul 2020 05:36:13 -0700 (PDT)
Received: from smtpe1.intersmtp.com (smtpe1.intersmtp.com [213.121.35.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id AD5DA3A0A49 for <quic@ietf.org>; Wed, 29 Jul 2020 05:36:12 -0700 (PDT)
Received: from tpw09926dag07e.domain1.systemhost.net (10.9.202.34) by BWP09926078.bt.com (10.36.82.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1713.5; Wed, 29 Jul 2020 13:35:59 +0100
Received: from tpw09926dag13g.domain1.systemhost.net (10.9.212.29) by tpw09926dag07e.domain1.systemhost.net (10.9.202.34) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 29 Jul 2020 13:36:09 +0100
Received: from bwp09926080.bt.com (10.36.82.111) by tpw09926dag13g.domain1.systemhost.net (10.9.212.29) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Wed, 29 Jul 2020 13:36:09 +0100
Received: from GBR01-LO2-obe.outbound.protection.outlook.com (104.47.21.53) by smtpe1.intersmtp.com (10.36.82.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1713.5; Wed, 29 Jul 2020 13:36:07 +0100
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SmUFgyXsIXP5VeKvnn80m1wuX8jmCgViNuSqkl/7nCdfeZABLOzmy3EwiJV3aDppG/ixVpg72YnYT3IFMONr0x4F9K1h09LegZj9nkFrNUt3EAUmh1Mz0FSTiOAccd72UMgSyC+V2ZBeR1B8ai/FhEQU/fSPFujP06tVbVqOSiOM3vjK7bMHjZU0hjpxkg/WX1c0HvrtzW859CioI4jOnGef4xqrqucDzjsOJc9zBayUa7QlmqgYptg5F9cBbDJb2OLgK0SfCgRxqWuEL9t033fRyjzd/oZSYi6loe+PUEfO/JlStVt9U2I4fCU11Ipvk3cyUfwQuWDEyBhHn9BrBQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s/PO47AX01/JJaJZA2feZvte5Oea8dfUNP/0kWzTrBc=; b=TNND5x9xNwPlsaH1qRYwOQJnEK7FVeXIsm/yV6WgTbB32vAKivWZA/44CcRqZEh/O/lENroCJR1r7A/RbBxqduF3BdepbH0Behj0KzYkRu97DkDyfUFq3sPL2YwdderbWrtBZ8apHaweviEejC4kxYvpleDIHge3119W06DmG5MYUYFaSFq8+3KSVnUtqnqN4wRlA31nwpreYWGUKqstWcZgoJswbDtos/fRXPlHHeYGU7ZQxxDtN3DPbLeTehEI6GRadg6KYpqCHWn9Y06BondFa/zz43Cx4GY4Do7z7I38k0pI8iCj1Z/vUKkZDmkNtatd47HGzOXl/QZmAO5prg==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bt.com; dmarc=pass action=none header.from=bt.com; dkim=pass header.d=bt.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bt.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s/PO47AX01/JJaJZA2feZvte5Oea8dfUNP/0kWzTrBc=; b=Ctb1x43KkalWKA8h49ize0nrtDxhB/Gl1hoXJelDwqHCJXsTaRi97kIWTMvfRZoq8vK5c7eFiR2nXK1/tx7fPFR46w5w2KEES0VVC2iMLRKWV0aJeaM3lfIqPbBklqfJyroMUYz/lGXVWP+44Kl1set+Jcd6acsNFNd+Oirf4Xw=
Received: from LNXP123MB2460.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:dc::10) by LO3P123MB3580.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:10a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.16; Wed, 29 Jul 2020 12:36:08 +0000
Received: from LNXP123MB2460.GBRP123.PROD.OUTLOOK.COM ([fe80::ec07:dcb5:1747:4632]) by LNXP123MB2460.GBRP123.PROD.OUTLOOK.COM ([fe80::ec07:dcb5:1747:4632%7]) with mapi id 15.20.3239.016; Wed, 29 Jul 2020 12:36:08 +0000
From: tim.jebb@bt.com
CC: quic@ietf.org
Subject: RE: Problems verifying sample packet protection in appendix A of Using TLS to Secure QUIC
Thread-Topic: Problems verifying sample packet protection in appendix A of Using TLS to Secure QUIC
Thread-Index: AdZZ60hBgJSiLWoSRDqZxGYKUQVBHwAI+HGAAVk5nPABjDC4QA==
Date: Wed, 29 Jul 2020 12:36:08 +0000
Message-ID: <LNXP123MB2460A8EB35971933082835C3F2700@LNXP123MB2460.GBRP123.PROD.OUTLOOK.COM>
References: <LNXP123MB2460833EC5BC592C8D410EDCF2610@LNXP123MB2460.GBRP123.PROD.OUTLOOK.COM> <CACdeXi+EUWRGoT7pWrqnEbQK9EoT0ERr7pKFmtOQ3pQZc9wfCw@mail.gmail.com> <LO2P123MB2462F4CDAD99B8E3DAA39F9FF2780@LO2P123MB2462.GBRP123.PROD.OUTLOOK.COM>
In-Reply-To: <LO2P123MB2462F4CDAD99B8E3DAA39F9FF2780@LO2P123MB2462.GBRP123.PROD.OUTLOOK.COM>
Accept-Language: en-GB, en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: ietf.org; dkim=none (message not signed) header.d=none;ietf.org; dmarc=none action=none header.from=bt.com;
x-originating-ip: [31.51.248.139]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 1fac3b16-5ce7-40bf-e774-08d833bbf7cb
x-ms-traffictypediagnostic: LO3P123MB3580:
x-microsoft-antispam-prvs: <LO3P123MB35805063F21D73CA30963BC7F2700@LO3P123MB3580.GBRP123.PROD.OUTLOOK.COM>
x-antispam-2: 1
x-ms-oob-tlc-oobclassifiers: OLM:9508;
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: SwHyZdJPCiIoL9HlmM3t7SaBFjfOfOpCwN7dBaN0zIgv+/Ao7Cwn9v0wJZHRNplRWool8Nbx6gHr91Us2KRnCvimEI6+HaPQ+VhEGZ8Odkxmd5LGDI5qxnSEaoVNuj5YctDyhOChftUgzbuLS2c8VRbjEP6La/16Nl+MZJ5ONHaPE5eU4+kFp7ldMZfH5CNduh6FNSkNefP16oFSo4/bHevVHmOgxb8t80OwOP4DKz0E+RP6q9Bv22Bqv+Hrdox4SJtaPxzJmtX+n4w/Q8faNwRbNiaC8yoxXsx30p47t8zUPvjFDB3rOXbDFUDSn6xZbUaLcDzEn229IZEk2vADz7uZ0nkB9DGmzP6NjXpwDuEAL5dyh36RjWaZPM2HN2TAuLHqKs5DYT9LdamCpseM0w==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:LNXP123MB2460.GBRP123.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(376002)(366004)(39860400002)(396003)(346002)(136003)(186003)(33656002)(16799955002)(71200400001)(52536014)(5660300002)(53546011)(109986005)(6506007)(4326008)(26005)(478600001)(55236004)(316002)(64756008)(66946007)(66556008)(66446008)(66476007)(166002)(966005)(76116006)(83380400001)(86362001)(55016002)(15650500001)(2906002)(8936002)(7696005)(8676002)(9686003); DIR:OUT; SFP:1101;
x-ms-exchange-antispam-messagedata: jW+6vaKe+mbEoVanstiH4K2ReiI+T31GCihJvnf+BQQghkBh9Q3Z8kWliXYFlesuBnpfHUAvgewzJ+bYSy92cwyEBbRPblebgamFgYMxscLu5azgeCLRfrR1bxfaXJi/lr6sy3ffYRZ2y/q3ASJaVs2lHF9CNNJ3PXFwBxhPY3hWJ4PcdMGDzV5r7G9R4x8pVtMGUeFGGLhgsqmSKWh12VSGd19JnvHqu9zUclrZKmrpe5LvFsS2R7y+/7hkOd45KLsSrYes95hLMZqGqxIrfI7KIXsYCmIrxP1Xw3fVKXikAumcrLcNREjSm8vrGCa7r+lg8U9T445XfP2frpzkcNz4iwD4FqHnsU3h+34VNFdRaLYuuUF9k6yYA831prWawMHzAa1SkDVE/a6k1liMlQAqRQHs/iPip+bzs01YVVSRtCyEBwPdNhqMWX00wfqnOOE44ZuR/w79U3qfwk8tyxh+go2q0b4fncNOftfvhTwql08MvsmF5YZGCQ6V9iT0Mfw9N05pMiYcyiKSrr/uV/pRCBuVs2ghym8hdO/0/CxPznXFeJfQ2c7OnRSB1julvGXpep52Ba8sIx6U9iyi1UfawwVnIKS1AJYgz3Db5HIsq+B55/OUHK50IoK7riyTQ+eR2NFLLJY5WLLVYT80KA==
x-ms-exchange-transport-forked: True
Content-Type: multipart/alternative; boundary="_000_LNXP123MB2460A8EB35971933082835C3F2700LNXP123MB2460GBRP_"
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: LNXP123MB2460.GBRP123.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-Network-Message-Id: 1fac3b16-5ce7-40bf-e774-08d833bbf7cb
X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jul 2020 12:36:08.1202 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: a7f35688-9c00-4d5e-ba41-29f146377ab0
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: TDuP2zltbeVeenTZ1J0MmSHH/7N+jYzHwMHcn4fuomaDGp2Ht1KyJox9OGPQYQvt
X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO3P123MB3580
X-OriginatorOrg: bt.com
Archived-At: <https://mailarchive.ietf.org/arch/msg/quic/FaQyeHz85TIotzDpvbE0wAs7_eQ>
X-BeenThere: quic@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Main mailing list of the IETF QUIC working group <quic.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/quic>, <mailto:quic-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/quic/>
List-Post: <mailto:quic@ietf.org>
List-Help: <mailto:quic-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/quic>, <mailto:quic-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 29 Jul 2020 12:36:16 -0000

Just an update:  I’ve got to the bottom of my problem:  I hadn’t realised that the salt changes between drafts of the RFC!

From: tim.jebb@bt.com <tim.jebb@bt.com>
Sent: 21 July 2020 16:43
To: nharper@google.com
Cc: quic@ietf.org
Subject: RE: Problems verifying sample packet protection in appendix A of Using TLS to Secure QUIC

Hi,

Unfortunately I’m still having problems removing packet protection.

Although I can now successfully process the sample packet in the draft RFC (thanks to Nick), my first attempt at a captured packet is failing (using the same code).  I can’t see where I’m going wrong.  It’s the header protection removal I’m having problems with.

If it’s not too much to ask, would anyone be in a position to process the client initial packet below, and give the intermediate values along the lines of those given in appendix A?

The packet is

uint8_t protected_frame1[302] =
{0xc8,0xff,0x00,0x00,0x1b,0x11,0x76,0xf8,0x1a,0x55,0x88,0xb2,0xf2,0x5c,0x5a,0xb6,
0xdb,0xd4,0x61,0xa8,0xd7,0x49,0xe1,0x03,0xc5,0xef,0x02,0x00,0x41,0x10,0xb0,0xbd,
0x14,0x04,0xf5,0x35,0x17,0x7f,0xcb,0xcf,0xd5,0xf0,0x6d,0x24,0xff,0xde,0x66,0xed,
0xf1,0x0d,0xf7,0x92,0x05,0x66,0x6b,0x18,0x51,0x18,0x9f,0x54,0xa0,0x92,0x7d,0xf2,
0x30,0xb5,0xcb,0xd7,0xc9,0x6d,0xe6,0xc5,0x76,0xe5,0x59,0x42,0x23,0x1e,0xc8,0x53,
0x9f,0xf2,0x82,0xe2,0xcf,0xd7,0x53,0x83,0x8b,0x12,0x53,0xce,0x19,0x5c,0xd6,0x32,
0x22,0x5d,0xe0,0xca,0x2e,0x37,0x42,0xc1,0xda,0x08,0x4d,0xa4,0xd1,0x18,0xc7,0x75,
0x7c,0x3c,0xae,0x3b,0xf6,0x95,0xa2,0xc6,0x83,0x99,0x97,0x9f,0x98,0x0d,0xdb,0xa6,
0xa9,0x77,0xbd,0xba,0x31,0x20,0xb2,0x8b,0xe8,0x0e,0x0b,0xe9,0xe0,0x89,0x3f,0x05,
0x8d,0xdd,0x8d,0x7b,0xe3,0x90,0xde,0xd6,0x68,0x79,0x62,0x8d,0x47,0xb7,0x47,0x78,
0x17,0x4e,0x9e,0x65,0x93,0xce,0x81,0x17,0xbf,0x5f,0x4b,0x16,0xb8,0x8d,0xe3,0x48,
0x4f,0x97,0x7e,0x22,0xde,0xd8,0x6e,0xb2,0x9b,0x00,0xbd,0xa4,0xa4,0xfb,0x74,0x9c,
0xee,0x83,0x29,0xd6,0xf1,0x32,0xb3,0x91,0xbb,0x6e,0x9a,0x93,0x71,0x61,0xc4,0xd9,
0xeb,0x30,0x2f,0x43,0x73,0x20,0xe4,0x78,0x29,0xff,0xe7,0x19,0x11,0x97,0xe8,0x33,
0xd5,0x47,0xd1,0x6e,0xc1,0xdc,0x91,0x0f,0xd6,0xfe,0xac,0x64,0x94,0x99,0x00,0xb9,
0x91,0x79,0xf6,0x1c,0x11,0x85,0x44,0xd1,0x9f,0x56,0xbe,0x3f,0x4f,0x52,0xa7,0x2c,
0x52,0x3d,0x2b,0x41,0xe0,0x42,0xa7,0x4c,0xbc,0x31,0xd4,0xb3,0xa4,0x55,0xde,0xce,
0x0c,0xbe,0x9d,0x29,0x59,0xdf,0xf8,0xfb,0x53,0x0c,0x64,0x2e,0xb5,0x2d,0xa4,0x3d,
0xea,0xf9,0x90,0x8c,0x1b,0x0b,0xd5,0x0d,0x44,0x59,0xe0,0xe4,0x74,0x85};

From: Nick Harper <nharper@google.com<mailto:nharper@google.com>>
Sent: 14 July 2020 19:47
To: Jebb,TR,Tim,VIE R <tim.jebb@bt.com<mailto:tim.jebb@bt.com>>
Cc: IETF QUIC WG <quic@ietf.org<mailto:quic@ietf.org>>
Subject: Re: Problems verifying sample packet protection in appendix A of Using TLS to Secure QUIC



On Tue, Jul 14, 2020 at 9:06 AM <tim.jebb@bt.com<mailto:tim.jebb@bt.com>> wrote:
Hi,

I’m working through Appendix A of the QUIC TLS doc to check my understanding, but am having trouble decrypting the sample client initial packet.  I’m unsure if I’ve made a silly error or two, or if I’ve made one or more incorrect assumptions.  Or both.

The functions I’m using are the OpenSSL EVP ones.  I’m attempting to follow the recipe here:
https://wiki.openssl.org/index.php/EVP_Authenticated_Encryption_and_Decryption#Authenticated_Decryption_using_GCM_mode in conjunction with the draft RFC.


EVP_CIPHER_CTX_new()

EVP_DecryptInit_ex(ctx, EVP_aes_128_gcm(), NULL, NULL, NULL)

EVP_DecryptInit_ex(ctx, NULL, NULL, client_key, iv)         where the client key is 0x175257a31eb09dea9366d8bb79ad80ba and the iv is 0x6b26114b9cba2b63a9e8dd4f

You need to compute the nonce from the IV and the packet number. I assume what the openssl documentation refers to as an IV is actually the nonce as described in RFC 5116.

EVP_DecryptUpdate(ctx, NULL, &len, pUnprotectedHeader, headerLength)           where the unprotected header is 0xc3ff00001d088394c8f03e5157080000449e00000002 – this I believe is the Additional Data required

EVP_DecryptUpdate(ctx, decryptedPayload, &len, pPayload, payloadLength-16))   here I’m passing in the encrypted payload beginning 0xfb66bc5f and ending 0xe82a4d919d48, length 1162.  I’m assuming that the final 16 bytes of the payload is the authentication tag so am not passing it in here.  Note that if this assumption about the authentication tag is correct, I think it could be more clearly stated in the draft RFC.

This is a quirk of the openssl API unfortunately. An AEAD decryption operation should take 4 inputs: the key, the nonce, the associated data, and the ciphertext. The ciphertext, as defined by RFC 5116, includes the tag. There's no requirement on the structure of an AEAD's ciphertext, including that some portion of the ciphertext be able to be identified as a tag. AES-GCM does have this structure where the tag is at the end of the ciphertext, and unfortunately openssl makes that part of the api for the AEAD open operation, even though someone using it should never have to know that detail of the AES-GCM algorithm.

EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, 16, tag) where tag is the final 16 bytes of the encrypted payload, ie 0x43b1ca70 a2d8d3f7 25ead139 1377dcc0

EVP_DecryptFinal_ex(ctx, decryptedPayload + len, &len)

Everything seems OK until the EVP_DecryptFinal_ex() call which fails.

Is there anything obviously wrong with the above?  I’ve not posted the full source code as I’m not asking people to check my working, I’m really asking if my assumptions are correct, am I using the correct functions, input data etc.

Thanks in advance

Tim