unit-tests: Completed coverage of hasher, crypter and libnttfft
authorAndreas Steffen <andreas.steffen@strongswan.org>
Fri, 9 Dec 2016 11:56:15 +0000 (12:56 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 14 Dec 2016 10:15:48 +0000 (11:15 +0100)
src/libstrongswan/math/libnttfft/tests/suites/test_ntt_fft.c
src/libstrongswan/tests/suites/test_crypter.c
src/libstrongswan/tests/suites/test_hasher.c

index d827718..2a0f3bd 100644 (file)
@@ -130,6 +130,12 @@ START_TEST(test_ntt_fft_speed)
 }
 END_TEST
 
+START_TEST(test_ntt_fft_init)
+{
+       libnttfft_init();
+}
+END_TEST
+
 Suite *ntt_fft_suite_create()
 {
        Suite *s;
@@ -137,6 +143,10 @@ Suite *ntt_fft_suite_create()
 
        s = suite_create("ntt_fft");
 
+       tc = tcase_create("init");
+       tcase_add_test(tc, test_ntt_fft_init);
+       suite_add_tcase(s, tc);
+
        tc = tcase_create("impulse");
        tcase_add_loop_test(tc, test_ntt_fft_impulse, 0, countof(fft_params));
        suite_add_tcase(s, tc);
index 4e7550a..321feed 100644 (file)
@@ -36,7 +36,8 @@ static crypter_oid_t oids[] = {
        { OID_AES256_CBC, ENCR_AES_CBC, 256 },
        { OID_CAMELLIA128_CBC, ENCR_CAMELLIA_CBC, 128 },
        { OID_CAMELLIA192_CBC, ENCR_CAMELLIA_CBC, 192 },
-       { OID_CAMELLIA256_CBC, ENCR_CAMELLIA_CBC, 256 }
+       { OID_CAMELLIA256_CBC, ENCR_CAMELLIA_CBC, 256 },
+       { OID_BLOWFISH_CBC, ENCR_BLOWFISH, 0 }
 };
 
 START_TEST(test_crypter_from_oid)
index de285ca..6a83fe7 100644 (file)
@@ -28,38 +28,47 @@ typedef struct {
 }hasher_oid_t;
 
 static hasher_oid_t oids[] = {
-       { OID_MD2, HASH_MD2, KEY_ANY },                         /*  0 */
-       { OID_MD5, HASH_MD5, KEY_ANY },                         /*  1 */
-       { OID_SHA1, HASH_SHA1, KEY_ANY },                       /*  2 */
-       { OID_SHA224, HASH_SHA224, KEY_ANY },                   /*  3 */
-       { OID_SHA256, HASH_SHA256, KEY_ANY },                   /*  4 */
-       { OID_SHA384, HASH_SHA384, KEY_ANY },                   /*  5 */
-       { OID_SHA512, HASH_SHA512, KEY_ANY },                   /*  6 */
-       { OID_SHA3_224, HASH_SHA3_224, KEY_ANY },               /*  7 */
-       { OID_SHA3_256, HASH_SHA3_256, KEY_ANY },               /*  8 */
-       { OID_SHA3_384, HASH_SHA3_384, KEY_ANY },               /*  9 */
-       { OID_SHA3_512, HASH_SHA3_512, KEY_ANY },               /* 10 */
-       { OID_UNKNOWN, HASH_UNKNOWN, KEY_ANY },                 /* 11 */
-       { OID_MD2_WITH_RSA, HASH_MD2, KEY_RSA },                /* 12 */
-       { OID_MD5_WITH_RSA, HASH_MD5, KEY_RSA },                /* 13 */
-       { OID_SHA1_WITH_RSA, HASH_SHA1, KEY_RSA },              /* 14 */
-       { OID_SHA224_WITH_RSA, HASH_SHA224, KEY_RSA },          /* 15 */
-       { OID_SHA256_WITH_RSA, HASH_SHA256, KEY_RSA },          /* 16 */
-       { OID_SHA384_WITH_RSA, HASH_SHA384, KEY_RSA },          /* 17 */
-       { OID_SHA512_WITH_RSA, HASH_SHA512, KEY_RSA },          /* 18 */
-       { OID_UNKNOWN, HASH_UNKNOWN, KEY_RSA },                 /* 19 */
-       { OID_ECDSA_WITH_SHA1, HASH_SHA1, KEY_ECDSA },          /* 20 */
-       { OID_ECDSA_WITH_SHA256, HASH_SHA256, KEY_ECDSA },      /* 21 */
-       { OID_ECDSA_WITH_SHA384, HASH_SHA384, KEY_ECDSA },      /* 22 */
-       { OID_ECDSA_WITH_SHA512, HASH_SHA512, KEY_ECDSA },      /* 23 */
-       { OID_UNKNOWN, HASH_UNKNOWN, KEY_ECDSA },               /* 24 */
-       { OID_BLISS_WITH_SHA2_256, HASH_SHA256, KEY_BLISS },    /* 25 */
-       { OID_BLISS_WITH_SHA2_384, HASH_SHA384, KEY_BLISS },    /* 26 */
-       { OID_BLISS_WITH_SHA2_512, HASH_SHA512, KEY_BLISS },    /* 27 */
-       { OID_BLISS_WITH_SHA3_256, HASH_SHA3_256, KEY_BLISS },  /* 28 */
-       { OID_BLISS_WITH_SHA3_384, HASH_SHA3_384, KEY_BLISS },  /* 29 */
-       { OID_BLISS_WITH_SHA3_512, HASH_SHA3_512, KEY_BLISS },  /* 30 */
-       { OID_UNKNOWN, HASH_UNKNOWN, KEY_BLISS }                /* 31 */
+       { OID_MD2, HASH_MD2, KEY_ANY },                                /*  0 */
+       { OID_MD5, HASH_MD5, KEY_ANY },                                /*  1 */
+       { OID_SHA1, HASH_SHA1, KEY_ANY },                              /*  2 */
+       { OID_SHA224, HASH_SHA224, KEY_ANY },                          /*  3 */
+       { OID_SHA256, HASH_SHA256, KEY_ANY },                          /*  4 */
+       { OID_SHA384, HASH_SHA384, KEY_ANY },                          /*  5 */
+       { OID_SHA512, HASH_SHA512, KEY_ANY },                          /*  6 */
+       { OID_SHA3_224, HASH_SHA3_224, KEY_ANY },                      /*  7 */
+       { OID_SHA3_256, HASH_SHA3_256, KEY_ANY },                      /*  8 */
+       { OID_SHA3_384, HASH_SHA3_384, KEY_ANY },                      /*  9 */
+       { OID_SHA3_512, HASH_SHA3_512, KEY_ANY },                      /* 10 */
+       { OID_UNKNOWN, HASH_UNKNOWN, KEY_ANY },                        /* 11 */
+       { OID_MD2_WITH_RSA, HASH_MD2, KEY_RSA },                       /* 12 */
+       { OID_MD5_WITH_RSA, HASH_MD5, KEY_RSA },                       /* 13 */
+       { OID_SHA1_WITH_RSA, HASH_SHA1, KEY_RSA },                     /* 14 */
+       { OID_SHA224_WITH_RSA, HASH_SHA224, KEY_RSA },                 /* 15 */
+       { OID_SHA256_WITH_RSA, HASH_SHA256, KEY_RSA },                 /* 16 */
+       { OID_SHA384_WITH_RSA, HASH_SHA384, KEY_RSA },                 /* 17 */
+       { OID_SHA512_WITH_RSA, HASH_SHA512, KEY_RSA },                 /* 18 */
+       { OID_RSASSA_PKCS1V15_WITH_SHA3_224, HASH_SHA3_224, KEY_RSA }, /* 19 */
+       { OID_RSASSA_PKCS1V15_WITH_SHA3_256, HASH_SHA3_256, KEY_RSA }, /* 20 */
+       { OID_RSASSA_PKCS1V15_WITH_SHA3_384, HASH_SHA3_384, KEY_RSA }, /* 21 */
+       { OID_RSASSA_PKCS1V15_WITH_SHA3_512, HASH_SHA3_512, KEY_RSA }, /* 22 */
+       { OID_UNKNOWN, HASH_UNKNOWN, KEY_RSA },                        /* 23 */
+       { OID_ED25519, HASH_IDENTITY, KEY_ED25519 },                   /* 24 */
+       { OID_UNKNOWN, HASH_UNKNOWN, KEY_ED25519 },                    /* 25 */
+       { OID_ED448, HASH_IDENTITY, KEY_ED448 },                       /* 26 */
+       { OID_UNKNOWN, HASH_UNKNOWN, KEY_ED448 },                      /* 27 */
+       { OID_ECDSA_WITH_SHA1, HASH_SHA1, KEY_ECDSA },                 /* 28 */
+       { OID_ECDSA_WITH_SHA256, HASH_SHA256, KEY_ECDSA },             /* 29 */
+       { OID_ECDSA_WITH_SHA384, HASH_SHA384, KEY_ECDSA },             /* 30 */
+       { OID_ECDSA_WITH_SHA512, HASH_SHA512, KEY_ECDSA },             /* 31 */
+       { OID_UNKNOWN, HASH_UNKNOWN, KEY_ECDSA },                      /* 32 */
+       { OID_BLISS_WITH_SHA2_256, HASH_SHA256, KEY_BLISS },           /* 33 */
+       { OID_BLISS_WITH_SHA2_384, HASH_SHA384, KEY_BLISS },           /* 34 */
+       { OID_BLISS_WITH_SHA2_512, HASH_SHA512, KEY_BLISS },           /* 35 */
+       { OID_BLISS_WITH_SHA3_256, HASH_SHA3_256, KEY_BLISS },         /* 36 */
+       { OID_BLISS_WITH_SHA3_384, HASH_SHA3_384, KEY_BLISS },         /* 37 */
+       { OID_BLISS_WITH_SHA3_512, HASH_SHA3_512, KEY_BLISS },         /* 38 */
+       { OID_UNKNOWN, HASH_UNKNOWN, KEY_BLISS },                      /* 39 */
+
 };
 
 START_TEST(test_hasher_from_oid)
@@ -113,6 +122,8 @@ static hasher_sig_scheme_t sig_schemes[] = {
        { SIGN_BLISS_WITH_SHA3_256,   HASH_SHA3_256   },
        { SIGN_BLISS_WITH_SHA3_384,   HASH_SHA3_384   },
        { SIGN_BLISS_WITH_SHA3_512,   HASH_SHA3_512   },
+       { SIGN_ED25519,               HASH_IDENTITY   },
+       { SIGN_ED448,                 HASH_IDENTITY   },
        { 30,                                             HASH_UNKNOWN    }
 };
 
@@ -214,6 +225,7 @@ typedef struct {
 }hasher_ikev2_t;
 
 static hasher_ikev2_t ikev2[] = {
+       { HASH_IDENTITY, TRUE  },
        { HASH_SHA1,     TRUE  },
        { HASH_SHA256,   TRUE  },
        { HASH_SHA384,   TRUE  },
@@ -244,7 +256,7 @@ Suite *hasher_suite_create()
        s = suite_create("hasher");
 
        tc = tcase_create("from_oid");
-       tcase_add_loop_test(tc, test_hasher_from_oid, 0, 15);
+       tcase_add_loop_test(tc, test_hasher_from_oid, 0, 28);
        suite_add_tcase(s, tc);
 
        tc = tcase_create("to_oid");