Skip to content

Commit

Permalink
Consistently use ClassicMcEliece for CMCE parameter names
Browse files Browse the repository at this point in the history
  • Loading branch information
randombit committed Jan 18, 2025
1 parent 91a2620 commit 1873d51
Show file tree
Hide file tree
Showing 12 changed files with 287 additions and 285 deletions.
32 changes: 16 additions & 16 deletions src/build-data/oids.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,24 @@
1.3.6.1.4.1.25258.1.12.3.6 = SphincsPlus-haraka-256f-r3.1

# Classic McEliece OID selection from IETF Hackathon/BouncyCastle for non PC instances
1.3.6.1.4.1.22554.5.1.1 = mceliece348864
1.3.6.1.4.1.22554.5.1.2 = mceliece348864f
1.3.6.1.4.1.22554.5.1.3 = mceliece460896
1.3.6.1.4.1.22554.5.1.4 = mceliece460896f
1.3.6.1.4.1.22554.5.1.5 = mceliece6688128
1.3.6.1.4.1.22554.5.1.6 = mceliece6688128f
1.3.6.1.4.1.22554.5.1.7 = mceliece6960119
1.3.6.1.4.1.22554.5.1.8 = mceliece6960119f
1.3.6.1.4.1.22554.5.1.9 = mceliece8192128
1.3.6.1.4.1.22554.5.1.10 = mceliece8192128f
1.3.6.1.4.1.22554.5.1.1 = ClassicMcEliece_348864
1.3.6.1.4.1.22554.5.1.2 = ClassicMcEliece_348864f
1.3.6.1.4.1.22554.5.1.3 = ClassicMcEliece_460896
1.3.6.1.4.1.22554.5.1.4 = ClassicMcEliece_460896f
1.3.6.1.4.1.22554.5.1.5 = ClassicMcEliece_6688128
1.3.6.1.4.1.22554.5.1.6 = ClassicMcEliece_6688128f
1.3.6.1.4.1.22554.5.1.7 = ClassicMcEliece_6960119
1.3.6.1.4.1.22554.5.1.8 = ClassicMcEliece_6960119f
1.3.6.1.4.1.22554.5.1.9 = ClassicMcEliece_8192128
1.3.6.1.4.1.22554.5.1.10 = ClassicMcEliece_8192128f

# Classic McEliece PC OIDs are currently in Botan's private arc
1.3.6.1.4.1.25258.1.18.1 = mceliece6688128pc
1.3.6.1.4.1.25258.1.18.2 = mceliece6688128pcf
1.3.6.1.4.1.25258.1.18.3 = mceliece6960119pc
1.3.6.1.4.1.25258.1.18.4 = mceliece6960119pcf
1.3.6.1.4.1.25258.1.18.5 = mceliece8192128pc
1.3.6.1.4.1.25258.1.18.6 = mceliece8192128pcf
1.3.6.1.4.1.25258.1.18.1 = ClassicMcEliece_6688128pc
1.3.6.1.4.1.25258.1.18.2 = ClassicMcEliece_6688128pcf
1.3.6.1.4.1.25258.1.18.3 = ClassicMcEliece_6960119pc
1.3.6.1.4.1.25258.1.18.4 = ClassicMcEliece_6960119pcf
1.3.6.1.4.1.25258.1.18.5 = ClassicMcEliece_8192128pc
1.3.6.1.4.1.25258.1.18.6 = ClassicMcEliece_8192128pcf

# XMSS
1.3.6.1.4.1.25258.1.5 = XMSS-draft6
Expand Down
66 changes: 33 additions & 33 deletions src/lib/asn1/oid_maps.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* OID maps
*
* This file was automatically generated by ./src/scripts/dev_tools/gen_oids.py on 2024-10-18
* This file was automatically generated by ./src/scripts/dev_tools/gen_oids.py on 2024-12-30
*
* All manual edits to this file will be lost. Edit the script
* then regenerate this source file.
Expand Down Expand Up @@ -142,16 +142,16 @@ std::unordered_map<std::string, std::string> OID_Map::load_oid2str_map() {
{"1.3.36.3.3.2.8.1.1.9", "brainpool320r1"},
{"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.22554.5.1.1", "mceliece348864"},
{"1.3.6.1.4.1.22554.5.1.10", "mceliece8192128f"},
{"1.3.6.1.4.1.22554.5.1.2", "mceliece348864f"},
{"1.3.6.1.4.1.22554.5.1.3", "mceliece460896"},
{"1.3.6.1.4.1.22554.5.1.4", "mceliece460896f"},
{"1.3.6.1.4.1.22554.5.1.5", "mceliece6688128"},
{"1.3.6.1.4.1.22554.5.1.6", "mceliece6688128f"},
{"1.3.6.1.4.1.22554.5.1.7", "mceliece6960119"},
{"1.3.6.1.4.1.22554.5.1.8", "mceliece6960119f"},
{"1.3.6.1.4.1.22554.5.1.9", "mceliece8192128"},
{"1.3.6.1.4.1.22554.5.1.1", "ClassicMcEliece_348864"},
{"1.3.6.1.4.1.22554.5.1.10", "ClassicMcEliece_8192128f"},
{"1.3.6.1.4.1.22554.5.1.2", "ClassicMcEliece_348864f"},
{"1.3.6.1.4.1.22554.5.1.3", "ClassicMcEliece_460896"},
{"1.3.6.1.4.1.22554.5.1.4", "ClassicMcEliece_460896f"},
{"1.3.6.1.4.1.22554.5.1.5", "ClassicMcEliece_6688128"},
{"1.3.6.1.4.1.22554.5.1.6", "ClassicMcEliece_6688128f"},
{"1.3.6.1.4.1.22554.5.1.7", "ClassicMcEliece_6960119"},
{"1.3.6.1.4.1.22554.5.1.8", "ClassicMcEliece_6960119f"},
{"1.3.6.1.4.1.22554.5.1.9", "ClassicMcEliece_8192128"},
{"1.3.6.1.4.1.25258.1.10.1", "Dilithium-4x4-AES-r3"},
{"1.3.6.1.4.1.25258.1.10.2", "Dilithium-6x5-AES-r3"},
{"1.3.6.1.4.1.25258.1.10.3", "Dilithium-8x7-AES-r3"},
Expand Down Expand Up @@ -189,12 +189,12 @@ std::unordered_map<std::string, std::string> OID_Map::load_oid2str_map() {
{"1.3.6.1.4.1.25258.1.17.1", "eFrodoKEM-640-AES"},
{"1.3.6.1.4.1.25258.1.17.2", "eFrodoKEM-976-AES"},
{"1.3.6.1.4.1.25258.1.17.3", "eFrodoKEM-1344-AES"},
{"1.3.6.1.4.1.25258.1.18.1", "mceliece6688128pc"},
{"1.3.6.1.4.1.25258.1.18.2", "mceliece6688128pcf"},
{"1.3.6.1.4.1.25258.1.18.3", "mceliece6960119pc"},
{"1.3.6.1.4.1.25258.1.18.4", "mceliece6960119pcf"},
{"1.3.6.1.4.1.25258.1.18.5", "mceliece8192128pc"},
{"1.3.6.1.4.1.25258.1.18.6", "mceliece8192128pcf"},
{"1.3.6.1.4.1.25258.1.18.1", "ClassicMcEliece_6688128pc"},
{"1.3.6.1.4.1.25258.1.18.2", "ClassicMcEliece_6688128pcf"},
{"1.3.6.1.4.1.25258.1.18.3", "ClassicMcEliece_6960119pc"},
{"1.3.6.1.4.1.25258.1.18.4", "ClassicMcEliece_6960119pcf"},
{"1.3.6.1.4.1.25258.1.18.5", "ClassicMcEliece_8192128pc"},
{"1.3.6.1.4.1.25258.1.18.6", "ClassicMcEliece_8192128pcf"},
{"1.3.6.1.4.1.25258.1.3", "McEliece"},
{"1.3.6.1.4.1.25258.1.5", "XMSS-draft6"},
{"1.3.6.1.4.1.25258.1.6.1", "GOST-34.10-2012-256/SHA-256"},
Expand Down Expand Up @@ -378,6 +378,22 @@ std::unordered_map<std::string, OID> OID_Map::load_str2oid_map() {
{"Camellia-256/SIV", OID({1, 3, 6, 1, 4, 1, 25258, 3, 4, 8})},
{"Certificate Comment", OID({2, 16, 840, 1, 113730, 1, 13})},
{"ChaCha20Poly1305", OID({1, 2, 840, 113549, 1, 9, 16, 3, 18})},
{"ClassicMcEliece_348864", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 1})},
{"ClassicMcEliece_348864f", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 2})},
{"ClassicMcEliece_460896", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 3})},
{"ClassicMcEliece_460896f", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 4})},
{"ClassicMcEliece_6688128", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 5})},
{"ClassicMcEliece_6688128f", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 6})},
{"ClassicMcEliece_6688128pc", OID({1, 3, 6, 1, 4, 1, 25258, 1, 18, 1})},
{"ClassicMcEliece_6688128pcf", OID({1, 3, 6, 1, 4, 1, 25258, 1, 18, 2})},
{"ClassicMcEliece_6960119", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 7})},
{"ClassicMcEliece_6960119f", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 8})},
{"ClassicMcEliece_6960119pc", OID({1, 3, 6, 1, 4, 1, 25258, 1, 18, 3})},
{"ClassicMcEliece_6960119pcf", OID({1, 3, 6, 1, 4, 1, 25258, 1, 18, 4})},
{"ClassicMcEliece_8192128", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 9})},
{"ClassicMcEliece_8192128f", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 10})},
{"ClassicMcEliece_8192128pc", OID({1, 3, 6, 1, 4, 1, 25258, 1, 18, 5})},
{"ClassicMcEliece_8192128pcf", OID({1, 3, 6, 1, 4, 1, 25258, 1, 18, 6})},
{"Compression.Zlib", OID({1, 2, 840, 113549, 1, 9, 16, 3, 8})},
{"Curve25519", OID({1, 3, 101, 110})},
{"DES/CBC", OID({1, 3, 14, 3, 2, 7})},
Expand Down Expand Up @@ -637,22 +653,6 @@ std::unordered_map<std::string, OID> OID_Map::load_str2oid_map() {
{"gost_256B", OID({1, 2, 643, 7, 1, 2, 1, 1, 2})},
{"gost_512A", OID({1, 2, 643, 7, 1, 2, 1, 2, 1})},
{"gost_512B", OID({1, 2, 643, 7, 1, 2, 1, 2, 2})},
{"mceliece348864", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 1})},
{"mceliece348864f", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 2})},
{"mceliece460896", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 3})},
{"mceliece460896f", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 4})},
{"mceliece6688128", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 5})},
{"mceliece6688128f", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 6})},
{"mceliece6688128pc", OID({1, 3, 6, 1, 4, 1, 25258, 1, 18, 1})},
{"mceliece6688128pcf", OID({1, 3, 6, 1, 4, 1, 25258, 1, 18, 2})},
{"mceliece6960119", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 7})},
{"mceliece6960119f", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 8})},
{"mceliece6960119pc", OID({1, 3, 6, 1, 4, 1, 25258, 1, 18, 3})},
{"mceliece6960119pcf", OID({1, 3, 6, 1, 4, 1, 25258, 1, 18, 4})},
{"mceliece8192128", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 9})},
{"mceliece8192128f", OID({1, 3, 6, 1, 4, 1, 22554, 5, 1, 10})},
{"mceliece8192128pc", OID({1, 3, 6, 1, 4, 1, 25258, 1, 18, 5})},
{"mceliece8192128pcf", OID({1, 3, 6, 1, 4, 1, 25258, 1, 18, 6})},
{"numsp256d1", OID({1, 3, 6, 1, 4, 1, 25258, 4, 1})},
{"numsp384d1", OID({1, 3, 6, 1, 4, 1, 25258, 4, 2})},
{"numsp512d1", OID({1, 3, 6, 1, 4, 1, 25258, 4, 3})},
Expand Down
134 changes: 68 additions & 66 deletions src/lib/pubkey/classic_mceliece/cmce_parameter_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,98 +8,100 @@

#include <botan/cmce_parameter_set.h>

#include <botan/internal/fmt.h>

namespace Botan {

Classic_McEliece_Parameter_Set Classic_McEliece_Parameter_Set::from_string(std::string_view param_name) {
Classic_McEliece_Parameter_Set Classic_McEliece_Parameter_Set::from_string(std::string_view nm) {
Code code = [&] {
if(param_name == "mceliece348864") {
return mceliece348864;
if(nm == "ClassicMcEliece_348864" || nm == "348864") {
return ClassicMcEliece_348864;
}
if(param_name == "mceliece348864f") {
return mceliece348864f;
if(nm == "ClassicMcEliece_348864f" || nm == "348864f") {
return ClassicMcEliece_348864f;
}
if(param_name == "mceliece460896") {
return mceliece460896;
if(nm == "ClassicMcEliece_460896" || nm == "460896") {
return ClassicMcEliece_460896;
}
if(param_name == "mceliece460896f") {
return mceliece460896f;
if(nm == "ClassicMcEliece_460896f" || nm == "460896f") {
return ClassicMcEliece_460896f;
}
if(param_name == "mceliece6688128") {
return mceliece6688128;
if(nm == "ClassicMcEliece_6688128" || nm == "6688128") {
return ClassicMcEliece_6688128;
}
if(param_name == "mceliece6688128f") {
return mceliece6688128f;
if(nm == "ClassicMcEliece_6688128f" || nm == "6688128f") {
return ClassicMcEliece_6688128f;
}
if(param_name == "mceliece6688128pc") {
return mceliece6688128pc;
if(nm == "ClassicMcEliece_6688128pc" || nm == "6688128pc") {
return ClassicMcEliece_6688128pc;
}
if(param_name == "mceliece6688128pcf") {
return mceliece6688128pcf;
if(nm == "ClassicMcEliece_6688128pcf" || nm == "6688128pcf") {
return ClassicMcEliece_6688128pcf;
}
if(param_name == "mceliece6960119") {
return mceliece6960119;
if(nm == "ClassicMcEliece_6960119" || nm == "6960119") {
return ClassicMcEliece_6960119;
}
if(param_name == "mceliece6960119f") {
return mceliece6960119f;
if(nm == "ClassicMcEliece_6960119f" || nm == "6960119f") {
return ClassicMcEliece_6960119f;
}
if(param_name == "mceliece6960119pc") {
return mceliece6960119pc;
if(nm == "ClassicMcEliece_6960119pc" || nm == "6960119pc") {
return ClassicMcEliece_6960119pc;
}
if(param_name == "mceliece6960119pcf") {
return mceliece6960119pcf;
if(nm == "ClassicMcEliece_6960119pcf" || nm == "6960119pcf") {
return ClassicMcEliece_6960119pcf;
}
if(param_name == "mceliece8192128") {
return mceliece8192128;
if(nm == "ClassicMcEliece_8192128" || nm == "8192128") {
return ClassicMcEliece_8192128;
}
if(param_name == "mceliece8192128f") {
return mceliece8192128f;
if(nm == "ClassicMcEliece_8192128f" || nm == "8192128f") {
return ClassicMcEliece_8192128f;
}
if(param_name == "mceliece8192128pc") {
return mceliece8192128pc;
if(nm == "ClassicMcEliece_8192128pc" || nm == "8192128pc") {
return ClassicMcEliece_8192128pc;
}
if(param_name == "mceliece8192128pcf") {
return mceliece8192128pcf;
if(nm == "ClassicMcEliece_8192128pcf" || nm == "8192128pcf") {
return ClassicMcEliece_8192128pcf;
}

throw Decoding_Error("Cannot convert string to CMCE parameter set");
throw Invalid_Argument(fmt("Cannot convert '{}' to ClassicMcEliece parameter set", nm));
}();
return Classic_McEliece_Parameter_Set(code);
}

std::string Classic_McEliece_Parameter_Set::to_string() const {
switch(m_code) {
case mceliece348864:
return "mceliece348864";
case mceliece348864f:
return "mceliece348864f";
case mceliece460896:
return "mceliece460896";
case mceliece460896f:
return "mceliece460896f";
case mceliece6688128:
return "mceliece6688128";
case mceliece6688128f:
return "mceliece6688128f";
case mceliece6688128pc:
return "mceliece6688128pc";
case mceliece6688128pcf:
return "mceliece6688128pcf";
case mceliece6960119:
return "mceliece6960119";
case mceliece6960119f:
return "mceliece6960119f";
case mceliece6960119pc:
return "mceliece6960119pc";
case mceliece6960119pcf:
return "mceliece6960119pcf";
case mceliece8192128:
return "mceliece8192128";
case mceliece8192128f:
return "mceliece8192128f";
case mceliece8192128pc:
return "mceliece8192128pc";
case mceliece8192128pcf:
return "mceliece8192128pcf";
case ClassicMcEliece_348864:
return "ClassicMcEliece_348864";
case ClassicMcEliece_348864f:
return "ClassicMcEliece_348864f";
case ClassicMcEliece_460896:
return "ClassicMcEliece_460896";
case ClassicMcEliece_460896f:
return "ClassicMcEliece_460896f";
case ClassicMcEliece_6688128:
return "ClassicMcEliece_6688128";
case ClassicMcEliece_6688128f:
return "ClassicMcEliece_6688128f";
case ClassicMcEliece_6688128pc:
return "ClassicMcEliece_6688128pc";
case ClassicMcEliece_6688128pcf:
return "ClassicMcEliece_6688128pcf";
case ClassicMcEliece_6960119:
return "ClassicMcEliece_6960119";
case ClassicMcEliece_6960119f:
return "ClassicMcEliece_6960119f";
case ClassicMcEliece_6960119pc:
return "ClassicMcEliece_6960119pc";
case ClassicMcEliece_6960119pcf:
return "ClassicMcEliece_6960119pcf";
case ClassicMcEliece_8192128:
return "ClassicMcEliece_8192128";
case ClassicMcEliece_8192128f:
return "ClassicMcEliece_8192128f";
case ClassicMcEliece_8192128pc:
return "ClassicMcEliece_8192128pc";
case ClassicMcEliece_8192128pcf:
return "ClassicMcEliece_8192128pcf";
}
BOTAN_ASSERT_UNREACHABLE();
}
Expand Down
40 changes: 20 additions & 20 deletions src/lib/pubkey/classic_mceliece/cmce_parameter_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@ namespace Botan {
class BOTAN_PUBLIC_API(3, 4) Classic_McEliece_Parameter_Set {
public:
enum class Code {
mceliece348864, // NIST
mceliece348864f, // NIST

mceliece460896, // NIST
mceliece460896f, // NIST

mceliece6688128, // ISO + NIST
mceliece6688128f, // ISO + NIST
mceliece6688128pc, // ISO
mceliece6688128pcf, // ISO

mceliece6960119, // ISO + NIST
mceliece6960119f, // ISO + NIST
mceliece6960119pc, // ISO
mceliece6960119pcf, // ISO

mceliece8192128, // ISO + NIST
mceliece8192128f, // ISO + NIST
mceliece8192128pc, // ISO
mceliece8192128pcf, // ISO
ClassicMcEliece_348864, // NIST
ClassicMcEliece_348864f, // NIST

ClassicMcEliece_460896, // NIST
ClassicMcEliece_460896f, // NIST

ClassicMcEliece_6688128, // ISO + NIST
ClassicMcEliece_6688128f, // ISO + NIST
ClassicMcEliece_6688128pc, // ISO
ClassicMcEliece_6688128pcf, // ISO

ClassicMcEliece_6960119, // ISO + NIST
ClassicMcEliece_6960119f, // ISO + NIST
ClassicMcEliece_6960119pc, // ISO
ClassicMcEliece_6960119pcf, // ISO

ClassicMcEliece_8192128, // ISO + NIST
ClassicMcEliece_8192128f, // ISO + NIST
ClassicMcEliece_8192128pc, // ISO
ClassicMcEliece_8192128pcf, // ISO
};

using enum Code;
Expand Down
Loading

0 comments on commit 1873d51

Please sign in to comment.