Re: [lp-wan] [lpwan] Interface Identifier computation on draft-ietf-lpwan-schc-over-lorawan-14

Olivier Gimenez <ogimenez@semtech.com> Tue, 26 January 2021 10:37 UTC

Return-Path: <ogimenez@semtech.com>
X-Original-To: lp-wan@ietfa.amsl.com
Delivered-To: lp-wan@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 8B0063A00D8 for <lp-wan@ietfa.amsl.com>; Tue, 26 Jan 2021 02:37:24 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.1
X-Spam-Level:
X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, TRACKER_ID=0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=semtech.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 5mBVnWJeGQZt for <lp-wan@ietfa.amsl.com>; Tue, 26 Jan 2021 02:37:22 -0800 (PST)
Received: from mail1.bemta24.messagelabs.com (mail1.bemta24.messagelabs.com [67.219.250.114]) (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 2AD663A017E for <lp-wan@ietf.org>; Tue, 26 Jan 2021 02:37:22 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semtech.com; s=k1; t=1611657441; i=@semtech.com; bh=suJGpGZVhJ9eLFbLUCBMBtOhnJbykCtgtX8xpiw2YDg=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=gpOTC7Nsez7806xu6sYHqg8btsZC7v9qHO+nWepgQi+DrWeUIzdUI1h9iC6NWtd3U YpaKdSl+v6TsjF1l7+TY6nWN5vY4vNk+9akWqUgcvzaFoUcrvbw+tV7nWwXtXdP2QT Z4WjvTbY/OZRS+yFK3TwwReHWyXuB96RUaDTgDAQ2t/si0SAHjahY6wF/b1xVvyjqP 9HLM4iS2xh7HZUe5WzqEEjiXOuuVw4Swukbgn71pZaXvrbZvvrYAwECoYIvGw84a/4 6DmS7xktCRSWhtBuIFhGL2qDZHpuCiLed64zpIg+5D4I/tV9s11PqKWGOYLvDnPV4C Q20v678jJdjpg==
Received: from [100.112.133.249] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-3.bemta.az-b.us-west-2.aws.symcld.net id AE/4E-54900-FD0FF006; Tue, 26 Jan 2021 10:37:19 +0000
X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKJsWRWlGSWpSXmKPExsXiofbjse69D/w JBp93mlssPL6X2eLNLHuLG5PXsVm8eb6E1YHFY+esu+weS5b8ZPLY076MPYA5ijUzLym/IoE1 Y+LzrSwFF04xVkzbeYu5gfHjccYuRi4OIYEHjBIX5y9jh3BeMEoc7W5ggnB2MkrcubQIKMPJw SagI/H/+SxWEFtEIFyi/9lmsDizQL1E26ozzCC2sEC8RO+iFjaImgSJzc3PoGwjiWPzvoLVsA ioSnyZf4UJxOYVsJJ41dcJFhcSsJFYcqoHaCYHB6eArcTGWYogYUYBMYnvp9YwQawSl7j1ZD6 YLSEgILFkz3lmCFtU4uXjf6wgN0sITGOWuHPwMFQRv8S8w9dZIWwFibYp3xghBiVKnFjWwApx g6DEyZlPWCBuUJRonbaQeQKj+Cwk+2YhaZmFpGUW0KnMApoS63fpQ5QoSkzpfsgOYWtItM6Zy 44svoCRfRWjeVJRZnpGSW5iZo6uoYGBrqGhka6hsamuqYleYpVukl5psW55anGJrpFeYnmxXn FlbnJOil5easkmRmDspxS0m+1gvPn6g94hRkkOJiVR3nWv+ROE+JLyUyozEosz4otKc1KLDzH KcHAoSfAWvwfKCRalpqdWpGXmANMQTFqCg0dJhDcLJM1bXJCYW5yZDpE6xRjIMeHl3EXMHAeP zgOS734uBpJXVi0Bkh/B5HcweWTu0kXMQix5+XmpUuK8a0EGCYAMyijNg1sDS62XGGWlhHkZG RgYhHgKUotyM0tQ5V8xinMwKgnzOoBM4cnMK4G75hXQoUxAhz45wwdyaEkiQkqqgSn0+oo/Kf Ii6lrXL7MdPu6wP7kr8uIk56lP4h5bX9xefEehM2/R05j0My0tM0ttzl+q/7On9oI959ZDTvP OTV0k1bKC69Mh7qwvMTd2yM88/PXotbOGX5i2BbsU7maYemzatZPBE8ufiYfVpe/u4VjC832O YlGh09E0L6V1op4PBROfrVBYuLLAzD1BwGx9dsENBjG2pRUBak9/b1kXW+3dw5Wd9bLVW1N2n YjL9MVNLT5uXf0i20J/X7Be9rcvU3mqdIbf0Smz7i7Z7XWD2zzm45L8T7u/uW4oYnlXs0zwZP lvw8fzptr+nWlxtOf3JMdYN4cH2guU/tYmicVdYvo0u+ORVUH7u8XxF28e+PJBiaU4I9FQi7m oOBEAXQQzwSgEAAA=
X-Env-Sender: ogimenez@semtech.com
X-Msg-Ref: server-29.tower-354.messagelabs.com!1611657437!1920038!1
X-Originating-IP: [72.38.248.227]
X-SYMC-ESS-Client-Auth: outbound-route-from=pass
X-StarScan-Received:
X-StarScan-Version: 9.60.3; banners=semtech.com,-,-
X-VirusChecked: Checked
Received: (qmail 18306 invoked from network); 26 Jan 2021 10:37:18 -0000
Received: from s72-38-248-227.static.datacom.cgocable.net (HELO ca01exedge1.semnet.dom) (72.38.248.227) by server-29.tower-354.messagelabs.com with ECDHE-RSA-AES256-SHA384 encrypted SMTP; 26 Jan 2021 10:37:18 -0000
Received: from ca01mail2.semnet.dom (10.2.50.41) by ca01exedge1.semnet.dom (10.2.110.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1034.26; Tue, 26 Jan 2021 05:36:21 -0500
Received: from ca01mail2.semnet.dom (10.2.50.41) by ca01mail2.semnet.dom (10.2.50.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.26; Tue, 26 Jan 2021 05:37:15 -0500
Received: from ca01mail2.semnet.dom ([fe80::fdc8:c457:b09e:605d]) by ca01mail2.semnet.dom ([fe80::fdc8:c457:b09e:605d%22]) with mapi id 15.01.1034.026; Tue, 26 Jan 2021 05:37:15 -0500
From: Olivier Gimenez <ogimenez@semtech.com>
To: Felipe Canales <felipe.canales.213@gmail.com>, "lp-wan@ietf.org" <lp-wan@ietf.org>
CC: "rodrigo.munoz.lara@gmail.com" <rodrigo.munoz.lara@gmail.com>, Sandra Céspedes <scespedes@niclabs.cl>
Thread-Topic: [lpwan] Interface Identifier computation on draft-ietf-lpwan-schc-over-lorawan-14
Thread-Index: AQHW87V17gxkzXsyvkaP7DId977r8Ko5rj/g
Date: Tue, 26 Jan 2021 10:37:15 +0000
Message-ID: <023d8aa123174126a579ecf1b4d4f541@semtech.com>
References: <CEAF044A-51B7-4DD9-AB30-5AC19C07D0C6@hxcore.ol>
In-Reply-To: <CEAF044A-51B7-4DD9-AB30-5AC19C07D0C6@hxcore.ol>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-dg-ref: PG1ldGE+PGF0IG5tPSJib2R5Lmh0bWwiIHA9ImM6XHVzZXJzXG9naW1lbmV6XGFwcGRhdGFccm9hbWluZ1wwOWQ4NDliNi0zMmQzLTRhNDAtODVlZS02Yjg0YmEyOWUzNWJcbXNnc1xtc2ctNzIyNGRkNTUtNWZjMi0xMWViLWI3OTYtYzg1Yjc2MWM1MDU3XGFtZS10ZXN0XDcyMjRkZDU2LTVmYzItMTFlYi1iNzk2LWM4NWI3NjFjNTA1N2JvZHkuaHRtbCIgc3o9IjE1NjI0IiB0PSIxMzI1NjEzMTAzMjAxODQ4NjYiIGg9IlNRRnB1YUlhVlRRTExxY3NJODhacm43Z3BSMD0iIGlkPSIiIGJsPSIwIiBibz0iMSIvPjwvbWV0YT4=
x-dg-rorf: true
x-originating-ip: [10.144.80.27]
Content-Type: multipart/alternative; boundary="_000_023d8aa123174126a579ecf1b4d4f541semtechcom_"
MIME-Version: 1.0
Archived-At: <https://mailarchive.ietf.org/arch/msg/lp-wan/I0gdJkBL-4lHOjmKaSJvfrpzGtc>
Subject: Re: [lp-wan] [lpwan] Interface Identifier computation on draft-ietf-lpwan-schc-over-lorawan-14
X-BeenThere: lp-wan@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Low-Power Wide Area Networking \(LP-WAN\), also known as LPWA or Low-Rate WAN \(LR-WAN\)" <lp-wan.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/lp-wan>, <mailto:lp-wan-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/lp-wan/>
List-Post: <mailto:lp-wan@ietf.org>
List-Help: <mailto:lp-wan-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/lp-wan>, <mailto:lp-wan-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 26 Jan 2021 10:37:25 -0000

Hello Felipe,

Thank you for your comment. You are right I made a mistake, I wanted to input the data as a series of 8 bytes but did it as their ASCII representation.
I do not know how it happened, as it has also been verified by someone else with another tool (Python vs Matlab)
With the fixed script using the DevEUI as integer, I get the same result than you:

devEUI 0x1122334455667788 - Type: <class 'bytes'>
appSKey 0x00AABBCCDDEEFF00AABBCCDDEEFFAABB - Type: <class 'str'>
key: 0x00AABBCCDDEEFF00AABBCCDDEEFFAABB - Type: <class 'bytes'>
CMAC: 0x4E822D9775B2649928F82066AF804FEC
IID: 0x4E822D9775B26499

If someone else want to check, I used:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Dependencies:
# pip install git+https://github.com/dlitz/pycrypto

import binascii
from Crypto.Hash import CMAC
from Crypto.Cipher import AES

# Input
devEUI = 0x1122334455667788
appSKey = "00AABBCCDDEEFF00AABBCCDDEEFFAABB"

# Conversion to bytes
devEUI = (devEUI).to_bytes(8, "big")
key = binascii.unhexlify(appSKey)

# CMAC computation
cmac = CMAC.new(key, ciphermod=AES)
cmac.update(devEUI)

print(f"devEUI 0x{devEUI.hex().upper()} - Type: {type(devEUI)}")
print(f"appSKey 0x{appSKey} - Type: {type(appSKey)}")
print(f"key: 0x{key.hex().upper()} - Type: {type(key)}")
print(f"CMAC: 0x{cmac.hexdigest().upper()}")
print(f"IID: 0x{cmac.hexdigest()[0:16].upper()}")

Is this OK for you?

Best regards
OIivier


From: lp-wan <lp-wan-bounces@ietf.org> On Behalf Of Felipe Canales
Sent: 25 January 2021 23:13
To: lp-wan@ietf.org
Cc: rodrigo.munoz.lara@gmail.com; Sandra Céspedes <scespedes@niclabs.cl>
Subject: [lp-wan] [lpwan] Interface Identifier computation on draft-ietf-lpwan-schc-over-lorawan-14

Dear Author,

In section 5.3 of draft-ietf-lpwan-schc-over-lorawan-14, the example given for the computation of an Interface IDentifier (IID) has 0x1122334455667788 as the DevEUI, and therefore as the message to be encoded using AES128_CMAC. The presence of the ‘0x’ prefix suggests that the value should be taken as a series of 8 bytes, each one represented by 2 hexadecimal digits. For example, the first byte would be 0x11. However, when applying the AES128_CMAC algorithm, the CMAC computed is not the one presented in the document but the following:
0x4e822d9775b2649928f82066af804fec

The CMAC presented can be achieved if the DevEUI is evaluated as a string, or in other words, as 16 bytes each one having the value of the ASCII representation of a digit. In this case, the first byte is 0x31 (the character ‘1’).

Which of these two scenarios is the intended one?

I’ve confirmed the CMACs I obtained using my code, with the following implementations of the algorithm specified in RFC 4493:
-          https://artjomb.github.io/cryptojs-extension/
-          https://github.com/SecureAuthCorp/impacket/blob/master/impacket/crypto.py

Regards.

Felipe Canales

To view our privacy policy, including the types of personal information we collect, process and share, and the rights and options you have in this respect, see www.semtech.com/legal.