certtool is able to set certificate policies via a template
[gnutls.git] / lib / gnutls_extensions.h
blob9aeae13f4a00680981046c8abc8cbb540b349ef7
1 /*
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 #ifndef GNUTLS_EXTENSIONS_H
24 #define GNUTLS_EXTENSIONS_H
26 #include <gnutls_str.h>
28 typedef int (*gnutls_ext_recv_func) (gnutls_session_t session,
29 const unsigned char *data, size_t len);
30 typedef int (*gnutls_ext_send_func) (gnutls_session_t session,
31 gnutls_buffer_st *extdata);
33 int _gnutls_parse_extensions (gnutls_session_t session,
34 gnutls_ext_parse_type_t parse_type,
35 const uint8_t * data, int data_size);
36 int _gnutls_gen_extensions (gnutls_session_t session, gnutls_buffer_st * extdata,
37 gnutls_ext_parse_type_t);
38 int _gnutls_ext_init (void);
39 void _gnutls_ext_deinit (void);
41 void _gnutls_extension_list_add (gnutls_session_t session, uint16_t type);
43 typedef void (*gnutls_ext_deinit_data_func) (extension_priv_data_t data);
44 typedef int (*gnutls_ext_pack_func) (extension_priv_data_t data,
45 gnutls_buffer_st * packed_data);
46 typedef int (*gnutls_ext_unpack_func) (gnutls_buffer_st * packed_data,
47 extension_priv_data_t * data);
49 void _gnutls_ext_free_session_data (gnutls_session_t session);
51 /* functions to be used by extensions internally
53 void _gnutls_ext_unset_session_data (gnutls_session_t session, uint16_t type);
54 void _gnutls_ext_set_session_data (gnutls_session_t session, uint16_t type,
55 extension_priv_data_t);
56 int _gnutls_ext_get_session_data (gnutls_session_t session,
57 uint16_t type, extension_priv_data_t *);
58 int _gnutls_ext_get_resumed_session_data (gnutls_session_t session,
59 uint16_t type,
60 extension_priv_data_t * data);
62 void _gnutls_ext_restore_resumed_session (gnutls_session_t session);
64 /* for session packing */
65 int _gnutls_ext_pack (gnutls_session_t session, gnutls_buffer_st * packed);
66 int _gnutls_ext_unpack (gnutls_session_t session, gnutls_buffer_st * packed);
68 typedef struct
70 const char *name;
71 uint16_t type;
72 gnutls_ext_parse_type_t parse_type;
74 /* this function must return 0 when Not Applicable
75 * size of extension data if ok
76 * < 0 on other error.
78 gnutls_ext_recv_func recv_func;
80 /* this function must return 0 when Not Applicable
81 * size of extension data if ok
82 * GNUTLS_E_INT_RET_0 if extension data size is zero
83 * < 0 on other error.
85 gnutls_ext_send_func send_func;
87 gnutls_ext_deinit_data_func deinit_func; /* this will be called to deinitialize
88 * internal data
90 gnutls_ext_pack_func pack_func; /* packs internal data to machine independent format */
91 gnutls_ext_unpack_func unpack_func; /* unpacks internal data */
93 } extension_entry_st;
95 int _gnutls_ext_register (extension_entry_st *);
97 #endif