Allow tests to build with non-default curve support.
diff --git a/test/test_compress.c b/test/test_compress.c
index ad56904..aef374c 100644
--- a/test/test_compress.c
+++ b/test/test_compress.c
@@ -27,16 +27,27 @@
int c;
const struct uECC_Curve_t * curves[5];
- curves[0] = uECC_secp160r1();
- curves[1] = uECC_secp192r1();
- curves[2] = uECC_secp224r1();
- curves[3] = uECC_secp256r1();
- curves[4] = uECC_secp256k1();
+ int num_curves = 0;
+#if uECC_SUPPORTS_secp160r1
+ curves[num_curves++] = uECC_secp160r1();
+#endif
+#if uECC_SUPPORTS_secp192r1
+ curves[num_curves++] = uECC_secp192r1();
+#endif
+#if uECC_SUPPORTS_secp224r1
+ curves[num_curves++] = uECC_secp224r1();
+#endif
+#if uECC_SUPPORTS_secp256r1
+ curves[num_curves++] = uECC_secp256r1();
+#endif
+#if uECC_SUPPORTS_secp256k1
+ curves[num_curves++] = uECC_secp256k1();
+#endif
printf("Testing compression and decompression of %d random EC points\n",
uECC_TEST_NUMBER_OF_ITERATIONS);
- for (c = 0; c < 5; ++c) {
+ for (c = 0; c < num_curves; ++c) {
for (i = 0; i < uECC_TEST_NUMBER_OF_ITERATIONS; ++i) {
printf(".");
fflush(stdout);
diff --git a/test/test_compute.c b/test/test_compute.c
index 4cdb38c..7b936d8 100644
--- a/test/test_compute.c
+++ b/test/test_compute.c
@@ -23,14 +23,25 @@
int c;
const struct uECC_Curve_t * curves[5];
- curves[0] = uECC_secp160r1();
- curves[1] = uECC_secp192r1();
- curves[2] = uECC_secp224r1();
- curves[3] = uECC_secp256r1();
- curves[4] = uECC_secp256k1();
+ int num_curves = 0;
+#if uECC_SUPPORTS_secp160r1
+ curves[num_curves++] = uECC_secp160r1();
+#endif
+#if uECC_SUPPORTS_secp192r1
+ curves[num_curves++] = uECC_secp192r1();
+#endif
+#if uECC_SUPPORTS_secp224r1
+ curves[num_curves++] = uECC_secp224r1();
+#endif
+#if uECC_SUPPORTS_secp256r1
+ curves[num_curves++] = uECC_secp256r1();
+#endif
+#if uECC_SUPPORTS_secp256k1
+ curves[num_curves++] = uECC_secp256k1();
+#endif
printf("Testing 256 random private key pairs\n");
- for (c = 0; c < 5; ++c) {
+ for (c = 0; c < num_curves; ++c) {
for (i = 0; i < 256; ++i) {
printf(".");
fflush(stdout);
diff --git a/test/test_ecdh.c b/test/test_ecdh.c
index d784a1d..7315b75 100644
--- a/test/test_ecdh.c
+++ b/test/test_ecdh.c
@@ -21,15 +21,26 @@
uint8_t secret2[32] = {0};
const struct uECC_Curve_t * curves[5];
- curves[0] = uECC_secp160r1();
- curves[1] = uECC_secp192r1();
- curves[2] = uECC_secp224r1();
- curves[3] = uECC_secp256r1();
- curves[4] = uECC_secp256k1();
+ int num_curves = 0;
+#if uECC_SUPPORTS_secp160r1
+ curves[num_curves++] = uECC_secp160r1();
+#endif
+#if uECC_SUPPORTS_secp192r1
+ curves[num_curves++] = uECC_secp192r1();
+#endif
+#if uECC_SUPPORTS_secp224r1
+ curves[num_curves++] = uECC_secp224r1();
+#endif
+#if uECC_SUPPORTS_secp256r1
+ curves[num_curves++] = uECC_secp256r1();
+#endif
+#if uECC_SUPPORTS_secp256k1
+ curves[num_curves++] = uECC_secp256k1();
+#endif
printf("Testing 256 random private key pairs\n");
- for (c = 0; c < 5; ++c) {
+ for (c = 0; c < num_curves; ++c) {
for (i = 0; i < 256; ++i) {
printf(".");
fflush(stdout);
diff --git a/test/test_ecdsa.c b/test/test_ecdsa.c
index ed1ea77..8699794 100644
--- a/test/test_ecdsa.c
+++ b/test/test_ecdsa.c
@@ -13,14 +13,25 @@
uint8_t sig[64] = {0};
const struct uECC_Curve_t * curves[5];
- curves[0] = uECC_secp160r1();
- curves[1] = uECC_secp192r1();
- curves[2] = uECC_secp224r1();
- curves[3] = uECC_secp256r1();
- curves[4] = uECC_secp256k1();
+ int num_curves = 0;
+#if uECC_SUPPORTS_secp160r1
+ curves[num_curves++] = uECC_secp160r1();
+#endif
+#if uECC_SUPPORTS_secp192r1
+ curves[num_curves++] = uECC_secp192r1();
+#endif
+#if uECC_SUPPORTS_secp224r1
+ curves[num_curves++] = uECC_secp224r1();
+#endif
+#if uECC_SUPPORTS_secp256r1
+ curves[num_curves++] = uECC_secp256r1();
+#endif
+#if uECC_SUPPORTS_secp256k1
+ curves[num_curves++] = uECC_secp256k1();
+#endif
printf("Testing 256 signatures\n");
- for (c = 0; c < 5; ++c) {
+ for (c = 0; c < num_curves; ++c) {
for (i = 0; i < 256; ++i) {
printf(".");
fflush(stdout);