Resolve compiler warnings in the test programs
authorJouni Malinen <j@w1.fi>
Sat, 5 Dec 2009 20:32:45 +0000 (22:32 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 5 Dec 2009 20:32:45 +0000 (22:32 +0200)
tests/test-aes.c
tests/test-md5.c
tests/test-ms_funcs.c
tests/test-sha1.c

index 8c0b152..f596a1e 100644 (file)
@@ -148,14 +148,14 @@ static int test_cbc(void)
                        break;
                }
                memcpy(buf, tv->plain, tv->len);
-               aes_128_cbc_encrypt(tv->key, tv->iv, buf, tv->len);
-               if (memcmp(buf, tv->cipher, tv->len) != 0) {
+               if (aes_128_cbc_encrypt(tv->key, tv->iv, buf, tv->len) ||
+                   memcmp(buf, tv->cipher, tv->len) != 0) {
                        printf("AES-CBC encrypt %d failed\n", i);
                        ret++;
                }
                memcpy(buf, tv->cipher, tv->len);
-               aes_128_cbc_decrypt(tv->key, tv->iv, buf, tv->len);
-               if (memcmp(buf, tv->plain, tv->len) != 0) {
+               if (aes_128_cbc_decrypt(tv->key, tv->iv, buf, tv->len) ||
+                   memcmp(buf, tv->plain, tv->len) != 0) {
                        printf("AES-CBC decrypt %d failed\n", i);
                        ret++;
                }
@@ -272,8 +272,8 @@ int main(int argc, char *argv[])
 
        for (i = 0; i < sizeof(test_vectors) / sizeof(test_vectors[0]); i++) {
                tv = &test_vectors[i];
-               omac1_aes_128(tv->k, tv->msg, tv->msg_len, result);
-               if (memcmp(result, tv->tag, 16) != 0) {
+               if (omac1_aes_128(tv->k, tv->msg, tv->msg_len, result) ||
+                   memcmp(result, tv->tag, 16) != 0) {
                        printf("OMAC1-AES-128 test vector %d failed\n", i);
                        ret++;
                }
@@ -287,8 +287,9 @@ int main(int argc, char *argv[])
                        addr[1] = tv->msg + 1;
                        len[1] = tv->msg_len - 1;
 
-                       omac1_aes_128_vector(tv->k, 2, addr, len, result);
-                       if (memcmp(result, tv->tag, 16) != 0) {
+                       if (omac1_aes_128_vector(tv->k, 2, addr, len,
+                                                result) ||
+                           memcmp(result, tv->tag, 16) != 0) {
                                printf("OMAC1-AES-128(vector) test vector %d "
                                       "failed\n", i);
                                ret++;
index ecd3183..c33f1c2 100644 (file)
@@ -21,7 +21,7 @@ int main(int argc, char *argv[])
 {
        struct {
                char *data;
-               u8 *hash;
+               char *hash;
        } tests[] = {
                {
                        "",
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
        for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
                printf("MD5 test case %d:", i);
 
-               addr[0] = tests[i].data;
+               addr[0] = (u8 *) tests[i].data;
                len[0] = strlen(tests[i].data);
                md5_vector(1, addr, len, hash);
                if (memcmp(hash, tests[i].hash, 16) != 0) {
@@ -80,9 +80,9 @@ int main(int argc, char *argv[])
                        printf(" OK");
 
                if (len[0]) {
-                       addr[0] = tests[i].data;
+                       addr[0] = (u8 *) tests[i].data;
                        len[0] = strlen(tests[i].data);
-                       addr[1] = tests[i].data + 1;
+                       addr[1] = (u8 *) tests[i].data + 1;
                        len[1] = strlen(tests[i].data) - 1;
                        md5_vector(1, addr, len, hash);
                        if (memcmp(hash, tests[i].hash, 16) != 0) {
index 231ccd2..ae36171 100644 (file)
@@ -18,8 +18,8 @@
 int main(int argc, char *argv[])
 {
        /* Test vector from RFC2759 example */
-       u8 *username = "User";
-       u8 *password = "clientPass";
+       char *username = "User";
+       char *password = "clientPass";
        u8 auth_challenge[] = {
                0x5B, 0x5D, 0x7C, 0x7D, 0x7B, 0x3F, 0x2F, 0x3E,
                0x3C, 0x2C, 0x60, 0x21, 0x32, 0x26, 0x26, 0x28
@@ -61,53 +61,54 @@ int main(int argc, char *argv[])
 
        printf("Testing ms_funcs.c\n");
 
-       challenge_hash(peer_challenge, auth_challenge,
-                      username, strlen(username),
-                      buf);
-       if (memcmp(challenge, buf, sizeof(challenge)) != 0) {
+       if (challenge_hash(peer_challenge, auth_challenge,
+                          (u8 *) username, strlen(username),
+                          buf) ||
+           memcmp(challenge, buf, sizeof(challenge)) != 0) {
                printf("challenge_hash failed\n");
                errors++;
        }
 
-       nt_password_hash(password, strlen(password), buf);
-       if (memcmp(password_hash, buf, sizeof(password_hash)) != 0) {
+       if (nt_password_hash((u8 *) password, strlen(password), buf) ||
+           memcmp(password_hash, buf, sizeof(password_hash)) != 0) {
                printf("nt_password_hash failed\n");
                errors++;
        }
 
-       generate_nt_response(auth_challenge, peer_challenge,
-                            username, strlen(username),
-                            password, strlen(password),
-                            buf);
-       if (memcmp(nt_response, buf, sizeof(nt_response)) != 0) {
+       if (generate_nt_response(auth_challenge, peer_challenge,
+                                (u8 *) username, strlen(username),
+                                (u8 *) password, strlen(password),
+                                buf) ||
+           memcmp(nt_response, buf, sizeof(nt_response)) != 0) {
                printf("generate_nt_response failed\n");
                errors++;
        }
 
-       hash_nt_password_hash(password_hash, buf);
-       if (memcmp(password_hash_hash, buf, sizeof(password_hash_hash)) != 0) {
+       if (hash_nt_password_hash(password_hash, buf) ||
+           memcmp(password_hash_hash, buf, sizeof(password_hash_hash)) != 0) {
                printf("hash_nt_password_hash failed\n");
                errors++;
        }
 
-       generate_authenticator_response(password, strlen(password),
-                                       peer_challenge, auth_challenge,
-                                       username, strlen(username),
-                                       nt_response, buf);
-       if (memcmp(authenticator_response, buf, sizeof(authenticator_response))
+       if (generate_authenticator_response((u8 *) password, strlen(password),
+                                           peer_challenge, auth_challenge,
+                                           (u8 *) username, strlen(username),
+                                           nt_response, buf) ||
+           memcmp(authenticator_response, buf, sizeof(authenticator_response))
            != 0) {
                printf("generate_authenticator_response failed\n");
                errors++;
        }
 
-       get_master_key(password_hash_hash, nt_response, buf);
-       if (memcmp(master_key, buf, sizeof(master_key)) != 0) {
+       if (get_master_key(password_hash_hash, nt_response, buf) ||
+           memcmp(master_key, buf, sizeof(master_key)) != 0) {
                printf("get_master_key failed\n");
                errors++;
        }
 
-       get_asymetric_start_key(master_key, buf, sizeof(send_start_key), 1, 1);
-       if (memcmp(send_start_key, buf, sizeof(send_start_key)) != 0) {
+       if (get_asymetric_start_key(master_key, buf, sizeof(send_start_key),
+                                   1, 1) ||
+           memcmp(send_start_key, buf, sizeof(send_start_key)) != 0) {
                printf("get_asymetric_start_key failed\n");
                errors++;
        }
index a2343cf..792eca0 100644 (file)
@@ -137,9 +137,9 @@ static int test_eap_fast(void)
        }
 
        printf("- PRF (TLS, SHA1/MD5) test case / key_block\n");
-       tls_prf(master_secret, sizeof(master_secret), "key expansion",
-               seed, sizeof(seed), buf, sizeof(key_block));
-       if (memcmp(key_block, buf, sizeof(key_block)) != 0) {
+       if (tls_prf(master_secret, sizeof(master_secret), "key expansion",
+                   seed, sizeof(seed), buf, sizeof(key_block)) ||
+           memcmp(key_block, buf, sizeof(key_block)) != 0) {
                printf("PRF test - FAILED!\n");
                errors++;
        }