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.3KB

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 <list>
  26. namespace rfb {
  27. const rdr::U8 secTypeInvalid = 0;
  28. const rdr::U8 secTypeNone = 1;
  29. const rdr::U8 secTypeVncAuth = 2;
  30. const rdr::U8 secTypeRA2 = 5;
  31. const rdr::U8 secTypeRA2ne = 6;
  32. const rdr::U8 secTypeSSPI = 7;
  33. const rdr::U8 secTypeSSPIne = 8;
  34. const rdr::U8 secTypeTight = 16;
  35. const rdr::U8 secTypeUltra = 17;
  36. const rdr::U8 secTypeTLS = 18;
  37. const rdr::U8 secTypeVeNCrypt= 19;
  38. const rdr::U8 secTypeRA256 = 129;
  39. const rdr::U8 secTypeRAne256 = 130;
  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. /* RSA-AES subtypes */
  49. const int secTypeRA2UserPass = 1;
  50. const int secTypeRA2Pass = 2;
  51. // result types
  52. const rdr::U32 secResultOK = 0;
  53. const rdr::U32 secResultFailed = 1;
  54. const rdr::U32 secResultTooMany = 2; // deprecated
  55. class Security {
  56. public:
  57. /*
  58. * Create Security instance.
  59. */
  60. Security();
  61. Security(StringParameter &secTypes);
  62. /*
  63. * Note about security types.
  64. *
  65. * Although RFB protocol specifies security types as U8 values,
  66. * we map VeNCrypt subtypes (U32) into the standard security types
  67. * to simplify user configuration. With this mapping user can configure
  68. * both VeNCrypt subtypes and security types with only one option.
  69. */
  70. /* Enable/Disable certain security type */
  71. void EnableSecType(rdr::U32 secType);
  72. void DisableSecType(rdr::U32 secType) { enabledSecTypes.remove(secType); }
  73. void SetSecTypes(std::list<rdr::U32> &secTypes) { enabledSecTypes = secTypes; }
  74. /* Check if certain type is supported */
  75. bool IsSupported(rdr::U32 secType);
  76. /* Get list of enabled security types without VeNCrypt subtypes */
  77. const std::list<rdr::U8> GetEnabledSecTypes(void);
  78. /* Get list of enabled VeNCrypt subtypes */
  79. const std::list<rdr::U32> GetEnabledExtSecTypes(void);
  80. /* Output char* is stored in static array */
  81. char *ToString(void);
  82. #ifdef HAVE_GNUTLS
  83. static StringParameter GnuTLSPriority;
  84. #endif
  85. private:
  86. std::list<rdr::U32> enabledSecTypes;
  87. };
  88. const char* secTypeName(rdr::U32 num);
  89. rdr::U32 secTypeNum(const char* name);
  90. std::list<rdr::U32> parseSecTypes(const char* types);
  91. }
  92. #endif