[MLS] Encoding padding as variable-size vector

"Alwen, Joel" <alwenjo@amazon.com> Thu, 21 April 2022 15:10 UTC

Return-Path: <prvs=10327f731=alwenjo@amazon.com>
X-Original-To: mls@ietfa.amsl.com
Delivered-To: mls@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 22F2C3A17CF for <mls@ietfa.amsl.com>; Thu, 21 Apr 2022 08:10:55 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -14.611
X-Spam-Level:
X-Spam-Status: No, score=-14.611 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_SPF_WL=-7.5] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=amazon.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 HwoaUtazfIKx for <mls@ietfa.amsl.com>; Thu, 21 Apr 2022 08:10:53 -0700 (PDT)
Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id D06843A186F for <mls@ietf.org>; Thu, 21 Apr 2022 08:10:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1650553853; x=1682089853; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=lddgwUg8YsbRs2NzMTKU2Z/FIwXaeayb9xoKBEgENt4=; b=qwPLbSVLTEPPh6XpG7t3pbrcKJB/qGldJSENRg8Kdc6BlrYoJkJLtByE NR1EgV4FXv/YhM6DfeQiDgcSctrugwK1OMGF8Ow9ML5rirMn3YZIodwhN nBzj5h09cerF1XLblW7zXcO3csmb6IYZe3YpgCuNlmw3Q///RSnkPgteu E=;
X-IronPort-AV: E=Sophos;i="5.90,279,1643673600"; d="scan'208";a="195177918"
Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-pdx-2c-a264e6fe.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP; 21 Apr 2022 15:10:40 +0000
Received: from EX13D48EUB002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2c-a264e6fe.us-west-2.amazon.com (Postfix) with ESMTPS id 5A3A54159C for <mls@ietf.org>; Thu, 21 Apr 2022 15:10:38 +0000 (UTC)
Received: from EX13D48EUB002.ant.amazon.com (10.43.166.35) by EX13D48EUB002.ant.amazon.com (10.43.166.35) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Thu, 21 Apr 2022 15:10:37 +0000
Received: from EX13D48EUB002.ant.amazon.com ([10.43.166.35]) by EX13D48EUB002.ant.amazon.com ([10.43.166.35]) with mapi id 15.00.1497.033; Thu, 21 Apr 2022 15:10:37 +0000
From: "Alwen, Joel" <alwenjo@amazon.com>
To: "mls@ietf.org" <mls@ietf.org>
Thread-Topic: Encoding padding as variable-size vector
Thread-Index: AdhVj6PTTzmLP8fwSaqHiJmt+UUMOQ==
Date: Thu, 21 Apr 2022 15:10:37 +0000
Message-ID: <9aa90871231e4291bb2a4d782b7b91c1@EX13D48EUB002.ant.amazon.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-exchange-transport-fromentityheader: Hosted
x-originating-ip: [10.43.164.90]
Content-Type: text/plain; charset="iso-8859-1"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/mls/uqXL0UprgE7sf6NGkV5dg1yFRxk>
X-Mailman-Approved-At: Tue, 26 Apr 2022 18:55:22 -0700
Subject: [MLS] Encoding padding as variable-size vector
X-BeenThere: mls@ietf.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: Messaging Layer Security <mls.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/mls>, <mailto:mls-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/mls/>
List-Post: <mailto:mls@ietf.org>
List-Help: <mailto:mls-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/mls>, <mailto:mls-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 21 Apr 2022 15:13:42 -0000

In the MLSCiphertextContent struct we have a field for padding represented using a variable-size vector which helps hide information about the length of content; notably application messages. But because of the way we encode variable-size vectors it turns out you can't actually pad the rest of the content with certain number of bytes: namely 0, 65, 16386, 16387. (E.g. if you pad with a vector of 63 bytes the TLS encoding actually produces 64 bytes for padding: 63 bytes + 1 length byte. But if you pad with 64 bytes you end up with a 66 byte encoding as now you need 2 bytes for the length.

Not being able to pad with 0 is OK. But 65 is kind of annoying. E.g. if you want to pad to a target content length X bytes then if the rest of the content ends up being X-65 bytes long you are out of luck. (Assuming I'm right about how this all works) it seems a bit silly to me for a padding scheme to have somewhat arbitrary gaps like that; especially at a not unreasonable number of bytes to want to pad with.

If I didn't miss something, and you all agree that its better to avoid having gaps like that then how about represent padding as, say, a fixed length vector's?

- Joël


Amazon Development Center Austria GmbH
Brueckenkopfgasse 1
8020 Graz
Oesterreich
Sitz in Graz
Firmenbuchnummer: FN 439453 f
Firmenbuchgericht: Landesgericht fuer Zivilrechtssachen Graz