From 707d361a503718f0636bc50fde56d46fb9edc980 Mon Sep 17 00:00:00 2001 From: Adam Tkac Date: Tue, 20 Jul 2010 15:16:10 +0000 Subject: [PATCH] [Development] Create VeNCrypt security types in Security class. Signed-off-by: Martin Koegler git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4103 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- common/rfb/CSecurityVeNCrypt.cxx | 26 +------------------------- common/rfb/CSecurityVeNCrypt.h | 3 --- common/rfb/Makefile.am | 16 +++++++++------- common/rfb/SSecurityPlain.cxx | 4 ---- common/rfb/SSecurityPlain.h | 4 ---- common/rfb/SSecurityVeNCrypt.cxx | 27 +-------------------------- common/rfb/SSecurityVeNCrypt.h | 6 ------ common/rfb/Security.cxx | 20 +++++++++++++++++--- 8 files changed, 28 insertions(+), 78 deletions(-) diff --git a/common/rfb/CSecurityVeNCrypt.cxx b/common/rfb/CSecurityVeNCrypt.cxx index 39a95f44..2d91190f 100644 --- a/common/rfb/CSecurityVeNCrypt.cxx +++ b/common/rfb/CSecurityVeNCrypt.cxx @@ -26,9 +26,7 @@ #include #include #include -#include #include -#include #include #include @@ -173,7 +171,7 @@ bool CSecurityVeNCrypt::processMsg(CConnection* cc) if (chosenType == secTypeInvalid || chosenType == secTypeVeNCrypt) throw AuthFailureException("No valid VeNCrypt sub-type"); - csecurity = CSecurityVeNCrypt::getCSecurityStack(chosenType); + csecurity = security->GetCSecurity(chosenType); /* send chosen type to server */ os->writeU32(chosenType); @@ -193,25 +191,3 @@ bool CSecurityVeNCrypt::processMsg(CConnection* cc) return csecurity->processMsg(cc); } -CSecurityStack* CSecurityVeNCrypt::getCSecurityStack(int secType) -{ - switch (secType) { - case secTypeTLSNone: - return new CSecurityStack(secTypeTLSNone, "TLS with no password", - new CSecurityTLS()); - case secTypeTLSVnc: - return new CSecurityStack(secTypeTLSVnc, "TLS with VNCAuth", - new CSecurityTLS(), new CSecurityVncAuth()); -#if 0 - /* Following subtypes are not implemented, yet */ - case secTypeTLSPlain: - case secTypeX509None: - case secTypeX509Vnc: - case secTypeX509Plain: -#endif - default: - throw Exception("Unsupported VeNCrypt subtype"); - } - - return NULL; /* not reached */ -} diff --git a/common/rfb/CSecurityVeNCrypt.h b/common/rfb/CSecurityVeNCrypt.h index 3ad6eb2c..1385f585 100644 --- a/common/rfb/CSecurityVeNCrypt.h +++ b/common/rfb/CSecurityVeNCrypt.h @@ -26,7 +26,6 @@ #define __CSECURITYVENCRYPT_H__ #include -#include #include #include @@ -43,8 +42,6 @@ namespace rfb { static StringParameter secTypesStr; protected: - static CSecurityStack* getCSecurityStack(int secType); - CSecurity *csecurity; Security *security; bool haveRecvdMajorVersion; diff --git a/common/rfb/Makefile.am b/common/rfb/Makefile.am index c683fe0c..7df6b6b9 100644 --- a/common/rfb/Makefile.am +++ b/common/rfb/Makefile.am @@ -1,17 +1,16 @@ noinst_LTLIBRARIES = librfb.la -VENCRYPT_HDRS = CSecurityStack.h CSecurityTLS.h CSecurityTLSBase.h \ - CSecurityVeNCrypt.h SSecurityPlain.h SSecurityStack.h SSecurityTLS.h \ - SSecurityTLSBase.h SSecurityVeNCrypt.h +VENCRYPT_HDRS = CSecurityTLS.h CSecurityTLSBase.h \ + SSecurityTLS.h SSecurityTLSBase.h -VENCRYPT_SRCS = CSecurityStack.cxx CSecurityTLS.cxx CSecurityTLSBase.cxx \ - CSecurityVeNCrypt.cxx SSecurityPlain.cxx SSecurityStack.cxx \ - SSecurityTLS.cxx SSecurityTLSBase.cxx SSecurityVeNCrypt.cxx +VENCRYPT_SRCS = CSecurityTLS.cxx CSecurityTLSBase.cxx \ + SSecurityTLS.cxx SSecurityTLSBase.cxx HDRS = Blacklist.h CapsContainer.h CapsList.h CConnection.h \ CMsgHandler.h CMsgReader.h CMsgReaderV3.h CMsgWriter.h \ CMsgWriterV3.h ColourCube.h ColourMap.h ComparingUpdateTracker.h \ Configuration.h ConnParams.h CSecurity.h CSecurityNone.h \ + CSecurityStack.h CSecurityVeNCrypt.h \ CSecurityVncAuth.h Cursor.h Decoder.h d3des.h Encoder.h \ encodings.h Exception.h hextileConstants.h hextileDecode.h \ HextileDecoder.h hextileEncodeBetter.h hextileEncode.h \ @@ -23,6 +22,7 @@ HDRS = Blacklist.h CapsContainer.h CapsList.h CConnection.h \ ScaledPixelBuffer.h ScaleFilters.h SConnection.h ScreenSet.h \ screenTypes.h SDesktop.h ServerCore.h SMsgHandler.h SMsgReader.h \ SMsgReaderV3.h SMsgWriter.h SMsgWriterV3.h SSecurity.h SSecurityNone.h \ + SSecurityPlain.h SSecurityStack.h SSecurityVeNCrypt.h \ SSecurityVncAuth.h Threading.h tightDecode.h \ TightDecoder.h tightEncode.h TightEncoder.h TightPalette.h Timer.h \ TransImageGetter.h transInitTempl.h transTempl.h TrueColourMap.h \ @@ -32,6 +32,7 @@ HDRS = Blacklist.h CapsContainer.h CapsList.h CConnection.h \ librfb_la_SOURCES = $(HDRS) Blacklist.cxx CConnection.cxx CMsgHandler.cxx \ CMsgReader.cxx CMsgReaderV3.cxx CMsgWriter.cxx CMsgWriterV3.cxx \ + CSecurityStack.cxx CSecurityVeNCrypt.cxx \ CSecurityVncAuth.cxx CapsContainer.cxx CapsList.cxx \ ComparingUpdateTracker.cxx Configuration.cxx ConnParams.cxx \ Cursor.cxx Decoder.cxx d3des.c Encoder.cxx \ @@ -41,7 +42,8 @@ librfb_la_SOURCES = $(HDRS) Blacklist.cxx CConnection.cxx CMsgHandler.cxx \ RREEncoder.cxx RREDecoder.cxx RawDecoder.cxx RawEncoder.cxx \ Region.cxx SConnection.cxx SMsgHandler.cxx \ SMsgReader.cxx SMsgReaderV3.cxx SMsgWriter.cxx SMsgWriterV3.cxx \ - ServerCore.cxx Security.cxx SSecurityVncAuth.cxx \ + ServerCore.cxx Security.cxx SSecurityPlain.cxx SSecurityStack.cxx \ + SSecurityVncAuth.cxx SSecurityVeNCrypt.cxx \ ScaledPixelBuffer.cxx ScaleFilters.cxx Timer.cxx TightDecoder.cxx \ TightEncoder.cxx TightPalette.cxx TransImageGetter.cxx \ UpdateTracker.cxx VNCSConnectionST.cxx \ diff --git a/common/rfb/SSecurityPlain.cxx b/common/rfb/SSecurityPlain.cxx index 6b7bd9e7..04eabe0d 100644 --- a/common/rfb/SSecurityPlain.cxx +++ b/common/rfb/SSecurityPlain.cxx @@ -21,10 +21,6 @@ #include #endif -#ifndef HAVE_GNUTLS -#error "This source should not be compiled without HAVE_GNUTLS defined" -#endif - #include #include #include diff --git a/common/rfb/SSecurityPlain.h b/common/rfb/SSecurityPlain.h index ecdd618b..f7a9c3dd 100644 --- a/common/rfb/SSecurityPlain.h +++ b/common/rfb/SSecurityPlain.h @@ -24,10 +24,6 @@ #include #endif -#ifndef HAVE_GNUTLS -#error "This header should not be included without HAVE_GNUTLS defined" -#endif - #include #include #include diff --git a/common/rfb/SSecurityVeNCrypt.cxx b/common/rfb/SSecurityVeNCrypt.cxx index 2dd331e9..c704d1e5 100644 --- a/common/rfb/SSecurityVeNCrypt.cxx +++ b/common/rfb/SSecurityVeNCrypt.cxx @@ -26,17 +26,11 @@ #include #endif -#ifndef HAVE_GNUTLS -#error "This source should not be compiled without HAVE_GNUTLS defined" -#endif - #include #include #include #include #include -#include -#include using namespace rfb; using namespace rdr; @@ -180,29 +174,10 @@ bool SSecurityVeNCrypt::processMsg(SConnection* sc) if (chosenType == secTypeInvalid || chosenType == secTypeVeNCrypt) throw AuthFailureException("No valid VeNCrypt sub-type"); - ssecurity = SSecurityVeNCrypt::getSSecurityStack(chosenType); + ssecurity = security->GetSSecurity(chosenType); } /* continue processing the messages */ return ssecurity->processMsg(sc); } -SSecurityStack* SSecurityVeNCrypt::getSSecurityStack(int secType) -{ - switch (secType) { - case secTypeTLSNone: - return new SSecurityStack(secTypeTLSNone, new SSecurityTLS()); - case secTypeTLSVnc: - return new SSecurityStack(secTypeTLSVnc, new SSecurityTLS(), new SSecurityVncAuth()); -#if 0 - /* Following types are not implemented, yet */ - case secTypeTLSPlain: - case secTypeX509None: - case secTypeX509Vnc: - case secTypeX509Plain: -#endif - default: - throw Exception("Bug in the SSecurityVeNCrypt::getSSecurityStack"); - } -} - diff --git a/common/rfb/SSecurityVeNCrypt.h b/common/rfb/SSecurityVeNCrypt.h index 3d5949ef..6201a7b7 100644 --- a/common/rfb/SSecurityVeNCrypt.h +++ b/common/rfb/SSecurityVeNCrypt.h @@ -29,10 +29,6 @@ #include #endif -#ifndef HAVE_GNUTLS -#error "This header should not be included without HAVE_GNUTLS defined" -#endif - #include #include @@ -49,8 +45,6 @@ namespace rfb { static StringParameter X509_CertFile, X509_KeyFile; protected: - static SSecurityStack* getSSecurityStack(int secType); - SSecurity *ssecurity; Security *security; bool haveSentVersion, haveRecvdMajorVersion, haveRecvdMinorVersion; diff --git a/common/rfb/Security.cxx b/common/rfb/Security.cxx index 4dea41ea..e6a51bcc 100644 --- a/common/rfb/Security.cxx +++ b/common/rfb/Security.cxx @@ -28,15 +28,19 @@ #define strcasecmp _stricmp #endif #include +#include #include #include #include #include #include #include +#include #include -#ifdef HAVE_GNUTLS #include +#ifdef HAVE_GNUTLS +#include +#include #endif #include @@ -116,8 +120,12 @@ SSecurity* Security::GetSSecurity(U32 secType) switch (secType) { case secTypeNone: return new SSecurityNone(); case secTypeVncAuth: return new SSecurityVncAuth(); -#ifdef HAVE_GNUTLS case secTypeVeNCrypt: return new SSecurityVeNCrypt(this); +#ifdef HAVE_GNUTLS + case secTypeTLSNone: + return new SSecurityStack(secTypeTLSNone, new SSecurityTLS()); + case secTypeTLSVnc: + return new SSecurityStack(secTypeTLSVnc, new SSecurityTLS(), new SSecurityVncAuth()); #endif } @@ -135,8 +143,14 @@ CSecurity* Security::GetCSecurity(U32 secType) switch (secType) { case secTypeNone: return new CSecurityNone(); case secTypeVncAuth: return new CSecurityVncAuth(); -#ifdef HAVE_GNUTLS case secTypeVeNCrypt: return new CSecurityVeNCrypt(this); +#ifdef HAVE_GNUTLS + case secTypeTLSNone: + return new CSecurityStack(secTypeTLSNone, "TLS with no password", + new CSecurityTLS()); + case secTypeTLSVnc: + return new CSecurityStack(secTypeTLSVnc, "TLS with VNCAuth", + new CSecurityTLS(), new CSecurityVncAuth()); #endif } -- 2.39.5