Tizen 2.0 Release
[external/libgnutls26.git] / lib / gnutls_algorithms.h
1 /*
2  * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2010
3  * Free Software Foundation, Inc.
4  *
5  * Author: Nikos Mavrogiannopoulos
6  *
7  * This file is part of GnuTLS.
8  *
9  * The GnuTLS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1 of
12  * the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22  * USA
23  *
24  */
25
26 #ifndef ALGORITHMS_H
27 #define ALGORITHMS_H
28
29 #include "gnutls_auth.h"
30
31 #define GNUTLS_RENEGO_PROTECTION_REQUEST_MAJOR 0x00
32 #define GNUTLS_RENEGO_PROTECTION_REQUEST_MINOR 0xFF
33
34 /* Functions for version handling. */
35 gnutls_protocol_t _gnutls_version_lowest (gnutls_session_t session);
36 gnutls_protocol_t _gnutls_version_max (gnutls_session_t session);
37 int _gnutls_version_priority (gnutls_session_t session,
38                               gnutls_protocol_t version);
39 int _gnutls_version_is_supported (gnutls_session_t session,
40                                   const gnutls_protocol_t version);
41 int _gnutls_version_get_major (gnutls_protocol_t ver);
42 int _gnutls_version_get_minor (gnutls_protocol_t ver);
43 gnutls_protocol_t _gnutls_version_get (int major, int minor);
44
45 /* Functions for feature checks */
46 int _gnutls_version_has_selectable_prf (gnutls_protocol_t version);
47 int _gnutls_version_has_selectable_sighash (gnutls_protocol_t version);
48 int _gnutls_version_has_extensions (gnutls_protocol_t version);
49 int _gnutls_version_has_explicit_iv (gnutls_protocol_t version);
50 int _gnutls_version_has_variable_padding (gnutls_protocol_t version);
51
52 /* Functions for MACs. */
53 int _gnutls_mac_is_ok (gnutls_mac_algorithm_t algorithm);
54 gnutls_mac_algorithm_t _gnutls_x509_oid2mac_algorithm (const char *oid);
55 const char *_gnutls_x509_mac_to_oid (gnutls_mac_algorithm_t mac);
56
57 /* Functions for cipher suites. */
58 int _gnutls_supported_ciphersuites (gnutls_session_t session,
59                                     cipher_suite_st ** ciphers);
60 int _gnutls_supported_ciphersuites_sorted (gnutls_session_t session,
61                                            cipher_suite_st ** ciphers);
62 const char *_gnutls_cipher_suite_get_name (cipher_suite_st * algorithm);
63 gnutls_cipher_algorithm_t _gnutls_cipher_suite_get_cipher_algo (const
64                                                                 cipher_suite_st
65                                                                 * algorithm);
66 gnutls_kx_algorithm_t _gnutls_cipher_suite_get_kx_algo (const cipher_suite_st
67                                                         * algorithm);
68 gnutls_mac_algorithm_t _gnutls_cipher_suite_get_mac_algo (const
69                                                           cipher_suite_st *
70                                                           algorithm);
71 gnutls_protocol_t _gnutls_cipher_suite_is_version_supported (const
72                                                              cipher_suite_st *
73                                                              algorithm,
74                                                              gnutls_protocol_t);
75 cipher_suite_st _gnutls_cipher_suite_get_suite_name (cipher_suite_st *
76                                                      algorithm);
77
78 /* Functions for ciphers. */
79 int _gnutls_cipher_is_block (gnutls_cipher_algorithm_t algorithm);
80 int _gnutls_cipher_is_ok (gnutls_cipher_algorithm_t algorithm);
81 int _gnutls_cipher_get_iv_size (gnutls_cipher_algorithm_t algorithm);
82 int _gnutls_cipher_get_export_flag (gnutls_cipher_algorithm_t algorithm);
83
84 /* Functions for key exchange. */
85 int _gnutls_kx_needs_dh_params (gnutls_kx_algorithm_t algorithm);
86 int _gnutls_kx_needs_rsa_params (gnutls_kx_algorithm_t algorithm);
87 mod_auth_st *_gnutls_kx_auth_struct (gnutls_kx_algorithm_t algorithm);
88 int _gnutls_kx_is_ok (gnutls_kx_algorithm_t algorithm);
89
90 /* Type to KX mappings. */
91 gnutls_kx_algorithm_t _gnutls_map_kx_get_kx (gnutls_credentials_type_t type,
92                                              int server);
93 gnutls_credentials_type_t _gnutls_map_kx_get_cred (gnutls_kx_algorithm_t
94                                                    algorithm, int server);
95
96 /* KX to PK mapping. */
97 gnutls_pk_algorithm_t _gnutls_map_pk_get_pk (gnutls_kx_algorithm_t
98                                              kx_algorithm);
99 gnutls_pk_algorithm_t _gnutls_x509_oid2pk_algorithm (const char *oid);
100 const char *_gnutls_x509_pk_to_oid (gnutls_pk_algorithm_t pk);
101
102 enum encipher_type
103 { CIPHER_ENCRYPT = 0, CIPHER_SIGN = 1, CIPHER_IGN };
104
105 enum encipher_type _gnutls_kx_encipher_type (gnutls_kx_algorithm_t algorithm);
106
107 /* Functions for sign algorithms. */
108 gnutls_sign_algorithm_t _gnutls_x509_oid2sign_algorithm (const char *oid);
109 gnutls_sign_algorithm_t _gnutls_x509_pk_to_sign (gnutls_pk_algorithm_t pk,
110                                                  gnutls_mac_algorithm_t mac);
111 gnutls_pk_algorithm_t _gnutls_x509_sign_to_pk (gnutls_sign_algorithm_t sign);
112 const char *_gnutls_x509_sign_to_oid (gnutls_pk_algorithm_t,
113                                       gnutls_mac_algorithm_t mac);
114 gnutls_sign_algorithm_t _gnutls_tls_aid_to_sign (const sign_algorithm_st *
115                                                  aid);
116 const sign_algorithm_st* _gnutls_sign_to_tls_aid (gnutls_sign_algorithm_t sign);
117 gnutls_mac_algorithm_t
118 _gnutls_sign_get_hash_algorithm (gnutls_sign_algorithm_t);
119 gnutls_pk_algorithm_t _gnutls_sign_get_pk_algorithm (gnutls_sign_algorithm_t);
120
121 int _gnutls_mac_priority (gnutls_session_t session,
122                           gnutls_mac_algorithm_t algorithm);
123 int _gnutls_cipher_priority (gnutls_session_t session,
124                              gnutls_cipher_algorithm_t algorithm);
125 int _gnutls_kx_priority (gnutls_session_t session,
126                          gnutls_kx_algorithm_t algorithm);
127
128 unsigned int _gnutls_pk_bits_to_subgroup_bits (unsigned int pk_bits);
129
130 #endif