Ver código fonte

Add script to create project

master
cfssi 4 anos atrás
pai
commit
65fca61dce

+ 21
- 0
LICENCE.txt Ver arquivo

@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 "Thibauld FENEUIL" <thibauld.feneuil@cryptoexperts.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

+ 96
- 3
README.md Ver arquivo

@@ -1,6 +1,6 @@
# ELMO Online
# Online ELMO
ELMO Online is a Python library which proposes an encapsulation of the binary project ELMO.
_Online ELMO_ is a Python library which proposes an encapsulation of the project _ELMO_.
[MOW17] **Towards Practical Tools for Side
Channel Aware Software Engineering : ’Grey Box’ Modelling for Instruction Leakages**
@@ -8,4 +8,97 @@ by _David McCann, Elisabeth Oswald et Carolyn Whitnall_.
https://www.usenix.org/conference/
usenixsecurity17/technical-sessions/presentation/mccann.
**ELMO GitHub**: https://github.com/sca-research/ELMO
**ELMO GitHub**: https://github.com/sca-research/ELMO
## Requirements
To use _Online ELMO_, you need at least Python3.5 and the packages present in the file requirements.txt
```bash
pip3 install -r requirements.txt
```
The library will install and compile ELMO. So, you need the GCC compiler collection and the command/utility 'make' (for more details, see the documentation of ELMO). On Ubuntu/Debian,
```bash
sudo apt install build-essential
```
To use ELMO on a leaking binary program, you need to compile the C implementations to binary programs (a ".bin" file). "ELMO is not linked to any ARM specific tools, so users should be fine to utilise whatever they want for this purpose."
ELMO Documentation: "A minimal working platform for compiling your code into an ARM Thumb binary would be to use the GNU ARM Embedded Toolchain (tested version: arm-none-eabi-gcc version 7.3.1 20180622, it can be downloaded from https://developer.arm.com/open-source/gnu-toolchain/gnu-rm).", see the documentation for more details.
## Installation
First, download _ELMO Online_.
```bash
git clone https://git.aprilas.fr/tfeneuil/OnlineELMO
```
And then, install ELMO by launching the ELMO run_server (you must have GCC to compile ELMO, if it is not the case, please do "sudo apt install build-essential" on Ubuntu/Debian)
```bash
./run
```
## Usage
### Create a new simulation project
What is a _simulation project_ ? It is a project to simulate the traces of _one_ binary program. It includes
- A Python class which enable to generate traces in Python ;
- The C program which will be compile to have the binary program for the analysis ;
- A linker script where the configuration of the simulated device are defined
```bash
python3 create-project.py
> Creation of a new simulation project...
> - What is the project classname? KyberSimulation # Please enter here the name of the Python class of the simulation
> - What is the project repository? Kyber/SimuOne # Please enter here the relative repository of the simulation
```
### Use a simulation project in a Python script
Warning! Before using it, you have to compile your project thanks to the provided Makefile.
```python
from elmo_online.launch import KyberSimulation
simulation = KyberSimulation(challenges)
simulation.run() # Launch the simulation
traces = simulation.get_traces()
# And now, I can analyse the traces
```
### Use the ELMO Engine
The engine use the model of ELMO to directly give the power consumption of an assembler instruction. In the model, to have the power consumption of an assembler instruction, it needs
- the type and the operands of the previous assembler instruction
- the type and the operands of the current assembler instruction
- the type of the next assembler instruction
The type of the instructions are:
- "0" for ADD(1-4), AND, CMP, CPY, EOR, MOV, ORR, ROR, SUB
- "1" for LSL(2), LSR(2)
- "2" for STR, STRB, STRH
- "3" for LDR, LDRB, LDRH
- "4" for MUL
- "5" for the other instructions
```python
from elmo_online.engine import ELMOEngine
engine = ELMOEngine()
for i in range(0, 256):
engine.add_point(
(3, 4, 5), # Types of the previous, current and next instructions
(0x0000, i), # Operands of the previous instructions
(0x2BAC, i) # Operands of the current instructions
)
engine.run() # Compute the power consumption of all these points
power = engine.power # Numpy 1D array with an entry for each previous point
engine.reset_points() # Reset the engine to study other points
```
## Licences
[MIT](LICENCE.txt)

+ 67
- 0
create-project.py Ver arquivo

@@ -0,0 +1,67 @@
import os, shutil
import re

print('Creation of a new simulation project...')

### Create the repository of the projects
global_path = 'projects'
os.makedirs(global_path, exist_ok=True)

### Get the project classname
project_classname = ''
search = re.compile(r'[^a-zA-Z0-9_]').search
while not project_classname:
classname = input(' - What is the project classname? ')
if search(classname):
print(' > Illegal characters detected! Please enter a name with only the following characters : a-z, A-Z, 0-9, and "_".')
else:
project_classname = classname.strip()

### Get and create the project repository
search = re.compile(r'[^a-zA-Z0-9.-_/]').search
project_repository = ''
while not project_repository:
repository = input(' - What is the project repository? ')
if search(repository):
print('Illegal characters detected! Please enter a name with only the following characters : a-z, A-Z, 0-9, ".", "-", "_" and "/".')
else:
try:
os.makedirs(global_path+'/'+repository, exist_ok=False)
project_repository = repository
except FileExistsError:
print('Error, a project with this repository already exists!')
project_path = global_path+'/'+repository

### Add contents in the project
files_from_ELMO = [
'Examples/elmoasmfunctions.o',
'Examples/elmoasmfunctions.s',
'Examples/elmoasmfunctionsdef.h',
'Examples/DPATraces/MBedAES/vector.o',
]
files_from_templates = [
'elmoasmfunctionsdef-extension.h',
'Makefile',
'project.c'
]

for filename in files_from_ELMO:
shutil.copy('elmo/'+filename, project_path)
for filename in files_from_templates:
shutil.copy('templates/'+filename, project_path)
shutil.copy('elmo/'+'Examples/DPATraces/MBedAES/MBedAES.ld', project_path+'/'+'project.ld')

### Create the project class
with open('templates/projectclass.py') as _source:
code = ''.join(_source.readlines())
code = code.replace('{{PROJECTCLASSNAME}}', project_classname)
with open(project_path+'/'+'projectclass.py', 'w') as _dest:
_dest.write(code)

print('')
print('Creation complete !')
print(' - Project repository: {}'.format(os.path.abspath(project_path)))
print(' - Project class "{}" in {}'.format(project_classname, os.path.abspath(project_path+'/'+'projectclass.py')))
print(' - Linker script: {}'.format(os.path.abspath(project_path+'/'+'project.ld')))
print('')
print('Please don\'t to compile the project with the present Makefile before using it!')

run → install Ver arquivo

@@ -1,24 +1,18 @@
#!/bin/bash

elmo_repository="elmo"
elmo_source="https://github.com/sca-research/ELMO.git"

echo "====== ELMO Online ======"
if [ -d ${elmo_repository} ]; then
echo " - ELMO tool already installed."
echo "ELMO tool already installed."
else
echo "ELMO tool NOT installed... Installing via online resources..."
# Download the tool
git clone --depth=1 --branch=master ${elmo_source} ${elmo_repository}
rm -rf ./${elmo_repository}/.git
# Compile the tool
cd ./${elmo_repository}
make
cd ..
fi

#current_directory=${PWD##*/}
#echo " - Current directory: ${current_directory}"
echo

#cd ..
#python3 -m ${current_directory}.run_server
python3 run_server.py

+ 0
- 1
projects/.gitignore Ver arquivo

@@ -1,3 +1,2 @@
*
!.gitignore
!elmoasmfunctions*

BIN
projects/elmoasmfunctions.o Ver arquivo


+ 0
- 257
projects/elmoasmfunctions.s Ver arquivo

@@ -1,257 +0,0 @@
##
## University of Bristol – Open Access Software Licence
## Copyright (c) 2016, The University of Bristol, a chartered
## corporation having Royal Charter number RC000648 and a charity
## (number X1121) and its place of administration being at Senate
## House, Tyndall Avenue, Bristol, BS8 1TH, United Kingdom.
## All rights reserved
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
##
## 1. Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
##
## 2. Redistributions in binary form must reproduce the above
## copyright notice, this list of conditions and the following
## disclaimer in the documentation and/or other materials provided
## with the distribution.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
## FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
## COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
## INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
## (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
## SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
## STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
## OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Any use of the software for scientific publications or commercial
## purposes should be reported to the University of Bristol
## (OSI-notifications@bristol.ac.uk and quote reference 2668). This is
## for impact and usage monitoring purposes only.
##
## Enquiries about further applications and development opportunities
## are welcome. Please contact elisabeth.oswald@bristol.ac.uk
##

.syntax unified
.text
.thumb

.func starttrigger
.global starttrigger

starttrigger:
push {r0-r7}
movs r4, #0xE0
lsls r4, #24
movs r5, #0x04
eors r4, r5
movs r5, #1
str r5, [r4, #0]
pop {r0-r7}
bx lr

.endfunc

.func endtrigger
.global endtrigger

endtrigger:
push {r0-r7}
movs r4, #0xE0
lsls r4, #24
movs r5, #0x04
eors r4, r5
movs r5, #0
str r5, [r4, #0]
pop {r0-r7}
bx lr

.endfunc

.func readbyte
.global readbyte

readbyte:
push {r0-r7}
movs r4, #0xE1
lsls r4, #24
ldr r1, [r4, #0]
strb r1, [r0, #0]
pop {r0-r7}

bx lr

.endfunc

.func LoadN
.global LoadN

LoadN:
push {r0-r7}
movs r4, #0xE1
lsls r4, #24
movs r5, #0x10
eors r4, r5
ldr r1, [r4, #0]
str r1, [r0, #0]
pop {r0-r7}

bx lr

.endfunc

.func randbyte
.global randbyte

randbyte:
push {r0-r7}
movs r4, #0xE1
lsls r4, #24
movs r5, #0x04
eors r4, r5
ldr r1, [r4, #0]
strb r1, [r0, #0]
pop {r0-r7}

bx lr

.endfunc

.func getstart
.global getstart

getstart:
push {r0-r7}
movs r4, #0xE1
lsls r4, #24
movs r5, #0x08
eors r4, r5
ldr r1, [r4, #0]
str r1, [r0, #0]
pop {r0-r7}

bx lr

.endfunc


.func getruncount
.global getruncount

getruncount:
push {r0-r7}
movs r4, #0xE1
lsls r4, #24
movs r5, #0x0C
eors r4, r5
ldr r1, [r4, #0]
str r1, [r0, #0]
pop {r0-r7}

bx lr

.endfunc



.func printbyte
.global printbyte

printbyte:
push {r0-r7}
movs r4, #0xE0
lsls r4, #24
ldrb r5, [r0]
str r5, [r4]
pop {r0-r7}
bx lr

.endfunc

.func endprogram
.global endprogram

endprogram:
push {r0-r7}
movs r4, #0xF0
lsls r4, #24
movs r5, #0

str r5, [r4]
pop {r0-r7}
bx lr

.endfunc

.func initialisemaskflow
.global initialisemaskflow

# Takes address of key as input (r0)
initialisemaskflow:
push {r0-r7}
movs r4, #0xE0
lsls r4, #24
movs r5, #0x40
eors r4, r5
str r0, [r4]
pop {r0-r7}
bx lr

.endfunc

.func resetmaskflow
.global resetmaskflow

resetmaskflow:
push {r0-r7}
movs r4, #0xE0
lsls r4, #24
movs r5, #0x42
eors r4, r5
movs r5, #0
str r5, [r4]
pop {r0-r7}
bx lr

.endfunc

.func setmaskflowstart
.global setmaskflowstart

# Takes r0 as start number

setmaskflowstart:
push {r0-r7}
movs r4, #0xE0
lsls r4, #24
movs r5, #0x44
eors r4, r5
str r0, [r4]
pop {r0-r7}
bx lr

.endfunc

.func resetdatafile
.global resetdatafile

resetdatafile:
push {r0-r7}
movs r4, #0xE0
lsls r4, #24
movs r5, #0x46
eors r4, r5
movs r5, #0
str r5, [r4]
pop {r0-r7}
bx lr

.endfunc

+ 0
- 55
projects/elmoasmfunctionsdef.h Ver arquivo

@@ -1,55 +0,0 @@
/*
* University of Bristol – Open Access Software Licence
* Copyright (c) 2016, The University of Bristol, a chartered
* corporation having Royal Charter number RC000648 and a charity
* (number X1121) and its place of administration being at Senate
* House, Tyndall Avenue, Bristol, BS8 1TH, United Kingdom.
* All rights reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Any use of the software for scientific publications or commercial
* purposes should be reported to the University of Bristol
* (OSI-notifications@bristol.ac.uk and quote reference 2668). This is
* for impact and usage monitoring purposes only.
*
* Enquiries about further applications and development opportunities
* are welcome. Please contact elisabeth.oswald@bristol.ac.uk
*/

extern void starttrigger(void);
extern void endtrigger(void);
extern void randbyte(unsigned char * pointer);
extern void LoadN(void* addr);
extern void readbyte(unsigned char * pointer);
extern void printbyte(unsigned char * pointer);
extern void endprogram(void);
extern void getstart(unsigned int * pointer);
extern void getruncount(unsigned int * pointer);
extern void initialisemaskflow(unsigned char * pointer);
extern void resetmaskflow(void);
extern void setmaskflowstart(unsigned int start);
extern void resetdatafile(void);

+ 1
- 0
requirements.txt Ver arquivo

@@ -0,0 +1 @@
numpy==1.19.1

+ 147
- 0
templates/Makefile Ver arquivo

@@ -0,0 +1,147 @@
##
## University of Bristol – Open Access Software Licence
## Copyright (c) 2016, The University of Bristol, a chartered
## corporation having Royal Charter number RC000648 and a charity
## (number X1121) and its place of administration being at Senate
## House, Tyndall Avenue, Bristol, BS8 1TH, United Kingdom.
## All rights reserved
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
##
## 1. Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
##
## 2. Redistributions in binary form must reproduce the above
## copyright notice, this list of conditions and the following
## disclaimer in the documentation and/or other materials provided
## with the distribution.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
## FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
## COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
## INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
## (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
## SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
## STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
## OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Any use of the software for scientific publications or commercial
## purposes should be reported to the University of Bristol
## (OSI-notifications@bristol.ac.uk and quote reference 2668). This is
## for impact and usage monitoring purposes only.
##
## Enquiries about further applications and development opportunities
## are welcome. Please contact elisabeth.oswald@bristol.ac.uk
##

##
## This file was based on files that are part of the libopencm3 project.
## See below for licecning information.
##
## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
## Copyright (C) 2010 Piotr Esden-Tempski <piotr@esden.net>
## Copyright (C) 2011 Fergus Noble <fergusnoble@gmail.com>
##
## This library is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This library is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with this library. If not, see <http://www.gnu.org/licenses/>.

# Remove to display makefile output
Q := @

BINARY = project

FP_FLAGS ?= -msoft-float
ARCH_FLAGS = -mthumb -mcpu=cortex-m0 $(FP_FLAGS)

###############################################################################
# Executables

PREFIX ?= arm-none-eabi
CC := $(PREFIX)-gcc
LD := $(PREFIX)-gcc
OBJCOPY := $(PREFIX)-objcopy
OBJDUMP := $(PREFIX)-objdump

###############################################################################
# Source files

LDSCRIPT = $(BINARY).ld
#OBJS += $(BINARY).o
ELMOASMFUNCTIONS = elmoasmfunctions.o

#!!! PLEASE ADD YOUR SOURCES, HEADERS AND OBJECTS HERE !!!
SOURCES = $(BINARY).c
HEADERS =
OBJECTS = $(BINARY).o

###############################################################################
# C flags

CFLAGS += -Os -g
CFLAGS += -Wextra -Wshadow -Wimplicit-function-declaration
CFLAGS += -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes
CFLAGS += -fno-common -ffunction-sections -fdata-sections

###############################################################################
# C & C++ preprocessor common flags

CPPFLAGS += -MD
CPPFLAGS += -Wall -Wundef

###############################################################################
# Linker flags

LDFLAGS += --static -nostartfiles
LDFLAGS += -T$(LDSCRIPT)
LDFLAGS += -Wl,-Map=$(*).map
LDFLAGS += -Wl,--gc-sections


###############################################################################
# Used libraries

LDLIBS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group

###############################################################################
###############################################################################
###############################################################################

all: elf bin list
elf: $(BINARY).elf
bin: $(BINARY).bin
list: $(BINARY).list

images: $(BINARY).images

$(BINARY).images: $(BINARY).bin $(BINARY).list $(BINARY).map

$(BINARY).bin: $(BINARY).elf
$(Q)$(OBJCOPY) -Obinary $(BINARY).elf $(BINARY).bin

$(BINARY).list: $(BINARY).elf
$(Q)$(OBJDUMP) -S $(BINARY).elf > $(BINARY).list

$(BINARY).elf $(BINARY).map: $(OBJS) $(LDSCRIPT)
$(Q)$(LD) $(LDFLAGS) vector.o $(ARCH_FLAGS) $(OBJS) $(ELMOASMFUNCTIONS) $(LDLIBS) -o $(BINARY).elf

%.o: %.c $(HEADER)
$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) $(ARCH_FLAGS) -c -o $@ $<

clean:
$(Q)$(RM) $(OBJECTS) $(BINARY).d $(BINARY).elf $(BINARY).bin $(BINARY).list $(BINARY).map

+ 35
- 0
templates/elmoasmfunctionsdef-extension.h Ver arquivo

@@ -0,0 +1,35 @@
#include "elmoasmfunctionsdef.h"

// Extension of the ELMO API for 2-bytes types
static void rand2bytes(uint16_t* elt) {
randbyte((uint8_t*) elt+1);
randbyte((uint8_t*) elt);
}
static void print2bytes(uint16_t* elt) {
printbyte((uint8_t*) elt+1);
printbyte((uint8_t*) elt);
}
static void read2bytes(uint16_t* elt) {
readbyte((uint8_t*) elt+1);
readbyte((uint8_t*) elt);
}

// Extension of the ELMO API for 4-bytes types
static void rand4bytes(uint32_t* elt) {
randbyte((uint8_t*) elt+3);
randbyte((uint8_t*) elt+2);
randbyte((uint8_t*) elt+1);
randbyte((uint8_t*) elt);
}
static void print4bytes(uint32_t* elt) {
printbyte((uint8_t*) elt+3);
printbyte((uint8_t*) elt+2);
printbyte((uint8_t*) elt+1);
printbyte((uint8_t*) elt);
}
static void read4bytes(uint32_t* elt) {
readbyte((uint8_t*) elt+3);
readbyte((uint8_t*) elt+2);
readbyte((uint8_t*) elt+1);
readbyte((uint8_t*) elt);
}

+ 30
- 0
templates/project.c Ver arquivo

@@ -0,0 +1,30 @@
#include <stdio.h>
#include <stdlib.h>

#include "elmoasmfunctionsdef.h"
#include "elmoasmfunctionsdef-extension.h"

// ELMO API :
// - printbyte(addr): Print single byte located at address 'addr' to output file;
// - randbyte(addr): Load byte of random to memory address 'addr';
// - readbyte(addr): Read byte from input file to address 'addr'.
// ELMO API (extension) :
// - print2bytes, rand2bytes and read2bytes: idem, but for an address pointing on 2 bytes;
// - print4bytes, rand4bytes and read4bytes: idem, but for an address pointing on 4 bytes.

int main(void) {
uint16_t num_challenge, nb_challenges;

read2bytes(&nb_challenges);
for(num_challenge=0; num_challenge<nb_challenges; num_challenge++) {

starttrigger(); // To start a new trace
// Do the leaking operations here...
endtrigger(); // To end the current trace

}

endprogram(); // To indicate to ELMO that the simulation is finished

return 0;
}

+ 17
- 0
templates/projectclass.py Ver arquivo

@@ -0,0 +1,17 @@
class {{PROJECTCLASSNAME}}(SimulationProject):
@classmethod
def get_binary(cl):
return 'project.bin'

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def set_input(self, input):
""" Write into the 'input' file of ELMO tool
the parameters and the challenges for the simulation """
super().set_input(input)

def set_input_for_each_challenge(self, input, challenge):
""" Write into the 'input' file of ELMO tool
the 'challenge' for the simulation """
super().set_input_for_each_challenge(input, challenge)

Carregando…
Cancelar
Salvar