| 1 | /* GIO - GLib Input, Output and Streaming Library | 
| 2 |  * | 
| 3 |  * Copyright (C) 2010 Red Hat, Inc. | 
| 4 |  * | 
| 5 |  * This library is free software; you can redistribute it and/or | 
| 6 |  * modify it under the terms of the GNU Lesser General Public | 
| 7 |  * License as published by the Free Software Foundation; either | 
| 8 |  * version 2.1 of the License, or (at your option) any later version. | 
| 9 |  * | 
| 10 |  * This library is distributed in the hope that it will be useful, | 
| 11 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 12 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
| 13 |  * Lesser General Public License for more details. | 
| 14 |  * | 
| 15 |  * You should have received a copy of the GNU Lesser General | 
| 16 |  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>. | 
| 17 |  */ | 
| 18 |  | 
| 19 | #ifndef __G_TLS_CONNECTION_H__ | 
| 20 | #define __G_TLS_CONNECTION_H__ | 
| 21 |  | 
| 22 | #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) | 
| 23 | #error "Only <gio/gio.h> can be included directly." | 
| 24 | #endif | 
| 25 |  | 
| 26 | #include <gio/giostream.h> | 
| 27 |  | 
| 28 | G_BEGIN_DECLS | 
| 29 |  | 
| 30 | #define G_TYPE_TLS_CONNECTION            (g_tls_connection_get_type ()) | 
| 31 | #define G_TLS_CONNECTION(inst)           (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_CONNECTION, GTlsConnection)) | 
| 32 | #define G_TLS_CONNECTION_CLASS(class)    (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TLS_CONNECTION, GTlsConnectionClass)) | 
| 33 | #define G_IS_TLS_CONNECTION(inst)        (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_CONNECTION)) | 
| 34 | #define G_IS_TLS_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TLS_CONNECTION)) | 
| 35 | #define G_TLS_CONNECTION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), G_TYPE_TLS_CONNECTION, GTlsConnectionClass)) | 
| 36 |  | 
| 37 | typedef struct _GTlsConnectionClass   GTlsConnectionClass; | 
| 38 | typedef struct _GTlsConnectionPrivate GTlsConnectionPrivate; | 
| 39 |  | 
| 40 | struct _GTlsConnection { | 
| 41 |   GIOStream parent_instance; | 
| 42 |  | 
| 43 |   GTlsConnectionPrivate *priv; | 
| 44 | }; | 
| 45 |  | 
| 46 | /** | 
| 47 |  * GTlsConnectionClass: | 
| 48 |  * @parent_class: The parent class. | 
| 49 |  * @accept_certificate: Check whether to accept a certificate. | 
| 50 |  * @handshake: Perform a handshake operation. | 
| 51 |  * @handshake_async: Start an asynchronous handshake operation. | 
| 52 |  * @handshake_finish: Finish an asynchronous handshake operation. | 
| 53 |  * @get_binding_data: Retrieve TLS channel binding data (Since: 2.66) | 
| 54 |  * @get_negotiated_protocol: Get ALPN-negotiated protocol (Since: 2.70) | 
| 55 |  * | 
| 56 |  * The class structure for the #GTlsConnection type. | 
| 57 |  * | 
| 58 |  * Since: 2.28 | 
| 59 |  */ | 
| 60 | struct _GTlsConnectionClass | 
| 61 | { | 
| 62 |   GIOStreamClass parent_class; | 
| 63 |  | 
| 64 |   /* signals */ | 
| 65 |   gboolean          ( *accept_certificate) (GTlsConnection       *connection, | 
| 66 | 					    GTlsCertificate      *peer_cert, | 
| 67 | 					    GTlsCertificateFlags  errors); | 
| 68 |  | 
| 69 |   /* methods */ | 
| 70 |   gboolean ( *handshake )        (GTlsConnection       *conn, | 
| 71 | 				  GCancellable         *cancellable, | 
| 72 | 				  GError              **error); | 
| 73 |  | 
| 74 |   void     ( *handshake_async )  (GTlsConnection       *conn, | 
| 75 | 				  int                   io_priority, | 
| 76 | 				  GCancellable         *cancellable, | 
| 77 | 				  GAsyncReadyCallback   callback, | 
| 78 | 				  gpointer              user_data); | 
| 79 |   gboolean ( *handshake_finish ) (GTlsConnection       *conn, | 
| 80 | 				  GAsyncResult         *result, | 
| 81 | 				  GError              **error); | 
| 82 |  | 
| 83 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS | 
| 84 |   gboolean ( *get_binding_data)  (GTlsConnection          *conn, | 
| 85 |                                   GTlsChannelBindingType   type, | 
| 86 |                                   GByteArray              *data, | 
| 87 |                                   GError                 **error); | 
| 88 | G_GNUC_END_IGNORE_DEPRECATIONS | 
| 89 |  | 
| 90 |   const gchar *(*get_negotiated_protocol) (GTlsConnection *conn); | 
| 91 |  | 
| 92 |   /*< private >*/ | 
| 93 |   /* Padding for future expansion */ | 
| 94 |   gpointer padding[6]; | 
| 95 | }; | 
| 96 |  | 
| 97 | GLIB_AVAILABLE_IN_ALL | 
| 98 | GType                 g_tls_connection_get_type                    (void) G_GNUC_CONST; | 
| 99 |  | 
| 100 | GLIB_DEPRECATED | 
| 101 | void                  g_tls_connection_set_use_system_certdb       (GTlsConnection       *conn, | 
| 102 |                                                                     gboolean              use_system_certdb); | 
| 103 | GLIB_DEPRECATED | 
| 104 | gboolean              g_tls_connection_get_use_system_certdb       (GTlsConnection       *conn); | 
| 105 |  | 
| 106 | GLIB_AVAILABLE_IN_ALL | 
| 107 | void                  g_tls_connection_set_database                (GTlsConnection       *conn, | 
| 108 | 								    GTlsDatabase         *database); | 
| 109 | GLIB_AVAILABLE_IN_ALL | 
| 110 | GTlsDatabase *        g_tls_connection_get_database                (GTlsConnection       *conn); | 
| 111 |  | 
| 112 | GLIB_AVAILABLE_IN_ALL | 
| 113 | void                  g_tls_connection_set_certificate             (GTlsConnection       *conn, | 
| 114 |                                                                     GTlsCertificate      *certificate); | 
| 115 | GLIB_AVAILABLE_IN_ALL | 
| 116 | GTlsCertificate      *g_tls_connection_get_certificate             (GTlsConnection       *conn); | 
| 117 |  | 
| 118 | GLIB_AVAILABLE_IN_ALL | 
| 119 | void                  g_tls_connection_set_interaction             (GTlsConnection       *conn, | 
| 120 |                                                                     GTlsInteraction      *interaction); | 
| 121 | GLIB_AVAILABLE_IN_ALL | 
| 122 | GTlsInteraction *     g_tls_connection_get_interaction             (GTlsConnection       *conn); | 
| 123 |  | 
| 124 | GLIB_AVAILABLE_IN_ALL | 
| 125 | GTlsCertificate      *g_tls_connection_get_peer_certificate        (GTlsConnection       *conn); | 
| 126 | GLIB_AVAILABLE_IN_ALL | 
| 127 | GTlsCertificateFlags  g_tls_connection_get_peer_certificate_errors (GTlsConnection       *conn); | 
| 128 |  | 
| 129 | GLIB_AVAILABLE_IN_ALL | 
| 130 | void                  g_tls_connection_set_require_close_notify    (GTlsConnection       *conn, | 
| 131 | 								    gboolean              require_close_notify); | 
| 132 | GLIB_AVAILABLE_IN_ALL | 
| 133 | gboolean              g_tls_connection_get_require_close_notify    (GTlsConnection       *conn); | 
| 134 |  | 
| 135 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS | 
| 136 | GLIB_DEPRECATED_IN_2_60 | 
| 137 | void                  g_tls_connection_set_rehandshake_mode        (GTlsConnection       *conn, | 
| 138 | 								    GTlsRehandshakeMode   mode); | 
| 139 | GLIB_DEPRECATED_IN_2_60 | 
| 140 | GTlsRehandshakeMode   g_tls_connection_get_rehandshake_mode        (GTlsConnection       *conn); | 
| 141 | G_GNUC_END_IGNORE_DEPRECATIONS | 
| 142 |  | 
| 143 | GLIB_AVAILABLE_IN_2_60 | 
| 144 | void                  g_tls_connection_set_advertised_protocols    (GTlsConnection       *conn, | 
| 145 |                                                                     const gchar * const  *protocols); | 
| 146 |  | 
| 147 | GLIB_AVAILABLE_IN_2_60 | 
| 148 | const gchar *         g_tls_connection_get_negotiated_protocol     (GTlsConnection       *conn); | 
| 149 |  | 
| 150 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS | 
| 151 | GLIB_AVAILABLE_IN_2_66 | 
| 152 | gboolean              g_tls_connection_get_channel_binding_data    (GTlsConnection          *conn, | 
| 153 |                                                                     GTlsChannelBindingType   type, | 
| 154 |                                                                     GByteArray              *data, | 
| 155 |                                                                     GError                 **error); | 
| 156 | G_GNUC_END_IGNORE_DEPRECATIONS | 
| 157 |  | 
| 158 | GLIB_AVAILABLE_IN_ALL | 
| 159 | gboolean              g_tls_connection_handshake                   (GTlsConnection       *conn, | 
| 160 | 								    GCancellable         *cancellable, | 
| 161 | 								    GError              **error); | 
| 162 |  | 
| 163 | GLIB_AVAILABLE_IN_ALL | 
| 164 | void                  g_tls_connection_handshake_async             (GTlsConnection       *conn, | 
| 165 | 								    int                   io_priority, | 
| 166 | 								    GCancellable         *cancellable, | 
| 167 | 								    GAsyncReadyCallback   callback, | 
| 168 | 								    gpointer              user_data); | 
| 169 | GLIB_AVAILABLE_IN_ALL | 
| 170 | gboolean              g_tls_connection_handshake_finish            (GTlsConnection       *conn, | 
| 171 | 								    GAsyncResult         *result, | 
| 172 | 								    GError              **error); | 
| 173 |  | 
| 174 | GLIB_AVAILABLE_IN_2_70 | 
| 175 | GTlsProtocolVersion   g_tls_connection_get_protocol_version        (GTlsConnection       *conn); | 
| 176 |  | 
| 177 | GLIB_AVAILABLE_IN_2_70 | 
| 178 | gchar *               g_tls_connection_get_ciphersuite_name        (GTlsConnection       *conn); | 
| 179 |  | 
| 180 | /** | 
| 181 |  * G_TLS_ERROR: | 
| 182 |  * | 
| 183 |  * Error domain for TLS. Errors in this domain will be from the | 
| 184 |  * #GTlsError enumeration. See #GError for more information on error | 
| 185 |  * domains. | 
| 186 |  */ | 
| 187 | #define G_TLS_ERROR (g_tls_error_quark ()) | 
| 188 | GLIB_AVAILABLE_IN_ALL | 
| 189 | GQuark g_tls_error_quark (void); | 
| 190 |  | 
| 191 | /** | 
| 192 |  * G_TLS_CHANNEL_BINDING_ERROR: | 
| 193 |  * | 
| 194 |  * Error domain for TLS channel binding. Errors in this domain will be from the | 
| 195 |  * #GTlsChannelBindingError enumeration. See #GError for more information on error | 
| 196 |  * domains. | 
| 197 |  * | 
| 198 |  * Since: 2.66 | 
| 199 |  */ | 
| 200 | #define G_TLS_CHANNEL_BINDING_ERROR (g_tls_channel_binding_error_quark ()) | 
| 201 | GLIB_AVAILABLE_IN_2_66 | 
| 202 | GQuark g_tls_channel_binding_error_quark (void); | 
| 203 |  | 
| 204 | /*< protected >*/ | 
| 205 | GLIB_AVAILABLE_IN_ALL | 
| 206 | gboolean              g_tls_connection_emit_accept_certificate     (GTlsConnection       *conn, | 
| 207 | 								    GTlsCertificate      *peer_cert, | 
| 208 | 								    GTlsCertificateFlags  errors); | 
| 209 |  | 
| 210 | G_END_DECLS | 
| 211 |  | 
| 212 | #endif /* __G_TLS_CONNECTION_H__ */ | 
| 213 |  |