You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Security.h 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. #ifndef __RFB_SECTYPES_H__
  22. #define __RFB_SECTYPES_H__
  23. #include <rdr/types.h>
  24. #include <rfb/Configuration.h>
  25. #include <rfb/CSecurity.h>
  26. #include <rfb/SSecurity.h>
  27. #include <list>
  28. namespace rfb {
  29. const rdr::U8 secTypeInvalid = 0;
  30. const rdr::U8 secTypeNone = 1;
  31. const rdr::U8 secTypeVncAuth = 2;
  32. const rdr::U8 secTypeRA2 = 5;
  33. const rdr::U8 secTypeRA2ne = 6;
  34. const rdr::U8 secTypeSSPI = 7;
  35. const rdr::U8 secTypeSSPIne = 8;
  36. const rdr::U8 secTypeTight = 16;
  37. const rdr::U8 secTypeUltra = 17;
  38. const rdr::U8 secTypeTLS = 18;
  39. const rdr::U8 secTypeVeNCrypt= 19;
  40. /* VeNCrypt subtypes */
  41. const int secTypePlain = 256;
  42. const int secTypeTLSNone = 257;
  43. const int secTypeTLSVnc = 258;
  44. const int secTypeTLSPlain = 259;
  45. const int secTypeX509None = 260;
  46. const int secTypeX509Vnc = 261;
  47. const int secTypeX509Plain = 262;
  48. // result types
  49. const rdr::U32 secResultOK = 0;
  50. const rdr::U32 secResultFailed = 1;
  51. const rdr::U32 secResultTooMany = 2; // deprecated
  52. enum SecurityClassType { SecurityViewer, SecurityServer };
  53. class Security {
  54. public:
  55. /*
  56. * Create Security instance.
  57. */
  58. Security(SecurityClassType secClassType);
  59. /*
  60. * Note about security types.
  61. *
  62. * Although RFB protocol specifies security types as U8 values,
  63. * we map VeNCrypt subtypes (U32) into the standard security types
  64. * to simplify user configuration. With this mapping user can configure
  65. * both VeNCrypt subtypes and security types with only one option.
  66. */
  67. /* Enable/Disable certain security type */
  68. void EnableSecType(rdr::U32 secType);
  69. void DisableSecType(rdr::U32 secType) { enabledSecTypes.remove(secType); }
  70. /* Check if certain type is supported */
  71. bool IsSupported(rdr::U32 secType);
  72. /* Get list of enabled security types without VeNCrypt subtypes */
  73. const std::list<rdr::U8> GetEnabledSecTypes(void);
  74. /* Get list of enabled VeNCrypt subtypes */
  75. const std::list<rdr::U32> GetEnabledExtSecTypes(void);
  76. /* Create server side SSecurity class instance */
  77. SSecurity* GetSSecurity(rdr::U32 secType);
  78. /* Create client side CSecurity class instance */
  79. CSecurity* GetCSecurity(rdr::U32 secType);
  80. static StringParameter secTypesViewer;
  81. static StringParameter secTypesServer;
  82. /*
  83. * Use variable directly instead of dumb get/set methods. It is used
  84. * only in viewer-side code and MUST be set by viewer.
  85. */
  86. private:
  87. std::list<rdr::U32> enabledSecTypes;
  88. };
  89. const char* secTypeName(rdr::U32 num);
  90. rdr::U32 secTypeNum(const char* name);
  91. std::list<rdr::U32> parseSecTypes(const char* types);
  92. }
  93. #endif