Repository: randombit/botan
Pull request #2003 (2019-06-23 11:45:43)

Change XMSS OIDs and feature macro name
Since draft6 and final RFC are not compatible, don't try to mix them.

I think the current public key format and the upcoming IETF format (https://tools.ietf.org/html/draft-vangeest-x509-hash-sigs-03) are identical. However for now we continue to use a private OID assignment. If in the end the final RFC specifying the public key format does match, then all we have to do is add a second OID that aliases.


Patch:
diff --git a/doc/dev_ref/oids.rst b/doc/dev_ref/oids.rst
index 674d88d84..6aac1a5a7 100644
--- a/doc/dev_ref/oids.rst
+++ b/doc/dev_ref/oids.rst
@@ -11,10 +11,11 @@ Values currently assigned are::
   publicKey   OBJECT IDENTIFIER ::= { randombit 1 }
 
   mceliece    OBJECT IDENTIFIER ::= { publicKey 3 }
-  -- {publicKey 4 } previously used as private X25519
-  xmss        OBJECT IDENTIFIER ::= { publicKey 5 }
+  -- { publicKey 4 } previously used as private X25519
+  -- { publicKey 5 } previously used for XMSS draft 6
   gost-3410-with-sha256 OBJECT IDENTIFIER ::= { publicKey 6 1 }
   kyber       OBJECT IDENTIFIER ::= { publicKey 7 }
+  xmss        OBJECT IDENTIFIER ::= { publicKey 8 }
 
   symmetricKey OBJECT IDENTIFIER ::= { randombit 3 }
 
diff --git a/src/build-data/oids.txt b/src/build-data/oids.txt
index ea8cab01f..f47e2e5de 100644
--- a/src/build-data/oids.txt
+++ b/src/build-data/oids.txt
@@ -13,7 +13,8 @@
 1.3.6.1.4.1.3029.1.2.1 = ElGamal
 1.3.6.1.4.1.25258.1.3 = McEliece
 1.3.101.110 = Curve25519
-1.3.6.1.4.1.25258.1.5 = XMSS
+1.3.6.1.4.1.25258.1.5 = XMSS-draft6
+1.3.6.1.4.1.25258.1.8 = XMSS
 1.3.101.112 = Ed25519
 
 # X9.62 ecPublicKey, valid for ECDSA and ECDH (RFC 3279 sec 2.3.5)
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp
index 0b68d579f..a481ec16a 100644
--- a/src/cli/speed.cpp
+++ b/src/cli/speed.cpp
@@ -633,7 +633,7 @@ class Speed final : public Command
                bench_mceliece(provider, msec);
                }
 #endif
-#if defined(BOTAN_HAS_XMSS)
+#if defined(BOTAN_HAS_XMSS_RFC8391)
             else if(algo == "XMSS")
                {
                bench_xmss(provider, msec);
@@ -2087,7 +2087,7 @@ class Speed final : public Command
          }
 #endif
 
-#if defined(BOTAN_HAS_XMSS)
+#if defined(BOTAN_HAS_XMSS_RFC8391)
       void bench_xmss(const std::string& provider,
                       std::chrono::milliseconds msec)
          {
diff --git a/src/lib/asn1/oid_maps.cpp b/src/lib/asn1/oid_maps.cpp
index 10d82187b..ed1e3df38 100644
--- a/src/lib/asn1/oid_maps.cpp
+++ b/src/lib/asn1/oid_maps.cpp
@@ -1,7 +1,7 @@
 /*
 * OID maps
 *
-* This file was automatically generated by ./src/scripts/oids.py on 2018-08-23
+* This file was automatically generated by ./src/scripts/oids.py on 2019-06-23
 *
 * All manual edits to this file will be lost. Edit the script
 * then regenerate this source file.
@@ -127,8 +127,9 @@ std::unordered_map<std::string, std::string> OIDS::load_oid2str_map()
       { "1.3.6.1.4.1.11591.15.1", "OpenPGP.Ed25519" },
       { "1.3.6.1.4.1.11591.4.11", "Scrypt" },
       { "1.3.6.1.4.1.25258.1.3", "McEliece" },
-      { "1.3.6.1.4.1.25258.1.5", "XMSS" },
+      { "1.3.6.1.4.1.25258.1.5", "XMSS-draft6" },
       { "1.3.6.1.4.1.25258.1.6.1", "GOST-34.10/EMSA1(SHA-256)" },
+      { "1.3.6.1.4.1.25258.1.8", "XMSS" },
       { "1.3.6.1.4.1.25258.3.1", "Serpent/CBC" },
       { "1.3.6.1.4.1.25258.3.101", "Serpent/GCM" },
       { "1.3.6.1.4.1.25258.3.102", "Twofish/GCM" },
@@ -445,7 +446,8 @@ std::unordered_map<std::string, OID> OIDS::load_str2oid_map()
       { "X520.State", OID({2,5,4,8}) },
       { "X520.Surname", OID({2,5,4,4}) },
       { "X520.Title", OID({2,5,4,12}) },
-      { "XMSS", OID({1,3,6,1,4,1,25258,1,5}) },
+      { "XMSS", OID({1,3,6,1,4,1,25258,1,8}) },
+      { "XMSS-draft6", OID({1,3,6,1,4,1,25258,1,5}) },
       { "brainpool160r1", OID({1,3,36,3,3,2,8,1,1,1}) },
       { "brainpool192r1", OID({1,3,36,3,3,2,8,1,1,3}) },
       { "brainpool224r1", OID({1,3,36,3,3,2,8,1,1,5}) },
diff --git a/src/lib/pubkey/pk_algs.cpp b/src/lib/pubkey/pk_algs.cpp
index db4638fe1..16bfbfb1f 100644
--- a/src/lib/pubkey/pk_algs.cpp
+++ b/src/lib/pubkey/pk_algs.cpp
@@ -65,7 +65,7 @@
   #include <botan/mceliece.h>
 #endif
 
-#if defined(BOTAN_HAS_XMSS)
+#if defined(BOTAN_HAS_XMSS_RFC8391)
   #include <botan/xmss.h>
 #endif
 
@@ -155,7 +155,7 @@ load_public_key(const AlgorithmIdentifier& alg_id,
       return std::unique_ptr<Public_Key>(new SM2_PublicKey(alg_id, key_bits));
 #endif
 
-#if defined(BOTAN_HAS_XMSS)
+#if defined(BOTAN_HAS_XMSS_RFC8391)
    if(alg_name == "XMSS")
       return std::unique_ptr<Public_Key>(new XMSS_PublicKey(key_bits));
 #endif
@@ -236,7 +236,7 @@ load_private_key(const AlgorithmIdentifier& alg_id,
       return std::unique_ptr<Private_Key>(new ElGamal_PrivateKey(alg_id, key_bits));
 #endif
 
-#if defined(BOTAN_HAS_XMSS)
+#if defined(BOTAN_HAS_XMSS_RFC8391)
    if(alg_name == "XMSS")
       return std::unique_ptr<Private_Key>(new XMSS_PrivateKey(key_bits));
 #endif
@@ -314,7 +314,7 @@ create_private_key(const std::string& alg_name,
       }
 #endif
 
-#if defined(BOTAN_HAS_XMSS)
+#if defined(BOTAN_HAS_XMSS_RFC8391)
    if(alg_name == "XMSS")
       {
       return std::unique_ptr<Private_Key>(
diff --git a/src/lib/pubkey/xmss/info.txt b/src/lib/pubkey/xmss/info.txt
index 154401af7..72b127831 100644
--- a/src/lib/pubkey/xmss/info.txt
+++ b/src/lib/pubkey/xmss/info.txt
@@ -1,5 +1,5 @@
 <defines>
-XMSS -> 20161008
+XMSS_RFC8391 -> 20190623
 </defines>
 
 <header:public>


Test patch:
diff --git a/src/tests/test_xmss.cpp b/src/tests/test_xmss.cpp
index 84d25aee4..ee801e6fc 100644
--- a/src/tests/test_xmss.cpp
+++ b/src/tests/test_xmss.cpp
@@ -7,7 +7,7 @@
 
 #include "tests.h"
 
-#if defined(BOTAN_HAS_XMSS)
+#if defined(BOTAN_HAS_XMSS_RFC8391)
    #include <botan/xmss.h>
    #include "test_pubkey.h"
 #endif
@@ -16,7 +16,7 @@ namespace Botan_Tests {
 
 namespace {
 
-#if defined(BOTAN_HAS_XMSS)
+#if defined(BOTAN_HAS_XMSS_RFC8391)
 
 class XMSS_Signature_Tests final : public PK_Signature_Generation_Test
    {