Re: [Cbor] draft-ietf-cbor-network-addresses: tag validity; deterministic encoding

Brian E Carpenter <brian.e.carpenter@gmail.com> Thu, 04 November 2021 21:03 UTC

Return-Path: <brian.e.carpenter@gmail.com>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 65AF03A0A21 for <cbor@ietfa.amsl.com>; Thu, 4 Nov 2021 14:03:45 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -5.429
X-Spam-Level:
X-Spam-Status: No, score=-5.429 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, FREEMAIL_FROM=0.001, NICE_REPLY_A=-3.33, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham 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 zFKzgS9QHyWd for <cbor@ietfa.amsl.com>; Thu, 4 Nov 2021 14:03:42 -0700 (PDT)
Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) (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 B35413A0A24 for <cbor@ietf.org>; Thu, 4 Nov 2021 14:03:42 -0700 (PDT)
Received: by mail-pg1-x52d.google.com with SMTP id r28so6529939pga.0 for <cbor@ietf.org>; Thu, 04 Nov 2021 14:03:42 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=mJfyrNbg6RxGpCAXD7hmHvDGSAAdJW5szzcmJIOlNK8=; b=j+Uup7foWYFD5nnHcOQInjBKYlqfY5ch68oYGG3mAs/4Qso8+uNQiJGiHxIwLHgk+c vHZEszOPfbmMQOXZJ8MaG5TCHr/G/0E27E5w8ZVrz9pH1EaIVRCv8tx/a8cr0J+hDfIu /ddsqYAwI9qOZL+kf+SJKxfTksllUN4kS7l0v7rwfk6C5sxLH47xheQ6y1GVP84CaGcW r1FmAoKaPa6/HyIEEsPEKklMx7r5p6Nwjo29PLCTe6lKTNrJX1tcQS7cwBkTlJGXuU8K TpPq+DTv17qJdtu/jVbTohJtpUTR2ZJDOdQEsfeAyGLv8ZgrZIl3qkH86+0FuIIlFMkV shUg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=mJfyrNbg6RxGpCAXD7hmHvDGSAAdJW5szzcmJIOlNK8=; b=gAf4aRMmcdwZmySpEDcZpjJwQUQ6OaRsTjHxn2/Q4j4tGgk0iu+hL3TdcTpOo9Z9xX atC0wlpvTv72xa7IfJAboIiJQKPwxKPUfcotdJiFefS0mjuKjVsMsy1SrBJpVZsf71X0 5qHsUdR7ZTayjKl7kbzqY1/cQQxuRNdMnSUfTrmOANFdbGAgqh18v5cC5trMiKhMbXx3 hTSPGNVEezmsUydSewjj0ooG6hPOyn+NP5HyhHo4aqg0NsPD9iW1nCa3tvMeoiEgougt 7jF/hsRdiOVq5mL2OBap+OtW1ais7TDsot4SekI8AweEH+Xz18G3R6jmbywWtUmWDiHn lAcw==
X-Gm-Message-State: AOAM532nbvW3J42uAHV6f/nKmoZg7f9ay3tFBrqhMuJghxoB5i6gMKzy VEN6Tr3S0B84ddMGnu+B6d1CjmnCfnb/hw==
X-Google-Smtp-Source: ABdhPJxw/6wp6+Su2/4UbR4h/oliClv8W/1sczMnEW4alFDUIezTj9ePiSAlw3bUqTApKAG/9BjW/w==
X-Received: by 2002:a63:4d03:: with SMTP id a3mr29316059pgb.424.1636059817632; Thu, 04 Nov 2021 14:03:37 -0700 (PDT)
Received: from ?IPv6:2406:e003:102d:e801:80b2:5c79:2266:e431? ([2406:e003:102d:e801:80b2:5c79:2266:e431]) by smtp.gmail.com with ESMTPSA id e187sm5716307pfe.181.2021.11.04.14.03.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Nov 2021 14:03:37 -0700 (PDT)
From: Brian E Carpenter <brian.e.carpenter@gmail.com>
To: Carsten Bormann <cabo@tzi.org>
Cc: cbor@ietf.org, Michael Richardson <mcr+ietf@sandelman.ca>
References: <891995AA-2854-431E-9242-98FFCDA5E161@tzi.org> <dab25fe3-43c4-865e-2c7a-54b24340c295@gmail.com> <19BCDB95-AB61-4F92-A38D-F6FD5CA8BBB1@tzi.org> <a616b11c-0fc3-436b-96b0-12a6156c37f5@gmail.com> <DAE0122E-D6AB-45B2-A287-AC270AD8A7CD@tzi.org> <d94b9b9b-1165-9f4d-2a55-1ed98fd8142b@gmail.com>
Message-ID: <d070dcfe-ad5b-a432-5380-6124bd2739b0@gmail.com>
Date: Fri, 5 Nov 2021 10:03:32 +1300
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0
MIME-Version: 1.0
In-Reply-To: <d94b9b9b-1165-9f4d-2a55-1ed98fd8142b@gmail.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/zuFaNYBClqQ31Ks9nuZyWNRmPDI>
Subject: Re: [Cbor] draft-ietf-cbor-network-addresses: tag validity; deterministic encoding
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 04 Nov 2021 21:03:45 -0000

I've fixed the code, run some unit tests and exercised it thoroughly in my GRASP app, and separated the code out as https://github.com/becarpenter/graspy/blob/master/tag5254.py. It's under a BSD licence if anyone is interested.

Is there a generic place for small items of CBOR-related code? This doesn't seem to deserve a repo on its own.

Regards
    Brian
On 03-Nov-21 17:07, Brian E Carpenter wrote:
> On 15-Oct-21 17:50, Carsten Bormann wrote:
>> On 15. Oct 2021, at 06:35, Brian E Carpenter <brian.e.carpenter@gmail.com> wrote:
>>>
>>> So, my ugly code is in the functions build5254() and detag5254() in https://github.com/becarpenter/graspy/blob/master/pfxm4.py
>>
>> Nice.
>>
>> After line 122, there needs to be the Python equivalent of a
>>
>> prefix.sub!(/\x00*\z/, ‘’)
> 
> 
> I took an executive decision to throw an exception for covert bits, rather than silently zero them, and in fact changed all my error returns to ValueError exceptions. I believe that's more Pythonesque.
>    
>> (Why not mix floating point calculations and a regex in the same five lines of code :-)
> 
> Because it makes my head hurt, that's why not.
>>
>> Before line 146, you’d need to check whether the size really is
> `asize`.
> 
> Yes, or that the type really is 'bytes' since Python won't check that for
> me.
> 
>> I think the while loop in 154 needs to be before 151.
> 
> I don't think it matters. Either way, the zero bytes get concatenated.
>    
>> If v[0] == 128 and prefix is 16 bytes, what does prefix[v[0]//8] yield in Python?
> 
> IndexError: index out of range
> 
> Good catch. In my app, that is a case that would never happen.
> 
> I've fixed my code, but will let my test app run for a few hours before 
I
> post the update to github.
> 
>      Brian
> 
> 
>