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.

SSecurityVncAuth.h 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. // SSecurityVncAuth - legacy VNC authentication protocol.
  19. // The getPasswd call can be overridden if you wish to store
  20. // the VncAuth password in an implementation-specific place.
  21. // Otherwise, the password is read from a BinaryParameter
  22. // called Password.
  23. #ifndef __RFB_SSECURITYVNCAUTH_H__
  24. #define __RFB_SSECURITYVNCAUTH_H__
  25. #include <rfb/Configuration.h>
  26. #include <rfb/Password.h>
  27. #include <rfb/SSecurity.h>
  28. #include <rfb/Security.h>
  29. #include <rdr/types.h>
  30. namespace rfb {
  31. class VncAuthPasswdGetter {
  32. public:
  33. // getVncAuthPasswd() fills buffer of given password and readOnlyPassword.
  34. // If there was no read only password in the file, readOnlyPassword buffer is null.
  35. virtual void getVncAuthPasswd(PlainPasswd *password, PlainPasswd *readOnlyPassword)=0;
  36. virtual ~VncAuthPasswdGetter() { }
  37. };
  38. class VncAuthPasswdParameter : public VncAuthPasswdGetter, BinaryParameter {
  39. public:
  40. VncAuthPasswdParameter(const char* name, const char* desc, StringParameter* passwdFile_);
  41. virtual void getVncAuthPasswd(PlainPasswd *password, PlainPasswd *readOnlyPassword);
  42. protected:
  43. StringParameter* passwdFile;
  44. };
  45. class SSecurityVncAuth : public SSecurity {
  46. public:
  47. SSecurityVncAuth(SConnection* sc);
  48. virtual bool processMsg();
  49. virtual int getType() const {return secTypeVncAuth;}
  50. virtual const char* getUserName() const {return 0;}
  51. virtual SConnection::AccessRights getAccessRights() const { return accessRights; }
  52. static StringParameter vncAuthPasswdFile;
  53. static VncAuthPasswdParameter vncAuthPasswd;
  54. private:
  55. bool verifyResponse(const PlainPasswd &password);
  56. enum {vncAuthChallengeSize = 16};
  57. rdr::U8 challenge[vncAuthChallengeSize];
  58. rdr::U8 response[vncAuthChallengeSize];
  59. bool sentChallenge;
  60. VncAuthPasswdGetter* pg;
  61. SConnection::AccessRights accessRights;
  62. };
  63. }
  64. #endif