X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fssli_gnutls.c;h=dfe2f2eeb47628fde849950c9d1608ce54b2a0c0;hb=5be6e1c86491889ca6967c85147cd537bfe65945;hp=ab32d1e0da20fd77d1e3364eb7565c0f2a6d6084;hpb=8e8ff9af85dcf79469150009a96e1f8583ccc538;p=umurmur.git diff --git a/src/ssli_gnutls.c b/src/ssli_gnutls.c index ab32d1e..dfe2f2e 100644 --- a/src/ssli_gnutls.c +++ b/src/ssli_gnutls.c @@ -2,10 +2,12 @@ #include "conf.h" #include "log.h" +#include + static gnutls_dh_params_t dhParameters; static gnutls_certificate_credentials_t certificate; -static const char * ciphers = "SECURE128:-VERS-DTLS-ALL:-VERS-SSL3.0:-VERS-TLS1.0:+COMP_ALL"; +static const char * ciphers = "NORMAL"; static gnutls_priority_t cipherCache; void initializeCertificate() @@ -60,7 +62,7 @@ void SSLi_deinit() SSL_handle_t * SSLi_newconnection( int * fileDescriptor, bool_t * isSSLReady ) { - gnutls_session_t * session; // Maybe we need to calloc here + gnutls_session_t * session = calloc(1, sizeof(gnutls_session_t)); gnutls_init(session, GNUTLS_SERVER); gnutls_priority_set(*session, cipherCache); @@ -70,15 +72,61 @@ SSL_handle_t * SSLi_newconnection( int * fileDescriptor, bool_t * isSSLReady ) gnutls_transport_set_int(*session, *fileDescriptor); + if(isSSLReady && SSLi_nonblockaccept(session, isSSLReady)) + *isSSLReady = true; + + return session; + } + +bool_t SSLi_getSHA1Hash(SSL_handle_t *ssl, uint8_t *hash) + { + *hash = 0; + return true; + } + +int SSLi_nonblockaccept( SSL_handle_t *session, bool_t * isSSLReady ) + { int error; do { - gnutls_handshake(*session); + error = gnutls_handshake(*session); } while(error < GNUTLS_E_SUCCESS && !gnutls_error_is_fatal(error)); if ( error < GNUTLS_E_SUCCESS ) { - Log_fatal("TLS handshake failed with error %i (%s).", error, gnutls_strerror(error)); + Log_warn("TLS handshake failed with error %i (%s).", error, gnutls_strerror(error)); } - return session; + if(isSSLReady) + *isSSLReady = true; + + return error; + } + +int SSLi_read(SSL_handle_t *session, uint8_t *buffer, int length) + { + return gnutls_record_recv(*session, buffer, length); } +int SSLi_write(SSL_handle_t *session, uint8_t *buffer, int length) + { + return gnutls_record_send(*session, buffer, length); + } + +int SSLi_get_error(SSL_handle_t *session, int code) + { + return code; + } + +bool_t SSLi_data_pending(SSL_handle_t *session) + { + return gnutls_record_check_pending(*session); + } + +void SSLi_shutdown(SSL_handle_t *session) + { + gnutls_bye(*session, GNUTLS_SHUT_WR); + } + +void SSLi_free(SSL_handle_t *session) + { + gnutls_deinit(*session); + }