Path: blob/main/crypto/libecc/scripts/gen_openssl_curves_tests.sh
34878 views
#/*1# * Copyright (C) 2017 - This file is part of libecc project2# *3# * Authors:4# * Ryad BENADJILA <[email protected]>5# * Arnaud EBALARD <[email protected]>6# * Jean-Pierre FLORI <[email protected]>7# *8# * Contributors:9# * Nicolas VIVET <[email protected]>10# * Karim KHALFALLAH <[email protected]>11# *12# * This software is licensed under a dual BSD and GPL v2 license.13# * See LICENSE file at the root folder of the project.14# */15#!/bin/sh1617CURVES=`openssl ecparam -list_curves | grep prime | cut -d':' -f1 | tr '\n' ' '`1819# Find a suitable python command if none has been provided20if [ -z "$PYTHON" ]21then22echo "Looking for suitable python and deps"23# Try to guess which python we want to use depending on the installed24# packages. We need Pyscard, Crypto, and IntelHex25for i in python python3 python2; do26if [ -x "`which $i`" ]; then27echo "Found and using python=$i"28PYTHON=$i29break30fi31done32else33echo "Using user provided python=$PYTHON"34fi3536if [ -z "$PYTHON" ]; then37echo "Failed to find working python cmd!" >&238exit39fi4041# Get the expand_libecc python script path42BASEDIR=$(dirname "$0")43EXPAND_LIBECC=$BASEDIR/expand_libecc.py4445for curve in $CURVES46do47echo "Adding $curve"48openssl ecparam -param_enc explicit -outform DER -name $curve -out "$curve".der49$PYTHON $EXPAND_LIBECC --name="$curve" --ECfile="$curve".der --add-test-vectors=250rm "$curve".der51done525354