Re: [saag] ASN.1 vs. DER Encoding

Peter Gutmann <pgut001@cs.auckland.ac.nz> Thu, 28 March 2019 01:39 UTC

Return-Path: <pgut001@cs.auckland.ac.nz>
X-Original-To: saag@ietfa.amsl.com
Delivered-To: saag@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 35F91120433 for <saag@ietfa.amsl.com>; Wed, 27 Mar 2019 18:39:07 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.199
X-Spam-Level:
X-Spam-Status: No, score=-4.199 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_MED=-2.3, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=auckland.ac.nz
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 8NMauwM3H4PE for <saag@ietfa.amsl.com>; Wed, 27 Mar 2019 18:39:02 -0700 (PDT)
Received: from mx4-int.auckland.ac.nz (mx4-int.auckland.ac.nz [130.216.125.246]) (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 ECBEC120425 for <saag@ietf.org>; Wed, 27 Mar 2019 18:39:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=auckland.ac.nz; i=@auckland.ac.nz; q=dns/txt; s=mail; t=1553737142; x=1585273142; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=pxpNzzxG00LG4EL1OTKEXWQNrs65g5ro8msTuzte5x8=; b=0l8gMNHOvaOLmkDT2oNZ3l/rSKbQPfmKw7S+mSjZM9lmspej2/qE2LsQ y2fRpgfqnaN0L6zzlWXEq92gx28inb3ZBJZ096hrI9cXWnTTQrGwmRCE2 OxDDVZ7m91uHGab5g6EAGIDUFGdmdARLCzD64vsSMh4oM97NL86KrMWeF xG3ltioNNRJgO5dZHin1iF3gbPSddf2r1l3sPa9HyomD5rmB2Rv7e+VAg vK4LRmTRpFFr/RzwortiGqK2yw8khEA1TNWKtj0giGBeVGcP//vTf78rq /tM7iT/3WLcJLxV386AzhQT6+kJWNWvuGTGJMM625CL4DghumnfeJmoS1 Q==;
X-IronPort-AV: E=Sophos;i="5.60,278,1549882800"; d="scan'208";a="53457508"
X-Ironport-HAT: MAIL-SERVERS - $RELAYED
X-Ironport-Source: 10.6.2.3 - Outgoing - Outgoing
Received: from exchangemx.uoa.auckland.ac.nz (HELO uxcn13-ogg-b.UoA.auckland.ac.nz) ([10.6.2.3]) by mx4-int.auckland.ac.nz with ESMTP/TLS/AES256-SHA; 28 Mar 2019 14:38:59 +1300
Received: from uxcn13-ogg-d.UoA.auckland.ac.nz (10.6.2.5) by uxcn13-ogg-b.UoA.auckland.ac.nz (10.6.2.3) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 28 Mar 2019 14:38:59 +1300
Received: from uxcn13-ogg-d.UoA.auckland.ac.nz ([10.6.2.5]) by uxcn13-ogg-d.UoA.auckland.ac.nz ([10.6.2.5]) with mapi id 15.00.1395.000; Thu, 28 Mar 2019 14:38:59 +1300
From: Peter Gutmann <pgut001@cs.auckland.ac.nz>
To: Nico Williams <nico@cryptonector.com>
CC: "Dr. Pala" <madwolf@openca.org>, "saag@ietf.org" <saag@ietf.org>
Thread-Topic: [saag] ASN.1 vs. DER Encoding
Thread-Index: AQHU4/B7Wn4JSCcuPE2ed5Fjno127KYdRg2AgABTYgCAAaGbjv//gw4AgAGH5cs=
Date: Thu, 28 Mar 2019 01:38:59 +0000
Message-ID: <1553737133841.88796@cs.auckland.ac.nz>
References: <20190326164951.GX4211@localhost> <20190326214816.GB4211@localhost> <1553679912618.8510@cs.auckland.ac.nz>,<20190327151545.GG4211@localhost>
In-Reply-To: <20190327151545.GG4211@localhost>
Accept-Language: en-NZ, en-GB, en-US
Content-Language: en-NZ
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-exchange-transport-fromentityheader: Hosted
x-originating-ip: [130.216.158.4]
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Archived-At: <https://mailarchive.ietf.org/arch/msg/saag/5wsl7oh9iZXADJqzHUiPOrG7zwc>
Subject: Re: [saag] ASN.1 vs. DER Encoding
X-BeenThere: saag@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Security Area Advisory Group <saag.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/saag>, <mailto:saag-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/saag/>
List-Post: <mailto:saag@ietf.org>
List-Help: <mailto:saag-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/saag>, <mailto:saag-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 28 Mar 2019 01:39:23 -0000

Nico Williams <nico@cryptonector.com> writes:

>A protocol using ASN.1 BER/DER/CER with IMPLICT tagging will lose some type
>information, so while you can check a lot of an encoded message's validity
>without reference to its schema, you cannot check all of it.

You can check it, you just need to use heurstics.  That's what dumpasn1 does,
it's aware of the situations in which there's encapsulation and can dig down
into both implicit-tagged data and hole encodings.

(Don't look at the code, it's full of hacks to handle broken encodings and
display things in twenty different custom ways, so it's not representative of
what a decoder should look like).

>Whereas if you have reference to its schema, then you can check all of it
>regardless of whether the encoding rules are TLV or not.

And that's the problem, you need to have the schema for the latest version of
every possible protocol you're likely to examine, and update the code every
time anything anywhere changes.  With a self-describing data type, you only
need to write the format firewall once and it'll work indefinitely.  I've been
using the same ASN.1 firewall code for over fifteen years...

Peter.