|
HAL
v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
|
Database of known S-boxes. More...
#include </home/runner/work/hal/hal/plugins/hawkeye/include/hawkeye/sbox_database.h>

Public Member Functions | |
| SBoxDatabase ()=default | |
| Construct an empty S-box database. More... | |
| SBoxDatabase (const std::map< std::string, std::vector< u8 >> &sboxes) | |
| Construct an S-box database from the given S-boxes. More... | |
| ~SBoxDatabase ()=default | |
| Destruct the S-box database. More... | |
| Result< std::monostate > | add (const std::string &name, const std::vector< u8 > &sbox) |
| Add an S-box to the database. More... | |
| Result< std::monostate > | add (const std::map< std::string, std::vector< u8 >> &sboxes) |
| Add multiple S-boxes to the database. More... | |
| Result< std::monostate > | load (const std::filesystem::path &file_path, bool overwrite=false) |
| Load S-boxes from a file and add them to the existing database. More... | |
| Result< std::monostate > | store (const std::filesystem::path &file_path) const |
| Store the S-box database to a database file. More... | |
| Result< std::string > | lookup (const std::vector< u8 > &sbox) const |
| Attempt to look up an S-box in the database. More... | |
| void | print () const |
| Print the database. More... | |
Static Public Member Functions | |
| static Result< SBoxDatabase > | from_file (const std::filesystem::path &file_path) |
| Construct an S-box database from file. More... | |
| static std::vector< u8 > | compute_linear_representative (const std::vector< u8 > &sbox) |
| Compute the linear representative of the given S-box. More... | |
Database of known S-boxes.
This class holds and manages known S-boxes and allows to perform efficient S-box lookups in the database.
Definition at line 49 of file sbox_database.h.
|
default |
Construct an empty S-box database.
Referenced by from_file().
| hal::hawkeye::SBoxDatabase::SBoxDatabase | ( | const std::map< std::string, std::vector< u8 >> & | sboxes | ) |
Construct an S-box database from the given S-boxes.
| [in] | sboxes | - A map from S-box name to the respective S-box. |
Definition at line 279 of file sbox_database.cpp.
References add().
|
default |
Destruct the S-box database.
| Result< std::monostate > hal::hawkeye::SBoxDatabase::add | ( | const std::string & | name, |
| const std::vector< u8 > & | sbox | ||
| ) |
Add an S-box to the database.
| [in] | name | - The name of the S-box. |
| [in] | sbox | - The S-box. |
Definition at line 297 of file sbox_database.cpp.
References compute_linear_representative(), ERR, name, and OK.
Referenced by add(), and SBoxDatabase().
|
static |
Compute the linear representative of the given S-box.
| [in] | sbox | - The S-box. |
Definition at line 1174 of file sbox_database.cpp.
References hal::state, x, and y.
Referenced by add(), lookup(), and hal::PYBIND11_PLUGIN().
|
static |
Construct an S-box database from file.
| [in] | file_path | - The path from which to load the S-box database file. |
Definition at line 284 of file sbox_database.cpp.
References ERR, OK, and SBoxDatabase().
Referenced by hal::PYBIND11_PLUGIN().
| Result< std::monostate > hal::hawkeye::SBoxDatabase::load | ( | const std::filesystem::path & | file_path, |
| bool | overwrite = false |
||
| ) |
Load S-boxes from a file and add them to the existing database.
| [in] | file_path | - The path from which to load the S-box database file. |
| [in] | overwrite | - Set true to overwrite existing database, false otherwise. Defaults to false. |
Definition at line 332 of file sbox_database.cpp.
Attempt to look up an S-box in the database.
| [in] | sbox | - The S-box to look for. |
Definition at line 439 of file sbox_database.cpp.
References compute_linear_representative(), ERR, and OK.
Referenced by hal::hawkeye::identify_sbox().
| void hal::hawkeye::SBoxDatabase::print | ( | ) | const |
Print the database.
Definition at line 474 of file sbox_database.cpp.
References name.
Referenced by hal::PYBIND11_PLUGIN().
| Result< std::monostate > hal::hawkeye::SBoxDatabase::store | ( | const std::filesystem::path & | file_path | ) | const |
Store the S-box database to a database file.
| [in] | file_path | - The path to where to store the S-box database file. |
Definition at line 385 of file sbox_database.cpp.