Re: [lamps] [Pqc] Multiple drafts with PQ algorithm key encodings that are not compatible.

Bas Westerbaan <bas@westerbaan.name> Wed, 28 September 2022 21:30 UTC

Return-Path: <bas@westerbaan.name>
X-Original-To: spasm@ietfa.amsl.com
Delivered-To: spasm@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id D0BB0C15DD4C; Wed, 28 Sep 2022 14:30:56 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -7.005
X-Spam-Level:
X-Spam-Status: No, score=-7.005 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, HTML_MESSAGE=0.001, HTTPS_HTTP_MISMATCH=0.1, MIME_QP_LONG_LINE=0.001, RCVD_IN_DNSWL_HI=-5, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=unavailable autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=westerbaan.name
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WUdLuQ2-bT2E; Wed, 28 Sep 2022 14:30:51 -0700 (PDT)
Received: from vinnana.westerbaan.name (westerbaan.name [95.217.81.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id C7341C15DD49; Wed, 28 Sep 2022 14:30:48 -0700 (PDT)
Received: from smtpclient.apple (2a02-a460-299e-0-749f-5468-6609-e911.fixed6.kpn.net [IPv6:2a02:a460:299e:0:749f:5468:6609:e911]) by vinnana.westerbaan.name (Postfix) with ESMTPSA id C5D9B3E4F45; Wed, 28 Sep 2022 23:30:43 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=westerbaan.name; s=2014; t=1664400643; bh=KOnq04bsIqdY1scIFshLcQNPL3ttfE4DFB5Awq2j5Ug=; h=From:Subject:Date:References:Cc:In-Reply-To:To:From; b=sMZC2hrEMHOQ0q8vXU2DTDXS+ArfOD6uLQPhPMXKcxUnFSRIiEAAg2T821CyKpKIz 9CkmdwzkTtKEIGCOFRK+7LeSv0oMlVwPqfTF9obznW1CZFWrOt5X5N203wXgz6YUHw Nii56xM7ncqEVsGvYkBf0gG6lbY44wIKJgZZ9aLY=
Content-Type: multipart/alternative; boundary="Apple-Mail-139EEC92-CECF-4543-AEAC-55CBEFFD2843"
Content-Transfer-Encoding: 7bit
From: Bas Westerbaan <bas@westerbaan.name>
Mime-Version: 1.0 (1.0)
Date: Wed, 28 Sep 2022 23:30:41 +0200
Message-Id: <2B8DF0B3-B79C-4688-B481-737BCCC9EFF1@westerbaan.name>
References: <574516F5-098F-4CB6-8D9C-F193BF1B1507@amazon.com>
Cc: Mike Ounsworth <Mike.Ounsworth@entrust.com>, John Gray <John.Gray=40entrust.com@dmarc.ietf.org>, pqc@ietf.org, spasm@ietf.org, cfrg@ietf.org, "Panos Kampanakis (pkampana)" <pkampana@cisco.com>, Sean Turner <sean@sn3rd.com>, cvvrede@gmail.com, sid@zurich.ibm.com, bhe@zurich.ibm.com, tvi@zurich.ibm.com, osb@zurich.ibm.com, dieter.bong@utimaco.com, joppe.bos@nxp.com, "Markku-Juhani O. Saarinen" <mjos@pqshield.com>
In-Reply-To: <574516F5-098F-4CB6-8D9C-F193BF1B1507@amazon.com>
To: "Massimo, Jake" <jakemas@amazon.com>
X-Mailer: iPad Mail (19H12)
Archived-At: <https://mailarchive.ietf.org/arch/msg/spasm/PZ3IB0ce6ilWlNxUXB4-tsilPO0>
X-Mailman-Approved-At: Thu, 29 Sep 2022 06:51:29 -0700
Subject: Re: [lamps] [Pqc] Multiple drafts with PQ algorithm key encodings that are not compatible.
X-BeenThere: spasm@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: "This is a venue for discussion of doing Some Pkix And SMime \(spasm\) work." <spasm.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/spasm>, <mailto:spasm-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/spasm/>
List-Post: <mailto:spasm@ietf.org>
List-Help: <mailto:spasm-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/spasm>, <mailto:spasm-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 28 Sep 2022 21:30:56 -0000

>      DilithiumPrivateKey ::= SEQUENCE {
>          version                               Version,
>          privateKeyAlgorithm      PrivateKeyAlgorithmIdentifier,
>          privateKey                        OCTET STRING,
>          publicKey                            [0] IMPLICIT DilithiumPublicKey OPTIONAL
>      }

PQC private keys are typically rather large and, for many schemes can be generated cheaply from a small seed (such as with Dilithium). That’s helpful if you store many private keys or are rather constrained in storage.

So I’d propose as format either storing the opaque private key (as specified by the CRYSTALS team) or the seed.

Best,

 Bas






> i.e., the parameters are defined/contained within privateKeyAlgorithm. This means we can support the byte array encoding for the private key proposed by the algorithm designers in privateKey an OCTET STRING.
>  
> Thoughts?
>  
> Cheers,
> Jake
>  
> From: Mike Ounsworth <Mike.Ounsworth@entrust.com>
> Date: Wednesday, 28 September 2022 at 13:26
> To: John Gray <John.Gray=40entrust.com@dmarc.ietf.org>, "pqc@ietf.org" <pqc@ietf.org>, "spasm@ietf.org" <spasm@ietf.org>, "cfrg@ietf.org" <cfrg@ietf.org>
> Cc: "Massimo, Jake" <jakemas@amazon.com>, "Panos Kampanakis (pkampana)" <pkampana@cisco.com>, Sean Turner <sean@sn3rd.com>, "bas@westerbaan.name" <bas@westerbaan.name>, "cvvrede@gmail.com" <cvvrede@gmail.com>, "sid@zurich.ibm.com" <sid@zurich.ibm.com>, "bhe@zurich.ibm.com" <bhe@zurich.ibm.com>, "tvi@zurich.ibm.com" <tvi@zurich.ibm.com>, "osb@zurich.ibm.com" <osb@zurich.ibm.com>, "dieter.bong@utimaco.com" <dieter.bong@utimaco.com>, "joppe.bos@nxp.com" <joppe.bos@nxp.com>
> Subject: RE: [EXTERNAL][Pqc] Multiple drafts with PQ algorithm key encodings that are not compatible.
>  
> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
> 
>  
> My curiosity is about the procedural aspect of draft-uni-qsckeys. Is this attached to a working group? Are you indenting to publishing this as an RFC, or is this just to bridge prototyping work until NIST publishes real standards?
>  
> ---
> Mike Ounsworth
> Software Security Architect, Entrust
>  
> From: Pqc <pqc-bounces@ietf.org> On Behalf Of John Gray
> Sent: September 28, 2022 1:34 PM
> To: pqc@ietf.org; spasm@ietf.org; cfrg@ietf.org
> Cc: Massimo, Jake <jakemas@amazon.com>; Panos Kampanakis (pkampana) <pkampana@cisco.com>; Sean Turner <sean@sn3rd.com>; bas@westerbaan.name; cvvrede@gmail.com; sid@zurich.ibm.com; bhe@zurich.ibm.com; tvi@zurich.ibm.com; osb@zurich.ibm.com; dieter.bong@utimaco.com; joppe.bos@nxp.com
> Subject: [EXTERNAL] [Pqc] Multiple drafts with PQ algorithm key encodings that are not compatible.
>  
> WARNING: This email originated outside of Entrust.
> DO NOT CLICK links or attachments unless you trust the sender and know the content is safe.
> We are doing some interoperability testing with different vendors using the new Dilithium, Falcon and SPHINCS+ algorithms.   We have come across at least two drafts which are trying to specify the ASN.1 encoding formats for these algorithms.   However, the encoding formats are not compatible with each other.   I imagine the authors of these drafts should get together and come up with a common format (I have copied them on this email).   This means we must choose one or the other, or even worse, support multiple formats (which can lead to bugs).   Initially I started more than a year ago using my own encoding format for internal prototyping, but now need to interoperate with others outside of our organization, so a common format is definitely needed at this point.   😊
>  
> We fully realize the OID values will be changing once official OIDs are registered, (changing those are trivial), but the ASN.1 formats of the public and private keys is kind of important as well…  😊
>  
> For example:
>  
> The LAMPS group has a specification of Dilithium public keys in this draft:
> https://datatracker.ietf.org/doc/draft-massimo-lamps-pq-sig-certificates/
>  
> the public key format is this:
>  
> The Dilithium public key MUST be encoded using the ASN.1 type
>    DilithiumPublicKey:
>  
>      DilithiumPublicKey ::= OCTET STRING
>  
> The private key format is this:
>  
>      DilithiumPrivateKey ::= SEQUENCE {
>          rho         BIT STRING,         - nonce/seed
>          K           BIT STRING,         - key/seed
>          tr          BIT STRING,         - PRF bytes (CRH in spec.)
>          s1          BIT STRING,         - vector l
>          s2          BIT STRING,         - vector k
>          t0          BIT STRING,         - encoded vector
>          PublicKey   IMPLICIT DilithiumPublicKey OPTIONAL
>      }
>  
>  
> In this draft:
> https://datatracker.ietf.org/doc/draft-uni-qsckeys/01/
>  
> Dilithium keys have this encoding:
>  
>  
>    DilithiumPublicKey ::= SEQUENCE {
>        rho         OCTET STRING,
>        t1          OCTET STRING
>    }
>  
>  
>   DilithiumPrivateKey ::= SEQUENCE {
>        version     INTEGER {v0(0)}     -- version (round 3)
>        nonce       BIT STRING,         -- rho
>        key         BIT STRING,         -- key/seed/D
>        tr          BIT STRING,         -- PRF bytes (CRH in spec)
>        s1          BIT STRING,         -- vector(L)
>        s2          BIT STRING,         -- vector(K)
>        t0          BIT STRING,
>        publicKey  [0] IMPLICIT DilithiumPublicKey OPTIONAL
>                                        -- see next section
>    }
>  
> The draft-uni-qsckeys does not cover SPHINCS+,  it does cover Falcon, but I don’t know of another draft that specifies Falcon.
>  
> There are also encodings for Kyber mentioned in two documents that I see.  There is an early   https://datatracker.ietf.org/doc/draft-ietf-lamps-kyber-certificates/  draft which mentions it is up to the document defining Kyber to give more details.    In the draft-uni-qsckeys draft it is more specific.    
>  
> https://datatracker.ietf.org/doc/draft-uni-qsckeys/01/
>  
>    KyberPrivateKey ::= SEQUENCE {
>        version     INTEGER {v0(0)}   -- version (round 3)
>        s           OCTET STRING,     -- sample s
>        publicKey   [0] IMPLICIT KyberPublicKey OPTIONAL,
>                                      -- see next section
>        hpk         OCTET STRING      -- H(pk)
>        nonce       OCTET STRING,     -- z
>    }
>  
> Partial public key encoding:
>  
> KyberPrivateKey ::= SEQUENCE {
>        version     INTEGER {v0(0)}   -- version (round 3)
>        s           OCTET STRING,     -- EMPTY
>        publicKey   [0] IMPLICIT KyberPublicKey OPTIONAL,
>                                      -- see next section
>        hpk         OCTET STRING      -- EMPTY
>        nonce       OCTET STRING,     -- d
>    }
>  
> Full public key encoding:
>  
>    KyberPublicKey ::= SEQUENCE {
>        t           OCTET STRING,
>        rho         OCTET STRING
>    }
>  
> Is https://datatracker.ietf.org/doc/draft-uni-qsckeys/01/ meant to become the document that defines the key formats for all the PQ keys that will be standardized?    If not, then it should probably just refer to whatever documents will define the formats so that we can at least agree on one common format for the PQ keys.
>  
>  
> Cheers,
>  
> John Gray
> Entrust
> Any email and files/attachments transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed. If this message has been sent to you in error, you must not copy, distribute or disclose of the information it contains. Please notify Entrust immediately and delete the message from your system.