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

Rob Stradling <rob.stradling@comodo.com> Wed, 18 May 2016 09:26 UTC

Return-Path: <rob.stradling@comodo.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 DB30312B053 for <pkix@ietfa.amsl.com>; Wed, 18 May 2016 02:26:00 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.2
X-Spam-Level:
X-Spam-Status: No, score=-4.2 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3] autolearn=ham autolearn_force=no
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 XzlL4G7mQ3b9 for <pkix@ietfa.amsl.com>; Wed, 18 May 2016 02:25:58 -0700 (PDT)
Received: from mmextmx1.mcr.colo.comodoca.net (mmextmx1.mcr.colo.comodoca.net [IPv6:2a02:1788:402:c00::c0a8:9cd5]) (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 0D0F412B04B for <pkix@ietf.org>; Wed, 18 May 2016 02:25:57 -0700 (PDT)
Received: (qmail 15832 invoked by uid 1004); 18 May 2016 09:25:55 -0000
Received: from ian.brad.office.comodo.net (HELO ian.brad.office.comodo.net) (192.168.0.202) by mmextmx1.mcr.colo.comodoca.net (qpsmtpd/0.84) with ESMTP; Wed, 18 May 2016 10:25:55 +0100
Received: (qmail 13048 invoked by uid 1000); 18 May 2016 09:25:55 -0000
Received: from and0004.comodo.net (HELO [192.168.0.58]) (192.168.0.58) (smtp-auth username rob, mechanism plain) by ian.brad.office.comodo.net (qpsmtpd/0.40) with (AES128-SHA encrypted) ESMTPSA; Wed, 18 May 2016 10:25:55 +0100
To: Sean Leonard <dev+ietf@seantek.com>, "pkix@ietf.org" <pkix@ietf.org>
References: <7b8c0b5a-2133-b094-2d09-e37efae98994@seantek.com>
From: Rob Stradling <rob.stradling@comodo.com>
Message-ID: <af723bb1-9cf6-d18d-7d0a-3c709daa0a94@comodo.com>
Date: Wed, 18 May 2016 10:25:55 +0100
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.1.0
MIME-Version: 1.0
In-Reply-To: <7b8c0b5a-2133-b094-2d09-e37efae98994@seantek.com>
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit
Archived-At: <http://mailarchive.ietf.org/arch/msg/pkix/BKrMeVnftPq8exxdDcwTLUyF6lM>
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 09:26:01 -0000

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