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 <stdint.h>
  26. #include <rfb/Configuration.h>
  27. #include <rfb/SSecurity.h>
  28. #include <rfb/Security.h>
  29. namespace rfb {
  30. class VncAuthPasswdGetter {
  31. public:
  32. // getVncAuthPasswd() fills buffer of given password and readOnlyPassword.
  33. // If there was no read only password in the file, readOnlyPassword buffer is null.
  34. virtual void getVncAuthPasswd(std::string *password, std::string *readOnlyPassword)=0;
  35. virtual ~VncAuthPasswdGetter() { }
  36. };
  37. class VncAuthPasswdParameter : public VncAuthPasswdGetter, BinaryParameter {
  38. public:
  39. VncAuthPasswdParameter(const char* name, const char* desc, StringParameter* passwdFile_);
  40. virtual void getVncAuthPasswd(std::string *password, std::string *readOnlyPassword);
  41. protected:
  42. StringParameter* passwdFile;
  43. };
  44. class SSecurityVncAuth : public SSecurity {
  45. public:
  46. SSecurityVncAuth(SConnection* sc);
  47. virtual bool processMsg();
  48. virtual int getType() const {return secTypeVncAuth;}
  49. virtual const char* getUserName() const {return 0;}
  50. virtual SConnection::AccessRights getAccessRights() const { return accessRights; }
  51. static StringParameter vncAuthPasswdFile;
  52. static VncAuthPasswdParameter vncAuthPasswd;
  53. private:
  54. bool verifyResponse(const char* password);
  55. enum {vncAuthChallengeSize = 16};
  56. uint8_t challenge[vncAuthChallengeSize];
  57. uint8_t response[vncAuthChallengeSize];
  58. bool sentChallenge;
  59. VncAuthPasswdGetter* pg;
  60. SConnection::AccessRights accessRights;
  61. };
  62. }
  63. #endif