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