Blame lib/auth/psk.h

Packit aea12f
/*
Packit aea12f
 * Copyright (C) 2005-2012 Free Software Foundation, Inc.
Packit aea12f
 *
Packit aea12f
 * Author: Nikos Mavrogiannopoulos
Packit aea12f
 *
Packit aea12f
 * This file is part of GnuTLS.
Packit aea12f
 *
Packit aea12f
 * The GnuTLS is free software; you can redistribute it and/or
Packit aea12f
 * modify it under the terms of the GNU Lesser General Public License
Packit aea12f
 * as published by the Free Software Foundation; either version 2.1 of
Packit aea12f
 * the License, or (at your option) any later version.
Packit aea12f
 *
Packit aea12f
 * This library is distributed in the hope that it will be useful, but
Packit aea12f
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit aea12f
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit aea12f
 * Lesser General Public License for more details.
Packit aea12f
 *
Packit aea12f
 * You should have received a copy of the GNU Lesser General Public License
Packit aea12f
 * along with this program.  If not, see <https://www.gnu.org/licenses/>
Packit aea12f
 *
Packit aea12f
 */
Packit aea12f
Packit aea12f
#ifndef GNUTLS_LIB_AUTH_PSK_H
Packit aea12f
#define GNUTLS_LIB_AUTH_PSK_H
Packit aea12f
Packit aea12f
#include <auth.h>
Packit aea12f
#include <auth/dh_common.h>
Packit aea12f
Packit aea12f
typedef struct gnutls_psk_client_credentials_st {
Packit aea12f
	gnutls_datum_t username;
Packit aea12f
	gnutls_datum_t key;
Packit Service 991b93
	gnutls_psk_client_credentials_function2 *get_function;
Packit Service 991b93
	gnutls_psk_client_credentials_function *get_function_legacy;
Packit aea12f
	/* TLS 1.3 - The HMAC algorithm to use to compute the binder values */
Packit aea12f
	const mac_entry_st *binder_algo;
Packit aea12f
} psk_client_credentials_st;
Packit aea12f
Packit aea12f
typedef struct gnutls_psk_server_credentials_st {
Packit aea12f
	char *password_file;
Packit aea12f
	/* callback function, instead of reading the
Packit aea12f
	 * password files.
Packit aea12f
	 */
Packit Service 991b93
	gnutls_psk_server_credentials_function2 *pwd_callback;
Packit Service 991b93
	gnutls_psk_server_credentials_function *pwd_callback_legacy;
Packit aea12f
Packit aea12f
	/* For DHE_PSK */
Packit aea12f
	gnutls_dh_params_t dh_params;
Packit aea12f
	unsigned int deinit_dh_params;
Packit aea12f
	gnutls_sec_param_t dh_sec_param;
Packit aea12f
	/* this callback is used to retrieve the DH or RSA
Packit aea12f
	 * parameters.
Packit aea12f
	 */
Packit aea12f
	gnutls_params_function *params_func;
Packit aea12f
Packit aea12f
	/* Identity hint. */
Packit aea12f
	char *hint;
Packit aea12f
	/* TLS 1.3 - HMAC algorithm for the binder values */
Packit aea12f
	const mac_entry_st *binder_algo;
Packit aea12f
} psk_server_cred_st;
Packit aea12f
Packit aea12f
/* these structures should not use allocated data */
Packit aea12f
typedef struct psk_auth_info_st {
Packit aea12f
	char username[MAX_USERNAME_SIZE + 1];
Packit Service 991b93
	uint16_t username_len;
Packit aea12f
	dh_info_st dh;
Packit aea12f
	char hint[MAX_USERNAME_SIZE + 1];
Packit aea12f
} *psk_auth_info_t;
Packit aea12f
Packit aea12f
typedef struct psk_auth_info_st psk_auth_info_st;
Packit aea12f
Packit Service 991b93
inline static
Packit Service 991b93
void _gnutls_copy_psk_username(psk_auth_info_t info, const gnutls_datum_t *username)
Packit Service 991b93
{
Packit Service 991b93
	assert(sizeof(info->username) > username->size);
Packit Service 991b93
	memcpy(info->username, username->data, username->size);
Packit Service 991b93
	info->username[username->size] = 0;
Packit Service 991b93
	info->username_len = username->size;
Packit Service 991b93
}
Packit Service 991b93
Packit aea12f
#ifdef ENABLE_PSK
Packit aea12f
Packit aea12f
int
Packit aea12f
_gnutls_set_psk_session_key(gnutls_session_t session, gnutls_datum_t * key,
Packit aea12f
			    gnutls_datum_t * psk2);
Packit aea12f
int _gnutls_gen_psk_server_kx(gnutls_session_t session,
Packit aea12f
			      gnutls_buffer_st * data);
Packit aea12f
int _gnutls_gen_psk_client_kx(gnutls_session_t, gnutls_buffer_st *);
Packit aea12f
Packit aea12f
#else
Packit aea12f
#define _gnutls_set_psk_session_key(x,y,z) GNUTLS_E_UNIMPLEMENTED_FEATURE
Packit aea12f
#endif				/* ENABLE_PSK */
Packit aea12f
Packit aea12f
#endif /* GNUTLS_LIB_AUTH_PSK_H */