/[anubis]/anubis/src/tls.c
ViewVC logotype

Diff of /anubis/src/tls.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by gray, Sat May 10 17:10:14 2003 UTC revision 1.6 by gray, Tue May 27 19:51:50 2003 UTC
# Line 38  static int cipher_info(gnutls_session); Line 38  static int cipher_info(gnutls_session);
38    
39  #define DH_BITS 768  #define DH_BITS 768
40  gnutls_dh_params dh_params;  gnutls_dh_params dh_params;
41    
42  /* FIXME: should they belong to struct secure_struct? */  /* FIXME: should they belong to struct secure_struct? */
43  static gnutls_certificate_client_credentials xcred;  static gnutls_certificate_client_credentials xcred;
44  static gnutls_certificate_server_credentials x509_cred;  static gnutls_certificate_server_credentials x509_cred;
# Line 78  _tls_read(void *sd, char *data, size_t s Line 79  _tls_read(void *sd, char *data, size_t s
79          if (rc >= 0) {          if (rc >= 0) {
80                  *nbytes = rc;                  *nbytes = rc;
81                  return 0;                  return 0;
82          }          }
83          return rc;          return rc;
84  }  }
85    
# Line 106  _tls_cleanup_x509() Line 107  _tls_cleanup_x509()
107                  gnutls_certificate_free_credentials(x509_cred);                  gnutls_certificate_free_credentials(x509_cred);
108  }  }
109    
110    static ssize_t
111    _tls_fd_pull(gnutls_transport_ptr fd, void *buf, size_t size)
112    {
113            int rc;
114            do {
115                    rc = read(fd, buf, size);
116            } while (rc == -1 && errno == EAGAIN);
117            return rc;
118    }
119    
120    static ssize_t
121    _tls_fd_push(gnutls_transport_ptr fd, const void *buf, size_t size)
122    {
123            int rc;
124            do {
125                    rc = write(fd, buf, size);
126            } while (rc == -1 && errno == EAGAIN);
127            return rc;
128    }
129    
130  void  void
131  init_ssl_libs(void)  init_ssl_libs(void)
132  {  {
# Line 121  start_ssl_client(int sd_server) Line 142  start_ssl_client(int sd_server)
142          gnutls_session session = 0;          gnutls_session session = 0;
143          const int protocol_priority[] = {GNUTLS_TLS1, GNUTLS_SSL3, 0};          const int protocol_priority[] = {GNUTLS_TLS1, GNUTLS_SSL3, 0};
144          const int kx_priority[] = {GNUTLS_KX_RSA, 0};          const int kx_priority[] = {GNUTLS_KX_RSA, 0};
145          const int cipher_priority[] = {GNUTLS_CIPHER_3DES_CBC, GNUTLS_CIPHER_ARCFOUR_128, 0};          const int cipher_priority[] = {GNUTLS_CIPHER_3DES_CBC,
146                                           GNUTLS_CIPHER_ARCFOUR_128,
147                                           0};
148          const int comp_priority[] = {GNUTLS_COMP_NULL, 0};          const int comp_priority[] = {GNUTLS_COMP_NULL, 0};
149          const int mac_priority[] = {GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0};          const int mac_priority[] = {GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0};
150    
# Line 149  start_ssl_client(int sd_server) Line 172  start_ssl_client(int sd_server)
172                    
173          gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred);          gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred);
174          atexit(_tls_cleanup_xcred);          atexit(_tls_cleanup_xcred);
175    
176            if (topt & T_LOCAL_MTA) {
177                    gnutls_transport_set_pull_function(session, _tls_fd_pull);
178                    gnutls_transport_set_push_function(session, _tls_fd_push);
179            }
180          gnutls_transport_set_ptr(session, sd_server);          gnutls_transport_set_ptr(session, sd_server);
181    
182          rs = gnutls_handshake(session);          rs = gnutls_handshake(session);
# Line 230  start_ssl_server(int sd_client) Line 258  start_ssl_server(int sd_client)
258    
259          session = initialize_tls_session();          session = initialize_tls_session();
260    
261            if (topt & T_STDINOUT) {
262                    gnutls_transport_set_pull_function(session, _tls_fd_pull);
263                    gnutls_transport_set_push_function(session, _tls_fd_push);
264            }
265          gnutls_transport_set_ptr(session, sd_client);          gnutls_transport_set_ptr(session, sd_client);
266          rs = gnutls_handshake(session);          rs = gnutls_handshake(session);
267          if (rs < 0) {          if (rs < 0) {

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26