Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 1 | /* 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 Tkac | 94d88c1 | 2010-04-23 13:59:52 +0000 | [diff] [blame] | 25 | #include <rdr/types.h> |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 26 | #include <rfb/Configuration.h> |
Adam Tkac | c210e8a | 2010-04-23 14:09:16 +0000 | [diff] [blame] | 27 | #include <rfb/CSecurity.h> |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 28 | #include <rfb/SSecurity.h> |
| 29 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 30 | #include <list> |
| 31 | |
| 32 | namespace rfb { |
Adam Tkac | 94d88c1 | 2010-04-23 13:59:52 +0000 | [diff] [blame] | 33 | const rdr::U8 secTypeInvalid = 0; |
| 34 | const rdr::U8 secTypeNone = 1; |
| 35 | const rdr::U8 secTypeVncAuth = 2; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 36 | |
Adam Tkac | 94d88c1 | 2010-04-23 13:59:52 +0000 | [diff] [blame] | 37 | const rdr::U8 secTypeRA2 = 5; |
| 38 | const rdr::U8 secTypeRA2ne = 6; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 39 | |
Adam Tkac | 94d88c1 | 2010-04-23 13:59:52 +0000 | [diff] [blame] | 40 | const rdr::U8 secTypeSSPI = 7; |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 41 | const rdr::U8 secTypeSSPIne = 8; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 42 | |
Adam Tkac | 94d88c1 | 2010-04-23 13:59:52 +0000 | [diff] [blame] | 43 | const rdr::U8 secTypeTight = 16; |
| 44 | const rdr::U8 secTypeUltra = 17; |
| 45 | const rdr::U8 secTypeTLS = 18; |
Adam Tkac | dfe19cf | 2010-04-23 14:14:11 +0000 | [diff] [blame] | 46 | const rdr::U8 secTypeVeNCrypt= 19; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 47 | |
Adam Tkac | 00b395a | 2010-07-20 15:09:33 +0000 | [diff] [blame] | 48 | /* VeNCrypt subtypes */ |
| 49 | const int secTypePlain = 256; |
| 50 | const int secTypeTLSNone = 257; |
| 51 | const int secTypeTLSVnc = 258; |
| 52 | const int secTypeTLSPlain = 259; |
| 53 | const int secTypeX509None = 260; |
| 54 | const int secTypeX509Vnc = 261; |
| 55 | const int secTypeX509Plain = 262; |
| 56 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 57 | // result types |
| 58 | |
Adam Tkac | 94d88c1 | 2010-04-23 13:59:52 +0000 | [diff] [blame] | 59 | const rdr::U32 secResultOK = 0; |
| 60 | const rdr::U32 secResultFailed = 1; |
| 61 | const rdr::U32 secResultTooMany = 2; // deprecated |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 62 | |
Adam Tkac | fb99315 | 2010-08-12 14:17:28 +0000 | [diff] [blame] | 63 | enum SecurityClassType { SecurityViewer, SecurityServer }; |
| 64 | |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 65 | class Security { |
| 66 | public: |
Adam Tkac | c210e8a | 2010-04-23 14:09:16 +0000 | [diff] [blame] | 67 | /* |
| 68 | * Create Security instance. |
| 69 | */ |
Adam Tkac | fb99315 | 2010-08-12 14:17:28 +0000 | [diff] [blame] | 70 | Security(SecurityClassType secClassType); |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 71 | |
Adam Tkac | 0c77e51 | 2010-07-20 15:10:16 +0000 | [diff] [blame] | 72 | /* |
| 73 | * Note about security types. |
| 74 | * |
| 75 | * Although RFB protocol specifies security types as U8 values, |
| 76 | * we map VeNCrypt subtypes (U32) into the standard security types |
| 77 | * to simplify user configuration. With this mapping user can configure |
| 78 | * both VeNCrypt subtypes and security types with only one option. |
| 79 | */ |
| 80 | |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 81 | /* Enable/Disable certain security type */ |
Adam Tkac | 0c77e51 | 2010-07-20 15:10:16 +0000 | [diff] [blame] | 82 | void EnableSecType(rdr::U32 secType); |
| 83 | void DisableSecType(rdr::U32 secType) { enabledSecTypes.remove(secType); } |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 84 | |
| 85 | /* Check if certain type is supported */ |
Adam Tkac | 0c77e51 | 2010-07-20 15:10:16 +0000 | [diff] [blame] | 86 | bool IsSupported(rdr::U32 secType); |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 87 | |
Adam Tkac | 0c77e51 | 2010-07-20 15:10:16 +0000 | [diff] [blame] | 88 | /* 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 Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 92 | |
| 93 | /* Create server side SSecurity class instance */ |
Adam Tkac | 0c77e51 | 2010-07-20 15:10:16 +0000 | [diff] [blame] | 94 | SSecurity* GetSSecurity(rdr::U32 secType); |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 95 | |
Adam Tkac | c210e8a | 2010-04-23 14:09:16 +0000 | [diff] [blame] | 96 | /* Create client side CSecurity class instance */ |
Adam Tkac | 0c77e51 | 2010-07-20 15:10:16 +0000 | [diff] [blame] | 97 | CSecurity* GetCSecurity(rdr::U32 secType); |
Adam Tkac | c210e8a | 2010-04-23 14:09:16 +0000 | [diff] [blame] | 98 | |
Adam Tkac | fb99315 | 2010-08-12 14:17:28 +0000 | [diff] [blame] | 99 | static StringParameter secTypesViewer; |
| 100 | static StringParameter secTypesServer; |
Adam Tkac | c210e8a | 2010-04-23 14:09:16 +0000 | [diff] [blame] | 101 | |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 102 | private: |
Adam Tkac | 0c77e51 | 2010-07-20 15:10:16 +0000 | [diff] [blame] | 103 | std::list<rdr::U32> enabledSecTypes; |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 104 | }; |
| 105 | |
Adam Tkac | 0c77e51 | 2010-07-20 15:10:16 +0000 | [diff] [blame] | 106 | const char* secTypeName(rdr::U32 num); |
| 107 | rdr::U32 secTypeNum(const char* name); |
| 108 | std::list<rdr::U32> parseSecTypes(const char* types); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | #endif |