Blame lib/datum.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_DATUM_H
Packit Service 4684c1
#define GNUTLS_LIB_DATUM_H
Packit Service 4684c1
Packit Service 4684c1
# include "gnutls_int.h"
Packit Service 4684c1
Packit Service 4684c1
/* This will copy the provided data in @dat. If the provided data are
Packit Service 4684c1
 * NULL or zero-size @dat will be NULL as well.
Packit Service 4684c1
 */
Packit Service 4684c1
NODISCARD ATTRIBUTE_NONNULL((1))
Packit Service 4684c1
int _gnutls_set_datum(gnutls_datum_t * dat, const void *data,
Packit Service 4684c1
		      size_t data_size);
Packit Service 4684c1
Packit Service 4684c1
/* This will always return a non-NULL, and zero-terminated string in @dat.
Packit Service 4684c1
 */
Packit Service 4684c1
NODISCARD ATTRIBUTE_NONNULL((1))
Packit Service 4684c1
int _gnutls_set_strdatum(gnutls_datum_t * dat, const void *data,
Packit Service 4684c1
			 size_t data_size);
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
inline static
Packit Service 4684c1
void _gnutls_free_datum(gnutls_datum_t * dat)
Packit Service 4684c1
{
Packit Service 4684c1
	if (dat != NULL) {
Packit Service 4684c1
		gnutls_free(dat->data);
Packit Service 4684c1
		dat->size = 0;
Packit Service 4684c1
	}
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
inline static ATTRIBUTE_NONNULL()
Packit Service 4684c1
void _gnutls_free_temp_key_datum(gnutls_datum_t * dat)
Packit Service 4684c1
{
Packit Service 4684c1
	if (dat->data != NULL) {
Packit Service 4684c1
		zeroize_temp_key(dat->data, dat->size);
Packit Service 4684c1
		gnutls_free(dat->data);
Packit Service 4684c1
	}
Packit Service 4684c1
Packit Service 4684c1
	dat->size = 0;
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
inline static ATTRIBUTE_NONNULL()
Packit Service 4684c1
void _gnutls_free_key_datum(gnutls_datum_t * dat)
Packit Service 4684c1
{
Packit Service 4684c1
	if (dat->data != NULL) {
Packit Service 4684c1
		zeroize_key(dat->data, dat->size);
Packit Service 4684c1
		gnutls_free(dat->data);
Packit Service 4684c1
	}
Packit Service 4684c1
Packit Service 4684c1
	dat->size = 0;
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
#endif /* GNUTLS_LIB_DATUM_H */