cleaned up errno handling.
[gnutls.git] / lib / gnutls_anon_cred.c
blob75e4bf7dfa344a12871b63e7592a47a1a909143c
1 /*
2 * Copyright (C) 2001-2012 Free Software Foundation, Inc.
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of GnuTLS.
8 * The GnuTLS is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
23 #include "gnutls_int.h"
25 #ifdef ENABLE_ANON
27 #include "gnutls_errors.h"
28 #include <auth/anon.h>
29 #include "gnutls_auth.h"
30 #include "gnutls_dh.h"
31 #include "gnutls_num.h"
32 #include "gnutls_mpi.h"
34 /**
35 * gnutls_anon_free_server_credentials:
36 * @sc: is a #gnutls_anon_server_credentials_t structure.
38 * This structure is complex enough to manipulate directly thus this
39 * helper function is provided in order to free (deallocate) it.
40 **/
41 void
42 gnutls_anon_free_server_credentials (gnutls_anon_server_credentials_t sc)
45 gnutls_free (sc);
48 /**
49 * gnutls_anon_allocate_server_credentials:
50 * @sc: is a pointer to a #gnutls_anon_server_credentials_t structure.
52 * This structure is complex enough to manipulate directly thus this
53 * helper function is provided in order to allocate it.
55 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
56 **/
57 int
58 gnutls_anon_allocate_server_credentials (gnutls_anon_server_credentials_t *
59 sc)
62 *sc = gnutls_calloc (1, sizeof (anon_server_credentials_st));
64 return 0;
68 /**
69 * gnutls_anon_free_client_credentials:
70 * @sc: is a #gnutls_anon_client_credentials_t structure.
72 * This structure is complex enough to manipulate directly thus this
73 * helper function is provided in order to free (deallocate) it.
74 **/
75 void
76 gnutls_anon_free_client_credentials (gnutls_anon_client_credentials_t sc)
80 static struct gnutls_anon_client_credentials_st anon_dummy_struct;
81 static const gnutls_anon_client_credentials_t anon_dummy = &anon_dummy_struct;
83 /**
84 * gnutls_anon_allocate_client_credentials:
85 * @sc: is a pointer to a #gnutls_anon_client_credentials_t structure.
87 * This structure is complex enough to manipulate directly thus
88 * this helper function is provided in order to allocate it.
90 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
91 **/
92 int
93 gnutls_anon_allocate_client_credentials (gnutls_anon_client_credentials_t *
94 sc)
96 /* anon_dummy is only there for *sc not to be null.
97 * it is not used at all;
99 *sc = anon_dummy;
101 return 0;
105 * gnutls_anon_set_server_dh_params:
106 * @res: is a gnutls_anon_server_credentials_t structure
107 * @dh_params: is a structure that holds Diffie-Hellman parameters.
109 * This function will set the Diffie-Hellman parameters for an
110 * anonymous server to use. These parameters will be used in
111 * Anonymous Diffie-Hellman cipher suites.
113 void
114 gnutls_anon_set_server_dh_params (gnutls_anon_server_credentials_t res,
115 gnutls_dh_params_t dh_params)
117 res->dh_params = dh_params;
121 * gnutls_anon_set_server_params_function:
122 * @res: is a gnutls_certificate_credentials_t structure
123 * @func: is the function to be called
125 * This function will set a callback in order for the server to get
126 * the Diffie-Hellman parameters for anonymous authentication. The
127 * callback should return %GNUTLS_E_SUCCESS (0) on success.
129 void
130 gnutls_anon_set_server_params_function (gnutls_anon_server_credentials_t res,
131 gnutls_params_function * func)
133 res->params_func = func;
136 #endif