Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:00:00

0001 /* GIO - GLib Input, Output and Streaming Library
0002  *
0003  * Copyright (C) 2010 Red Hat, Inc.
0004  *
0005  * SPDX-License-Identifier: LGPL-2.1-or-later
0006  *
0007  * This library is free software; you can redistribute it and/or
0008  * modify it under the terms of the GNU Lesser General Public
0009  * License as published by the Free Software Foundation; either
0010  * version 2.1 of the License, or (at your option) any later version.
0011  *
0012  * This library is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015  * Lesser General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Lesser General
0018  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
0019  */
0020 
0021 #ifndef __G_TLS_CONNECTION_H__
0022 #define __G_TLS_CONNECTION_H__
0023 
0024 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
0025 #error "Only <gio/gio.h> can be included directly."
0026 #endif
0027 
0028 #include <gio/giostream.h>
0029 
0030 G_BEGIN_DECLS
0031 
0032 #define G_TYPE_TLS_CONNECTION            (g_tls_connection_get_type ())
0033 #define G_TLS_CONNECTION(inst)           (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_CONNECTION, GTlsConnection))
0034 #define G_TLS_CONNECTION_CLASS(class)    (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TLS_CONNECTION, GTlsConnectionClass))
0035 #define G_IS_TLS_CONNECTION(inst)        (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_CONNECTION))
0036 #define G_IS_TLS_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TLS_CONNECTION))
0037 #define G_TLS_CONNECTION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), G_TYPE_TLS_CONNECTION, GTlsConnectionClass))
0038 
0039 typedef struct _GTlsConnectionClass   GTlsConnectionClass;
0040 typedef struct _GTlsConnectionPrivate GTlsConnectionPrivate;
0041 
0042 struct _GTlsConnection {
0043   GIOStream parent_instance;
0044 
0045   GTlsConnectionPrivate *priv;
0046 };
0047 
0048 /**
0049  * GTlsConnectionClass:
0050  * @parent_class: The parent class.
0051  * @accept_certificate: Check whether to accept a certificate.
0052  * @handshake: Perform a handshake operation.
0053  * @handshake_async: Start an asynchronous handshake operation.
0054  * @handshake_finish: Finish an asynchronous handshake operation.
0055  * @get_binding_data: Retrieve TLS channel binding data (Since: 2.66)
0056  * @get_negotiated_protocol: Get ALPN-negotiated protocol (Since: 2.70)
0057  *
0058  * The class structure for the #GTlsConnection type.
0059  *
0060  * Since: 2.28
0061  */
0062 struct _GTlsConnectionClass
0063 {
0064   GIOStreamClass parent_class;
0065 
0066   /* signals */
0067   gboolean          ( *accept_certificate) (GTlsConnection       *connection,
0068                         GTlsCertificate      *peer_cert,
0069                         GTlsCertificateFlags  errors);
0070 
0071   /* methods */
0072   gboolean ( *handshake )        (GTlsConnection       *conn,
0073                   GCancellable         *cancellable,
0074                   GError              **error);
0075 
0076   void     ( *handshake_async )  (GTlsConnection       *conn,
0077                   int                   io_priority,
0078                   GCancellable         *cancellable,
0079                   GAsyncReadyCallback   callback,
0080                   gpointer              user_data);
0081   gboolean ( *handshake_finish ) (GTlsConnection       *conn,
0082                   GAsyncResult         *result,
0083                   GError              **error);
0084 
0085 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
0086   gboolean ( *get_binding_data)  (GTlsConnection          *conn,
0087                                   GTlsChannelBindingType   type,
0088                                   GByteArray              *data,
0089                                   GError                 **error);
0090 G_GNUC_END_IGNORE_DEPRECATIONS
0091 
0092   const gchar *(*get_negotiated_protocol) (GTlsConnection *conn);
0093 
0094   /*< private >*/
0095   /* Padding for future expansion */
0096   gpointer padding[6];
0097 };
0098 
0099 GIO_AVAILABLE_IN_ALL
0100 GType                 g_tls_connection_get_type                    (void) G_GNUC_CONST;
0101 
0102 GIO_DEPRECATED
0103 void                  g_tls_connection_set_use_system_certdb       (GTlsConnection       *conn,
0104                                                                     gboolean              use_system_certdb);
0105 GIO_DEPRECATED
0106 gboolean              g_tls_connection_get_use_system_certdb       (GTlsConnection       *conn);
0107 
0108 GIO_AVAILABLE_IN_ALL
0109 void                  g_tls_connection_set_database                (GTlsConnection       *conn,
0110                                     GTlsDatabase         *database);
0111 GIO_AVAILABLE_IN_ALL
0112 GTlsDatabase *        g_tls_connection_get_database                (GTlsConnection       *conn);
0113 
0114 GIO_AVAILABLE_IN_ALL
0115 void                  g_tls_connection_set_certificate             (GTlsConnection       *conn,
0116                                                                     GTlsCertificate      *certificate);
0117 GIO_AVAILABLE_IN_ALL
0118 GTlsCertificate      *g_tls_connection_get_certificate             (GTlsConnection       *conn);
0119 
0120 GIO_AVAILABLE_IN_ALL
0121 void                  g_tls_connection_set_interaction             (GTlsConnection       *conn,
0122                                                                     GTlsInteraction      *interaction);
0123 GIO_AVAILABLE_IN_ALL
0124 GTlsInteraction *     g_tls_connection_get_interaction             (GTlsConnection       *conn);
0125 
0126 GIO_AVAILABLE_IN_ALL
0127 GTlsCertificate      *g_tls_connection_get_peer_certificate        (GTlsConnection       *conn);
0128 GIO_AVAILABLE_IN_ALL
0129 GTlsCertificateFlags  g_tls_connection_get_peer_certificate_errors (GTlsConnection       *conn);
0130 
0131 GIO_AVAILABLE_IN_ALL
0132 void                  g_tls_connection_set_require_close_notify    (GTlsConnection       *conn,
0133                                     gboolean              require_close_notify);
0134 GIO_AVAILABLE_IN_ALL
0135 gboolean              g_tls_connection_get_require_close_notify    (GTlsConnection       *conn);
0136 
0137 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
0138 GIO_DEPRECATED_IN_2_60
0139 void                  g_tls_connection_set_rehandshake_mode        (GTlsConnection       *conn,
0140                                     GTlsRehandshakeMode   mode);
0141 GIO_DEPRECATED_IN_2_60
0142 GTlsRehandshakeMode   g_tls_connection_get_rehandshake_mode        (GTlsConnection       *conn);
0143 G_GNUC_END_IGNORE_DEPRECATIONS
0144 
0145 GIO_AVAILABLE_IN_2_60
0146 void                  g_tls_connection_set_advertised_protocols    (GTlsConnection       *conn,
0147                                                                     const gchar * const  *protocols);
0148 
0149 GIO_AVAILABLE_IN_2_60
0150 const gchar *         g_tls_connection_get_negotiated_protocol     (GTlsConnection       *conn);
0151 
0152 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
0153 GIO_AVAILABLE_IN_2_66
0154 gboolean              g_tls_connection_get_channel_binding_data    (GTlsConnection          *conn,
0155                                                                     GTlsChannelBindingType   type,
0156                                                                     GByteArray              *data,
0157                                                                     GError                 **error);
0158 G_GNUC_END_IGNORE_DEPRECATIONS
0159 
0160 GIO_AVAILABLE_IN_ALL
0161 gboolean              g_tls_connection_handshake                   (GTlsConnection       *conn,
0162                                     GCancellable         *cancellable,
0163                                     GError              **error);
0164 
0165 GIO_AVAILABLE_IN_ALL
0166 void                  g_tls_connection_handshake_async             (GTlsConnection       *conn,
0167                                     int                   io_priority,
0168                                     GCancellable         *cancellable,
0169                                     GAsyncReadyCallback   callback,
0170                                     gpointer              user_data);
0171 GIO_AVAILABLE_IN_ALL
0172 gboolean              g_tls_connection_handshake_finish            (GTlsConnection       *conn,
0173                                     GAsyncResult         *result,
0174                                     GError              **error);
0175 
0176 GIO_AVAILABLE_IN_2_70
0177 GTlsProtocolVersion   g_tls_connection_get_protocol_version        (GTlsConnection       *conn);
0178 
0179 GIO_AVAILABLE_IN_2_70
0180 gchar *               g_tls_connection_get_ciphersuite_name        (GTlsConnection       *conn);
0181 
0182 /**
0183  * G_TLS_ERROR:
0184  *
0185  * Error domain for TLS. Errors in this domain will be from the
0186  * #GTlsError enumeration. See #GError for more information on error
0187  * domains.
0188  */
0189 #define G_TLS_ERROR (g_tls_error_quark ())
0190 GIO_AVAILABLE_IN_ALL
0191 GQuark g_tls_error_quark (void);
0192 
0193 /**
0194  * G_TLS_CHANNEL_BINDING_ERROR:
0195  *
0196  * Error domain for TLS channel binding. Errors in this domain will be from the
0197  * #GTlsChannelBindingError enumeration. See #GError for more information on error
0198  * domains.
0199  *
0200  * Since: 2.66
0201  */
0202 #define G_TLS_CHANNEL_BINDING_ERROR (g_tls_channel_binding_error_quark ())
0203 GIO_AVAILABLE_IN_2_66
0204 GQuark g_tls_channel_binding_error_quark (void);
0205 
0206 /*< protected >*/
0207 GIO_AVAILABLE_IN_ALL
0208 gboolean              g_tls_connection_emit_accept_certificate     (GTlsConnection       *conn,
0209                                     GTlsCertificate      *peer_cert,
0210                                     GTlsCertificateFlags  errors);
0211 
0212 G_END_DECLS
0213 
0214 #endif /* __G_TLS_CONNECTION_H__ */