Re: [pkix] World's smallest well-formed certificate

Erwann Abalea <eabalea@gmail.com> Wed, 18 May 2016 13:02 UTC

Return-Path: <eabalea@gmail.com>
X-Original-To: pkix@ietfa.amsl.com
Delivered-To: pkix@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id BE66412D1BF for <pkix@ietfa.amsl.com>; Wed, 18 May 2016 06:02:10 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.393
X-Spam-Level:
X-Spam-Status: No, score=-1.393 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, TRACKER_ID=1.306] autolearn=no 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 YN4TxMPE3__g for <pkix@ietfa.amsl.com>; Wed, 18 May 2016 06:02:08 -0700 (PDT)
Received: from mail-lf0-x22a.google.com (mail-lf0-x22a.google.com [IPv6:2a00:1450:4010:c07::22a]) (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 7683E12D1D8 for <pkix@ietf.org>; Wed, 18 May 2016 06:01:53 -0700 (PDT)
Received: by mail-lf0-x22a.google.com with SMTP id y84so19768797lfc.0 for <pkix@ietf.org>; Wed, 18 May 2016 06:01:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=DIKjgrIWr0Gq067Pxk3rqipGWp4/RvQMOhzuC8sqtXA=; b=pXIe2BuDJjFwrecH0luNkKpJlYvOqb/yU5/k70WtGP/yBsdMKmYPiPJhPRoPQcEWzL n5qj2g65pgRuRJuCXFP3k6OSCZqN0yB3Zx8uZFeGdaGeEuZQ9UCBBA4LYm3XYvyXAfUE NV94hX7HBrcj0Yq+TOGQyryjpu9ffTnXNP5Z5zyb4JiC88tZGQtexKy3x389sDO3X7SF vjFaCuuLjRgMp154j6ISxs1tGCMXfMgpaTmIhHMWAS47ktLUoeSK3fngWVAexBcqGcs5 mJN+xdiYkpySx0hxEEcotVn07vtc4fnL7uthr24/xvcfCdqw8uRYPL30w0VTXx/KBRmb Qp9w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=DIKjgrIWr0Gq067Pxk3rqipGWp4/RvQMOhzuC8sqtXA=; b=dbtt/00yJ8dfAuZrlGxVZPEjho3S22BZckw8F2b7JlMwGvWG6heod8I3EjL3G0HaFo ZNMoWhaP2hZnbmMtZG5u0ysnpbw9saaqM+OburqywtLGn1XbZSmmaUOUwq2oWzyQnZFa A8PXeq1YCdHsXSy4QlXDRnrPlJ/C8dE96nYHt6ZX9N/Lk4Rjv8UONNzFQPLflRv5zFby +6b7sxw3UCf7UErWaE9J1WsXXMa8VkOpT58O664HWgrVrxJfmsAnie51GFnzF4x2UNMN Ij9l8p3kVt9LaqAZYH3EHScQfAqIs23uhBmerOnTdnhq2d8PNx4UQ0hrw6Fc+JPNsy21 kEaA==
X-Gm-Message-State: AOPr4FWZlOCSRzHjWMkiH8jdOGGZ4m2wFh8e7ehmsoKHnxQJdierOa3Z/NwPtS+OFjpgM2RqjPRIzJuWCoEuXg==
MIME-Version: 1.0
X-Received: by 10.25.30.7 with SMTP id e7mr2227451lfe.137.1463576511717; Wed, 18 May 2016 06:01:51 -0700 (PDT)
Received: by 10.114.4.138 with HTTP; Wed, 18 May 2016 06:01:51 -0700 (PDT)
In-Reply-To: <af723bb1-9cf6-d18d-7d0a-3c709daa0a94@comodo.com>
References: <7b8c0b5a-2133-b094-2d09-e37efae98994@seantek.com> <af723bb1-9cf6-d18d-7d0a-3c709daa0a94@comodo.com>
Date: Wed, 18 May 2016 15:01:51 +0200
Message-ID: <CA+i=0E78phJHizoOniU3+wrJBWKbLhCKwZKVF5oLC0xwqV74GQ@mail.gmail.com>
From: Erwann Abalea <eabalea@gmail.com>
To: Rob Stradling <rob.stradling@comodo.com>
Content-Type: multipart/alternative; boundary=001a1140215c152aef05331d766f
Archived-At: <http://mailarchive.ietf.org/arch/msg/pkix/BSsTl25XveUa-sLRb5uWtbhhdTg>
Cc: "pkix@ietf.org" <pkix@ietf.org>, Sean Leonard <dev+ietf@seantek.com>
Subject: Re: [pkix] World's smallest well-formed certificate
X-BeenThere: pkix@ietf.org
X-Mailman-Version: 2.1.17
Precedence: list
List-Id: PKIX Working Group <pkix.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/pkix>, <mailto:pkix-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/pkix/>
List-Post: <mailto:pkix@ietf.org>
List-Help: <mailto:pkix-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/pkix>, <mailto:pkix-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 18 May 2016 13:02:11 -0000

Bonjour,

Your examples have serial numbers encoded with a zero length, this is not
DER compliant.
The Name type used for issuer and subject is an unconstrained SEQUENCE OF,
so in theory it can be empty and be well-formed (from a DER point of view).

My proposal, 66 octets:
-----BEGIN CERTIFICATE-----
MEAwNgIBADADBgEAMAAwHhcNMTYwNTE4MDAwMDAwWhcNMTcwNTE4MDAwMDAwWjAA
MAgwAwYBAAMBADADBgEAAwEA
-----END CERTIFICATE-----


2016-05-18 11:25 GMT+02:00 Rob Stradling <rob.stradling@comodo.com>om>:

> Hi Sean.  I can get OpenSSL to not barf in 99 bytes...
>
> $ echo "-----BEGIN CERTIFICATE-----
> MGEwVwIAMAMGAQAwCTEHMAUGAQATADAeFw0xNjA1MTgwMDAwMDBaFw0xNzA1MTgw
> MDAwMDBaMAkxBzAFBgEAEwAwGDANBgkqhkiG9w0BAQEFAAMHADAEAgACADADBgEA
> AwEA
> -----END CERTIFICATE-----" | openssl x509 -text -noout
> Certificate:
>     Data:
>         Version: 1 (0x0)
>         Serial Number: 0 (0x0)
>     Signature Algorithm: 0.0
>         Issuer: 0.0=
>         Validity
>             Not Before: May 18 00:00:00 2016 GMT
>             Not After : May 18 00:00:00 2017 GMT
>         Subject: 0.0=
>         Subject Public Key Info:
>             Public Key Algorithm: rsaEncryption
>                 Public-Key: (0 bit)
>                 Modulus: 0
>                 Exponent: 0
>     Signature Algorithm: 0.0
>
>
> I see what you mean about barfing on a "malformed" public key.  This was
> my first attempt...
>
> $ echo "-----BEGIN CERTIFICATE-----
> MFEwRwIAMAMGAQAwCTEHMAUGAQATADAeFw0xNjA1MTgwMDAwMDBaFw0xNzA1MTgw
> MDAwMDBaMAkxBzAFBgEAEwAwCDADBgEAAwEAMAMGAQADAQA=
> -----END CERTIFICATE-----" | openssl x509 -text -noout
> Certificate:
>     Data:
>         Version: 1 (0x0)
>         Serial Number: 0 (0x0)
>     Signature Algorithm: 0.0
>         Issuer: 0.0=
>         Validity
>             Not Before: May 18 00:00:00 2016 GMT
>             Not After : May 18 00:00:00 2017 GMT
>         Subject: 0.0=
>         Subject Public Key Info:
>             Public Key Algorithm: 0.0
>             Unable to load Public Key
> 3073144508:error:0609E09C:digital envelope
> routines:PKEY_SET_TYPE:unsupported algorithm:p_lib.c:231:
> 3073144508:error:0B07706F:x509 certificate
> routines:X509_PUBKEY_get:unsupported algorithm:x_pubkey.c:148:
>     Signature Algorithm: 0.0
>
> P.S. OpenSSL barfs on an RDN Attribute of type NULL, so I used a
> zero-length PrintableString instead.
>
> On 18/05/16 08:29, Sean Leonard wrote:
>
>> I'm working on a problem that involves the DER encoding of the smallest
>> well-formed (yet pathological) certificate. How many octets can the
>> world's smallest well-formed certificate be?
>>
>> A Certificate is a SEQUENCE of TBSCertificate, AlgorithmIdentifier, and
>> BIT STRING (the signature). The world's smallest certificate would be
>> version = 1 (therefore omitted), a serial number of 0, a hypothetical
>> signature (AlgorithmIdentifier) that has the world's smallest object
>> identifier (0.0) and no parameters, an issuer Name (distinguished name)
>> that has one RDN that has one Attribute whose type is the world's
>> smallest object identifier (0.0) and whose value is the ASN.1's smallest
>> value (NULL), with proper validity times, the same or similar smallest
>> subject Name, a well-formed SubjectPublicKeyInfo, and none of the
>> optional fields: issuerUniqueID, subjectUniqueID, and extensions.
>>
>> By "well-formed", I mean that an ASN.1 '88 parser (i.e., one that does
>> not enforce information object classes) will parse it (including the BIT
>> STRING contents) and not barf. Such a certificate could not possibly be
>> "valid", since the signature block would not be a real digital signature.
>>
>> Sean
>>
>> (PS For those who want to know "why", it's because I am trying to test
>> some assumptions about how small a certificate can be.)
>>
>
> --
> Rob Stradling
> Senior Research & Development Scientist
> COMODO - Creating Trust Online
>
>
> _______________________________________________
> pkix mailing list
> pkix@ietf.org
> https://www.ietf.org/mailman/listinfo/pkix
>



-- 
Erwann.