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.

SecurityServer.cxx 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright (C) 2010 TigerVNC Team
  3. *
  4. * This is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This software is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this software; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  17. * USA.
  18. */
  19. #ifdef HAVE_CONFIG_H
  20. #include <config.h>
  21. #endif
  22. #include <rdr/Exception.h>
  23. #include <rfb/Security.h>
  24. #include <rfb/SSecurityNone.h>
  25. #include <rfb/SSecurityStack.h>
  26. #include <rfb/SSecurityPlain.h>
  27. #include <rfb/SSecurityVncAuth.h>
  28. #include <rfb/SSecurityVeNCrypt.h>
  29. #ifdef HAVE_GNUTLS
  30. #include <rfb/SSecurityTLS.h>
  31. #endif
  32. #ifdef HAVE_NETTLE
  33. #include <rfb/SSecurityRSAAES.h>
  34. #endif
  35. using namespace rdr;
  36. using namespace rfb;
  37. StringParameter SecurityServer::secTypes
  38. ("SecurityTypes",
  39. "Specify which security scheme to use (None, VncAuth, Plain"
  40. #ifdef HAVE_GNUTLS
  41. ", TLSNone, TLSVnc, TLSPlain, X509None, X509Vnc, X509Plain"
  42. #endif
  43. #ifdef HAVE_NETTLE
  44. ", RA2, RA2ne, RA2_256, RA2ne_256"
  45. #endif
  46. ")",
  47. #ifdef HAVE_GNUTLS
  48. "TLSVnc,"
  49. #endif
  50. "VncAuth",
  51. ConfServer);
  52. SSecurity* SecurityServer::GetSSecurity(SConnection* sc, U32 secType)
  53. {
  54. if (!IsSupported(secType))
  55. goto bail;
  56. switch (secType) {
  57. case secTypeNone: return new SSecurityNone(sc);
  58. case secTypeVncAuth: return new SSecurityVncAuth(sc);
  59. case secTypeVeNCrypt: return new SSecurityVeNCrypt(sc, this);
  60. case secTypePlain: return new SSecurityPlain(sc);
  61. #ifdef HAVE_GNUTLS
  62. case secTypeTLSNone:
  63. return new SSecurityStack(sc, secTypeTLSNone, new SSecurityTLS(sc, true));
  64. case secTypeTLSVnc:
  65. return new SSecurityStack(sc, secTypeTLSVnc, new SSecurityTLS(sc, true), new SSecurityVncAuth(sc));
  66. case secTypeTLSPlain:
  67. return new SSecurityStack(sc, secTypeTLSPlain, new SSecurityTLS(sc, true), new SSecurityPlain(sc));
  68. case secTypeX509None:
  69. return new SSecurityStack(sc, secTypeX509None, new SSecurityTLS(sc, false));
  70. case secTypeX509Vnc:
  71. return new SSecurityStack(sc, secTypeX509None, new SSecurityTLS(sc, false), new SSecurityVncAuth(sc));
  72. case secTypeX509Plain:
  73. return new SSecurityStack(sc, secTypeX509Plain, new SSecurityTLS(sc, false), new SSecurityPlain(sc));
  74. #endif
  75. #ifdef HAVE_NETTLE
  76. case secTypeRA2:
  77. return new SSecurityRSAAES(sc, secTypeRA2, 128, true);
  78. case secTypeRA2ne:
  79. return new SSecurityRSAAES(sc, secTypeRA2ne, 128, false);
  80. case secTypeRA256:
  81. return new SSecurityRSAAES(sc, secTypeRA256, 256, true);
  82. case secTypeRAne256:
  83. return new SSecurityRSAAES(sc, secTypeRAne256, 256, false);
  84. #endif
  85. }
  86. bail:
  87. throw Exception("Security type not supported");
  88. }