blob: c1bc9224dfebdc9a028b13cfa368f1e5044a1db7 [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18//
19// secTypes.h - constants for the various security types.
20//
21
22#ifndef __RFB_SECTYPES_H__
23#define __RFB_SECTYPES_H__
24
Adam Tkac94d88c12010-04-23 13:59:52 +000025#include <rdr/types.h>
Adam Tkac1d15e2d2010-04-23 14:06:38 +000026#include <rfb/Configuration.h>
Adam Tkacc210e8a2010-04-23 14:09:16 +000027#include <rfb/CSecurity.h>
Adam Tkac1d15e2d2010-04-23 14:06:38 +000028
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000029#include <list>
30
31namespace rfb {
Adam Tkac94d88c12010-04-23 13:59:52 +000032 const rdr::U8 secTypeInvalid = 0;
33 const rdr::U8 secTypeNone = 1;
34 const rdr::U8 secTypeVncAuth = 2;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000035
Adam Tkac94d88c12010-04-23 13:59:52 +000036 const rdr::U8 secTypeRA2 = 5;
37 const rdr::U8 secTypeRA2ne = 6;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000038
Adam Tkac94d88c12010-04-23 13:59:52 +000039 const rdr::U8 secTypeSSPI = 7;
Adam Tkac1d15e2d2010-04-23 14:06:38 +000040 const rdr::U8 secTypeSSPIne = 8;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000041
Adam Tkac94d88c12010-04-23 13:59:52 +000042 const rdr::U8 secTypeTight = 16;
43 const rdr::U8 secTypeUltra = 17;
44 const rdr::U8 secTypeTLS = 18;
Adam Tkacdfe19cf2010-04-23 14:14:11 +000045 const rdr::U8 secTypeVeNCrypt= 19;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000046
Adam Tkac00b395a2010-07-20 15:09:33 +000047 /* VeNCrypt subtypes */
48 const int secTypePlain = 256;
49 const int secTypeTLSNone = 257;
50 const int secTypeTLSVnc = 258;
51 const int secTypeTLSPlain = 259;
52 const int secTypeX509None = 260;
53 const int secTypeX509Vnc = 261;
54 const int secTypeX509Plain = 262;
55
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000056 // result types
57
Adam Tkac94d88c12010-04-23 13:59:52 +000058 const rdr::U32 secResultOK = 0;
59 const rdr::U32 secResultFailed = 1;
60 const rdr::U32 secResultTooMany = 2; // deprecated
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000061
Adam Tkac1d15e2d2010-04-23 14:06:38 +000062 class Security {
63 public:
Adam Tkacc210e8a2010-04-23 14:09:16 +000064 /*
65 * Create Security instance.
66 */
Pierre Ossmane5fe0702011-05-16 12:46:16 +000067 Security();
Adam Tkacbfd66c12010-10-01 08:33:29 +000068 Security(StringParameter &secTypes);
Adam Tkac1d15e2d2010-04-23 14:06:38 +000069
Adam Tkac0c77e512010-07-20 15:10:16 +000070 /*
71 * Note about security types.
72 *
73 * Although RFB protocol specifies security types as U8 values,
74 * we map VeNCrypt subtypes (U32) into the standard security types
75 * to simplify user configuration. With this mapping user can configure
76 * both VeNCrypt subtypes and security types with only one option.
77 */
78
Adam Tkac1d15e2d2010-04-23 14:06:38 +000079 /* Enable/Disable certain security type */
Adam Tkac0c77e512010-07-20 15:10:16 +000080 void EnableSecType(rdr::U32 secType);
81 void DisableSecType(rdr::U32 secType) { enabledSecTypes.remove(secType); }
Adam Tkac1d15e2d2010-04-23 14:06:38 +000082
Adam Tkac98bf0e92011-02-01 14:34:30 +000083 void SetSecTypes(std::list<rdr::U32> &secTypes) { enabledSecTypes = secTypes; }
84
Adam Tkac1d15e2d2010-04-23 14:06:38 +000085 /* Check if certain type is supported */
Adam Tkac0c77e512010-07-20 15:10:16 +000086 bool IsSupported(rdr::U32 secType);
Adam Tkac1d15e2d2010-04-23 14:06:38 +000087
Adam Tkac0c77e512010-07-20 15:10:16 +000088 /* Get list of enabled security types without VeNCrypt subtypes */
89 const std::list<rdr::U8> GetEnabledSecTypes(void);
90 /* Get list of enabled VeNCrypt subtypes */
91 const std::list<rdr::U32> GetEnabledExtSecTypes(void);
Adam Tkac1d15e2d2010-04-23 14:06:38 +000092
Adam Tkaca9a7b4b2011-02-01 14:34:55 +000093 /* Output char* is stored in static array */
94 char *ToString(void);
95
Pierre Ossman27eb55e2015-01-29 13:31:06 +010096#ifdef HAVE_GNUTLS
97 static StringParameter GnuTLSPriority;
98#endif
99
Adam Tkac1d15e2d2010-04-23 14:06:38 +0000100 private:
Adam Tkac0c77e512010-07-20 15:10:16 +0000101 std::list<rdr::U32> enabledSecTypes;
Adam Tkac1d15e2d2010-04-23 14:06:38 +0000102 };
103
Adam Tkac0c77e512010-07-20 15:10:16 +0000104 const char* secTypeName(rdr::U32 num);
105 rdr::U32 secTypeNum(const char* name);
106 std::list<rdr::U32> parseSecTypes(const char* types);
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +0000107}
108
109#endif