8000 Adjust FIPS initialization and status query · githubzhaoliang/sqlcipher@5fd8aba · GitHub
[go: up one dir, main page]

Skip to content

Commit 5fd8aba

Browse files
Adjust FIPS initialization and status query
1 parent 29b00cb commit 5fd8aba

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/crypto_openssl.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ typedef struct {
4242
EVP_CIPHER *evp_cipher;
4343
} openssl_ctx;
4444

45-
static int openssl_fips_status = 0;
4645
static unsigned int openssl_external_init = 0;
4746
static unsigned int openssl_init_count = 0;
4847
static sqlite3_mutex* openssl_rand_mutex = NULL;
@@ -77,14 +76,16 @@ static int sqlcipher_openssl_activate(void *ctx) {
7776
openssl_external_init = 1;
7877
}
7978

80-
if(openssl_init_count == 0 && openssl_external_init == 0) {
8179
#ifdef SQLCIPHER_FIPS
82-
openssl_fips_status = FIPS_mode_set(1);
83-
if(!openssl_fips_status){
80+
if(!FIPS_mode()){
81+
if(!FIPS_mode_set(1)){
8482
ERR_load_crypto_strings();
85-
ERR_print_errors_fp(stdout);
83+
ERR_print_errors_fp(stderr);
8684
}
85+
}
8786
#endif
87+
88+
if(openssl_init_count == 0 && openssl_external_init == 0) {
8889
/* if the library was not externally initialized, then should be now */
8990
OpenSSL_add_all_algorithms();
9091
}
@@ -232,7 +233,7 @@ static int sqlcipher_openssl_ctx_free(void **ctx) {
232233
}
233234

234235
static int sqlcipher_openssl_fips_status(void *ctx) {
235-
return openssl_fips_status;
236+
return FIPS_mode();
236237
}
237238

238239
int sqlcipher_openssl_setup(sqlcipher_provider *p) {

0 commit comments

Comments
 (0)
0