Fix CVE-2017-6891 in minitasn1 code
[platform/upstream/gnutls.git] / lib / gnutls_state.h
1 /*
2  * Copyright (C) 2000-2012 Free Software Foundation, Inc.
3  *
4  * Author: Nikos Mavrogiannopoulos
5  *
6  * This file is part of GnuTLS.
7  *
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 2.1 of
11  * the License, or (at your option) any later version.
12  *
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.
17  *
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/>
20  *
21  */
22
23 #ifndef GNUTLS_STATE_H
24 #define GNUTLS_STATE_H
25
26 #include <gnutls_int.h>
27
28 void _gnutls_session_cert_type_set(gnutls_session_t session,
29                                    gnutls_certificate_type_t);
30
31 inline static gnutls_ecc_curve_t
32 _gnutls_session_ecc_curve_get(gnutls_session_t session)
33 {
34         return session->security_parameters.ecc_curve;
35 }
36
37 int _gnutls_session_is_ecc(gnutls_session_t session);
38
39 void
40 _gnutls_session_ecc_curve_set(gnutls_session_t session,
41                               gnutls_ecc_curve_t c);
42
43 void
44 _gnutls_record_set_default_version(gnutls_session_t session,
45                                    unsigned char major,
46                                    unsigned char minor);
47
48 #include <gnutls_auth.h>
49
50 #define CHECK_AUTH(auth, ret) if (gnutls_auth_get_type(session) != auth) { \
51         gnutls_assert(); \
52         return ret; \
53         }
54
55 #endif
56
57 int _gnutls_session_cert_type_supported(gnutls_session_t,
58                                         gnutls_certificate_type_t);
59 int _gnutls_dh_set_secret_bits(gnutls_session_t session, unsigned bits);
60
61 int _gnutls_dh_set_peer_public(gnutls_session_t session, bigint_t public);
62 int _gnutls_dh_set_group(gnutls_session_t session, bigint_t gen,
63                          bigint_t prime);
64
65 static inline int _gnutls_dh_get_min_prime_bits(gnutls_session_t session)
66 {
67         if (session->internals.priorities.dh_prime_bits != 0)
68                 return session->internals.priorities.dh_prime_bits;
69         else
70                 return gnutls_sec_param_to_pk_bits(GNUTLS_PK_DH,
71                                                    session->internals.
72                                                    priorities.level);
73 }
74
75 void _gnutls_handshake_internal_state_clear(gnutls_session_t);
76
77 int _gnutls_session_is_resumable(gnutls_session_t session);
78
79 int _gnutls_session_is_psk(gnutls_session_t session);
80
81 int _gnutls_openpgp_send_fingerprint(gnutls_session_t session);
82
83 int _gnutls_PRF(gnutls_session_t session,
84                 const uint8_t * secret, unsigned int secret_size,
85                 const char *label, int label_size,
86                 const uint8_t * seed, int seed_size,
87                 int total_bytes, void *ret);
88
89 #define DEFAULT_CERT_TYPE GNUTLS_CRT_X509