15 #include "tlsgnutlsserveranon.h"
31 gnutls_anon_free_server_credentials( m_anoncred );
32 gnutls_dh_params_deinit( m_dhParams );
45 const int protocolPriority[] = { GNUTLS_TLS1, 0 };
46 const int kxPriority[] = { GNUTLS_KX_ANON_DH, 0 };
47 const int cipherPriority[] = { GNUTLS_CIPHER_AES_256_CBC, GNUTLS_CIPHER_AES_128_CBC,
48 GNUTLS_CIPHER_3DES_CBC, GNUTLS_CIPHER_ARCFOUR, 0 };
49 const int compPriority[] = { GNUTLS_COMP_ZLIB, GNUTLS_COMP_NULL, 0 };
50 const int macPriority[] = { GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0 };
52 if( m_initLib && gnutls_global_init() != 0 )
55 if( gnutls_anon_allocate_server_credentials( &m_anoncred ) < 0 )
59 gnutls_anon_set_server_dh_params( m_anoncred, m_dhParams );
61 if( gnutls_init( m_session, GNUTLS_SERVER ) != 0 )
64 gnutls_protocol_set_priority( *m_session, protocolPriority );
65 gnutls_cipher_set_priority( *m_session, cipherPriority );
66 gnutls_compression_set_priority( *m_session, compPriority );
67 gnutls_kx_set_priority( *m_session, kxPriority );
68 gnutls_mac_set_priority( *m_session, macPriority );
69 gnutls_credentials_set( *m_session, GNUTLS_CRD_ANON, m_anoncred );
71 gnutls_dh_set_prime_bits( *m_session, m_dhBits );
73 gnutls_transport_set_ptr( *m_session, (gnutls_transport_ptr_t)
this );
74 gnutls_transport_set_push_function( *m_session, pushFunc );
75 gnutls_transport_set_pull_function( *m_session, pullFunc );
81 void GnuTLSServerAnon::generateDH()
83 gnutls_dh_params_init( &m_dhParams );
84 gnutls_dh_params_generate2( m_dhParams, m_dhBits );
87 void GnuTLSServerAnon::getCertInfo()
92 info = gnutls_compression_get_name( gnutls_compression_get( *m_session ) );
96 info = gnutls_mac_get_name( gnutls_mac_get( *m_session ) );
98 m_certInfo.
mac = info;
100 info = gnutls_cipher_get_name( gnutls_cipher_get( *m_session ) );
104 info = gnutls_protocol_get_name( gnutls_protocol_get_version( *m_session ) );
113 #endif // HAVE_GNUTLS