Esempio n. 1
0
int main(int argc, char **argv)
{
    SECStatus rv = SECFailure;
    PRBool good_result = PR_FALSE;

    if (argc != 2)
      return Usage();
    
    rv = RNG_RNGInit();
    if (rv != SECSuccess) {
        SECU_PrintPRandOSError("");
        return -1;
    }
    rv = BL_Init();
    if (rv != SECSuccess) {
        SECU_PrintPRandOSError("");
        return -1;
    }
    RNG_SystemInfoForRNG();

    good_result = BLAPI_SHVerifyFile(argv[1]);
    printf("%s\n", 
      (good_result ? "SUCCESS" : "FAILURE"));
    return (good_result) ? SECSuccess : SECFailure;
}
Esempio n. 2
0
/*
 * This function is called at dll load time, the code tha makes this
 * happen is platform specific on defined above.
 */
static void
sftk_startup_tests(void)
{
    SECStatus rv;
    const char *libraryName = SOFTOKEN_LIB_NAME;

    PORT_Assert(!sftk_self_tests_ran);
    PORT_Assert(!sftk_self_tests_success);
    sftk_self_tests_ran = PR_TRUE;
    sftk_self_tests_success = PR_FALSE; /* just in case */

    /* need to initiallize the oid library before the RSA tests */
    rv = SECOID_Init();
    if (rv != SECSuccess) {
        return;
    }
    /* make sure freebl is initialized, or our RSA check
     * may fail. This is normally done at freebl load time, but it's
     * possible we may have shut freebl down without unloading it. */
    rv = BL_Init();
    if (rv != SECSuccess) {
        return;
    }

    rv = RNG_RNGInit();
    if (rv != SECSuccess) {
        return;
    }
    /* check the RSA combined functions in softoken */
    rv = sftk_fips_RSA_PowerUpSelfTest();
    if (rv != SECSuccess) {
        return;
    }
    if (!BLAPI_SHVerify(libraryName,
                        (PRFuncPtr)&sftk_fips_RSA_PowerUpSelfTest)) {
        /* something is wrong with the library, fail without enabling
         * the token */
        return;
    }
    sftk_self_tests_success = PR_TRUE;
}