Re: [openpgp] The combinatorial complexity of OpenPGPv4

Falcon Darkstar Momot <falcon@iridiumlinux.org> Sat, 14 March 2015 01:20 UTC

Return-Path: <falcon@iridiumlinux.org>
X-Original-To: openpgp@ietfa.amsl.com
Delivered-To: openpgp@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 8EF201A8876 for <openpgp@ietfa.amsl.com>; Fri, 13 Mar 2015 18:20:07 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.911
X-Spam-Level:
X-Spam-Status: No, score=-1.911 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=ham
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 NG_hf_CQniJM for <openpgp@ietfa.amsl.com>; Fri, 13 Mar 2015 18:20:03 -0700 (PDT)
Received: from smtp.iridiumlinux.org (akira.iridiumlinux.org [184.70.203.174]) by ietfa.amsl.com (Postfix) with ESMTP id AF6EC1A8871 for <openpgp@ietf.org>; Fri, 13 Mar 2015 18:20:03 -0700 (PDT)
Received: by smtp.iridiumlinux.org (Postfix, from userid 65534) id EADE013F42DF; Fri, 13 Mar 2015 19:20:02 -0600 (MDT)
X-Spam-ASN:
Received: from [192.168.0.5] (c-24-143-80-128.customer.broadstripe.net [24.143.80.128]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.iridiumlinux.org (Postfix) with ESMTPSA id E001C13F428C for <openpgp@ietf.org>; Fri, 13 Mar 2015 19:20:00 -0600 (MDT)
Message-ID: <55038CBE.7070608@iridiumlinux.org>
Date: Fri, 13 Mar 2015 18:19:58 -0700
From: Falcon Darkstar Momot <falcon@iridiumlinux.org>
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0
MIME-Version: 1.0
To: openpgp@ietf.org
References: <CAA7UWsV9RbPCNfbxumsQ-r02Rb3PG6h1fu_ENQrcSg=45a+QnA@mail.gmail.com>
In-Reply-To: <CAA7UWsV9RbPCNfbxumsQ-r02Rb3PG6h1fu_ENQrcSg=45a+QnA@mail.gmail.com>
Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg="sha1"; boundary="------------ms010306010408020008060605"
Archived-At: <http://mailarchive.ietf.org/arch/msg/openpgp/jJ2nfRdQo3yJcPX_oC95MBszXMU>
Subject: Re: [openpgp] The combinatorial complexity of OpenPGPv4
X-BeenThere: openpgp@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: "Ongoing discussion of OpenPGP issues." <openpgp.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/openpgp>, <mailto:openpgp-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/openpgp/>
List-Post: <mailto:openpgp@ietf.org>
List-Help: <mailto:openpgp-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/openpgp>, <mailto:openpgp-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 14 Mar 2015 01:20:07 -0000

I feel like perhaps this type of exhaustive testing is neither necessary
nor expected, and that a few end-to-end tests designed to exercise edge
cases could be combined with more exhaustive unit tests to achieve
reasonable results.  Protocol modularity is not evil.

--Falcon Darkstar Momot
--Shadytel

On 13/03/2015 17:04, David Leon Gil wrote:
> Suppose that I want to test whether an implementation
> handles all OpenPGPv4 signed-then-encrypted messages
> correctly. How many test cases do I need?
>
> Let's suppose, first, that I prove that handling of
> PTag formats is independent of the rest of the code.
>
> In that case, the packet composition is either:
>
>     PKESK
>     SEIPD
>       COMPRESSED
>       LITERAL
>       SIGNATURE
>     MDC
>
> Or:
>
>     PKESK
>     SE
>       COMPRESSED
>       LITERAL
>       SIGNATURE
>
> How many different ways can I compose this message?
>
> 15 * 24 * 4 * 3 * 35
> - 15: PKESK
>   - RSA-ES
>   - RSA-E
>   - ELG-E
>   - 12 ECDH combinations:
>     - 3 curves
>       - P-256
>       - P-384
>       - P-521
>     - 4 KDF hash algorithms
>       - SHA2-224
>       - SHA2-256
>       - SHA2-384
>       - SHA2-512
> - 24: SEIPD
>   - 2 choices of packet type
>     - SE
>     - SEIPD
>   - 12 encryption algorithms
>     - Plaintext (prohibited)
>     - IDEA
>     - TripleDES
>     - CAST5
>     - Blowfish
>     - AES128
>     - AES192
>     - AES256
>     - Twofish
>     - CAMELLIA128
>     - CAMELLIA192
>     - CAMELLIA256
> - 4: Compressed
>   - Uncompressed
>   - ZLIB
>   - DEFLATE
>   - BZIP2
> - 3: Literal
>   - UTF-8
>   - Binary
>   - Local
> - 35: Signature
>  - 5 asymmetric algorithms:
>    - RSA-ES
>    - RSA-S
>    - DSA
>    - ECDSA
>    - ED25519 (GnuPG)
>  - 7 hash algorithms:
>    - MD5
>    - SHA-1
>    - RIPEMD160
>    - SHA2-224
>    - SHA2-256
>    - SHA2-384
>    - SHA2-512
>
> Or: 151,200 test cases. For the simplest message anyone
> wants to send.
>
> Not including any of the details of signature subpackets,
> or unusual (but valid) variants of PKESKs etc. I previously
> calculated that number, but it is so absurdly huge I won't
> bother.
>
> - David
>
> _______________________________________________
> openpgp mailing list
> openpgp@ietf.org
> https://www.ietf.org/mailman/listinfo/openpgp