forked from ANSSI-FR/libecc
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgen_openssl_curves_tests.sh
52 lines (47 loc) · 1.58 KB
/
gen_openssl_curves_tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#/*
# * Copyright (C) 2017 - This file is part of libecc project
# *
# * Authors:
# * Ryad BENADJILA <[email protected]>
# * Arnaud EBALARD <[email protected]>
# * Jean-Pierre FLORI <[email protected]>
# *
# * Contributors:
# * Nicolas VIVET <[email protected]>
# * Karim KHALFALLAH <[email protected]>
# *
# * This software is licensed under a dual BSD and GPL v2 license.
# * See LICENSE file at the root folder of the project.
# */
#!/bin/sh
CURVES=`openssl ecparam -list_curves | grep prime | cut -d':' -f1 | tr '\n' ' '`
# Find a suitable python command if none has been provided
if [ -z "$PYTHON" ]
then
echo "Looking for suitable python and deps"
# Try to guess which python we want to use depending on the installed
# packages. We need Pyscard, Crypto, and IntelHex
for i in python python3 python2; do
if [ -x "`which $i`" ]; then
echo "Found and using python=$i"
PYTHON=$i
break
fi
done
else
echo "Using user provided python=$PYTHON"
fi
if [ -z "$PYTHON" ]; then
echo "Failed to find working python cmd!" >&2
exit
fi
# Get the expand_libecc python script path
BASEDIR=$(dirname "$0")
EXPAND_LIBECC=$BASEDIR/expand_libecc.py
for curve in $CURVES
do
echo "Adding $curve"
openssl ecparam -param_enc explicit -outform DER -name $curve -out "$curve".der
$PYTHON $EXPAND_LIBECC --name="$curve" --ECfile="$curve".der --add-test-vectors=2
rm "$curve".der
done