#include <openssl/crypto.h>
#include "../../internal.h"
#include "../delocate.h"
int FIPS_mode(void) { … }
int FIPS_mode_set(int on) { … }
const char *FIPS_module_name(void) { … }
uint32_t FIPS_version(void) { … }
int FIPS_query_algorithm_status(const char *algorithm) { … }
#if defined(BORINGSSL_FIPS_COUNTERS)
size_t FIPS_read_counter(enum fips_counter_t counter) {
size_t index = (size_t)counter;
if (index > fips_counter_max) {
abort();
}
const size_t *array =
CRYPTO_get_thread_local(OPENSSL_THREAD_LOCAL_FIPS_COUNTERS);
if (!array) {
return 0;
}
return array[index];
}
void boringssl_fips_inc_counter(enum fips_counter_t counter) {
size_t index = (size_t)counter;
if (index > fips_counter_max) {
abort();
}
size_t *array =
CRYPTO_get_thread_local(OPENSSL_THREAD_LOCAL_FIPS_COUNTERS);
if (!array) {
const size_t num_bytes = sizeof(size_t) * (fips_counter_max + 1);
array = OPENSSL_zalloc(num_bytes);
if (!array) {
return;
}
if (!CRYPTO_set_thread_local(OPENSSL_THREAD_LOCAL_FIPS_COUNTERS, array,
OPENSSL_free)) {
return;
}
}
array[index]++;
}
#else
size_t FIPS_read_counter(enum fips_counter_t counter) { … }
#endif