[Hipsec] Implementation questions from students

Andrei Gurtov <andrei.gurtov@liu.se> Tue, 13 October 2020 14:32 UTC

Return-Path: <andrei.gurtov@liu.se>
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 A10D73A044A for <hipsec@ietfa.amsl.com>; Tue, 13 Oct 2020 07:32:33 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.085
X-Spam-Level:
X-Spam-Status: No, score=-2.085 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_KAM_HTML_FONT_INVALID=0.01, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=liu.se
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 nC-jiYG40Th4 for <hipsec@ietfa.amsl.com>; Tue, 13 Oct 2020 07:32:31 -0700 (PDT)
Received: from carinthia.it.liu.se (carinthia.it.liu.se [130.236.3.99]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 09F653A0317 for <hipsec@ietf.org>; Tue, 13 Oct 2020 07:32:30 -0700 (PDT)
Received: from e-mailfilter01.sunet.se (e-mailfilter01.sunet.se [IPv6:2001:6b0:8:2::201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by carinthia.it.liu.se (Postfix) with ESMTPS id 6F2608034F; Tue, 13 Oct 2020 16:32:28 +0200 (CEST)
DKIM-Filter: OpenDKIM Filter v2.11.0 carinthia.it.liu.se 6F2608034F
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=liu.se; s=liu.liu; t=1602599548; bh=Lz/AjGM36rga5+c5lsmn3PAKlDaTcgKbA8L89M88FQw=; h=From:Subject:To:References:Cc:Date:In-Reply-To:From; b=ru3WPq9RPo1DR70YpI+8h/m38K8dEkSQvoSzMt98Ug83HQEIWOgE2tjIxbtwRgIBJ +EUrfzh+I4OPSZcoGhe8kkcoupDfqVkuKzaMe4dB32AO+UfOa582oShYxGBRBynPRp HJ15E4edXVYTb1kQXe61ajc6NLLFPLpAGfIUNahBQxaZofHqKHNrAfkv3PKLkWgGwf RLN3QrD8Xj5KFRFuRyQBtOxHK9yECXOZXTkNKSYtnni9sWL6JeskcMpAOEHwI+zEBM AqzeBX33EHYeT/76u0gatJkk1m2N6IKdSUZmsNNzjdyIFD1iNPPNAQsbfbzaQwW1P0 ZNF0vnSUg/DPQ==
Received: from andania.it.liu.se (andania.it.liu.se [130.236.8.136]) by e-mailfilter01.sunet.se (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 09DEWRBX001654 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 13 Oct 2020 16:32:27 +0200
Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2107.outbound.protection.outlook.com [104.47.18.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by andania.it.liu.se (Postfix) with ESMTPS id 23613A015D; Tue, 13 Oct 2020 16:32:27 +0200 (CEST)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MzKoloriaV244Ftj2XN6GVAcsoxDQ6wp82bZ3tcS2kgBzn995d1sLs/PfGTxhBxNZ7reT1/iLLUMOWzOsaURvxkLkSKHq2rpCAphWBJxhTqKrg1zIVhBvb+LUYpRuVujhO9wd5WW+Y5y76HneLswpHj5Nn3wKuWBxos5yFNJ5ufAM8QrLQtUpCDDQKXS0ICNooJ3sPyjYTtP7GKLfbRYH+wIRXVudBE5H3mEl/VLi8jpAdtwIAASHG+iN0KXdzIp+goTLQZPoFkiAdpbTpddIl/RLEnj2CUlBv93YL1movvOT5CX1cY9K8gGFWDhMa/tTXPCp9iIAzRw3INzWw5IWA==
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=PZpRR/uXekpOvJpoRfDwm+C7l63hPC5JTheXAeYLKTw=; b=AkNaBleGmqwRzxJD8J7I7IxUZ20Vec4IjEbxGUch0Gj2SWo9OPguT8Ohw6H92edOmdwxkSmqxnnU1c6GT/YHmc1tZdSaTzbTY9QsXSSna+QbZM2L+CsE5heOR1eYbxFwlPpBzkkKFnicCAy1tS4iYM6jhtsrGbkPqEXETQAOul8QUnScKdIvLS+Qwv8g2y0h5/HfdSDEunoc7zVAXFpBtfWnqYSd943EI8GXcJQP0vBpaZB6YXMUBPImmO29+OOIydOpWa5gc8UhGE/5gnGVh5uV8PpMrZKv0jZdggNMtha76SzxvmgPY+DlHDSik2798UfuZ+SubFsbLwSfCwC9gQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=liu.se; dmarc=pass action=none header.from=liu.se; dkim=pass header.d=liu.se; arc=none
Authentication-Results: temperednetworks.com; dkim=none (message not signed) header.d=none;temperednetworks.com; dmarc=none action=none header.from=liu.se;
Received: from AM8P191MB1201.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:1ec::17) by AM4P191MB0098.EURP191.PROD.OUTLOOK.COM (2603:10a6:200:5e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.22; Tue, 13 Oct 2020 14:32:26 +0000
Received: from AM8P191MB1201.EURP191.PROD.OUTLOOK.COM ([fe80::7405:9262:f0eb:4de]) by AM8P191MB1201.EURP191.PROD.OUTLOOK.COM ([fe80::7405:9262:f0eb:4de%5]) with mapi id 15.20.3455.030; Tue, 13 Oct 2020 14:32:26 +0000
From: Andrei Gurtov <andrei.gurtov@liu.se>
To: "hipsec@ietf.org" <hipsec@ietf.org>
References: <58faed1c-5758-f597-8633-519b81dbc923@student.liu.se>
Cc: Jeff Ahrenholz <j.ahrenholz@temperednetworks.com>
Message-ID: <b9199e76-ec16-80f3-48a0-d34acfbadf7f@liu.se>
Date: Tue, 13 Oct 2020 16:32:23 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1
In-Reply-To: <58faed1c-5758-f597-8633-519b81dbc923@student.liu.se>
Content-Type: multipart/alternative; boundary="------------917B974972E36C0426F4AA2A"
Content-Language: en-US
X-Originating-IP: [217.210.49.61]
X-ClientProxiedBy: HE1PR05CA0389.eurprd05.prod.outlook.com (2603:10a6:7:94::48) To AM8P191MB1201.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:1ec::17)
MIME-Version: 1.0
X-MS-Exchange-MessageSentRepresentingType: 1
Received: from [192.168.50.200] (217.210.49.61) by HE1PR05CA0389.eurprd05.prod.outlook.com (2603:10a6:7:94::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20 via Frontend Transport; Tue, 13 Oct 2020 14:32:25 +0000
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: e5b38a4f-73c4-4282-fd53-08d86f84cde2
X-MS-TrafficTypeDiagnostic: AM4P191MB0098:
X-Microsoft-Antispam-PRVS: <AM4P191MB00984F3DB7CEE5730E578D9684040@AM4P191MB0098.EURP191.PROD.OUTLOOK.COM>
X-MS-Oob-TLC-OOBClassifiers: OLM:10000;
X-MS-Exchange-SenderADCheck: 1
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: Ulvg1VihnjZRGX2pbJ2hZC1rg8louE0WNw7rjKvELCTE93UmT5zoaJZpDJrfZe9einhkjtgKzGJ0WUFaUSYU/GSy0mHRHjZUXEulxbqWrQzjPDJc0BHCBZafBHsZboX58CEJpfDHPTc/MzuNMqIZTkekQMbc+jh/uEbBVMVu5Ia+qwFoKwtZeJiMeIbUX4YdAZalm8R3Lv8FccomKY1rnfixaVq0yyMbn8fTa/QeLeGpZABpWiBe/Gw/GQL272/OiazCtOLFRCApwr529QwvJYJGs9HziZt2NZrUeZaYNIS2CXb0gDhDYbgGf7mndNI7CGi/ml4CABid+SXYNYH6gXi1CtIDqXYa12UA7KTo4zckW9BKIuiA40YypKlcR/THQBjur4wWqeS6rNS0QrmLPieaViQZl25kZFM1favGSitqsm8HcT4CTDBDDBXo0lOyM4koXqti/3ZGzXaHeVU3TA==
X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8P191MB1201.EURP191.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(4636009)(39850400004)(396003)(136003)(366004)(376002)(346002)(186003)(16526019)(36756003)(26005)(33964004)(31696002)(52116002)(2616005)(956004)(5660300002)(66556008)(31686004)(4326008)(66476007)(66946007)(786003)(316002)(2906002)(3480700007)(16576012)(8936002)(8676002)(83080400001)(83380400001)(166002)(966005)(6916009)(44832011)(86362001)(21615005)(478600001)(6486002)(43740500002); DIR:OUT; SFP:1102;
X-MS-Exchange-AntiSpam-MessageData: cNyHupilY7x6Oi0Txwljxa4A2FZ4DMZEdfwl/FoTOGWAG4cum43uM3h8Ro+AbAObSmTUhMY9ns5npttJCmU7GEMv/ooCARXeVDfeTx3jeEO9gxGUJ8Jg9BqvzpUnHxX3mUiMLuzTP+9la5UB8APK62Mo3kt/aXwtrWuI6Rb3g3wsqGr0WqhdoWbKmssRqH3pNXvXBBKsOiRtbxRducLrisIuhtNCD9VnjG2/BtujkNXxHqftPg6bE7r1jZnATZSxOi+sjv4b43kFtPHjMiD9cvyfnhA3FhGy6rjEESvjRv9Q1+cBaYQQ6I4zSS+kgMWRQvssRaZvuBbPVUKW11r85ptLzfPjzucBaddjE2NYVHZXtZFmboRd0LFgE4vYBPWrO6eBNIUvYhiEx6+jlvWODw5zE2jrSDlAWa+dIUgwXn2lKs6MiGyT9O1KaAsZAxPZIiRnz04HbQDSKv4KKGhX1pJjp6rPmGx03GvfJBsPGknPFaS2tbMbqLohQa0Z8b93o0xKC5a/w7wlZt00Qzwxfb7jXf9/fo69xVozYpZrbHJt2ODefRmbWjDeiqRGZmCFp+8VmR9n0rG58zKCS+bXjmny64y31vyhCueyDpLNfz64e/pKBnL2rXNUQ1v8rBvs1w0whyz7mmGe8BX+h4OrhQ==
X-OriginatorOrg: liu.se
X-MS-Exchange-CrossTenant-Network-Message-Id: e5b38a4f-73c4-4282-fd53-08d86f84cde2
X-MS-Exchange-CrossTenant-AuthSource: AM8P191MB1201.EURP191.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2020 14:32:26.0217 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 913f18ec-7f26-4c5f-a816-784fe9a58edd
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName: bNk4ceRHDm2xNetpX5/rDhufVNrn7eyqcC05DWxi7i8pm9ihGEAa7wNfTOVZoIAK
X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4P191MB0098
X-Bayes-Prob: 0.0001 (Score 0, tokens from: outbound, outbound-liu-se:default, base:default, @@RPTN)
X-p0f-Info: os=Linux 3.11 and newer, link=Ethernet or modem
X-CanIt-Geo: ip=104.47.18.107; country=NL; region=North Holland; city=Amsterdam; latitude=52.3534; longitude=4.9087; http://maps.google.com/maps?q=52.3534,4.9087&z=6
X-CanItPRO-Stream: outbound-liu-se:outbound (inherits from outbound-liu-se:default, base:default)
X-Canit-Stats-ID: 093DqwrS3 - 919f81a54324 - 20201013
X-CanIt-Archive-Cluster: PfMRe/vJWMiXwM2YIH5BVExnUnw
X-Scanned-By: CanIt (www . roaringpenguin . com)
Archived-At: <https://mailarchive.ietf.org/arch/msg/hipsec/k9gvl2lGeHE5guunX6eh7SCYqZA>
Subject: [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: Tue, 13 Oct 2020 14:32:34 -0000

Hello,

Some questions from a group of students working on HIPv2 implementation.
I guess mostly to OpenHIP. A few were already answered on DRIP list.

br Andrei


-------- Forwarded Message --------

	

	

	

	

	

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));

    (https://bitbucket.org/openhip/openhip/src/37972774633783905ec4f7961d2a5476092ed529/src/protocol/hip_output.c#lines-1373)

    The expression used as index into /hmac_md//[]/ seems to be
    calculated erroneously, as /sizeof(hmac->hmac)/ evaluates to 64
    bytes and /hmac_md_len/ is the output size of the hash function
    used. Since SHA256 for example produces 256 bits / 8 = 32 bytes as
    output, this calculation evaluates to 32 - 64 = -32 when treated as
    signed integers. This results in the data between /hmac_md[-32]/ and
    /hmac_md[32]/ being read, which reads out of bounds for the array.
    Using GDB we have observed that this causes other values located on
    the stack (such as /hmac_md_len/) to be copied into /hmac->hmac//./
    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.

 2. When parsing incoming R1 packets (and probably some other types as
    well), the peer's HIT from the packet seems to be validated against
    a locally computed HIT from the peer's HI. This occurs before any
    parameters other than the puzzle, host ID, and signature have been
    parsed. In /hip_parse_R1()/, /validate_hit()/ uses /hi_to_hit()/ to
    compute this and compares the returned value to the one received
    from the peer. However, since the HIT_SUITE_LIST parameter has not
    yet been parsed, the variable /hip_a->peer_hi->hit_suite_id/ still
    has its default value of 0. 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 if the received HIT happens to
    also be calculated with SHA256. Other algorithms (such as cSHAKE
    which we are adding) will cause this to fail, as
    /hip_a->peer_hi->hit_suite_id/ is only set correctly after the HIT
    has been verified. 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?

 3. What should the lengths for the key and IV be for River/Lake Keyak?
    It seems that these lengths are variable and can be chosen at runtime.

 4. There does not seem to be any support for EdDSA25519ph or EdDSA448ph
    in OpenSSL, and we cannot find any C implementations from a
    reputable source. Would it be OK if we held off on adding these for
    the time being? EdDSA25519 and EdDSA448 are implemented in OpenSSL
    1.1.1 and seem to work for use in OpenHIP.

 5. In section 6 of
    https://www.ietf.org/id/draft-moskowitz-hip-new-crypto-05.html,
    there is a comment about how SHAKE, cSHAKE or KMAC could be used as
    a pseudo-random generator. Should we do something with this
    information, or is it just there for future reference? Isn't
    randomness usually handled by the kernel since it has access to
    higher-quality entropy sources, and if so, is there any place in the
    OpenHIP code where it would be beneficial to use SHAKE/cSHAKE/KMAC
    for this purpose?

 6. Should the new encryption- and signature algorithms we are adding be
    used as default in OpenHIP or just be available as a command line
    option?

 7. (This is mostly a minor thing) When we are adding KMAC as an
    alternative to HMAC, is it proper to put this into a function called
    /build_tlv_*hmac*()/? 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? Or should we add a new function called
    /build_tlv_kmac()/? (Although this might lead to a lot of
    switch-case statements everywhere that /build_tlv_hmac()/ is called)