Re: [AVTCORE] AES-GCM SRTP (RFC 7714) KDF implementation

"Cullen Jennings (fluffy)" <fluffy@cisco.com> Sat, 20 August 2016 13:29 UTC

Return-Path: <fluffy@cisco.com>
X-Original-To: avt@ietfa.amsl.com
Delivered-To: avt@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 53BE812D0A5 for <avt@ietfa.amsl.com>; Sat, 20 Aug 2016 06:29:20 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -115.768
X-Spam-Level:
X-Spam-Status: No, score=-115.768 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.247, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=cisco.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 caIxZwh5VyTS for <avt@ietfa.amsl.com>; Sat, 20 Aug 2016 06:29:18 -0700 (PDT)
Received: from rcdn-iport-8.cisco.com (rcdn-iport-8.cisco.com [173.37.86.79]) (using TLSv1.2 with cipher DHE-RSA-SEED-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 3732E12D0A3 for <avt@ietf.org>; Sat, 20 Aug 2016 06:29:18 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=3863; q=dns/txt; s=iport; t=1471699758; x=1472909358; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=lzEOg/dOVWJ2tMkBKBKGSrEoZGZJxxkl9AZXHgx5B4Y=; b=OGcOnrjgkjvT382RgI63iinA1akfuxnxUXYHFOPEAoC6dzC5Zs7XHu+r otsN2KBqNIEGqzGxuQKGRDpxMDQj3wn1vbF092BTfV5GCQ0p+7iTmN/Gv 2DJCJsh12+QiIDDIyWkHPONt2s/g0oGzIceWGJ5l33G/YyB5IpPuY2DMs 4=;
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: A0AIAgA+WrhX/5JdJa1eg0RWfAe3bYF9JIV5AoFYOBQCAQEBAQEBAV4nhF4BAQQBAQE4PwULAgEIGB4QJwslAgQBDQWIKQgOuxkBAQEBAQEBAQEBAQEBAQEBAQEBAQEXBYgjCIJNgTmDB4Msgi8FiCuRHQGGH4h/j1CMP4N3AR42gh+BW3CGL38BAQE
X-IronPort-AV: E=Sophos;i="5.28,549,1464652800"; d="scan'208";a="138012277"
Received: from rcdn-core-10.cisco.com ([173.37.93.146]) by rcdn-iport-8.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Aug 2016 13:29:17 +0000
Received: from XCH-RTP-004.cisco.com (xch-rtp-004.cisco.com [64.101.220.144]) by rcdn-core-10.cisco.com (8.14.5/8.14.5) with ESMTP id u7KDTG7L026403 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Sat, 20 Aug 2016 13:29:17 GMT
Received: from xch-rtp-004.cisco.com (64.101.220.144) by XCH-RTP-004.cisco.com (64.101.220.144) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Sat, 20 Aug 2016 09:29:16 -0400
Received: from xch-rtp-004.cisco.com ([64.101.220.144]) by XCH-RTP-004.cisco.com ([64.101.220.144]) with mapi id 15.00.1210.000; Sat, 20 Aug 2016 09:29:16 -0400
From: "Cullen Jennings (fluffy)" <fluffy@cisco.com>
To: Paul Jones <paulej@packetizer.com>, Eric Rescorla <ekr@rtfm.com>, Martin Thomson <martin.thomson@gmail.com>
Thread-Topic: [AVTCORE] AES-GCM SRTP (RFC 7714) KDF implementation
Thread-Index: AQHR+ubZ9mh23xIC9EenVde5Kf8BAw==
Date: Sat, 20 Aug 2016 13:29:16 +0000
Message-ID: <D5E3E4C0-9873-451F-BB6A-973BB03E4D32@cisco.com>
References: <em43c05a1d-4be9-4d0b-96f9-0ea529996685@sydney>
In-Reply-To: <em43c05a1d-4be9-4d0b-96f9-0ea529996685@sydney>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-exchange-messagesentrepresentingtype: 1
x-ms-exchange-transport-fromentityheader: Hosted
x-originating-ip: [10.20.249.165]
Content-Type: text/plain; charset="us-ascii"
Content-ID: <3E9BC3536CEF1F489041D94868B8D672@emea.cisco.com>
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Archived-At: <https://mailarchive.ietf.org/arch/msg/avt/9lPzX-FXpETE1sUM5mxFbZdRAJ8>
Cc: "avt@ietf.org" <avt@ietf.org>
Subject: Re: [AVTCORE] AES-GCM SRTP (RFC 7714) KDF implementation
X-BeenThere: avt@ietf.org
X-Mailman-Version: 2.1.17
Precedence: list
List-Id: Audio/Video Transport Core Maintenance <avt.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/avt>, <mailto:avt-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/avt/>
List-Post: <mailto:avt@ietf.org>
List-Help: <mailto:avt-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/avt>, <mailto:avt-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 20 Aug 2016 13:29:20 -0000

Ekr, Martin, 

Any thoughts on this ?

Thanks


> On Aug 4, 2016, at 9:45 PM, Paul E. Jones <paulej@packetizer.com> wrote:
> 
> AVT,
> 
> There are now at least two implementation of RFC 7714 and at least two interpretations of how to treat the master salt value when used with in KDF.  So that we can ensure consistent implementation, it was suggested that I bring this issue to the WG.
> 
> The issue has to do with the salt length and the KDF.  As you know, RFC 3711 uses AES-CM for the KDF and assumes an initial SRTP master salt that is 14 octets in length (see section 5.3/RFC3711).  AES-GCM, though, utilizes a 12 octet salt value.
> 
> We have this when AES-CM is used (example taken from RFC 3711) with a 14 octet salt:
>  
>       index DIV kdr:                 000000000000
>       label:                       02
>       master salt:   0EC675AD498AFEEBB6960B3AABE6
>       -----------------------------------------------
>       xor:           0EC675AD498AFEE9B6960B3AABE6     (x, PRF input)
> 
>  
> This value is then multiplied by 2^16 per 4.3.3/RFC3711 (i.e., pad zeros on the right) to produce a 16-octet salt value that is then used in the AES-CM KDF logic.
> 
> When the 12 octet salt used in AES-GCM is provided, libsrtp (https://github.com/cisco/libsrtp) will assume that zeros are padded on the right to produce a 14-octet salt value (to get the default master salt length needed per section 5.3).  Thus, assuming a salt value of 0EC675AD498AFEEBB6960B3A, these steps are performed:
>  
>       index DIV kdr:                 000000000000
>       label:                       02
>       master salt:   0EC675AD498AFEEBB6960B3A
> 0000
>      (two padding octets on the right)
>       -----------------------------------------------
>       xor:           0EC675AD498AFEE9B6960B3A0000     (x, PRF input)
> 
>  
> Again, this value is then multiplied by 2^16 per 4.3.3/RFC3711 (i.e., pad zeros on the right) to produce a 16-octet salt value that is then used in the AES-CM KDF logic.
> 
> However, there is a statement in 4.3.1/RFC3711 that says "Let x = key_id XOR master_salt, where key_id and master_salt are aligned so that their least significant bits agree (right-alignment)."  That might suggest that the XOR should have been performed without padding as shown above and as implemented in libsrtp.
>  
> If padding on the right was the wrong thing to do, that would mean that the XOR step using the initial 12 octet AES-GCM salt should have been this:
>  
>       index DIV kdr:             000000000000
>       label:                   02
>       master salt:   0EC675AD498AFEEBB6960B3A
>       -------------------------------------------
>       xor:           0EC675AD4988FEEBB6960B3A     (x, PRF input)
> 
>  
> Then the x*2^16 operation that then follows as per 4.3.3/RFC3711 would result in:
> 0EC675AD4988FEEBB6960B3A0000
>  
> However, this is only a 14 octet value and we need 16 octets for the AES-CM KDF (which was the reason the step in 4.3.3 exists for the default 14 octet salt).  Thus, we are short two octets.
> 
> We either need to pad the initial 12 octet AES-GCM input salt at the start in some way to form the expected 14 octet salt value expected per section 5.3 (the approach taken by libsrtp), or we need additional padding after the above x*2^16 step (e.g., introduce a second x*2^16 step).
> 
> Given that at least two implementers interpreted the specs differently, I think it would be of benefit to discuss this in the WG and document the proper behavior.
> 
> Paul
> _______________________________________________
> Audio/Video Transport Core Maintenance
> avt@ietf.org
> https://www.ietf.org/mailman/listinfo/avt