Add support for memory leak checking in fips_algvs.
[openssl.git] / fips / fips_test_suite.c
index 0046b9b0d50c035170dfed6e3fccbd872028b0f9..db0f18a16ba2f52f22cc07af9efc02ad160018d4 100644 (file)
@@ -651,6 +651,8 @@ static int Zeroize()
     for(i = 0; i < sizeof(userkey); i++) printf("%02x", userkey[i]);
         printf("\n");
 
     for(i = 0; i < sizeof(userkey); i++) printf("%02x", userkey[i]);
         printf("\n");
 
+    FIPS_rsa_free(key);
+
     return 1;
     }
 
     return 1;
     }
 
@@ -696,7 +698,7 @@ static int do_drbg_test(int type, int flags)
        }
     rv = 1;
     err:
        }
     rv = 1;
     err:
-    FIPS_drbg_uninstantiate(dctx);
+    FIPS_drbg_free(dctx);
     return rv;
     }
 
     return rv;
     }
 
@@ -995,13 +997,18 @@ static int post_cb(int op, int id, int subid, void *ex)
        return 1;
        }
 
        return 1;
        }
 
-int main(int argc,char **argv)
+#ifdef FIPS_ALGVS
+int fips_test_suite_main(int argc, char **argv)
+#else
+int main(int argc, char **argv)
+#endif
     {
     int bad_rsa = 0, bad_dsa = 0;
     int do_rng_stick = 0;
     int do_drbg_stick = 0;
     int no_exit = 0;
     int no_dh = 0;
     {
     int bad_rsa = 0, bad_dsa = 0;
     int do_rng_stick = 0;
     int do_drbg_stick = 0;
     int no_exit = 0;
     int no_dh = 0;
+    char *pass = FIPS_AUTH_USER_PASS;
 
     FIPS_post_set_callback(post_cb);
 
 
     FIPS_post_set_callback(post_cb);
 
@@ -1077,18 +1084,26 @@ int main(int argc,char **argv)
            do_drbg_stick = 1;
            no_exit = 1;
            printf("DRBG test with stuck continuous test...\n");
            do_drbg_stick = 1;
            no_exit = 1;
            printf("DRBG test with stuck continuous test...\n");
+       } else if (!strcmp(argv[1], "user")) {
+               pass = FIPS_AUTH_USER_PASS;
+       } else if (!strcmp(argv[1], "officer")) {
+               pass = FIPS_AUTH_OFFICER_PASS;
+       } else if (!strcmp(argv[1], "badpass")) {
+               pass = "bad invalid password";
+       } else if (!strcmp(argv[1], "nopass")) {
+               pass = "";
         } else {
             printf("Bad argument \"%s\"\n", argv[1]);
         } else {
             printf("Bad argument \"%s\"\n", argv[1]);
-            exit(1);
+            return 1;
         }
        if (!no_exit) {
                fips_algtest_init_nofips();
         }
        if (!no_exit) {
                fips_algtest_init_nofips();
-               if (!FIPS_module_mode_set(1)) {
+               if (!FIPS_module_mode_set(1, pass)) {
                    printf("Power-up self test failed\n");
                    printf("Power-up self test failed\n");
-                   exit(1);
+                   return 1;
                }
                printf("Power-up self test successful\n");
                }
                printf("Power-up self test successful\n");
-               exit(0);
+               return 0;
        }
     }
 
        }
     }
 
@@ -1105,9 +1120,9 @@ int main(int argc,char **argv)
     /* Power-up self test
     */
     ERR_clear_error();
     /* Power-up self test
     */
     ERR_clear_error();
-    test_msg("2. Automatic power-up self test", FIPS_module_mode_set(1));
+    test_msg("2. Automatic power-up self test", FIPS_module_mode_set(1, pass));
     if (!FIPS_module_mode())
     if (!FIPS_module_mode())
-       exit(1);
+       return 1;
     if (do_drbg_stick)
             FIPS_drbg_stick();
     if (do_rng_stick)
     if (do_drbg_stick)
             FIPS_drbg_stick();
     if (do_rng_stick)