diff --git a/ecc/Makefile b/ecc/Makefile index d88b1559..94df7053 100644 --- a/ecc/Makefile +++ b/ecc/Makefile @@ -34,5 +34,5 @@ debug: all clean: rm -f $(TARGETS) - rm ECC*.der - rm ECC*.pem + rm -f ECC*.der + rm -f ECC*.pem diff --git a/ecc/ecc-key-export.c b/ecc/ecc-key-export.c index 771e976f..fa957270 100644 --- a/ecc/ecc-key-export.c +++ b/ecc/ecc-key-export.c @@ -133,6 +133,10 @@ int main(void) #ifdef WOLFSSL_DER_TO_PEM memset(pem, 0, sizeof(pem)); ret = wc_DerToPem(der, derSz, pem, sizeof(pem), ECC_PUBLICKEY_TYPE); + if (ret < 0) { + /* try old type */ + ret = wc_DerToPem(der, derSz, pem, sizeof(pem), PUBLICKEY_TYPE); + } if (ret < 0) { printf("wc_DerToPem error %s (%d)\n", wc_GetErrorString(ret), ret); return -1; @@ -147,10 +151,10 @@ int main(void) } fwrite(pem, pemSz, 1, fp); fclose(fp); -#endif printf("ECC Public Key Exported to %s\n", "./" XSTRINGIFY(TEST_ECC_KEY_CURVE) "_pub.pem"); +#endif wc_ecc_free(&key); wc_FreeRng(&rng); diff --git a/ecc/parsekeys.sh b/ecc/parsekeys.sh index 5f458e73..c651fe58 100755 --- a/ecc/parsekeys.sh +++ b/ecc/parsekeys.sh @@ -1,7 +1,32 @@ #!/bin/sh -openssl ec -inform der -in ECC_SECP256K1.der -text -openssl ec -inform pem -in ECC_SECP256K1.pem -text +# SECP256R1 +if [ -f ECC_SECP256R1.der ]; then + openssl ec -inform der -in ECC_SECP256R1.der -text +fi +if [ -f ECC_SECP256R1_pub.der ]; then + openssl ec -inform der -in ECC_SECP256R1_pub.der -text -pubin +fi -openssl ec -inform der -in ECC_SECP256K1_pub.der -text -pubin -openssl ec -inform pem -in ECC_SECP256K1_pub.pem -text -pubin +if [ -f ECC_SECP256R1.pem ]; then + openssl ec -inform pem -in ECC_SECP256R1.pem -text +fi +if [ -f ECC_SECP256R1_pub.pem ]; then + openssl ec -inform pem -in ECC_SECP256K1_pub.pem -text -pubin +fi + + +# SECP256K1 +if [ -f ECC_SECP256K1.der ]; then + openssl ec -inform der -in ECC_SECP256K1.der -text +fi +if [ -f ECC_SECP256K1_pub.der ]; then + openssl ec -inform der -in ECC_SECP256K1_pub.der -text -pubin +fi + +if [ -f ECC_SECP256K1.pem ]; then + openssl ec -inform pem -in ECC_SECP256K1.pem -text +fi +if [ -f ECC_SECP256K1_pub.pem ]; then + openssl ec -inform pem -in ECC_SECP256K1_pub.pem -text -pubin +fi