Re: [Sframe] Question about sframe_salt

"Mularczyk, Marta" <mulmarta@amazon.ch> Fri, 04 August 2023 13:45 UTC

Return-Path: <prvs=573a891a7=mulmarta@amazon.ch>
X-Original-To: sframe@ietfa.amsl.com
Delivered-To: sframe@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 14817C169521 for <sframe@ietfa.amsl.com>; Fri, 4 Aug 2023 06:45:31 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.404
X-Spam-Level:
X-Spam-Status: No, score=-4.404 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=amazon.ch
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2z7q5AwxPi3T for <sframe@ietfa.amsl.com>; Fri, 4 Aug 2023 06:45:27 -0700 (PDT)
Received: from smtp-fw-80009.amazon.com (smtp-fw-80009.amazon.com [99.78.197.220]) (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 E2DF5C151AFD for <sframe@ietf.org>; Fri, 4 Aug 2023 06:45:26 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.ch; i=@amazon.ch; q=dns/txt; s=amazon201209; t=1691156726; x=1722692726; h=from:to:cc:date:message-id:references:in-reply-to: mime-version:subject; bh=kDn6yD79MzMqbaoXFXJoMns+b2gPro0QANO1mCDYroA=; b=Qc3JsCVhor/fCYxXY+7YARveV8QIA6ufW0r5rLbP9bNISxG8Z1nbEVYp tgQoCXXvvlBhgowEMB2oVeFUiJrceDOfCwOLL072JBaONGS5PG/F6bMCu Sj7LmLf0pf3Lw3xZKPOUoz3Uu8eP8HzY7ciuTCbkpQM/kav6SO0vEbAEG 4=;
X-IronPort-AV: E=Sophos; i="6.01,255,1684800000"; d="scan'208,217"; a="20572149"
Thread-Topic: [Sframe] Question about sframe_salt
Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1e-m6i4x-529f0975.us-east-1.amazon.com) ([10.25.36.214]) by smtp-border-fw-80009.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2023 13:45:25 +0000
Received: from EX19D020EUA002.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1e-m6i4x-529f0975.us-east-1.amazon.com (Postfix) with ESMTPS id ECC094712F; Fri, 4 Aug 2023 13:45:24 +0000 (UTC)
Received: from EX19D027EUC002.ant.amazon.com (10.252.61.165) by EX19D020EUA002.ant.amazon.com (10.252.50.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Fri, 4 Aug 2023 13:45:24 +0000
Received: from EX19D027EUC001.ant.amazon.com (10.252.61.221) by EX19D027EUC002.ant.amazon.com (10.252.61.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Fri, 4 Aug 2023 13:45:24 +0000
Received: from EX19D027EUC001.ant.amazon.com ([fe80::bb51:11a0:d28b:f79e]) by EX19D027EUC001.ant.amazon.com ([fe80::bb51:11a0:d28b:f79e%3]) with mapi id 15.02.1118.030; Fri, 4 Aug 2023 13:45:24 +0000
From: "Mularczyk, Marta" <mulmarta@amazon.ch>
To: Richard Barnes <rlb@ipv.sx>
CC: "sframe@ietf.org" <sframe@ietf.org>
Thread-Index: AQHZxixvDcE/RoaZ60OHm/RJZ6sIfq/Y4RCAgAFFUVw=
Date: Fri, 04 Aug 2023 13:45:23 +0000
Message-ID: <36e35625b97340bba78f9336b7bf6b5a@amazon.ch>
References: <946e9afba6bc430bae83a135105c26e6@amazon.ch>, <CAL02cgT63W27xEbf6oxYomh_1tNN3X-CL7M5xAQkbqt-nsy5Yw@mail.gmail.com>
In-Reply-To: <CAL02cgT63W27xEbf6oxYomh_1tNN3X-CL7M5xAQkbqt-nsy5Yw@mail.gmail.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-originating-ip: [10.252.51.69]
Content-Type: multipart/alternative; boundary="_000_36e35625b97340bba78f9336b7bf6b5aamazonch_"
MIME-Version: 1.0
Archived-At: <https://mailarchive.ietf.org/arch/msg/sframe/0ikMAGw51Xpe0cqaeqepBJi4alo>
Subject: Re: [Sframe] Question about sframe_salt
X-BeenThere: sframe@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: Secure Media Frames <sframe.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/sframe>, <mailto:sframe-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/sframe/>
List-Post: <mailto:sframe@ietf.org>
List-Help: <mailto:sframe-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/sframe>, <mailto:sframe-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 04 Aug 2023 13:45:31 -0000

Oh, interesting! Thanks for finding all that!

The [MF00] reference was quite helpful.

What I understood is that it's not about the IV being secret but about it not being repeated between different secret keys. Using the same IV would allow an attacker to build a variant of a rainbow table which allows to quickly recover secret keys. And of course using IV = CTR means we all use IV = 0 at the beginning.

-Marta


________________________________
From: Sframe <sframe-bounces@ietf.org> on behalf of Richard Barnes <rlb@ipv.sx>
Sent: Thursday, August 3, 2023 8:17:05 PM
To: Mularczyk, Marta
Cc: sframe@ietf.org
Subject: RE: [EXTERNAL] [Sframe] Question about sframe_salt


CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.


The construction here is just mimicking what SRTP does for AES-CTR IV formation [1]:

> IV = (k_s * 2^16) XOR (SSRC * 2^64) XOR (i * 2^16)

The differences here are just that (1) the SFrame CTR value replaces the SRTP counter `i` and (2) we allow for 32 bits of counter instead of 16.  There is some rationale in RFC 3711 for this design [2]:

>   The effective key size is determined (upper bounded) by the size of
>   the master key and, for encryption, the size of the salting key.  Any
>   additive stream cipher is vulnerable to attacks that use statistical
>   knowledge about the plaintext source to enable key collision and
>   time-memory tradeoff attacks [MF00] [H80] [BS00].

If I understand correctly, the core thing the salt does is make sure that the IV is unknown to any attacker who doesn't also have the key, so that the attacker can't perform certain attacks that would require knowledge of the IV.  Just using nonce = CTR would obviously make the nonce known to the attacker.  This pattern turns out to be pretty universal in protocols that encrypt streams of objects:

* TLS/DTLS XORs a per-record sequence number with a per-stream `client/server_write_iv` [3]
* MLS derives a completely fresh nonce for each message it protects [4]
* IPsec ESP has an explicit IV, but the GCM integration adds a random salt [5]
* SSH derives IVs from secret state via hashing [6]
* HPKE XORs a message counter with a "base nonce" [7]
* NaCl doesn't specify a nonce formation, but notes "Choosing the nonce as a counter followed by (e.g.) 32 random bits helps protect some protocols against denial-of-service attacks" [8]

The only exception I came across in a brief search is Noise, which appears to use an unmodified counter for its nonce [9].

--Richard

[1] https://datatracker.ietf.org/doc/html/rfc3711#section-4.1.1
[2] https://datatracker.ietf.org/doc/html/rfc3711#section-7.2
[3] https://datatracker.ietf.org/doc/html/rfc8446#section-5.3
[4] https://datatracker.ietf.org/doc/html/rfc9420#name-encryption-keys
[5] https://datatracker.ietf.org/doc/html/rfc4106#section-3.1
[6] https://datatracker.ietf.org/doc/html/rfc4253#section-7.2
[7] https://datatracker.ietf.org/doc/html/rfc9180#name-encryption-and-decryption
[8] https://cr.yp.to/highspeed/naclcrypto-20090310.pdf
[9] http://www.noiseprotocol.org/noise.html#security-considerations



On Thu, Aug 3, 2023 at 1:05 PM Mularczyk, Marta <mulmarta=40amazon.ch@dmarc.ietf.org<mailto:40amazon.ch@dmarc.ietf.org>> wrote:

Hi all!


Another small question, this time not necessarily to change anything. Why is the nonce computed as xor(sframe_salt, CTR) instead of nonce = CTR? Is there an attack this prevents?


Best,

Marta

--
Sframe mailing list
Sframe@ietf.org<mailto:Sframe@ietf.org>
https://www.ietf.org/mailman/listinfo/sframe