Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Clean up references to FIPS
This removes the fips configure option. This option is broken as the
required FIPS code is not available.

FIPS_mode() and FIPS_mode_set() are retained for compatibility, but
FIPS_mode() always returns 0, and FIPS_mode_set() can only be used to
turn FIPS mode off.

Reviewed-by: Stephen Henson <steve@openssl.org>
  • Loading branch information
ekasper committed Feb 28, 2017
1 parent 223a90c commit b53338c
Show file tree
Hide file tree
Showing 23 changed files with 12 additions and 230 deletions.
37 changes: 3 additions & 34 deletions Configure
Expand Up @@ -302,12 +302,9 @@ $config{openssldir}="";
$config{processor}="";
$config{libdir}="";
$config{cross_compile_prefix}="";
$config{fipslibdir}="/usr/local/ssl/fips-2.0/lib/";
my $nofipscanistercheck=0;
$config{baseaddr}="0xFB00000";
my $auto_threads=1; # enable threads automatically? true by default
my $default_ranlib;
$config{fips}=0;

# Top level directories to build
$config{dirs} = [ "crypto", "ssl", "engines", "apps", "test", "util", "tools", "fuzz" ];
Expand Down Expand Up @@ -685,7 +682,7 @@ while (@argvcopy)
{ $config{processor}=386; }
elsif (/^fips$/)
{
$config{fips}=1;
die "FIPS mode not supported\n";
}
elsif (/^rsaref$/)
{
Expand All @@ -695,8 +692,7 @@ while (@argvcopy)
}
elsif (/^nofipscanistercheck$/)
{
$config{fips} = 1;
$nofipscanistercheck = 1;
die "FIPS mode not supported\n";
}
elsif (/^[-+]/)
{
Expand Down Expand Up @@ -734,10 +730,6 @@ while (@argvcopy)
{
$withargs{fuzzer_include}=$1;
}
elsif (/^--with-fipslibdir=(.*)$/)
{
$config{fipslibdir}="$1/";
}
elsif (/^--with-baseaddr=(.*)$/)
{
$config{baseaddr}="$1";
Expand Down Expand Up @@ -821,15 +813,6 @@ if ($libs =~ /(^|\s)-Wl,-rpath,/
"***** any of asan, msan or ubsan\n";
}

if ($config{fips})
{
delete $disabled{"shared"} if ($disabled{"shared"} =~ /^default/);
}
else
{
@{$config{dirs}} = grep !/^fips$/, @{$config{dirs}};
}

my @tocheckfor = (keys %disabled);
while (@tocheckfor) {
my %new_tocheckfor = ();
Expand Down Expand Up @@ -1058,15 +1041,6 @@ if (!$disabled{dso} && $target{dso_scheme} ne "")

$config{ex_libs}="$libs$config{ex_libs}" if ($libs ne "");

if ($disabled{asm})
{
if ($config{fips})
{
@{$config{defines}} = grep !/^[BL]_ENDIAN$/, @{$config{defines}};
@{$target{defines}} = grep !/^[BL]_ENDIAN$/, @{$target{defines}};
}
}

# If threads aren't disabled, check how possible they are
unless ($disabled{threads}) {
if ($auto_threads) {
Expand Down Expand Up @@ -1107,8 +1081,7 @@ if (defined($disabled{"deprecated"})) {
if ($target{shared_target} eq "")
{
$no_shared_warn = 1
if ((!$disabled{shared} || !$disabled{"dynamic-engine"})
&& !$config{fips});
if (!$disabled{shared} || !$disabled{"dynamic-engine"});
$disabled{shared} = "no-shared-target";
$disabled{pic} = $disabled{shared} = $disabled{"dynamic-engine"} =
"no-shared-target";
Expand Down Expand Up @@ -1172,10 +1145,6 @@ unless ($disabled{asm}) {
push @{$config{defines}}, "OPENSSL_BN_ASM_MONT5" if ($target{bn_asm_src} =~ /-mont5/);
push @{$config{defines}}, "OPENSSL_BN_ASM_GF2m" if ($target{bn_asm_src} =~ /-gf2m/);

if ($config{fips}) {
push @{$config{openssl_other_defines}}, "OPENSSL_FIPS";
}

if ($target{sha1_asm_src}) {
push @{$config{defines}}, "SHA1_ASM" if ($target{sha1_asm_src} =~ /sx86/ || $target{sha1_asm_src} =~ /sha1/);
push @{$config{defines}}, "SHA256_ASM" if ($target{sha1_asm_src} =~ /sha256/);
Expand Down
10 changes: 0 additions & 10 deletions apps/openssl.c
Expand Up @@ -21,9 +21,6 @@
# include <openssl/engine.h>
#endif
#include <openssl/err.h>
#ifdef OPENSSL_FIPS
# include <openssl/fips.h>
#endif
#define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */
#include "s_apps.h"
/* Needed to get the other O_xxx flags. */
Expand Down Expand Up @@ -143,15 +140,8 @@ int main(int argc, char *argv[])
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);

if (getenv("OPENSSL_FIPS")) {
#ifdef OPENSSL_FIPS
if (!FIPS_mode_set(1)) {
ERR_print_errors(bio_err);
return 1;
}
#else
BIO_printf(bio_err, "FIPS mode not supported.\n");
return 1;
#endif
}

if (!apps_startup())
Expand Down
4 changes: 0 additions & 4 deletions crypto/aes/asm/aes-mips.pl
Expand Up @@ -105,10 +105,6 @@
#include "mips_arch.h"
.text
#ifdef OPENSSL_FIPSCANISTER
# include <openssl/fipssyms.h>
#endif
#if !defined(__mips_eabi) && (!defined(__vxworks) || defined(__pic__))
.option pic2
#endif
Expand Down
4 changes: 0 additions & 4 deletions crypto/bn/asm/sparcv8plus.S
Expand Up @@ -144,10 +144,6 @@
* }
*/

#ifdef OPENSSL_FIPSCANISTER
#include <openssl/fipssyms.h>
#endif

#if defined(__SUNPRO_C) && defined(__sparcv9)
/* They've said -xarch=v9 at command line */
.register %g2,#scratch
Expand Down
4 changes: 0 additions & 4 deletions crypto/des/asm/des_enc.m4
Expand Up @@ -31,10 +31,6 @@

#include <openssl/opensslconf.h>

#ifdef OPENSSL_FIPSCANISTER
#include <openssl/fipssyms.h>
#endif

#if defined(__SUNPRO_C) && defined(__sparcv9)
# define ABI64 /* They've said -xarch=v9 at command line */
#elif defined(__GNUC__) && defined(__arch64__)
Expand Down
9 changes: 0 additions & 9 deletions crypto/err/err_all.c
Expand Up @@ -31,9 +31,6 @@
#include <openssl/ui.h>
#include <openssl/ocsp.h>
#include <openssl/err.h>
#ifdef OPENSSL_FIPS
# include <openssl/fips.h>
#endif
#include <openssl/ts.h>
#include <openssl/cms.h>
#include <openssl/ct.h>
Expand All @@ -43,9 +40,6 @@
int err_load_crypto_strings_int(void)
{
if (
#ifdef OPENSSL_FIPS
FIPS_set_error_callbacks(ERR_put_error, ERR_add_error_vdata) == 0 ||
#endif
#ifndef OPENSSL_NO_ERR
ERR_load_ERR_strings() == 0 || /* include error strings for SYSerr */
ERR_load_BN_strings() == 0 ||
Expand Down Expand Up @@ -91,9 +85,6 @@ int err_load_crypto_strings_int(void)
#ifndef OPENSSL_NO_UI
ERR_load_UI_strings() == 0 ||
#endif
# ifdef OPENSSL_FIPS
ERR_load_FIPS_strings() == 0 ||
# endif
# ifndef OPENSSL_NO_CMS
ERR_load_CMS_strings() == 0 ||
# endif
Expand Down
8 changes: 0 additions & 8 deletions crypto/evp/evp_cnf.c
Expand Up @@ -38,16 +38,8 @@ static int alg_module_init(CONF_IMODULE *md, const CONF *cnf)
return 0;
}
if (m > 0) {
#ifdef OPENSSL_FIPS
if (!FIPS_mode() && !FIPS_mode_set(1)) {
EVPerr(EVP_F_ALG_MODULE_INIT,
EVP_R_ERROR_SETTING_FIPS_MODE);
return 0;
}
#else
EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_FIPS_MODE_NOT_SUPPORTED);
return 0;
#endif
}
} else {
EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_UNKNOWN_OPTION);
Expand Down
12 changes: 1 addition & 11 deletions crypto/o_fips.c
Expand Up @@ -8,27 +8,17 @@
*/

#include "internal/cryptlib.h"
#ifdef OPENSSL_FIPS
# include <openssl/fips.h>
#endif

int FIPS_mode(void)
{
#ifdef OPENSSL_FIPS
return FIPS_module_mode();
#else
/* This version of the library does not support FIPS mode. */
return 0;
#endif
}

int FIPS_mode_set(int r)
{
#ifdef OPENSSL_FIPS
return FIPS_module_mode_set(r);
#else
if (r == 0)
return 1;
CRYPTOerr(CRYPTO_F_FIPS_MODE_SET, CRYPTO_R_FIPS_MODE_NOT_SUPPORTED);
return 0;
#endif
}
19 changes: 3 additions & 16 deletions crypto/o_init.c
Expand Up @@ -9,26 +9,13 @@

#include <e_os.h>
#include <openssl/err.h>
#ifdef OPENSSL_FIPS
# include <openssl/fips.h>
# include <openssl/rand.h>
#endif

/*
* Perform any essential OpenSSL initialization operations. Currently only
* sets FIPS callbacks
* Perform any essential OpenSSL initialization operations. Currently does
* nothing.
*/

void OPENSSL_init(void)
{
static int done = 0;
if (done)
return;
done = 1;
#ifdef OPENSSL_FIPS
FIPS_set_locking_callbacks(CRYPTO_lock, CRYPTO_add_lock);
FIPS_set_error_callbacks(ERR_put_error, ERR_add_error_vdata);
FIPS_set_malloc_callbacks(CRYPTO_malloc, CRYPTO_free);
RAND_init_fips();
#endif
return;
}
4 changes: 0 additions & 4 deletions crypto/rand/md_rand.c
Expand Up @@ -29,10 +29,6 @@

#include <internal/thread_once.h>

#ifdef OPENSSL_FIPS
# include <openssl/fips.h>
#endif

#if defined(BN_DEBUG) || defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
# define PREDICT
#endif
Expand Down
5 changes: 0 additions & 5 deletions crypto/rand/rand_lib.c
Expand Up @@ -15,11 +15,6 @@

#include <openssl/engine.h>

#ifdef OPENSSL_FIPS
# include <openssl/fips.h>
# include <openssl/fips_rand.h>
#endif

#ifndef OPENSSL_NO_ENGINE
/* non-NULL if default_RAND_meth is ENGINE-provided */
static ENGINE *funct_ref = NULL;
Expand Down
4 changes: 0 additions & 4 deletions crypto/sha/asm/sha1-mips.pl
Expand Up @@ -342,10 +342,6 @@ sub BODY_40_59 {
$code=<<___;
#include "mips_arch.h"
#ifdef OPENSSL_FIPSCANISTER
# include <openssl/fipssyms.h>
#endif
.text
.set noat
Expand Down
4 changes: 0 additions & 4 deletions crypto/sha/asm/sha512-mips.pl
Expand Up @@ -304,10 +304,6 @@ sub BODY_16_XX {
$code.=<<___;
#include "mips_arch.h"
#ifdef OPENSSL_FIPSCANISTER
# include <openssl/fipssyms.h>
#endif
.text
.set noat
#if !defined(__mips_eabi) && (!defined(__vxworks) || defined(__pic__))
Expand Down
4 changes: 0 additions & 4 deletions crypto/sparccpuid.S
Expand Up @@ -5,10 +5,6 @@
! in the file LICENSE in the source distribution or at
! https://www.openssl.org/source/license.html

#ifdef OPENSSL_FIPSCANISTER
#include <openssl/fipssyms.h>
#endif

#if defined(__SUNPRO_C) && defined(__sparcv9)
# define ABI64 /* They've said -xarch=v9 at command line */
#elif defined(__GNUC__) && defined(__arch64__)
Expand Down
13 changes: 2 additions & 11 deletions doc/man5/config.pod
Expand Up @@ -193,17 +193,8 @@ This modules has the name B<alg_section> which points to a section containing
algorithm commands.

Currently the only algorithm command supported is B<fips_mode> whose
value should be a boolean string such as B<on> or B<off>. If the value is
B<on> this attempt to enter FIPS mode. If the call fails or the library is
not FIPS capable then an error occurs.

For example:

alg_section = evp_settings

[evp_settings]

fips_mode = on
value can only be the boolean string B<off>. If B<fips_mode> is set to B<on>,
an error occurs as this library version is not FIPS capable.

=head2 SSL Configuration Module

Expand Down
6 changes: 1 addition & 5 deletions include/openssl/opensslv.h
Expand Up @@ -40,11 +40,7 @@ extern "C" {
* major minor fix final patch/beta)
*/
# define OPENSSL_VERSION_NUMBER 0x10101000L
# ifdef OPENSSL_FIPS
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1-fips-dev xx XXX xxxx"
# else
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1-dev xx XXX xxxx"
# endif
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1-dev xx XXX xxxx"

/*-
* The macros below are to be used for shared library (.so, .dll, ...)
Expand Down
7 changes: 0 additions & 7 deletions ssl/record/ssl3_record.c
Expand Up @@ -1119,13 +1119,6 @@ int tls1_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send)
EVP_MD_CTX_free(hmac);
return 0;
}
if (!send && !SSL_READ_ETM(ssl) && FIPS_mode())
if (!tls_fips_digest_extra(ssl->enc_read_ctx,
mac_ctx, rec->input,
rec->length, rec->orig_len)) {
EVP_MD_CTX_free(hmac);
return 0;
}
}

EVP_MD_CTX_free(hmac);
Expand Down

0 comments on commit b53338c

Please sign in to comment.