Blame lib/mem.h

Packit Service 4684c1
/*
Packit Service 4684c1
 * Copyright (C) 2000-2012 Free Software Foundation, Inc.
Packit Service 4684c1
 *
Packit Service 4684c1
 * Author: Nikos Mavrogiannopoulos
Packit Service 4684c1
 *
Packit Service 4684c1
 * This file is part of GnuTLS.
Packit Service 4684c1
 *
Packit Service 4684c1
 * The GnuTLS is free software; you can redistribute it and/or
Packit Service 4684c1
 * modify it under the terms of the GNU Lesser General Public License
Packit Service 4684c1
 * as published by the Free Software Foundation; either version 2.1 of
Packit Service 4684c1
 * the License, or (at your option) any later version.
Packit Service 4684c1
 *
Packit Service 4684c1
 * This library is distributed in the hope that it will be useful, but
Packit Service 4684c1
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 4684c1
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 4684c1
 * Lesser General Public License for more details.
Packit Service 4684c1
 *
Packit Service 4684c1
 * You should have received a copy of the GNU Lesser General Public License
Packit Service 4684c1
 * along with this program.  If not, see <https://www.gnu.org/licenses/>
Packit Service 4684c1
 *
Packit Service 4684c1
 */
Packit Service 4684c1
Packit Service 4684c1
#ifndef GNUTLS_LIB_MEM_H
Packit Service 4684c1
#define GNUTLS_LIB_MEM_H
Packit Service 4684c1
Packit Service 4684c1
#include <config.h>
Packit Service 4684c1
Packit Service 4684c1
/* this realloc function will return ptr if size==0, and
Packit Service 4684c1
 * will free the ptr if the new allocation failed.
Packit Service 4684c1
 */
Packit Service 4684c1
void *gnutls_realloc_fast(void *ptr, size_t size);
Packit Service 4684c1
Packit Service 4684c1
void *_gnutls_calloc(size_t nmemb, size_t size);
Packit Service 4684c1
char *_gnutls_strdup(const char *);
Packit Service 4684c1
Packit Service 4684c1
unsigned _gnutls_mem_is_zero(const uint8_t *ptr, unsigned size);
Packit Service 4684c1
Packit Service 4684c1
/* To avoid undefined behavior when s1 or s2 are null and n = 0 */
Packit Service 4684c1
inline static
Packit Service 4684c1
int safe_memcmp(const void *s1, const void *s2, size_t n)
Packit Service 4684c1
{
Packit Service 4684c1
	if (n == 0)
Packit Service 4684c1
		return 0;
Packit Service 4684c1
	return memcmp(s1, s2, n);
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
#define zrelease_mpi_key(mpi) if (*mpi!=NULL) { \
Packit Service 4684c1
		_gnutls_mpi_clear(*mpi); \
Packit Service 4684c1
		_gnutls_mpi_release(mpi); \
Packit Service 4684c1
	}
Packit Service 4684c1
Packit Service 4684c1
#define zeroize_key(x, size) gnutls_memset(x, 0, size)
Packit Service 4684c1
Packit Service 4684c1
#define zeroize_temp_key zeroize_key
Packit Service 4684c1
#define zrelease_temp_mpi_key zrelease_mpi_key
Packit Service 4684c1
Packit Service 4684c1
#endif /* GNUTLS_LIB_MEM_H */