sboxUv2.databases package

This module provides utilities to store S-boxes and their properties in tinySQL databases.

Submodules

sboxUv2.databases.database module

class sboxUv2.databases.database.FunctionsDB(db_file, row_structure)[source]

Bases: object

This idea of this class is to factor away the interaction with any database of S-boxes.

In particular, it handles the generation of the SELECT queries, and the (admitedly small) boilerplate needed by the with syntax.

__init__(db_file, row_structure)[source]

Initializes a database of S-boxes. It contains a table called “functions” storing S-boxes, and a table called “bibliography” which contains bibliography entries. The exact structure of the rows of the “functions” table is specified by the row_structure argument, which must be a dictionary where keys are the identifiers of the rows of the database, and the values are the tinysql type of the corresponding row.

This class should be thought of as a virtual class since it doesn’t provide all that is needed. In particular, the specifics of how to parse the content of a row and how to generate one are not provided: this is a job too specific for a general purpose class, and is left to its children.

Parameters:
  • db_file (str) – the path to the file that will/already does store the database.

  • row_structure (dict) – a description of the structure of the rows of the “functions” table.

create()[source]
insert_function(entry)[source]
parse_function_from_row(row)[source]
query_functions(query_description)[source]

sboxUv2.databases.literatureDB module

class sboxUv2.databases.literatureDB.LiteratureSBoxes[source]

Bases: FunctionsDB

This class is expected to be bundled with a literal TinySQL database file called “literature_sboxes.db”, and allows an easy interaction with it.

It builds upon the FunctionDB class, and contains just a bit of logic on top to handle the computation of all the S-box properties we are interested in.

# !TODO! add representative of linear equivalence classes; and the # !logic to use it

insert_function_from_lut(s, name, bibliography, usage=None)[source]
parse_function_from_row(row)[source]