blob: 8c53f09450a864bdbd4051066290e18e7882764b [file] [log] [blame]
Manuel Pégourié-Gonnard500de6e2014-12-19 18:06:47 +01001#!/bin/sh
2
Paul Bakker6152b022015-04-14 15:00:09 +02003# Measure heap usage (and performance) of ECC operations with various values of
Manuel Pégourié-Gonnard500de6e2014-12-19 18:06:47 +01004# the relevant tunable compile-time parameters.
Manuel Pégourié-Gonnard8b7d7d62015-02-05 10:00:30 +00005#
6# Usage (preferably on a 32-bit platform):
7# cmake -D CMAKE_BUILD_TYPE=Release .
8# scripts/ecc-heap.sh | tee ecc-heap.log
Manuel Pégourié-Gonnard500de6e2014-12-19 18:06:47 +01009
10set -eu
11
12CONFIG_H='include/polarssl/config.h'
13
14if [ -r $CONFIG_H ]; then :; else
15 echo "$CONFIG_H not found" >&2
16 exit 1
17fi
18
19if grep -i cmake Makefile >/dev/null; then :; else
20 echo "Needs Cmake" >&2
21 exit 1
22fi
23
24if git status | grep -F $CONFIG_H >/dev/null 2>&1; then
25 echo "config.h not clean" >&2
26 exit 1
27fi
28
29CONFIG_BAK=${CONFIG_H}.bak
30cp $CONFIG_H $CONFIG_BAK
31
32cat << EOF >$CONFIG_H
33#define POLARSSL_PLATFORM_C
34#define POLARSSL_PLATFORM_MEMORY
35#define POLARSSL_MEMORY_BUFFER_ALLOC_C
36#define POLARSSL_MEMORY_DEBUG
37
38#define POLARSSL_TIMING_C
39
40#define POLARSSL_BIGNUM_C
41#define POLARSSL_ECP_C
42#define POLARSSL_ASN1_PARSE_C
43#define POLARSSL_ASN1_WRITE_C
44#define POLARSSL_ECDSA_C
45#define POLARSSL_ECDH_C
46
47#define POLARSSL_ECP_DP_SECP192R1_ENABLED
48#define POLARSSL_ECP_DP_SECP224R1_ENABLED
49#define POLARSSL_ECP_DP_SECP256R1_ENABLED
50#define POLARSSL_ECP_DP_SECP384R1_ENABLED
51#define POLARSSL_ECP_DP_SECP521R1_ENABLED
Manuel Pégourié-Gonnard8b7d7d62015-02-05 10:00:30 +000052#define POLARSSL_ECP_DP_M255_ENABLED
Manuel Pégourié-Gonnard500de6e2014-12-19 18:06:47 +010053
54#include "check_config.h"
55
56//#define POLARSSL_ECP_WINDOW_SIZE 6
57//#define POLARSSL_ECP_FIXED_POINT_OPTIM 1
58EOF
59
60for F in 0 1; do
61 for W in 2 3 4 5 6; do
62 scripts/config.pl set POLARSSL_ECP_WINDOW_SIZE $W
63 scripts/config.pl set POLARSSL_ECP_FIXED_POINT_OPTIM $F
64 make benchmark >/dev/null 2>&1
65 echo "fixed point optim = $F, max window size = $W"
66 echo "--------------------------------------------"
67 programs/test/benchmark
68 done
69done
70
71# cleanup
72
73mv $CONFIG_BAK $CONFIG_H
74make clean