Sync with TP.
[gnutls.git] / lib / gnutls_anon_cred.c
blobc09730069ad326ecf8bd61cbc8ca1b85327097bd
1 /*
2 * Copyright (C) 2001, 2004, 2005, 2007, 2008, 2009 Free Software Foundation
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of GNUTLS.
8 * The GNUTLS library 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 2.1 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
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 * USA
25 #include "gnutls_int.h"
27 #ifdef ENABLE_ANON
29 #include "gnutls_errors.h"
30 #include "auth_anon.h"
31 #include "gnutls_auth.h"
32 #include "gnutls_dh.h"
33 #include "gnutls_num.h"
34 #include "gnutls_mpi.h"
36 /**
37 * gnutls_anon_free_server_credentials - Used to free an allocated gnutls_anon_server_credentials_t structure
38 * @sc: is a #gnutls_anon_server_credentials_t structure.
40 * This structure is complex enough to manipulate directly thus this
41 * helper function is provided in order to free (deallocate) it.
42 **/
43 void
44 gnutls_anon_free_server_credentials (gnutls_anon_server_credentials_t sc)
47 gnutls_free (sc);
50 /**
51 * gnutls_anon_allocate_server_credentials - Used to allocate an gnutls_anon_server_credentials_t structure
52 * @sc: is a pointer to a #gnutls_anon_server_credentials_t structure.
54 * This structure is complex enough to manipulate directly thus this
55 * helper function is provided in order to allocate it.
57 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
58 **/
59 int
60 gnutls_anon_allocate_server_credentials (gnutls_anon_server_credentials_t *
61 sc)
64 *sc = gnutls_calloc (1, sizeof (anon_server_credentials_st));
66 return 0;
70 /**
71 * gnutls_anon_free_client_credentials - Used to free an allocated gnutls_anon_client_credentials_t structure
72 * @sc: is a #gnutls_anon_client_credentials_t structure.
74 * This structure is complex enough to manipulate directly thus this
75 * helper function is provided in order to free (deallocate) it.
76 **/
77 void
78 gnutls_anon_free_client_credentials (gnutls_anon_client_credentials_t sc)
82 static struct gnutls_anon_client_credentials_st anon_dummy_struct;
83 static const gnutls_anon_client_credentials_t anon_dummy = &anon_dummy_struct;
85 /**
86 * gnutls_anon_allocate_client_credentials - Used to allocate a credentials structure
87 * @sc: is a pointer to a #gnutls_anon_client_credentials_t structure.
89 * This structure is complex enough to manipulate directly thus
90 * this helper function is provided in order to allocate it.
92 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
93 **/
94 int
95 gnutls_anon_allocate_client_credentials (gnutls_anon_client_credentials_t *
96 sc)
98 /* anon_dummy is only there for *sc not to be null.
99 * it is not used at all;
101 *sc = anon_dummy;
103 return 0;
107 * gnutls_anon_set_server_dh_params - set the DH parameters for a server to use
108 * @res: is a gnutls_anon_server_credentials_t structure
109 * @dh_params: is a structure that holds Diffie-Hellman parameters.
111 * This function will set the Diffie-Hellman parameters for an
112 * anonymous server to use. These parameters will be used in
113 * Anonymous Diffie-Hellman cipher suites.
115 void
116 gnutls_anon_set_server_dh_params (gnutls_anon_server_credentials_t res,
117 gnutls_dh_params_t dh_params)
119 res->dh_params = dh_params;
123 * gnutls_anon_set_server_params_function - set the DH parameters callback
124 * @res: is a gnutls_certificate_credentials_t structure
125 * @func: is the function to be called
127 * This function will set a callback in order for the server to get
128 * the Diffie-Hellman parameters for anonymous authentication. The
129 * callback should return zero on success.
131 void
132 gnutls_anon_set_server_params_function (gnutls_anon_server_credentials_t res,
133 gnutls_params_function * func)
135 res->params_func = func;
138 #endif