| # Python-ELMO | # Python-ELMO | ||||
| _Python-ELMO_ is a Python library which proposes an encapsulation of the project _ELMO_. | |||||
| _Python-ELMO_ is a Python library which proposes an encapsulation of the project _ELMO_, a statistical leakage simulator for the ARM M0 family. | |||||
| [MOW17] **Towards Practical Tools for Side | [MOW17] **Towards Practical Tools for Side | ||||
| Channel Aware Software Engineering : ’Grey Box’ Modelling for Instruction Leakages** | Channel Aware Software Engineering : ’Grey Box’ Modelling for Instruction Leakages** | ||||
| **ELMO GitHub**: https://github.com/sca-research/ELMO | **ELMO GitHub**: https://github.com/sca-research/ELMO | ||||
| **Python-ELMO Contributors**: Thibauld Feneuil | |||||
| ## Requirements | ## Requirements | ||||
| To use _Python-ELMO_, you need at least Python3.5 and ```numpy```. | To use _Python-ELMO_, you need at least Python3.5 and ```numpy```. | ||||
| First, download _Python-ELMO_. | First, download _Python-ELMO_. | ||||
| ```bash | ```bash | ||||
| git clone https://git.aprilas.fr/tfeneuil/python-elmo | |||||
| git clone https://github.com/ThFeneuil/python-elmo | |||||
| ``` | ``` | ||||
| And then, install ELMO thanks to the installation script. It will use Internet to download the [ELMO project](https://github.com/sca-research/ELMO). | And then, install ELMO thanks to the installation script. It will use Internet to download the [ELMO project](https://github.com/sca-research/ELMO). | ||||
| - The file ```project.c``` where you must put the leaking code; | - The file ```project.c``` where you must put the leaking code; | ||||
| - The file ```projectclass.py``` where there is the class of the simulation which will enable you to generate traces of the project in Python scripts; | - The file ```projectclass.py``` where there is the class of the simulation which will enable you to generate traces of the project in Python scripts; | ||||
| - A ```Makefile``` ready to be used with a compiler _arm-none-eabi-gcc_. | - A ```Makefile``` ready to be used with a compiler _arm-none-eabi-gcc_. | ||||
| Usually a leaking code runs challenges, one challenge giving a power trace. A challenge is the execution of a code with a specific set of data. This set of data is given in the input of the leakage simulation. For example, one can imagine that the leaking code is a symmetric encryption and one wants to study its power leakage according to the message and the secret key. Then, a challenge is the simulation of the leakage for a specific message and for a specific secret key. | Usually a leaking code runs challenges, one challenge giving a power trace. A challenge is the execution of a code with a specific set of data. This set of data is given in the input of the leakage simulation. For example, one can imagine that the leaking code is a symmetric encryption and one wants to study its power leakage according to the message and the secret key. Then, a challenge is the simulation of the leakage for a specific message and for a specific secret key. | ||||
| So, the classical form of ```project.c``` is the following one: | So, the classical form of ```project.c``` is the following one: | ||||
| - Stop the record of the power leakage (end a power trace) with ```endtrigger```. | - Stop the record of the power leakage (end a power trace) with ```endtrigger```. | ||||
| - Eventually output some data with ```printbyte```. | - Eventually output some data with ```printbyte```. | ||||
| - Indicate to ELMO tool that the simulation is finished with ```endprogram```. | - Indicate to ELMO tool that the simulation is finished with ```endprogram```. | ||||
| The file ```projectclass.py``` contains a subclass of ```SimulationProject```. It is the description of the ```project.c``` file for the ELMO tool, in order to correctly realise the simulation. It also provides methods to manage the simulation (see following sections). | The file ```projectclass.py``` contains a subclass of ```SimulationProject```. It is the description of the ```project.c``` file for the ELMO tool, in order to correctly realise the simulation. It also provides methods to manage the simulation (see following sections). | ||||
| - The classmethod ```get_binary_path(cl)``` must return the relative path of the leakage binary (```project.c``` correctly compiled). | - The classmethod ```get_binary_path(cl)``` must return the relative path of the leakage binary (```project.c``` correctly compiled). | ||||
| - The method ```set_input_for_each_challenge(self, input, challenge)``` must write a ```challenge``` in ```input``` using the function ```write```. | - The method ```set_input_for_each_challenge(self, input, challenge)``` must write a ```challenge``` in ```input``` using the function ```write```. |
| elmodefines_h = ''.join(elmodefines_lines) | elmodefines_h = ''.join(elmodefines_lines) | ||||
| with open(elmodefines_h_path, 'w') as _file: | with open(elmodefines_h_path, 'w') as _file: | ||||
| _file.write(elmodefines_h) | _file.write(elmodefines_h) | ||||
| # Compile the tool | # Compile the tool | ||||
| check_call("make clean".split(), cwd=elmo_complete_path) | check_call("make clean".split(), cwd=elmo_complete_path) | ||||
| check_call("make".split(), cwd=elmo_complete_path) | check_call("make".split(), cwd=elmo_complete_path) | ||||
| class PostBuildCommand(build_py): | class PostBuildCommand(build_py): | ||||
| """ Build Command to add the ELMO installation """ | """ Build Command to add the ELMO installation """ | ||||
| def run(self): | def run(self): | ||||
| build_py.run(self) | build_py.run(self) | ||||
| # ELMO Installation | # ELMO Installation | ||||
| elmo_complete_path = os.path.join( | elmo_complete_path = os.path.join( | ||||
| self.build_lib, | self.build_lib, | ||||
| setuptools.setup( | setuptools.setup( | ||||
| name="python-elmo", | name="python-elmo", | ||||
| version="0.0.1", | |||||
| version="0.1.0", | |||||
| author="Thibauld Feneuil", | author="Thibauld Feneuil", | ||||
| author_email="thibauld.feneuil@cryptoexperts.com", | author_email="thibauld.feneuil@cryptoexperts.com", | ||||
| description="Emulator for power Leakage for the M0", | |||||
| description="A Python encapsulation of a statistical leakage simulator for the ARM M0 family", | |||||
| long_description=long_description, | long_description=long_description, | ||||
| long_description_content_type="text/markdown", | long_description_content_type="text/markdown", | ||||
| url=PELMO_SOURCE, | url=PELMO_SOURCE, | ||||
| project_urls={ | project_urls={ | ||||
| 'ELMO Source': ELMO_SOURCE, | |||||
| 'pELMO Source': PELMO_SOURCE, | |||||
| "ELMO Source": ELMO_SOURCE, | |||||
| }, | }, | ||||
| packages=setuptools.find_packages(), | packages=setuptools.find_packages(), | ||||
| keywords="python3 crypto", | |||||
| classifiers=[ | classifiers=[ | ||||
| "Development Status :: 2 - Pre-Alpha", | |||||
| "Intended Audience :: Developers", | |||||
| "Intended Audience :: Science/Research", | |||||
| "License :: OSI Approved :: MIT License", | |||||
| "Programming Language :: Python", | |||||
| "Programming Language :: Python :: 3", | "Programming Language :: Python :: 3", | ||||
| "Operating System :: MacOS", | |||||
| "Operating System :: POSIX :: Linux", | |||||
| "Topic :: Scientific/Engineering", | |||||
| "Topic :: Security :: Cryptography", | |||||
| "Topic :: Software Development :: Libraries :: Python Modules", | |||||
| ], | ], | ||||
| python_requires='>=3.5', | |||||
| python_requires=">=3.5", | |||||
| cmdclass={ | cmdclass={ | ||||
| 'build_py': PostBuildCommand, | |||||
| "build_py": PostBuildCommand, | |||||
| }, | }, | ||||
| install_requires=['numpy'], | |||||
| install_requires=["numpy"], | |||||
| include_package_data=True, | include_package_data=True, | ||||
| ) | ) |