Blame lib/fips.h

Packit 549fdc
/*
Packit 549fdc
 * Copyright (C) 2013 Red Hat
Packit 549fdc
 *
Packit 549fdc
 * Author: Nikos Mavrogiannopoulos
Packit 549fdc
 *
Packit 549fdc
 * This file is part of GnuTLS.
Packit 549fdc
 *
Packit 549fdc
 * The GnuTLS is free software; you can redistribute it and/or
Packit 549fdc
 * modify it under the terms of the GNU Lesser General Public License
Packit 549fdc
 * as published by the Free Software Foundation; either version 2.1 of
Packit 549fdc
 * the License, or (at your option) any later version.
Packit 549fdc
 *
Packit 549fdc
 * This library is distributed in the hope that it will be useful, but
Packit 549fdc
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 549fdc
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 549fdc
 * Lesser General Public License for more details.
Packit 549fdc
 *
Packit 549fdc
 * You should have received a copy of the GNU Lesser General Public License
Packit 549fdc
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
Packit 549fdc
 *
Packit 549fdc
 */
Packit 549fdc
Packit 549fdc
#ifndef FIPS_H
Packit 549fdc
# define FIPS_H
Packit 549fdc
Packit 549fdc
#include "gnutls_int.h"
Packit 549fdc
#include <gnutls/gnutls.h>
Packit 549fdc
Packit 549fdc
#define FIPS140_RND_KEY_SIZE 32
Packit 549fdc
Packit 549fdc
typedef enum {
Packit 549fdc
  LIB_STATE_POWERON,
Packit 549fdc
  LIB_STATE_INIT,
Packit 549fdc
  LIB_STATE_SELFTEST,
Packit 549fdc
  LIB_STATE_OPERATIONAL,
Packit 549fdc
  LIB_STATE_ERROR,
Packit 549fdc
  LIB_STATE_SHUTDOWN
Packit 549fdc
} gnutls_lib_state_t;
Packit 549fdc
Packit 549fdc
/* do not access directly */
Packit 549fdc
extern unsigned int _gnutls_lib_mode;
Packit 549fdc
extern gnutls_crypto_rnd_st _gnutls_fips_rnd_ops;
Packit 549fdc
Packit 549fdc
inline static 
Packit 549fdc
void _gnutls_switch_lib_state(gnutls_lib_state_t state)
Packit 549fdc
{
Packit 549fdc
	/* Once into zombie state no errors can change us */
Packit 549fdc
	_gnutls_lib_mode = state;
Packit 549fdc
}
Packit 549fdc
Packit 549fdc
inline static gnutls_lib_state_t _gnutls_get_lib_state(void)
Packit 549fdc
{
Packit 549fdc
	return _gnutls_lib_mode;
Packit 549fdc
}
Packit 549fdc
Packit 549fdc
int _gnutls_fips_perform_self_checks1(void);
Packit 549fdc
int _gnutls_fips_perform_self_checks2(void);
Packit 549fdc
void _gnutls_fips_mode_reset_zombie(void);
Packit 549fdc
Packit 549fdc
#ifdef ENABLE_FIPS140
Packit 549fdc
unsigned _gnutls_fips_mode_enabled(void);
Packit 549fdc
#else
Packit 549fdc
# define _gnutls_fips_mode_enabled() 0
Packit 549fdc
#endif
Packit 549fdc
Packit 549fdc
# define HAVE_LIB_ERROR() unlikely(_gnutls_get_lib_state() != LIB_STATE_OPERATIONAL && _gnutls_get_lib_state() != LIB_STATE_SELFTEST)
Packit 549fdc
Packit 549fdc
# define FAIL_IF_LIB_ERROR \
Packit 549fdc
	if (HAVE_LIB_ERROR()) return GNUTLS_E_LIB_IN_ERROR_STATE
Packit 549fdc
Packit 549fdc
void _gnutls_switch_lib_state(gnutls_lib_state_t state);
Packit 549fdc
Packit 549fdc
void _gnutls_lib_simulate_error(void);
Packit 549fdc
void _gnutls_lib_force_operational(void);
Packit 549fdc
Packit 549fdc
#endif /* FIPS_H */