1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 #include <gnutls/gnutls.h>
17 #include <gnutls/x509.h>
19 #include "inspircd_config.h"
20 #include "configreader.h"
26 #include "transport.h"
29 #pragma comment(lib, "libgnutls-13.lib")
30 #undef MAX_DESCRIPTORS
31 #define MAX_DESCRIPTORS 10000
34 /* $ModDesc: Provides SSL support for clients */
35 /* $CompileFlags: exec("libgnutls-config --cflags") */
36 /* $LinkerFlags: rpath("libgnutls-config --libs") exec("libgnutls-config --libs") */
37 /* $ModDep: transport.h */
38 /* $CopyInstall: conf/key.pem $(CONPATH) */
39 /* $CopyInstall: conf/cert.pem $(CONPATH) */
41 enum issl_status { ISSL_NONE, ISSL_HANDSHAKING_READ, ISSL_HANDSHAKING_WRITE, ISSL_HANDSHAKEN, ISSL_CLOSING, ISSL_CLOSED };
43 bool isin(int port, const std::vector<int> &portlist)
45 for(unsigned int i = 0; i < portlist.size(); i++)
46 if(portlist[i] == port)
52 /** Represents an SSL user's extra data
54 class issl_session : public classbase
57 gnutls_session_t sess;
65 class ModuleSSLGnuTLS : public Module
72 std::vector<int> listenports;
75 issl_session sessions[MAX_DESCRIPTORS];
77 gnutls_certificate_credentials x509_cred;
78 gnutls_dh_params dh_params;
91 ModuleSSLGnuTLS(InspIRCd* Me)
94 ServerInstance->Modules->PublishInterface("BufferedSocketHook", this);
96 // Not rehashable...because I cba to reduce all the sizes of existing buffers.
97 inbufsize = ServerInstance->Config->NetBufferSize;
99 gnutls_global_init(); // This must be called once in the program
101 if(gnutls_certificate_allocate_credentials(&x509_cred) != 0)
102 ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: Failed to allocate certificate credentials");
104 // Guessing return meaning
105 if(gnutls_dh_params_init(&dh_params) < 0)
106 ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: Failed to initialise DH parameters");
108 // Needs the flag as it ignores a plain /rehash
109 OnRehash(NULL,"ssl");
111 // Void return, guess we assume success
112 gnutls_certificate_set_dh_params(x509_cred, dh_params);
115 virtual void OnRehash(User* user, const std::string ¶m)
120 Conf = new ConfigReader(ServerInstance);
122 for(unsigned int i = 0; i < listenports.size(); i++)
124 ServerInstance->Config->DelIOHook(listenports[i]);
131 for(int i = 0; i < Conf->Enumerate("bind"); i++)
133 // For each <bind> tag
134 std::string x = Conf->ReadValue("bind", "type", i);
135 if(((x.empty()) || (x == "clients")) && (Conf->ReadValue("bind", "ssl", i) == "gnutls"))
137 // Get the port we're meant to be listening on with SSL
138 std::string port = Conf->ReadValue("bind", "port", i);
139 irc::portparser portrange(port, false);
141 while ((portno = portrange.GetToken()))
146 if (ServerInstance->Config->AddIOHook(portno, this))
148 listenports.push_back(portno);
149 for (size_t i = 0; i < ServerInstance->Config->ports.size(); i++)
150 if (ServerInstance->Config->ports[i]->GetPort() == portno)
151 ServerInstance->Config->ports[i]->SetDescription("ssl");
152 ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: Enabling SSL for port %d", portno);
153 sslports.append("*:").append(ConvToStr(portno)).append(";");
157 ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: FAILED to enable SSL on port %d, maybe you have another ssl or similar module loaded?", portno);
160 catch (ModuleException &e)
162 ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: FAILED to enable SSL on port %d: %s. Maybe it's already hooked by the same port on a different IP, or you have an other SSL or similar module loaded?", portno, e.GetReason());
168 std::string confdir(ServerInstance->ConfigFileName);
169 // +1 so we the path ends with a /
170 confdir = confdir.substr(0, confdir.find_last_of('/') + 1);
172 cafile = Conf->ReadValue("gnutls", "cafile", 0);
173 crlfile = Conf->ReadValue("gnutls", "crlfile", 0);
174 certfile = Conf->ReadValue("gnutls", "certfile", 0);
175 keyfile = Conf->ReadValue("gnutls", "keyfile", 0);
176 dh_bits = Conf->ReadInteger("gnutls", "dhbits", 0, false);
178 // Set all the default values needed.
185 if (certfile.empty())
186 certfile = "cert.pem";
191 if((dh_bits != 768) && (dh_bits != 1024) && (dh_bits != 2048) && (dh_bits != 3072) && (dh_bits != 4096))
194 // Prepend relative paths with the path to the config directory.
196 cafile = confdir + cafile;
198 if(crlfile[0] != '/')
199 crlfile = confdir + crlfile;
201 if(certfile[0] != '/')
202 certfile = confdir + certfile;
204 if(keyfile[0] != '/')
205 keyfile = confdir + keyfile;
209 if((ret =gnutls_certificate_set_x509_trust_file(x509_cred, cafile.c_str(), GNUTLS_X509_FMT_PEM)) < 0)
210 ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: Failed to set X.509 trust file '%s': %s", cafile.c_str(), gnutls_strerror(ret));
212 if((ret = gnutls_certificate_set_x509_crl_file (x509_cred, crlfile.c_str(), GNUTLS_X509_FMT_PEM)) < 0)
213 ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: Failed to set X.509 CRL file '%s': %s", crlfile.c_str(), gnutls_strerror(ret));
215 if((ret = gnutls_certificate_set_x509_key_file (x509_cred, certfile.c_str(), keyfile.c_str(), GNUTLS_X509_FMT_PEM)) < 0)
217 // If this fails, no SSL port will work. At all. So, do the smart thing - throw a ModuleException
218 throw ModuleException("Unable to load GnuTLS server certificate: " + std::string(gnutls_strerror(ret)));
221 // This may be on a large (once a day or week) timer eventually.
227 void GenerateDHParams()
229 // Generate Diffie Hellman parameters - for use with DHE
230 // kx algorithms. These should be discarded and regenerated
231 // once a day, once a week or once a month. Depending on the
232 // security requirements.
236 if((ret = gnutls_dh_params_generate2(dh_params, dh_bits)) < 0)
237 ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: Failed to generate DH parameters (%d bits): %s", dh_bits, gnutls_strerror(ret));
240 virtual ~ModuleSSLGnuTLS()
242 gnutls_dh_params_deinit(dh_params);
243 gnutls_certificate_free_credentials(x509_cred);
244 gnutls_global_deinit();
247 virtual void OnCleanup(int target_type, void* item)
249 if(target_type == TYPE_USER)
251 User* user = (User*)item;
253 if(user->GetExt("ssl", dummy) && isin(user->GetPort(), listenports))
255 // User is using SSL, they're a local user, and they're using one of *our* SSL ports.
256 // Potentially there could be multiple SSL modules loaded at once on different ports.
257 User::QuitUser(ServerInstance, user, "SSL module unloading");
259 if (user->GetExt("ssl_cert", dummy) && isin(user->GetPort(), listenports))
262 user->GetExt("ssl_cert", tofree);
264 user->Shrink("ssl_cert");
269 virtual void OnUnloadModule(Module* mod, const std::string &name)
273 for(unsigned int i = 0; i < listenports.size(); i++)
275 ServerInstance->Config->DelIOHook(listenports[i]);
276 for (size_t j = 0; j < ServerInstance->Config->ports.size(); j++)
277 if (ServerInstance->Config->ports[j]->GetPort() == listenports[i])
278 ServerInstance->Config->ports[j]->SetDescription("plaintext");
283 virtual Version GetVersion()
285 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
288 void Implements(char* List)
290 List[I_On005Numeric] = List[I_OnRawSocketConnect] = List[I_OnRawSocketAccept] = List[I_OnRawSocketClose] = List[I_OnRawSocketRead] = List[I_OnRawSocketWrite] = List[I_OnCleanup] = 1;
291 List[I_OnBufferFlushed] = List[I_OnRequest] = List[I_OnSyncUserMetaData] = List[I_OnDecodeMetaData] = List[I_OnUnloadModule] = List[I_OnRehash] = List[I_OnWhois] = List[I_OnPostConnect] = 1;
294 virtual void On005Numeric(std::string &output)
296 output.append(" SSL=" + sslports);
299 virtual char* OnRequest(Request* request)
301 ISHRequest* ISR = (ISHRequest*)request;
302 if (strcmp("IS_NAME", request->GetId()) == 0)
306 else if (strcmp("IS_HOOK", request->GetId()) == 0)
311 ret = ServerInstance->Config->AddIOHook((Module*)this, (BufferedSocket*)ISR->Sock) ? (char*)"OK" : NULL;
313 catch (ModuleException &e)
319 else if (strcmp("IS_UNHOOK", request->GetId()) == 0)
321 return ServerInstance->Config->DelIOHook((BufferedSocket*)ISR->Sock) ? (char*)"OK" : NULL;
323 else if (strcmp("IS_HSDONE", request->GetId()) == 0)
325 if (ISR->Sock->GetFd() < 0)
328 issl_session* session = &sessions[ISR->Sock->GetFd()];
329 return (session->status == ISSL_HANDSHAKING_READ || session->status == ISSL_HANDSHAKING_WRITE) ? NULL : (char*)"OK";
331 else if (strcmp("IS_ATTACH", request->GetId()) == 0)
333 if (ISR->Sock->GetFd() > -1)
335 issl_session* session = &sessions[ISR->Sock->GetFd()];
338 if ((Extensible*)ServerInstance->FindDescriptor(ISR->Sock->GetFd()) == (Extensible*)(ISR->Sock))
340 VerifyCertificate(session, (BufferedSocket*)ISR->Sock);
350 virtual void OnRawSocketAccept(int fd, const std::string &ip, int localport)
352 /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
353 if ((fd < 0) || (fd > MAX_DESCRIPTORS))
356 issl_session* session = &sessions[fd];
359 session->inbuf = new char[inbufsize];
360 session->inbufoffset = 0;
362 gnutls_init(&session->sess, GNUTLS_SERVER);
364 gnutls_set_default_priority(session->sess); // Avoid calling all the priority functions, defaults are adequate.
365 gnutls_credentials_set(session->sess, GNUTLS_CRD_CERTIFICATE, x509_cred);
366 gnutls_dh_set_prime_bits(session->sess, dh_bits);
368 /* This is an experimental change to avoid a warning on 64bit systems about casting between integer and pointer of different sizes
369 * This needs testing, but it's easy enough to rollback if need be
370 * Old: gnutls_transport_set_ptr(session->sess, (gnutls_transport_ptr_t) fd); // Give gnutls the fd for the socket.
371 * New: gnutls_transport_set_ptr(session->sess, &fd); // Give gnutls the fd for the socket.
373 * With testing this seems to...not work :/
376 gnutls_transport_set_ptr(session->sess, (gnutls_transport_ptr_t) fd); // Give gnutls the fd for the socket.
378 gnutls_certificate_server_set_request(session->sess, GNUTLS_CERT_REQUEST); // Request client certificate if any.
383 virtual void OnRawSocketConnect(int fd)
385 /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
386 if ((fd < 0) || (fd > MAX_DESCRIPTORS))
389 issl_session* session = &sessions[fd];
392 session->inbuf = new char[inbufsize];
393 session->inbufoffset = 0;
395 gnutls_init(&session->sess, GNUTLS_CLIENT);
397 gnutls_set_default_priority(session->sess); // Avoid calling all the priority functions, defaults are adequate.
398 gnutls_credentials_set(session->sess, GNUTLS_CRD_CERTIFICATE, x509_cred);
399 gnutls_dh_set_prime_bits(session->sess, dh_bits);
400 gnutls_transport_set_ptr(session->sess, (gnutls_transport_ptr_t) fd); // Give gnutls the fd for the socket.
405 virtual void OnRawSocketClose(int fd)
407 /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
408 if ((fd < 0) || (fd > MAX_DESCRIPTORS))
411 CloseSession(&sessions[fd]);
413 EventHandler* user = ServerInstance->SE->GetRef(fd);
415 if ((user) && (user->GetExt("ssl_cert", dummy)))
418 user->GetExt("ssl_cert", tofree);
420 user->Shrink("ssl_cert");
424 virtual int OnRawSocketRead(int fd, char* buffer, unsigned int count, int &readresult)
426 /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
427 if ((fd < 0) || (fd > MAX_DESCRIPTORS))
430 issl_session* session = &sessions[fd];
435 CloseSession(session);
439 if (session->status == ISSL_HANDSHAKING_READ)
441 // The handshake isn't finished, try to finish it.
443 if(!Handshake(session))
445 // Couldn't resume handshake.
449 else if (session->status == ISSL_HANDSHAKING_WRITE)
452 MakePollWrite(session);
456 // If we resumed the handshake then session->status will be ISSL_HANDSHAKEN.
458 if (session->status == ISSL_HANDSHAKEN)
460 // Is this right? Not sure if the unencrypted data is garaunteed to be the same length.
461 // Read into the inbuffer, offset from the beginning by the amount of data we have that insp hasn't taken yet.
462 int ret = gnutls_record_recv(session->sess, session->inbuf + session->inbufoffset, inbufsize - session->inbufoffset);
466 // Client closed connection.
468 CloseSession(session);
473 if (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED)
481 CloseSession(session);
486 // Read successfully 'ret' bytes into inbuf + inbufoffset
487 // There are 'ret' + 'inbufoffset' bytes of data in 'inbuf'
488 // 'buffer' is 'count' long
490 unsigned int length = ret + session->inbufoffset;
494 memcpy(buffer, session->inbuf, count);
495 // Move the stuff left in inbuf to the beginning of it
496 memcpy(session->inbuf, session->inbuf + count, (length - count));
497 // Now we need to set session->inbufoffset to the amount of data still waiting to be handed to insp.
498 session->inbufoffset = length - count;
499 // Insp uses readresult as the count of how much data there is in buffer, so:
504 // There's not as much in the inbuf as there is space in the buffer, so just copy the whole thing.
505 memcpy(buffer, session->inbuf, length);
506 // Zero the offset, as there's nothing there..
507 session->inbufoffset = 0;
513 else if(session->status == ISSL_CLOSING)
519 virtual int OnRawSocketWrite(int fd, const char* buffer, int count)
521 /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
522 if ((fd < 0) || (fd > MAX_DESCRIPTORS))
525 issl_session* session = &sessions[fd];
526 const char* sendbuffer = buffer;
530 CloseSession(session);
534 session->outbuf.append(sendbuffer, count);
535 sendbuffer = session->outbuf.c_str();
536 count = session->outbuf.size();
538 if (session->status == ISSL_HANDSHAKING_WRITE)
540 // The handshake isn't finished, try to finish it.
548 if (session->status == ISSL_HANDSHAKEN)
550 ret = gnutls_record_send(session->sess, sendbuffer, count);
554 CloseSession(session);
558 if(ret != GNUTLS_E_AGAIN && ret != GNUTLS_E_INTERRUPTED)
560 CloseSession(session);
569 session->outbuf = session->outbuf.substr(ret);
573 MakePollWrite(session);
575 /* Who's smart idea was it to return 1 when we havent written anything?
576 * This fucks the buffer up in BufferedSocket :p
578 return ret < 1 ? 0 : ret;
581 // :kenny.chatspike.net 320 Om Epy|AFK :is a Secure Connection
582 virtual void OnWhois(User* source, User* dest)
587 // Bugfix, only send this numeric for *our* SSL users
588 if(dest->GetExt("ssl", dummy) || (IS_LOCAL(dest) && isin(dest->GetPort(), listenports)))
590 ServerInstance->SendWhoisLine(source, dest, 320, "%s %s :is using a secure connection", source->nick, dest->nick);
594 virtual void OnSyncUserMetaData(User* user, Module* proto, void* opaque, const std::string &extname, bool displayable)
596 // check if the linking module wants to know about OUR metadata
599 // check if this user has an swhois field to send
600 if(user->GetExt(extname, dummy))
602 // call this function in the linking module, let it format the data how it
603 // sees fit, and send it on its way. We dont need or want to know how.
604 proto->ProtoSendMetaData(opaque, TYPE_USER, user, extname, displayable ? "Enabled" : "ON");
609 virtual void OnDecodeMetaData(int target_type, void* target, const std::string &extname, const std::string &extdata)
611 // check if its our metadata key, and its associated with a user
612 if ((target_type == TYPE_USER) && (extname == "ssl"))
614 User* dest = (User*)target;
615 // if they dont already have an ssl flag, accept the remote server's
616 if (!dest->GetExt(extname, dummy))
618 dest->Extend(extname, "ON");
623 bool Handshake(issl_session* session)
625 int ret = gnutls_handshake(session->sess);
629 if(ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED)
631 // Handshake needs resuming later, read() or write() would have blocked.
633 if(gnutls_record_get_direction(session->sess) == 0)
635 // gnutls_handshake() wants to read() again.
636 session->status = ISSL_HANDSHAKING_READ;
640 // gnutls_handshake() wants to write() again.
641 session->status = ISSL_HANDSHAKING_WRITE;
642 MakePollWrite(session);
648 CloseSession(session);
649 session->status = ISSL_CLOSING;
656 // Handshake complete.
657 // This will do for setting the ssl flag...it could be done earlier if it's needed. But this seems neater.
658 User* extendme = ServerInstance->FindDescriptor(session->fd);
661 if (!extendme->GetExt("ssl", dummy))
662 extendme->Extend("ssl", "ON");
665 // Change the seesion state
666 session->status = ISSL_HANDSHAKEN;
668 // Finish writing, if any left
669 MakePollWrite(session);
675 virtual void OnPostConnect(User* user)
677 // This occurs AFTER OnUserConnect so we can be sure the
678 // protocol module has propagated the NICK message.
679 if ((user->GetExt("ssl", dummy)) && (IS_LOCAL(user)))
681 // Tell whatever protocol module we're using that we need to inform other servers of this metadata NOW.
682 std::deque<std::string>* metadata = new std::deque<std::string>;
683 metadata->push_back(user->nick);
684 metadata->push_back("ssl"); // The metadata id
685 metadata->push_back("ON"); // The value to send
686 Event* event = new Event((char*)metadata,(Module*)this,"send_metadata");
687 event->Send(ServerInstance); // Trigger the event. We don't care what module picks it up.
691 VerifyCertificate(&sessions[user->GetFd()],user);
692 if (sessions[user->GetFd()].sess)
694 std::string cipher = gnutls_kx_get_name(gnutls_kx_get(sessions[user->GetFd()].sess));
695 cipher.append("-").append(gnutls_cipher_get_name(gnutls_cipher_get(sessions[user->GetFd()].sess))).append("-");
696 cipher.append(gnutls_mac_get_name(gnutls_mac_get(sessions[user->GetFd()].sess)));
697 user->WriteServ("NOTICE %s :*** You are connected using SSL cipher \"%s\"", user->nick, cipher.c_str());
702 void MakePollWrite(issl_session* session)
704 //OnRawSocketWrite(session->fd, NULL, 0);
705 EventHandler* eh = ServerInstance->FindDescriptor(session->fd);
707 ServerInstance->SE->WantWrite(eh);
710 virtual void OnBufferFlushed(User* user)
712 if (user->GetExt("ssl"))
714 issl_session* session = &sessions[user->GetFd()];
715 if (session && session->outbuf.size())
716 OnRawSocketWrite(user->GetFd(), NULL, 0);
720 void CloseSession(issl_session* session)
724 gnutls_bye(session->sess, GNUTLS_SHUT_WR);
725 gnutls_deinit(session->sess);
730 delete[] session->inbuf;
733 session->outbuf.clear();
734 session->inbuf = NULL;
735 session->sess = NULL;
736 session->status = ISSL_NONE;
739 void VerifyCertificate(issl_session* session, Extensible* user)
741 if (!session->sess || !user)
745 const gnutls_datum_t* cert_list;
747 unsigned int cert_list_size;
748 gnutls_x509_crt_t cert;
750 unsigned char digest[MAXBUF];
751 size_t digest_size = sizeof(digest);
752 size_t name_size = sizeof(name);
753 ssl_cert* certinfo = new ssl_cert;
755 user->Extend("ssl_cert",certinfo);
757 /* This verification function uses the trusted CAs in the credentials
758 * structure. So you must have installed one or more CA certificates.
760 ret = gnutls_certificate_verify_peers2(session->sess, &status);
764 certinfo->data.insert(std::make_pair("error",std::string(gnutls_strerror(ret))));
768 if (status & GNUTLS_CERT_INVALID)
770 certinfo->data.insert(std::make_pair("invalid",ConvToStr(1)));
774 certinfo->data.insert(std::make_pair("invalid",ConvToStr(0)));
776 if (status & GNUTLS_CERT_SIGNER_NOT_FOUND)
778 certinfo->data.insert(std::make_pair("unknownsigner",ConvToStr(1)));
782 certinfo->data.insert(std::make_pair("unknownsigner",ConvToStr(0)));
784 if (status & GNUTLS_CERT_REVOKED)
786 certinfo->data.insert(std::make_pair("revoked",ConvToStr(1)));
790 certinfo->data.insert(std::make_pair("revoked",ConvToStr(0)));
792 if (status & GNUTLS_CERT_SIGNER_NOT_CA)
794 certinfo->data.insert(std::make_pair("trusted",ConvToStr(0)));
798 certinfo->data.insert(std::make_pair("trusted",ConvToStr(1)));
801 /* Up to here the process is the same for X.509 certificates and
802 * OpenPGP keys. From now on X.509 certificates are assumed. This can
803 * be easily extended to work with openpgp keys as well.
805 if (gnutls_certificate_type_get(session->sess) != GNUTLS_CRT_X509)
807 certinfo->data.insert(std::make_pair("error","No X509 keys sent"));
811 ret = gnutls_x509_crt_init(&cert);
814 certinfo->data.insert(std::make_pair("error",gnutls_strerror(ret)));
819 cert_list = gnutls_certificate_get_peers(session->sess, &cert_list_size);
820 if (cert_list == NULL)
822 certinfo->data.insert(std::make_pair("error","No certificate was found"));
826 /* This is not a real world example, since we only check the first
827 * certificate in the given chain.
830 ret = gnutls_x509_crt_import(cert, &cert_list[0], GNUTLS_X509_FMT_DER);
833 certinfo->data.insert(std::make_pair("error",gnutls_strerror(ret)));
837 gnutls_x509_crt_get_dn(cert, name, &name_size);
839 certinfo->data.insert(std::make_pair("dn",name));
841 gnutls_x509_crt_get_issuer_dn(cert, name, &name_size);
843 certinfo->data.insert(std::make_pair("issuer",name));
845 if ((ret = gnutls_x509_crt_get_fingerprint(cert, GNUTLS_DIG_MD5, digest, &digest_size)) < 0)
847 certinfo->data.insert(std::make_pair("error",gnutls_strerror(ret)));
851 certinfo->data.insert(std::make_pair("fingerprint",irc::hex(digest, digest_size)));
854 /* Beware here we do not check for errors.
856 if ((gnutls_x509_crt_get_expiration_time(cert) < time(0)) || (gnutls_x509_crt_get_activation_time(cert) > time(0)))
858 certinfo->data.insert(std::make_pair("error","Not activated, or expired certificate"));
861 gnutls_x509_crt_deinit(cert);
868 MODULE_INIT(ModuleSSLGnuTLS)