Fixes to better handle various wolfSSL versions and build options.

pull/128/head
David Garske 2019-02-20 10:29:50 -08:00
parent 732952dd4e
commit 586a97b1dc
3 changed files with 36 additions and 7 deletions

View File

@ -34,5 +34,5 @@ debug: all
clean:
rm -f $(TARGETS)
rm ECC*.der
rm ECC*.pem
rm -f ECC*.der
rm -f ECC*.pem

View File

@ -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);

View File

@ -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