Re: [babel] Babel-MAC: key size and digest size

Donald Eastlake <d3e3e3@gmail.com> Thu, 02 January 2020 01:11 UTC

Return-Path: <d3e3e3@gmail.com>
X-Original-To: babel@ietfa.amsl.com
Delivered-To: babel@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 8CC0F1200F6 for <babel@ietfa.amsl.com>; Wed, 1 Jan 2020 17:11:35 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.748
X-Spam-Level:
X-Spam-Status: No, score=-1.748 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=no 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 sXQrQ1v6DRLZ for <babel@ietfa.amsl.com>; Wed, 1 Jan 2020 17:11:34 -0800 (PST)
Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) (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 488121200DF for <babel@ietf.org>; Wed, 1 Jan 2020 17:11:34 -0800 (PST)
Received: by mail-il1-x136.google.com with SMTP id b15so33030161iln.3 for <babel@ietf.org>; Wed, 01 Jan 2020 17:11:34 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=/jHmNZ4Kvsb5tFUIvqNVDRGNO8I5px+xxTK2R+oUUqE=; b=CnGPAHM8n7c6Chbuw1sbJ/ggGs0Agz+zoQXiP5ot4gbuLkbGyC7IP6kO5LxMn3Eovd P+pCb4XqUQwA8ARObQq2lRlv7vVLvRsZNqrL9SskrpwCrLcN3HNtFiGUtCMbNU6c/2vL boLzThYwI3s3HZyNDJt16J8xloQv5vyWbKX8De9eRUr0xnn08dhcbLgYZxiPNMjdV91A zeWbp2BuucefiAf6kSyx8EKNAUiB6yARl2Io5hpoOWF2FIxrfltYFCCSoTpLCmqfKeLh Hrh5i1wDk2YZmRboTK1rGM9H+fkQs8wT4RJ+uyWA5IWNgnOnas22k6YL+Z/ZsJUFPtoS 4ldA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=/jHmNZ4Kvsb5tFUIvqNVDRGNO8I5px+xxTK2R+oUUqE=; b=DHuCouipITkzUD9IL5bQF5yC0gLWVje02JN4rtja2vOnDKvADQRzO0PU7xFjUpLDvi 6A7j9E22VFTKpP6XWqf3hQYIXa0RCjIIpAQrVjSzRa+yxzbA7roUeHlLdqOhH0chZw+E h/gcLIpdL9BsjhVUah8oi3Mp8mxS3zcgBbhilEyzoF7ILvL/oCMnj6485HSDggaFYlg0 ZUmXy53UI6+5KqQk/zUvwYZpOTKNd7hi5pm0MO3gxvuDQZwWoN0xTVAH8t5qha/1/2j2 jxVMxV8B0R7Nyo0keFaPEHvm310xkLfNweJLBTc4S+VjuKifOFqFRWtaxEOyrvxwzLC/ RDfg==
X-Gm-Message-State: APjAAAVYH/mAPnt91EGeK8zGndVHfNlUT3JKuTcQavrmPBJHsGBqJanG hTct+CjzYXuOCEbt1sIsxKnshA6jXbqrrUa/B/zN8LPG
X-Google-Smtp-Source: APXvYqwBpOncTTokz83+yRRnDfbCfvE290lZbJfNoaQYOQKbHt/ijKWeU1kp0ZWLs9aGJpi4KyF4PGSIV8ZAczxye2Y=
X-Received: by 2002:a92:cd52:: with SMTP id v18mr71129438ilq.83.1577927493402; Wed, 01 Jan 2020 17:11:33 -0800 (PST)
MIME-Version: 1.0
References: <CAC=54BL7Be5joBChiO1e=1nB7QpY8Ozx3qwDMUzEpDp2noWD3A@mail.gmail.com> <CAC=54BLsU5e4iY8T=NX0_5gt3A7=nZb0qnyGeVA5YnGu7knVHQ@mail.gmail.com>
In-Reply-To: <CAC=54BLsU5e4iY8T=NX0_5gt3A7=nZb0qnyGeVA5YnGu7knVHQ@mail.gmail.com>
From: Donald Eastlake <d3e3e3@gmail.com>
Date: Wed, 01 Jan 2020 20:11:22 -0500
Message-ID: <CAF4+nEFiAmREAQL-78OsqDVUx5ZZDhtgv=Ew2k54y0xOUihxNQ@mail.gmail.com>
To: Antonin Décimo <antonin.decimo@gmail.com>
Cc: Babel at IETF <babel@ietf.org>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/babel/N3PaEnAWsWd1nDzy1uUqAym_Nyo>
Subject: Re: [babel] Babel-MAC: key size and digest size
X-BeenThere: babel@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "A list for discussion of the Babel Routing Protocol." <babel.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/babel>, <mailto:babel-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/babel/>
List-Post: <mailto:babel@ietf.org>
List-Help: <mailto:babel-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/babel>, <mailto:babel-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 02 Jan 2020 01:11:36 -0000

Hi Antonin,

Thanks for your comments. They look plausible to me although it is
common to use truncated MACs. However, I'm thinking that at this
stage, it would be best to get draft-ietf-babel-rfc6126bis, and the
draft that are being held up by it through the process, and then start
an update to or a revision of the Babel HMAC draft.

Donald
===============================
 Donald E. Eastlake 3rd   +1-508-333-2270 (cell)
 2386 Panoramic Circle, Apopka, FL 32703 USA
 d3e3e3@gmail.com


On Sat, Dec 28, 2019 at 1:15 PM Antonin Décimo <antonin.decimo@gmail.com> wrote:
>
> Hello again,
>
> I'm keeping in mind that (§7):
> > Every implementation MUST implement HMAC-SHA256 as defined in
> > [RFC6234] and Section 2 of [RFC2104] , SHOULD implement keyed
> > BLAKE2s [RFC7693] , and MAY implement other MAC algorithms.
>
>
> 1. Key length
>
> This is the change I'm proposing in §7:
>
>  Keys must be chosen in a manner that makes them difficult to guess.
> -Ideally, they should have a length of 32 octets (both for HMAC-SHA256
> -and Blake2s), and be chosen randomly.
> +Ideally, they should be chosen randomly, and have the maximum key
> +length supported by the MAC algorithm (32 octets for keyed BLAKE2S)
> +or no less than the block size of the MAC algorithm (64 octets for
> +HMAC-SHA256).
>
>
> 2. Digest length
>
> After a bit of sleep, I realised that reading the length of the MAC
> TLV in order to compute a MAC of this length is not compliant with the
> protocol (§4.3) since MACs are computed without looking into the
> packet.
>
> > Then, for each key configured on the receiving interface, the
> > receiver computes the MAC of the packet. It then compares every
> > generated MAC against every MAC included in the packet;
>
> Still, it was an error I was almost going to make. I propose the
> following change to ensure that we're always using the maximum digest
> length of the MAC algorithm.
>
> This is the change I'm proposing in §4.1:
>
>  implementation MUST implement HMAC-SHA256 as defined in
>  <xref target="RFC6234"/> and Section 2 of <xref target="RFC2104"/>,
>  SHOULD implement keyed BLAKE2s <xref target="RFC7693"/>, and MAY implement
>  other MAC algorithms.
> +The length of the MAC MUST be the maximum MAC length computable by
> +the MAC algorithm (32 octets for both HMAC-SHA256 and keyed
> +BLAKE2S).
>
>
> 3. Lazy computation
>
> With the idea that computing a MAC is more costly than comparing MACs,
> and that there's a very limited amount of MACs to check, I propose we
> lazily compute MACs. Instead of computing the MAC for every key on
> packet reception, we compute the MAC with the first key, then check it
> against the MACs carried by the packet. If there's a match, the packet
> is immediately accepted. If there's no match, we the proceed to the
> next key until all keys are exhausted, and the packet is rejected.
>
> This is the change I'm proposing in §4.3:
>
> -Then, for each key configured on the receiving interface, the
> -receiver computes the MAC of the packet.  It then compares every
> -generated MAC against every MAC included in the packet; if there is
> -at least one match, the packet passes the MAC test; if there is none,
> -the packet MUST be silently dropped and processing stops at this
> -point.
> +Then, for each key configured on the receiving interface, the
> +receiver computes the MAC of the packet and compares it against every
> +MAC included in the packet; if there is at least one match, the
> +packet passes the MAC test; if there is none, the receiver proceeds
> +with the next key.  If none of the MAC matched, the packet MUST be
> +silently dropped and processing stops at this point.
>
>
> Cheers!
>
> -- Antonin
>
> _______________________________________________
> babel mailing list
> babel@ietf.org
> https://www.ietf.org/mailman/listinfo/babel