test-vectors: Support testing DH groups
authorMartin Willi <martin@revosec.ch>
Thu, 9 Apr 2015 10:16:25 +0000 (12:16 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 15 Apr 2015 12:37:38 +0000 (14:37 +0200)
src/libstrongswan/plugins/test_vectors/test_vectors_plugin.c

index cd0a12a..5c1259c 100644 (file)
@@ -25,6 +25,7 @@
 #define TEST_VECTOR_HASHER(x) hasher_test_vector_t x;
 #define TEST_VECTOR_PRF(x) prf_test_vector_t x;
 #define TEST_VECTOR_RNG(x) rng_test_vector_t x;
+#define TEST_VECTOR_DH(x) dh_test_vector_t x;
 
 #include "test_vectors.h"
 
@@ -34,6 +35,7 @@
 #undef TEST_VECTOR_HASHER
 #undef TEST_VECTOR_PRF
 #undef TEST_VECTOR_RNG
+#undef TEST_VECTOR_DH
 
 #define TEST_VECTOR_CRYPTER(x)
 #define TEST_VECTOR_AEAD(x)
@@ -41,6 +43,7 @@
 #define TEST_VECTOR_HASHER(x)
 #define TEST_VECTOR_PRF(x)
 #define TEST_VECTOR_RNG(x)
+#define TEST_VECTOR_DH(x)
 
 /* create test vector arrays */
 #undef TEST_VECTOR_CRYPTER
@@ -91,6 +94,14 @@ static rng_test_vector_t *rng[] = {
 #undef TEST_VECTOR_RNG
 #define TEST_VECTOR_RNG(x)
 
+#undef TEST_VECTOR_DH
+#define TEST_VECTOR_DH(x) &x,
+static dh_test_vector_t *dh[] = {
+#include "test_vectors.h"
+};
+#undef TEST_VECTOR_DH
+#define TEST_VECTOR_DH(x)
+
 typedef struct private_test_vectors_plugin_t private_test_vectors_plugin_t;
 
 /**
@@ -175,7 +186,11 @@ plugin_t *test_vectors_plugin_create()
                lib->crypto->add_test_vector(lib->crypto,
                                                                         RANDOM_NUMBER_GENERATOR, rng[i]);
        }
+       for (i = 0; i < countof(dh); i++)
+       {
+               lib->crypto->add_test_vector(lib->crypto,
+                                                                        DIFFIE_HELLMAN_GROUP, dh[i]);
+       }
 
        return &this->public.plugin;
 }
-