|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +######################################################################### |
| 4 | +# DO NOT CHANGE: Preparing DATA |
| 5 | +#------------------------------------------------------------------------ |
| 6 | +source "${DATA_COMMON}/DATA_init.sh" || { echo "source data.sh first!" && exit 1; } |
| 7 | +######################################################################### |
| 8 | + |
| 9 | +#------------------------------------------------------------------------ |
| 10 | +# Specify your framework settings used by DATA |
| 11 | +#------------------------------------------------------------------------ |
| 12 | + |
| 13 | +# The name of the framework. Do not use spaces or special characters. |
| 14 | +export FRAMEWORK=botan |
| 15 | + |
| 16 | +# The file containing all supported algorithms |
| 17 | +export TARGETFILE=targets.txt |
| 18 | + |
| 19 | +# The number of measurements for difference detection (phase1) |
| 20 | +export PHASE1_TRACES=3 |
| 21 | + |
| 22 | +# The number of constant keys for generic tests (phase2) |
| 23 | +# Make sure that PHASE2_FIXEDKEYS <= PHASE1_TRACES |
| 24 | +export PHASE2_FIXEDKEYS=3 |
| 25 | + |
| 26 | +# The number of measurements per constant key for generic tests (phase2) |
| 27 | +export PHASE2_TRACES=100 |
| 28 | + |
| 29 | +# The number of measurements for specific tests (phase3) |
| 30 | +export PHASE3_TRACES=200 |
| 31 | + |
| 32 | +# (Optional) Additional flags for the pintool. Supported flags are: |
| 33 | +# -main <main> Start recording at function <main>. Note that the <main> |
| 34 | +# symbol must exist, otherwise this will yield empty traces! |
| 35 | +# -heap Trace heap allocations and replace heap addresses with |
| 36 | +# relative offset |
| 37 | +export PINTOOL_ARGS="-heap" |
| 38 | + |
| 39 | +#------------------------------------------------------------------------ |
| 40 | +# Implement your framework-specific callbacks |
| 41 | +#------------------------------------------------------------------------ |
| 42 | +# |
| 43 | +# Globally available environment variables: |
| 44 | +# $FRAMEWORK The framework name |
| 45 | +# $BASEDIR The absolute directory path of this script |
| 46 | +# $DATA_COMMON The absolute directory for common DATA scripts |
| 47 | +# $DATA_LEAKAGE_MODELS The absolute directory for DATA leakage models |
| 48 | +# |
| 49 | +# Available for cb_genkey, cb_pre_run, cb_run_command, cb_post_run |
| 50 | +# $ALGO The currently tested algo |
| 51 | +# |
| 52 | +# Available for cb_pre_run, cb_run_command, cb_post_run |
| 53 | +# $ENVFILE |
| 54 | + |
| 55 | +export BINARY=${PWD}/bin/dilithium |
| 56 | + |
| 57 | +# The leakage model of phase 3. |
| 58 | +# See ${DATA_LEAKAGE_MODELS} for all options. |
| 59 | +# export SPECIFIC_LEAKAGE_CALLBACK=${DATA_LEAKAGE_MODELS}/rsa_privkey_hw.py |
| 60 | + |
| 61 | +# DATA callback for setting up the framework to analyze. This callback |
| 62 | +# is invoked once inside the current directory before analysis starts. |
| 63 | +# Implement framework-specific tasks here like framework compilation. |
| 64 | +function cb_prepare_framework { |
| 65 | + : |
| 66 | +} |
| 67 | + |
| 68 | +# DATA callback for generating keys. This callback is invoked every |
| 69 | +# time a new key is needed. Implement key generation according to |
| 70 | +# your algorithm and store the generated key inside a file named $2. |
| 71 | +# |
| 72 | +# $1 ... key file name |
| 73 | +function cb_genkey { |
| 74 | + ${BINARY} ${ALGO} keygen $1 |
| 75 | + RES=$((RES + $?)) |
| 76 | +} |
| 77 | + |
| 78 | +# DATA callback for custom commands that are executed immediately before |
| 79 | +# the algorithm is profiled. It is executed in a temporary directory |
| 80 | +# which contains the keyfile $1 and ${ENVFILE}. |
| 81 | +# |
| 82 | +# If 'cb_run_command' needs any other files, copy them to ${PWD}. |
| 83 | +# |
| 84 | +# $1 ... key file name |
| 85 | +function cb_pre_run { |
| 86 | + log_verbose "running with key $1" |
| 87 | +} |
| 88 | + |
| 89 | +# DATA callback for the main invocation of the tested algorithm. |
| 90 | +# It shall return the bash command to execute as string. It is |
| 91 | +# executed inside a temporary directory with a clean environment. |
| 92 | +# If you need special files or environment variables set, specify |
| 93 | +# them in cb_pre_run. |
| 94 | +# |
| 95 | +# $1 ... key file name |
| 96 | +function cb_run_command { |
| 97 | + echo "${BINARY} ${ALGO} sign $1" |
| 98 | +} |
| 99 | + |
| 100 | +# DATA callback for custom commands that are executed immediately after |
| 101 | +# the algorithm is profiled. It is executed in a temporary directory. |
| 102 | +# You can cleanup any custom files generated by your algorithm. |
| 103 | +# |
| 104 | +# $1 ... key file name |
| 105 | +function cb_post_run { |
| 106 | + : |
| 107 | +} |
| 108 | + |
| 109 | +# DATA callback for preparing an individual algorithm. It shall: |
| 110 | +# 1. Parse the next algorithm from the commandline string of all algorithms |
| 111 | +# and set up anything necessary for analyzing this algorithm. |
| 112 | +# If the algorithm needs additional parameters (like key sizes), |
| 113 | +# increase $SHIFT accordingly. |
| 114 | +# 2. Configure $WORKDIR, which will create a subdirectory holding all |
| 115 | +# intermediate files generated by the algorithm and the results. |
| 116 | +# Do not use an absolute path! |
| 117 | +# |
| 118 | +# $* ... algorithm string from the commandline |
| 119 | +function cb_prepare_algo { |
| 120 | + ALGO=$1 |
| 121 | + # key bits |
| 122 | + SHIFT=$((SHIFT)) |
| 123 | + |
| 124 | + WORKDIR="dilithium-$ALGO" |
| 125 | +} |
| 126 | + |
| 127 | +######################################################################### |
| 128 | +# DO NOT CHANGE: Running DATA's commandline parser |
| 129 | +#------------------------------------------------------------------------ |
| 130 | +DATA_parse "$@" |
| 131 | +#------------------------------------------------------------------------ |
| 132 | +# DO NOT ADD CODE AFTER THIS LINE |
| 133 | +######################################################################### |
0 commit comments