107
107
"hwcrhk", /* This is a HACK which will disappear in 0.9.8 */
108
#if CRYPTO_NUM_LOCKS != 33
110
#if CRYPTO_NUM_LOCKS != 35
109
111
# error "Inconsistency between crypto.h and cryptlib.c"
512
514
file,line,assertion);
519
static int fips_started = 0;
520
static int fips_mode = 0;
521
static void *fips_rand_check = 0;
522
static unsigned long fips_thread = 0;
524
void fips_set_started(void)
529
int fips_is_started(void)
534
int fips_is_owning_thread(void)
538
if (fips_is_started())
540
CRYPTO_r_lock(CRYPTO_LOCK_FIPS2);
541
if (fips_thread != 0 && fips_thread == CRYPTO_thread_id())
543
CRYPTO_r_unlock(CRYPTO_LOCK_FIPS2);
548
int fips_set_owning_thread(void)
552
if (fips_is_started())
554
CRYPTO_w_lock(CRYPTO_LOCK_FIPS2);
555
if (fips_thread == 0)
557
fips_thread = CRYPTO_thread_id();
560
CRYPTO_w_unlock(CRYPTO_LOCK_FIPS2);
565
int fips_clear_owning_thread(void)
569
if (fips_is_started())
571
CRYPTO_w_lock(CRYPTO_LOCK_FIPS2);
572
if (fips_thread == CRYPTO_thread_id())
577
CRYPTO_w_unlock(CRYPTO_LOCK_FIPS2);
582
void fips_set_mode(int onoff)
584
int owning_thread = fips_is_owning_thread();
586
if (fips_is_started())
588
if (!owning_thread) CRYPTO_w_lock(CRYPTO_LOCK_FIPS);
590
if (!owning_thread) CRYPTO_w_unlock(CRYPTO_LOCK_FIPS);
594
void fips_set_rand_check(void *rand_check)
596
int owning_thread = fips_is_owning_thread();
598
if (fips_is_started())
600
if (!owning_thread) CRYPTO_w_lock(CRYPTO_LOCK_FIPS);
601
fips_rand_check = rand_check;
602
if (!owning_thread) CRYPTO_w_unlock(CRYPTO_LOCK_FIPS);
609
int owning_thread = fips_is_owning_thread();
611
if (fips_is_started())
613
if (!owning_thread) CRYPTO_r_lock(CRYPTO_LOCK_FIPS);
615
if (!owning_thread) CRYPTO_r_unlock(CRYPTO_LOCK_FIPS);
620
void *FIPS_rand_check(void)
623
int owning_thread = fips_is_owning_thread();
625
if (fips_is_started())
627
if (!owning_thread) CRYPTO_r_lock(CRYPTO_LOCK_FIPS);
628
ret = fips_rand_check;
629
if (!owning_thread) CRYPTO_r_unlock(CRYPTO_LOCK_FIPS);
634
#endif /* OPENSSL_FIPS */