blob: fb24bdb420c32838b0de442ffe966c618e261d6d [file] [log] [blame]
Adam Tkacdfe19cf2010-04-23 14:14:11 +00001/*
2 * Copyright (C) 2005-2006 Martin Koegler
3 * Copyright (C) 2006 OCCAM Financial Technology
4 * Copyright (C) 2010 TigerVNC Team
5 *
6 * This is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This software is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this software; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 * USA.
20 */
21//
22// SSecurityVeNCrypt
23//
24
25#ifndef __SSECURITYVENCRYPT_H__
26#define __SSECURITYVENCRYPT_H__
27
Adam Tkacdf799702010-04-28 15:45:53 +000028#ifdef HAVE_CONFIG_H
29#include <config.h>
30#endif
31
32#ifndef HAVE_GNUTLS
33#error "This header should not be included without HAVE_GNUTLS defined"
34#endif
35
Adam Tkacdfe19cf2010-04-23 14:14:11 +000036#include <rfb/SSecurityStack.h>
37#include <rfb/SConnection.h>
38
39namespace rfb {
40
41 /* VeNCrypt subtypes */
42 const int secTypePlain = 256;
43 const int secTypeTLSNone = 257;
44 const int secTypeTLSVnc = 258;
45 const int secTypeTLSPlain = 259;
46 const int secTypeX509None = 260;
47 const int secTypeX509Vnc = 261;
48 const int secTypeX509Plain = 262;
49
50 class SSecurityVeNCrypt : public SSecurity {
51 public:
52 SSecurityVeNCrypt(void);
53 ~SSecurityVeNCrypt();
54 virtual bool processMsg(SConnection* sc);// { return true; }
55 virtual int getType() const { return secTypeVeNCrypt; }
56 virtual const char* getUserName() const { return NULL; }
57
58 static StringParameter X509_CertFile, X509_KeyFile, secTypesStr;
59
Adam Tkacdfe19cf2010-04-23 14:14:11 +000060 /* XXX Derive Security class and merge those functions appropriately ? */
61 static void getSecTypes(std::list<rdr::U32>* secTypes);
62 static rdr::U32 secTypeNum(const char *name);
63 static char* secTypeName(rdr::U32 num);
64 static std::list<rdr::U32> parseSecTypes(const char *types);
Adam Tkacb10489b2010-04-23 14:16:04 +000065 protected:
66 static SSecurityStack* getSSecurityStack(int secType);
Adam Tkacdfe19cf2010-04-23 14:14:11 +000067
Adam Tkacc86db212010-07-20 15:08:58 +000068 SSecurity *ssecurity;
Adam Tkacdfe19cf2010-04-23 14:14:11 +000069 bool haveSentVersion, haveRecvdMajorVersion, haveRecvdMinorVersion;
70 bool haveSentTypes, haveChosenType;
71 rdr::U8 majorVersion, minorVersion, numTypes;
72 rdr::U32 *subTypes, chosenType;
73 };
74}
75#endif