diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2014-11-21 15:29:08 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2014-11-21 15:29:08 +0100 |
commit | d1a5ece8edf10b5f6efcf47982877e7b59b5dcc0 (patch) | |
tree | 144c189be1e3bba6cc4fe9bd8a5fcc64a2685601 /lib | |
parent | 5272bfc1caa548f2ffaa3dc44069309dfb1a4b80 (diff) | |
download | gnutls-d1a5ece8edf10b5f6efcf47982877e7b59b5dcc0.tar.gz |
compilation fix for FIPS140-2 mode
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fips.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/fips.c b/lib/fips.c index 5dab35f1cb..b99da2d44b 100644 --- a/lib/fips.c +++ b/lib/fips.c @@ -37,6 +37,8 @@ unsigned int _gnutls_lib_mode = LIB_STATE_POWERON; #define FIPS_KERNEL_FILE "/proc/sys/crypto/fips_enabled" #define FIPS_SYSTEM_FILE "/etc/system-fips" +static int _fips_mode = -1; + /* Returns: * 0 - FIPS mode disabled * 1 - FIPS mode enabled and enforced @@ -46,21 +48,20 @@ unsigned _gnutls_fips_mode_enabled(void) { unsigned f1p = 0, f2p; FILE* fd; -static int fips_mode = -1; const char *p; - if (fips_mode != -1) - return fips_mode; + if (_fips_mode != -1) + return _fips_mode; p = getenv("GNUTLS_FORCE_FIPS_MODE"); if (p) { if (p[0] == '1') - fips_mode = 1; + _fips_mode = 1; else if (p[0] == '2') - fips_mode = 2; + _fips_mode = 2; else - fips_mode = 0; - return fips_mode; + _fips_mode = 0; + return _fips_mode; } fd = fopen(FIPS_KERNEL_FILE, "r"); @@ -76,20 +77,20 @@ const char *p; if (f1p != 0 && f2p != 0) { _gnutls_debug_log("FIPS140-2 mode enabled\n"); - fips_mode = 1; - return fips_mode; + _fips_mode = 1; + return _fips_mode; } if (f2p != 0) { /* a funny state where self tests are performed * and ignored */ _gnutls_debug_log("FIPS140-2 ZOMBIE mode enabled\n"); - fips_mode = 2; - return fips_mode; + _fips_mode = 2; + return _fips_mode; } - fips_mode = 0; - return fips_mode; + _fips_mode = 0; + return _fips_mode; } /* This _fips_mode == 2 is a strange mode where checks are being |