1#!/bin/bash
2# SPDX-License-Identifier: BSD-2-Clause
3
4EC_CURVES="prime192v1 secp224r1 prime256v1 secp384r1 secp521r1"
5
6echo "/*"
7echo " * DER encoded EC parameters generated with script:"
8echo " *   ta/pkcs11/scripts/dump_ec_params.sh"
9echo " */"
10echo ""
11
12for EC_CURVE in ${EC_CURVES} ; do
13	echo "static const uint8_t ${EC_CURVE}_name_der[] = {"
14	openssl ecparam -name ${EC_CURVE} -param_enc named_curve | \
15		openssl asn1parse -noout -out /dev/stdout | \
16		hexdump -v -e '/8 "\t"' -e '/1 "0x%02x, " ' -e '/8 "\n"' | \
17		sed 's/0x  ,//g'
18	echo "};"
19	echo ""
20done
21
22for EC_CURVE in ${EC_CURVES} ; do
23	echo "static const uint8_t ${EC_CURVE}_oid_der[] = {"
24	openssl ecparam -name ${EC_CURVE} -param_enc explicit | \
25		openssl asn1parse -noout -out /dev/stdout | \
26		hexdump -v -e '/8 "\t"' -e '/1 "0x%02x, " ' -e '/8 "\n"' | \
27		sed 's/0x  ,//g'
28	echo "};"
29	echo ""
30done
31