Re: [Hipsec] Implementation questions from students

Jeff Ahrenholz <j.ahrenholz@tempered.io> Wed, 14 October 2020 20:30 UTC

Return-Path: <j.ahrenholz@tempered.io>
X-Original-To: hipsec@ietfa.amsl.com
Delivered-To: hipsec@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 420723A1051 for <hipsec@ietfa.amsl.com>; Wed, 14 Oct 2020 13:30:06 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.9
X-Spam-Level:
X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=temperednetworks.onmicrosoft.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 n4TY605vZyN8 for <hipsec@ietfa.amsl.com>; Wed, 14 Oct 2020 13:30:04 -0700 (PDT)
Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2072.outbound.protection.outlook.com [40.107.100.72]) (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 128983A1050 for <hipsec@ietf.org>; Wed, 14 Oct 2020 13:30:03 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cdOL/o7TjIeVPlW1pcdJKz0fBhkQihb22qNvnDkzRO5qxMDUVzW57YeCVuJkQKwoUwnqzDB8bhsvkdHQ2zRhfflMvANMx6K50PmdDTOexOlF8nVFMCnBQR1IECROIbIb0fsaQ8gzqDmUGzwyKoHN8tBEnZ2uaFyqyvnAEDESsHKuaFUMgDuqUWk4/KdKG27/toioHDcAFGz2V26FrEQpQI/hrjhIoISBc18ABLK+EwQQhS2FTS0PoGd6SbbZs1yfgfEJqQOKOHC/vICJDNy90TKNCXiczN6WhfTlGsYjg2ICDFmyaJiOtiy0tO7ujhHRXBp2Ivavbv1KNS8YMSttaw==
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=hpaTS8joeoiD9hktCQOcwK38uHJt0kV0n5vHAcDvhFk=; b=FllS31y+bTW/J3s/EB3ax6s1qfbnDObMjE5c5KF2fzWnyx5f4ozRWqs00qVPKAnxUr+4RbQDe2ZQXfNY0Cjuhw6L67U3z3s6VqFpQWVnjy0frbe8G/RPSVBp1TDjokKtOUlEYLcufOAtjJPdZ6G66HCE36kRS8lTxs0qBpFXO3BnHL8dxvDaT+0HBvgxico4FTwxD99Ms20S+uUmTpJTuW3+L2M43dyYCUZyI5ywFeIb2BGW4QDA2wjxtFB2mnEuK/aC7alAnB2dEXRmUoS8g9IPn44cZPt4q47W8w5TWBxJOPri1yhPGwZ3TjtKQBn4mx5bv+W4Crb5gkQJCSNMww==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=tempered.io; dmarc=pass action=none header.from=tempered.io; dkim=pass header.d=tempered.io; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=TemperedNetworks.onmicrosoft.com; s=selector1-TemperedNetworks-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hpaTS8joeoiD9hktCQOcwK38uHJt0kV0n5vHAcDvhFk=; b=TZmn+FrLAINKuJfUcEeE1LBbou1t2UY3PwdSX8CKsP4SQXMG1zU74z0M2odcMuxN0X94U3MoauAjr7Rzt9HO1mEztK/ufEXQUGiBLTnMq29xaImhRwGOPcnFU8nejqh08GG7ChW0w2q23BKu/zmWjqHbWKJj36YJLlF4/QddvoU=
Received: from MWHPR22MB0974.namprd22.prod.outlook.com (2603:10b6:300:132::14) by MWHPR22MB0509.namprd22.prod.outlook.com (2603:10b6:300:fe::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.25; Wed, 14 Oct 2020 20:30:00 +0000
Received: from MWHPR22MB0974.namprd22.prod.outlook.com ([fe80::dcd8:f714:7f98:56aa]) by MWHPR22MB0974.namprd22.prod.outlook.com ([fe80::dcd8:f714:7f98:56aa%11]) with mapi id 15.20.3477.020; Wed, 14 Oct 2020 20:29:59 +0000
From: Jeff Ahrenholz <j.ahrenholz@tempered.io>
To: Andrei Gurtov <andrei.gurtov@liu.se>, "hipsec@ietf.org" <hipsec@ietf.org>
Thread-Topic: Implementation questions from students
Thread-Index: AQHWoW2xXP7Ry03/oECEe3FISYkr/KmXGV0A
Date: Wed, 14 Oct 2020 20:29:59 +0000
Message-ID: <522C0841-12D8-44CF-937C-EC45197E7C90@tempered.io>
References: <58faed1c-5758-f597-8633-519b81dbc923@student.liu.se> <b9199e76-ec16-80f3-48a0-d34acfbadf7f@liu.se>
In-Reply-To: <b9199e76-ec16-80f3-48a0-d34acfbadf7f@liu.se>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: liu.se; dkim=none (message not signed) header.d=none;liu.se; dmarc=none action=none header.from=tempered.io;
x-originating-ip: [73.254.156.159]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: d9a914b9-c503-473b-e7d6-08d8707fec2a
x-ms-traffictypediagnostic: MWHPR22MB0509:
x-microsoft-antispam-prvs: <MWHPR22MB05096ADB165A23E647077997ED050@MWHPR22MB0509.namprd22.prod.outlook.com>
x-ms-oob-tlc-oobclassifiers: OLM:9508;
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: 6EWHLANDSOcfgm/nyjWf3apobVDl0ne7k6zwZMYqB0d7zm/UC+nTwJcJvmpuZkZLItL67M/Ig8OhIrt70OTMBcpahctAxwVXVUYx4DAIAi4dYsHKb60935tUbmeLEagnju/R9COaoNVnKXTKAah1wMvE/JioLFS+vOkJJpcSt+ioKY/l+uJAcQ50YraOwtiYMrBDzO1jdVc2RaW67Jyu2GIrJAhfLTJWwRamBN7Yeo9kfK4jyhz2AcDfJGRM8dHpZUH/ZerdmvCpG4AhuMeabzL1ngb9KoHNg0K4K6y6ZEyKolQKYiBw8j0Nt845xzQ0a1GCMA44IwVMFJblGlWGGSmMW7KFGsDKCNYZhlKVkbHNadxrbNC8aC0DAOrPbcl17xYu981SPZx0wgVGul0Jtg==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR22MB0974.namprd22.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(396003)(136003)(346002)(39830400003)(366004)(316002)(110136005)(478600001)(296002)(76116006)(36756003)(6486002)(26005)(64756008)(66476007)(5660300002)(186003)(71200400001)(66946007)(2616005)(66556008)(66446008)(6506007)(86362001)(83080400001)(8936002)(6512007)(8676002)(33656002)(3480700007)(2906002)(83380400001); DIR:OUT; SFP:1101;
x-ms-exchange-antispam-messagedata: i6Nt/c+rPLXOVdOcfy6298bYH1RW1Upqp87mdR+ym2Riivks6v/4z8h/05njEQ4GqyoOvZPQtULxxPEU6SyxYUNtHbR7IZ1UMoJf3VAEgiV+99s3vyJG8PLFkm4KT77PhakJmm0bipeFRejwtHh6TINt7Mywwg0U+N7PmA5AOiiM/YS+KRk3oleGIhg/SGXt6TmXjFttjXw63gznrlmkmpag//PE+RqckzlaWVBHvFJeT6qiMVmmsFk27uhnYVpG+rz0K5O+ezP951cFORYA9njSwniAYa91VEavjLyHmt9HsW1hjtj4UbBXyP/WHRDFpY0Cx9SKiNKicsqOClpL52PPtRK0IoGjmkLbBu42MhStSdov+OeX0kjgjS68L76QmVvEE/IVCn2SZ8tv52mKJtC+fMV0dsGhC/8oW1AvEJElP+SfpN1AfRdejmwRRMkNLNRSDXDc33T16wtFoUN2EzrPSZeKGY/Wl+bTUcHqOMaCQse7W3Sb40z2VUBJmyYzA1K0zmW7WHFV5ebOieRfzfXqzPWkHCaXNxjxVKHP6nGhaUU5Y3qM/I6wbAx5KHAWt9Py7lWto9UQqIWbxF/gjxPkYa3gmWyMkiWJl6GBmYhPstV6C/nRqTUgK+WnHqun9y/Zy2IOGj0dblhc4+564w==
x-ms-exchange-transport-forked: True
Content-Type: text/plain; charset="utf-8"
Content-ID: <07CC53C865F2954BA9C240295E925FFE@namprd22.prod.outlook.com>
Content-Transfer-Encoding: base64
MIME-Version: 1.0
X-OriginatorOrg: tempered.io
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: MWHPR22MB0974.namprd22.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: d9a914b9-c503-473b-e7d6-08d8707fec2a
X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Oct 2020 20:29:59.5818 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 0816e7af-ac4a-4e9e-ae57-e5f50bdac4dd
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: XEU47sFYEZoHZWL3SQMctNIjLAWWt3gCKyQ5xTyTpCDPRSWhR+R5U0zt3gn6nZWxHqmNbcec8gpmGhyjRRaYCw==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR22MB0509
Archived-At: <https://mailarchive.ietf.org/arch/msg/hipsec/jq49wmPp0kLns_vhmefWZi8u2f0>
Subject: Re: [Hipsec] Implementation questions from students
X-BeenThere: hipsec@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "This is the official IETF Mailing List for the HIP Working Group." <hipsec.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/hipsec>, <mailto:hipsec-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/hipsec/>
List-Post: <mailto:hipsec@ietf.org>
List-Help: <mailto:hipsec-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hipsec>, <mailto:hipsec-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 14 Oct 2020 20:30:06 -0000

Hi Andrei et al.,

Some inline comments below...

> We had some questions about the HIP project that you could perhaps forward to the correct person:
> 1. In the function build_tlv_hmac() in src/protocol/hip_output.c, there is the following bit of code:
> /* get lower 160-bits of HMAC computation */
> memcpy( hmac->hmac,
>         &hmac_md[hmac_md_len - sizeof(hmac->hmac)],
>         sizeof(hmac->hmac));

We currently use the HMAC() function writing directly into the TLV buffer. We're not truncating the output hash when using AES-256.

> Also, per RFC 7401 (HIPv2), "The size of the HMAC is the natural size of 
> the hash computation output depending on the used hash function". Thus 
> there does not seem to be a need to truncate this value to 160 bits?
>  At least one implementation (https://www.cryptosys.net/manapi/api_kmac.html)
> of the KMAC function (that we have added as an option to HMAC) also states
> that the output of the KMAC function cannot be truncated when used as a message authentication code.

This likely stems from the original RFC 5201 / RFC 5202 required algorithms. You're correct, with AES-256 and others you do not need to truncate the output hash. Although that is allowed by old RFCs such as RFC 2104.

> There is a fallback in hi_to_hit() which silently uses SHA256 as
> the hashing algorithm for creating a HIT from a HI if the HIT suite 
> is set to an invalid value, which enables the verification to succeed 
...
> We have worked around this issue by first ignoring all parameters 
> other than the HIT_SUITE_LIST (thus ensuring that the HIT suite 
> variable is set before any other parameters are parsed), then continuing
> with parsing the signature-related parameters and finally the others. 
> Is this an acceptable solution to this problem? Those silent fallbacks 
> seem to cause more problems that they solve, maybe they should be removed
> or at least emit a warning when triggered?

Yes, I think you should remove the silent fallback.

You should be able to use the OGA ID field of the HIT in order to validate the HIT.
From RFC 7401 section 3.1:

"  One of these
   measures allows different hash functions for creating a HIT.  HIT
   Suites group the sets of algorithms that are required to generate and
   use a particular HIT.  The Suites are encoded in HIT Suite IDs.
   These HIT Suite IDs are transmitted in the ORCHID Generation
   Algorithm (OGA) field in the ORCHID.  With the HIT Suite ID in the
   OGA ID field, a host can tell, from another host's HIT, whether it
   supports the necessary hash and signature algorithms to establish a
   HIP association with that host."

The HIT_SUITE_LIST TLV is used to list the supported HIT SUITE IDs.

See RFC 7401 section 5.2.10 around this text:

"   The ID field in the HIT_SUITE_LIST is defined as an eight-bit field,
   as opposed to the four-bit HIT Suite ID and OGA ID field in the
   ORCHID."

I don't think you should parse the HIT_SUITE_LIST when validating the HIT.

> Seeing as this function will then sometimes calculate a HMAC and other
> times a KMAC, should it be renamed to build_tlv_mac()? Or will it be
> less intrusive to others (that might be used to the name) to not
> change it even though the name might be misleading? 

The new name build_tlv_mac() sounds good.

regards,
-Jeff