15 #include "tlsgnutlsserveranon.h"
31 gnutls_anon_free_server_credentials( m_anoncred );
32 gnutls_dh_params_deinit( m_dhParams );
45 if( m_initLib && gnutls_global_init() != 0 )
48 if( gnutls_anon_allocate_server_credentials( &m_anoncred ) < 0 )
52 gnutls_anon_set_server_dh_params( m_anoncred, m_dhParams );
54 if( gnutls_init( m_session, GNUTLS_SERVER ) != 0 )
57 #if GNUTLS_VERSION_NUMBER >= 0x020600
58 int ret = gnutls_priority_set_direct( *m_session,
"SECURE128:+PFS:+COMP-ALL:+VERS-TLS-ALL:-VERS-SSL3.0:+SIGN-ALL:+CURVE-ALL:+ANON-ECDH:+ANON-DH", 0 );
59 if( ret != GNUTLS_E_SUCCESS )
62 const int protocolPriority[] = {
66 GNUTLS_TLS1_1, GNUTLS_TLS1, 0 };
67 const int kxPriority[] = { GNUTLS_KX_ANON_DH, 0 };
68 const int cipherPriority[] = { GNUTLS_CIPHER_AES_256_CBC, GNUTLS_CIPHER_AES_128_CBC,
69 GNUTLS_CIPHER_3DES_CBC, GNUTLS_CIPHER_ARCFOUR, 0 };
70 const int compPriority[] = { GNUTLS_COMP_ZLIB, GNUTLS_COMP_NULL, 0 };
71 const int macPriority[] = { GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0 };
72 gnutls_protocol_set_priority( *m_session, protocolPriority );
73 gnutls_cipher_set_priority( *m_session, cipherPriority );
74 gnutls_compression_set_priority( *m_session, compPriority );
75 gnutls_kx_set_priority( *m_session, kxPriority );
76 gnutls_mac_set_priority( *m_session, macPriority );
79 gnutls_credentials_set( *m_session, GNUTLS_CRD_ANON, m_anoncred );
81 gnutls_dh_set_prime_bits( *m_session, m_dhBits );
83 gnutls_transport_set_ptr( *m_session,
static_cast<gnutls_transport_ptr_t
>(
this ) );
84 gnutls_transport_set_push_function( *m_session, pushFunc );
85 gnutls_transport_set_pull_function( *m_session, pullFunc );
91 void GnuTLSServerAnon::generateDH()
93 gnutls_dh_params_init( &m_dhParams );
94 gnutls_dh_params_generate2( m_dhParams, m_dhBits );
97 void GnuTLSServerAnon::getCertInfo()
This is the common base class for (stream) encryption using GnuTLS.
virtual ~GnuTLSServerAnon()
GnuTLSServerAnon(TLSHandler *th)
virtual bool init(const std::string &clientKey=EmptyString, const std::string &clientCerts=EmptyString, const StringList &cacerts=StringList())
An interface that allows for interacting with TLS implementations derived from TLSBase.
The namespace for the gloox library.
std::list< std::string > StringList