unit-tests: Call functions with TEST_ prefix in ntru test
authorTobias Brunner <tobias@strongswan.org>
Fri, 28 Feb 2014 16:15:47 +0000 (17:15 +0100)
committerTobias Brunner <tobias@strongswan.org>
Thu, 20 Mar 2014 14:37:44 +0000 (15:37 +0100)
src/libstrongswan/tests/suites/test_ntru.c

index 3204c89..8c17fdf 100644 (file)
@@ -94,7 +94,7 @@ START_TEST(test_ntru_drbg_strength)
        entropy = lib->crypto->create_rng(lib->crypto, RNG_STRONG);
        ck_assert(entropy != NULL);
 
-       drbg = ntru_drbg_create(strengths[_i].requested, chunk_empty, entropy);
+       drbg = TEST_ntru_drbg_create(strengths[_i].requested, chunk_empty, entropy);
        if (strengths[_i].standard)
        {
                ck_assert(drbg != NULL);
@@ -251,7 +251,7 @@ START_TEST(test_ntru_drbg)
 
        out = chunk_alloc(128);
        entropy = test_rng_create(drbg_tests[_i].entropy);
-       drbg = ntru_drbg_create(256, drbg_tests[_i].pers_str, entropy);
+       drbg = TEST_ntru_drbg_create(256, drbg_tests[_i].pers_str, entropy);
        ck_assert(drbg != NULL);
        ck_assert(drbg->reseed(drbg));
        ck_assert(drbg->generate(drbg, 256, 128, out.ptr));
@@ -273,7 +273,7 @@ START_TEST(test_ntru_drbg_reseed)
                                                  "libstrongswan.plugins.ntru.max_drbg_requests", 2);
        out = chunk_alloc(128);
        entropy = test_rng_create(drbg_tests[0].entropy);
-       drbg = ntru_drbg_create(256, chunk_empty, entropy);
+       drbg = TEST_ntru_drbg_create(256, chunk_empty, entropy);
 
        /* bad output parameters */
        ck_assert(!drbg->generate(drbg, 256, 0, out.ptr));
@@ -291,13 +291,13 @@ START_TEST(test_ntru_drbg_reseed)
        drbg->destroy(drbg);
 
        /* no entropy available for DRBG instantiation */
-       drbg = ntru_drbg_create(256, chunk_empty, entropy);
+       drbg = TEST_ntru_drbg_create(256, chunk_empty, entropy);
        ck_assert(drbg == NULL);
        entropy->destroy(entropy);
 
        /* one automatic reseeding occurs */
        entropy = test_rng_create(drbg_tests[0].entropy);
-       drbg = ntru_drbg_create(256, chunk_empty, entropy);
+       drbg = TEST_ntru_drbg_create(256, chunk_empty, entropy);
        ck_assert(drbg->generate(drbg, 256, 128, out.ptr));
        ck_assert(drbg->generate(drbg, 256, 128, out.ptr));
        ck_assert(drbg->generate(drbg, 256, 128, out.ptr));
@@ -382,7 +382,7 @@ uint16_t indices_ees1171ep1[] = {
  */
 mgf1_test_t mgf1_tests[] = {
        {       HASH_SHA1, 20, 60, 20, 15, 24,
-               chunk_from_chars( 
+               chunk_from_chars(
                                                0xED, 0xA5, 0xC3, 0xBC, 0xAF, 0xB3, 0x20, 0x7D,
                                                0x14, 0xA1, 0x54, 0xF7, 0x8B, 0x37, 0xF2, 0x8D,
                                                0x8C, 0x9B, 0xD5, 0x63, 0x57, 0x38, 0x11, 0xC2,
@@ -416,7 +416,7 @@ mgf1_test_t mgf1_tests[] = {
                                                0x40, 0x4B, 0xE7, 0x22, 0x3A, 0x56, 0x10, 0x6D,
                                                0x4D, 0x29, 0x0B, 0xCE, 0xA6, 0x21, 0xB5, 0x5C,
                                                0x71, 0x66, 0x2F, 0x70, 0x35, 0xD8, 0x8A, 0x92,
-                                               0x33, 0xF0, 0x16, 0xD4, 0x0E, 0x43, 0x8A, 0x14), 
+                                               0x33, 0xF0, 0x16, 0xD4, 0x0E, 0x43, 0x8A, 0x14),
                chunk_from_chars(
                                1, 2, 1, 0, 0,  1, 1, 1, 2, 0,  1, 0, 1, 1, 1,  0, 2, 0, 1, 1,
                                0, 0, 0, 1, 1,  0, 2, 0, 2, 2,  1, 2, 2, 2, 1,  2, 1, 1, 0, 0,
@@ -474,7 +474,7 @@ mgf1_test_t mgf1_tests[] = {
                                                0x76, 0x89, 0x8B, 0x1B, 0x60, 0xEC, 0x10, 0x9D,
                                                0x8F, 0x13, 0xF2, 0xFE, 0xD9, 0x85, 0xC1, 0xAB,
                                                0x7E, 0xEE, 0xB1, 0x31, 0xDD, 0xF7, 0x7F, 0x0C,
-                                               0x7D, 0xF9, 0x6B, 0x7B, 0x19, 0x80, 0xBD, 0x28), 
+                                               0x7D, 0xF9, 0x6B, 0x7B, 0x19, 0x80, 0xBD, 0x28),
                chunk_from_chars(
                                                0xF1, 0x19, 0x02, 0x4F, 0xDA, 0x58, 0x05, 0x9A,
                                                0x07, 0xDF, 0x61, 0x81, 0x22, 0x0E, 0x15, 0x46,
@@ -550,14 +550,14 @@ START_TEST(test_ntru_mgf1)
        mask2.len = mgf1_tests[_i].ml2;
        mask3.len = mgf1_tests[_i].ml3;
 
-       mgf1 = ntru_mgf1_create(HASH_UNKNOWN, mgf1_tests[_i].seed, TRUE);
+       mgf1 = TEST_ntru_mgf1_create(HASH_UNKNOWN, mgf1_tests[_i].seed, TRUE);
        ck_assert(mgf1 == NULL);
 
-       mgf1 = ntru_mgf1_create(mgf1_tests[_i].alg, chunk_empty, TRUE);
+       mgf1 = TEST_ntru_mgf1_create(mgf1_tests[_i].alg, chunk_empty, TRUE);
        ck_assert(mgf1 == NULL);
 
        /* return mask in allocated chunk */
-       mgf1 = ntru_mgf1_create(mgf1_tests[_i].alg, mgf1_tests[_i].seed, TRUE);
+       mgf1 = TEST_ntru_mgf1_create(mgf1_tests[_i].alg, mgf1_tests[_i].seed, TRUE);
        ck_assert(mgf1);
 
        /* check hash size */
@@ -573,14 +573,15 @@ START_TEST(test_ntru_mgf1)
        mgf1->destroy(mgf1);
 
        /* copy mask to pre-allocated buffer */
-       mgf1 = ntru_mgf1_create(mgf1_tests[_i].alg, mgf1_tests[_i].seed, TRUE);
+       mgf1 = TEST_ntru_mgf1_create(mgf1_tests[_i].alg, mgf1_tests[_i].seed, TRUE);
        ck_assert(mgf1);
        ck_assert(mgf1->get_mask(mgf1, mgf1_tests[_i].mask.len, mask.ptr));
        ck_assert(chunk_equals(mask, mgf1_tests[_i].mask));
        mgf1->destroy(mgf1);
 
        /* get mask in batches without hashing the seed */
-       mgf1 = ntru_mgf1_create(mgf1_tests[_i].alg, mgf1_tests[_i].hashed_seed, FALSE);
+       mgf1 = TEST_ntru_mgf1_create(mgf1_tests[_i].alg, mgf1_tests[_i].hashed_seed,
+                                                                FALSE);
        ck_assert(mgf1);
 
        /* first batch */
@@ -608,16 +609,16 @@ START_TEST(test_ntru_trits)
        ntru_trits_t *mask;
        chunk_t trits;
 
-       mask = ntru_trits_create(mgf1_tests[_i].trits.len, HASH_UNKNOWN,
-                                                        mgf1_tests[_i].seed);
+       mask = TEST_ntru_trits_create(mgf1_tests[_i].trits.len, HASH_UNKNOWN,
+                                                                 mgf1_tests[_i].seed);
        ck_assert(mask == NULL);
 
-       mask = ntru_trits_create(mgf1_tests[_i].trits.len, mgf1_tests[_i].alg,
-                                                        chunk_empty);
+       mask = TEST_ntru_trits_create(mgf1_tests[_i].trits.len, mgf1_tests[_i].alg,
+                                                                 chunk_empty);
        ck_assert(mask == NULL);
 
-       mask = ntru_trits_create(mgf1_tests[_i].trits.len, mgf1_tests[_i].alg,
-                                                        mgf1_tests[_i].seed);
+       mask = TEST_ntru_trits_create(mgf1_tests[_i].trits.len, mgf1_tests[_i].alg,
+                                                                 mgf1_tests[_i].seed);
        ck_assert(mask);
 
        trits = chunk_create(mask->get_trits(mask), mask->get_size(mask));
@@ -625,7 +626,7 @@ START_TEST(test_ntru_trits)
        mask->destroy(mask);
 
        /* generate a multiple of 5 trits */
-       mask = ntru_trits_create(10, mgf1_tests[_i].alg, mgf1_tests[_i].seed);
+       mask = TEST_ntru_trits_create(10, mgf1_tests[_i].alg, mgf1_tests[_i].seed);
        ck_assert(mask);
 
        trits = chunk_create(mask->get_trits(mask), mask->get_size(mask));
@@ -646,17 +647,17 @@ START_TEST(test_ntru_poly)
        seed.len = mgf1_tests[_i].seed_len;
 
        p = &mgf1_tests[_i].poly_test[0];
-       poly = ntru_poly_create_from_seed(HASH_UNKNOWN, seed, p->c_bits, p->N, p->q,
-                                                                         p->indices_len, p->indices_len,
-                                                                         p->is_product_form);
+       poly = TEST_ntru_poly_create_from_seed(HASH_UNKNOWN, seed, p->c_bits, p->N,
+                                                                                  p->q, p->indices_len, p->indices_len,
+                                                                                  p->is_product_form);
        ck_assert(poly == NULL);
 
        for (n = 0; n < 2; n++)
        {
                p = &mgf1_tests[_i].poly_test[n];
-               poly = ntru_poly_create_from_seed(mgf1_tests[_i].alg, seed, p->c_bits,
-                                                                                 p->N, p->q, p->indices_len,
-                                                                                 p->indices_len, p->is_product_form);
+               poly = TEST_ntru_poly_create_from_seed(mgf1_tests[_i].alg, seed,
+                                                                               p->c_bits, p->N, p->q, p->indices_len,
+                                                                               p->indices_len, p->is_product_form);
                ck_assert(poly != NULL && poly->get_size(poly) == p->indices_size);
 
                indices = poly->get_indices(poly);
@@ -756,8 +757,8 @@ START_TEST(test_ntru_ring_mult)
        int i;
 
        t = &ring_mult_tests[_i];
-       poly = ntru_poly_create_from_data(t->indices, t->N, t->q, t->indices_len_p,
-                                                                         t->indices_len_m, t->is_product_form);
+       poly = TEST_ntru_poly_create_from_data(t->indices, t->N, t->q,
+                                               t->indices_len_p, t->indices_len_m, t->is_product_form);
        ck_assert(poly != NULL);
 
        c = malloc(t->N * sizeof(uint16_t));
@@ -784,8 +785,8 @@ START_TEST(test_ntru_array)
 
        t = &ring_mult_tests[array_tests[_i]];
 
-       poly = ntru_poly_create_from_data(t->indices, t->N, t->q, t->indices_len_p,
-                                                                         t->indices_len_m, t->is_product_form);
+       poly = TEST_ntru_poly_create_from_data(t->indices, t->N, t->q,
+                                               t->indices_len_p, t->indices_len_m, t->is_product_form);
        ck_assert(poly != NULL);
 
        c = malloc(t->N * sizeof(uint16_t));
@@ -803,8 +804,8 @@ END_TEST
 
 START_TEST(test_ntru_param_set)
 {
-       ck_assert(ntru_param_set_get_by_id(-1) == NULL);
-       ck_assert(ntru_param_set_get_by_id(16) == NULL);
+       ck_assert(TEST_ntru_param_set_get_by_id(-1) == NULL);
+       ck_assert(TEST_ntru_param_set_get_by_id(16) == NULL);
 }
 END_TEST
 
@@ -964,7 +965,7 @@ privkey_test_t privkey_tests[] = {
                                                0xB1, 0x6D, 0x88, 0x41, 0x62, 0x4D, 0x18, 0xB6,
                                                0x3F, 0x12, 0x81, 0xDE, 0xE6, 0xDC, 0x4A, 0x31,
                                                0x61, 0x26, 0xB1, 0x4B, 0x95, 0xC1, 0x69, 0xDC,
-                                               0xDC, 0xAC, 0xD0, 0x15, 0xFC, 0x21, 0xC5, 0x20, 
+                                               0xDC, 0xAC, 0xD0, 0x15, 0xFC, 0x21, 0xC5, 0x20,
                                                0x5F, 0x97, 0x76, 0x41, 0xC1, 0xF2, 0xD7, 0x95,
                                                0x1D, 0x25, 0x23, 0x36, 0x86, 0xFA, 0x7E, 0xF4,
                                                0x14, 0x9F, 0x9D, 0x9F, 0xB2, 0xBB, 0x25, 0x1D,
@@ -1066,13 +1067,14 @@ START_TEST(test_ntru_privkey)
        uint32_t strength;
        chunk_t encoding, privkey_encoding, pubkey_encoding;
 
-       params = ntru_param_set_get_by_id(privkey_tests[_i].id);
+       params = TEST_ntru_param_set_get_by_id(privkey_tests[_i].id);
        strength = params->sec_strength_len * BITS_PER_BYTE;
        entropy = test_rng_create(privkey_tests[_i].entropy);
-       drbg = ntru_drbg_create(strength, chunk_from_str("IKE NTRU-KE"), entropy);
+       drbg = TEST_ntru_drbg_create(strength, chunk_from_str("IKE NTRU-KE"),
+                                                                entropy);
        ck_assert(drbg != NULL);
 
-       privkey = ntru_private_key_create(drbg, params);
+       privkey = TEST_ntru_private_key_create(drbg, params);
        ck_assert(privkey);
 
        privkey_encoding = privkey->get_encoding(privkey);