2 * Copyright (C) 2000-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 /* This file contains the Anonymous Diffie-Hellman key exchange part of
24 * the anonymous authentication. The functions here are used in the
28 #include <gnutls_int.h>
32 #include "gnutls_auth.h"
33 #include "gnutls_errors.h"
34 #include "gnutls_dh.h"
35 #include "auth/anon.h"
36 #include "gnutls_num.h"
37 #include "gnutls_mpi.h"
38 #include <gnutls_state.h>
39 #include <auth/ecdh_common.h>
42 static int gen_anon_ecdh_server_kx (gnutls_session_t
, gnutls_buffer_st
*);
43 static int proc_anon_ecdh_client_kx (gnutls_session_t
, uint8_t *, size_t);
44 static int proc_anon_ecdh_server_kx (gnutls_session_t
, uint8_t *, size_t);
46 const mod_auth_st anon_ecdh_auth_struct
= {
50 gen_anon_ecdh_server_kx
,
51 _gnutls_gen_ecdh_common_client_kx
, /* this can be shared */
56 NULL
, /* certificate */
57 proc_anon_ecdh_server_kx
,
58 proc_anon_ecdh_client_kx
,
64 gen_anon_ecdh_server_kx (gnutls_session_t session
, gnutls_buffer_st
* data
)
67 gnutls_anon_server_credentials_t cred
;
69 cred
= (gnutls_anon_server_credentials_t
)
70 _gnutls_get_cred (session
, GNUTLS_CRD_ANON
, NULL
);
74 return GNUTLS_E_INSUFFICIENT_CREDENTIALS
;
78 _gnutls_auth_info_set (session
, GNUTLS_CRD_ANON
,
79 sizeof (anon_auth_info_st
), 1)) < 0)
85 ret
= _gnutls_ecdh_common_print_server_kx (session
, data
, _gnutls_session_ecc_curve_get(session
));
96 proc_anon_ecdh_client_kx (gnutls_session_t session
, uint8_t * data
,
99 gnutls_anon_server_credentials_t cred
;
101 cred
= (gnutls_anon_server_credentials_t
)
102 _gnutls_get_cred (session
, GNUTLS_CRD_ANON
, NULL
);
106 return GNUTLS_E_INSUFFICIENT_CREDENTIALS
;
109 return _gnutls_proc_ecdh_common_client_kx (session
, data
, _data_size
,
110 _gnutls_session_ecc_curve_get(session
), NULL
);
114 proc_anon_ecdh_server_kx (gnutls_session_t session
, uint8_t * data
,
122 _gnutls_auth_info_set (session
, GNUTLS_CRD_ANON
,
123 sizeof (anon_auth_info_st
), 1)) < 0)
129 ret
= _gnutls_proc_ecdh_common_server_kx (session
, data
, _data_size
);
139 #endif /* ENABLE_ANON */