forked from randombit/botan
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eff28ee
commit 63c1b8c
Showing
17 changed files
with
220 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
#include <botan/cmce_parameter_set.h> | ||
|
||
namespace Botan { | ||
|
||
Classic_McEliece_Parameter_Set param_set_from_str(std::string_view param_name) { | ||
if(param_name == "mceliece348864") { | ||
return Classic_McEliece_Parameter_Set::mceliece348864; | ||
} | ||
if(param_name == "mceliece348864f") { | ||
return Classic_McEliece_Parameter_Set::mceliece348864f; | ||
} | ||
if(param_name == "mceliece460896") { | ||
return Classic_McEliece_Parameter_Set::mceliece460896; | ||
} | ||
if(param_name == "mceliece460896f") { | ||
return Classic_McEliece_Parameter_Set::mceliece460896f; | ||
} | ||
if(param_name == "mceliece6688128") { | ||
return Classic_McEliece_Parameter_Set::mceliece6688128; | ||
} | ||
if(param_name == "mceliece6688128f") { | ||
return Classic_McEliece_Parameter_Set::mceliece6688128f; | ||
} | ||
if(param_name == "mceliece6688128pc") { | ||
return Classic_McEliece_Parameter_Set::mceliece6688128pc; | ||
} | ||
if(param_name == "mceliece6688128pcf") { | ||
return Classic_McEliece_Parameter_Set::mceliece6688128pcf; | ||
} | ||
if(param_name == "mceliece6960119") { | ||
return Classic_McEliece_Parameter_Set::mceliece6960119; | ||
} | ||
if(param_name == "mceliece6960119f") { | ||
return Classic_McEliece_Parameter_Set::mceliece6960119f; | ||
} | ||
if(param_name == "mceliece6960119pc") { | ||
return Classic_McEliece_Parameter_Set::mceliece6960119pc; | ||
} | ||
if(param_name == "mceliece6960119pcf") { | ||
return Classic_McEliece_Parameter_Set::mceliece6960119pcf; | ||
} | ||
if(param_name == "mceliece8192128") { | ||
return Classic_McEliece_Parameter_Set::mceliece8192128; | ||
} | ||
if(param_name == "mceliece8192128f") { | ||
return Classic_McEliece_Parameter_Set::mceliece8192128f; | ||
} | ||
if(param_name == "mceliece8192128pc") { | ||
return Classic_McEliece_Parameter_Set::mceliece8192128pc; | ||
} | ||
if(param_name == "mceliece8192128pcf") { | ||
return Classic_McEliece_Parameter_Set::mceliece8192128pcf; | ||
} | ||
// TODO: Remove on final PR | ||
if(param_name == "test") { | ||
return Classic_McEliece_Parameter_Set::test; | ||
} | ||
if(param_name == "testf") { | ||
return Classic_McEliece_Parameter_Set::testf; | ||
} | ||
if(param_name == "testpc") { | ||
return Classic_McEliece_Parameter_Set::testpc; | ||
} | ||
if(param_name == "testpcf") { | ||
return Classic_McEliece_Parameter_Set::testpcf; | ||
} | ||
|
||
throw Decoding_Error("Cannot convert string to CMCE parameter set"); | ||
} | ||
|
||
std::string str_from_param_set(Classic_McEliece_Parameter_Set param) { | ||
switch(param) { | ||
case Classic_McEliece_Parameter_Set::mceliece348864: | ||
return "mceliece348864"; | ||
case Classic_McEliece_Parameter_Set::mceliece348864f: | ||
return "mceliece348864f"; | ||
case Classic_McEliece_Parameter_Set::mceliece460896: | ||
return "mceliece460896"; | ||
case Classic_McEliece_Parameter_Set::mceliece460896f: | ||
return "mceliece460896f"; | ||
case Classic_McEliece_Parameter_Set::mceliece6688128: | ||
return "mceliece6688128"; | ||
case Classic_McEliece_Parameter_Set::mceliece6688128f: | ||
return "mceliece6688128f"; | ||
case Classic_McEliece_Parameter_Set::mceliece6688128pc: | ||
return "mceliece6688128pc"; | ||
case Classic_McEliece_Parameter_Set::mceliece6688128pcf: | ||
return "mceliece6688128pcf"; | ||
case Classic_McEliece_Parameter_Set::mceliece6960119: | ||
return "mceliece6960119"; | ||
case Classic_McEliece_Parameter_Set::mceliece6960119f: | ||
return "mceliece6960119f"; | ||
case Classic_McEliece_Parameter_Set::mceliece6960119pc: | ||
return "mceliece6960119pc"; | ||
case Classic_McEliece_Parameter_Set::mceliece6960119pcf: | ||
return "mceliece6960119pcf"; | ||
case Classic_McEliece_Parameter_Set::mceliece8192128: | ||
return "mceliece8192128"; | ||
case Classic_McEliece_Parameter_Set::mceliece8192128f: | ||
return "mceliece8192128f"; | ||
case Classic_McEliece_Parameter_Set::mceliece8192128pc: | ||
return "mceliece8192128pc"; | ||
case Classic_McEliece_Parameter_Set::mceliece8192128pcf: | ||
return "mceliece8192128pcf"; | ||
// TODO: Remove on final PR | ||
case Classic_McEliece_Parameter_Set::test: | ||
return "test"; | ||
case Classic_McEliece_Parameter_Set::testf: | ||
return "testf"; | ||
case Classic_McEliece_Parameter_Set::testpc: | ||
return "testpc"; | ||
case Classic_McEliece_Parameter_Set::testpcf: | ||
return "testpcf"; | ||
default: | ||
throw Decoding_Error("Parameter set not supported"); | ||
} | ||
BOTAN_ASSERT_UNREACHABLE(); | ||
} | ||
|
||
Classic_McEliece_Parameter_Set param_set_from_oid(const OID& oid) { | ||
return param_set_from_str(oid.to_formatted_string()); | ||
} | ||
|
||
} // namespace Botan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#ifndef CMCE_PARAMETER_SET_H | ||
#define CMCE_PARAMETER_SET_H | ||
|
||
#include <botan/oids.h> | ||
|
||
namespace Botan { | ||
|
||
/** | ||
* All Classic McEliece parameter sets defined in the NIST Round 4 | ||
* submission and the Classic McEliece ISO Draft. | ||
* | ||
* Instances are defined in the following format: | ||
* mceliece{n}{t}{[pc]}{[f]} | ||
* | ||
* Instance with 'pc' use plaintext confirmation as defined in the ISO Draft. | ||
* Instance with 'f' use matrix reduction with the semi-systematic form. | ||
*/ | ||
enum class Classic_McEliece_Parameter_Set { | ||
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 | ||
|
||
toy, | ||
/// Self-created test instance: m=8, n=128, t=8, f(z)=z^8+z^7+z^2+z+1, F(y)=y^8+y^4+y^3+y^2+1 | ||
/// Minimal instance without semi-systematic matrix creation and no plaintext confirmation | ||
test, | ||
/// Minimal instance with semi-systematic matrix creation and no plaintext confirmation | ||
testf, | ||
/// Minimal instance without semi-systematic matrix creation and with plaintext confirmation | ||
testpc, | ||
/// Minimal instance with semi-systematic matrix creation and with plaintext confirmation | ||
testpcf | ||
}; | ||
|
||
/** | ||
* @brief Get the parameter set for a given parameter set name. | ||
*/ | ||
Classic_McEliece_Parameter_Set param_set_from_str(std::string_view param_name); | ||
|
||
/** | ||
* @brief Get the parameter set name for a given parameter set. | ||
*/ | ||
std::string str_from_param_set(Classic_McEliece_Parameter_Set param); | ||
|
||
/** | ||
* @brief Get the parameter set for a given OID. | ||
*/ | ||
Classic_McEliece_Parameter_Set param_set_from_oid(const OID& oid); | ||
|
||
} // namespace Botan | ||
|
||
#endif // CMCE_PARAMETER_SET_H |
Oops, something went wrong.