blob: a1d1747290a3c3c1775ef28910c07e7f5bdb43ee [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* 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
24#ifndef __RFB_SSECURITYVNCAUTH_H__
25#define __RFB_SSECURITYVNCAUTH_H__
26
Adam Tkac162ac352010-04-23 14:02:43 +000027#include <rfb/Configuration.h>
Michal Srb270a31c2014-11-10 15:32:00 +020028#include <rfb/Password.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000029#include <rfb/SSecurity.h>
Adam Tkac5a0caed2010-04-23 13:58:10 +000030#include <rfb/Security.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000031#include <rdr/types.h>
32
33namespace rfb {
34
35 class VncAuthPasswdGetter {
36 public:
Michal Srb519784a2014-11-24 13:53:23 +020037 // getVncAuthPasswd() fills buffer of given password and readOnlyPassword.
38 // If there was no read only password in the file, readOnlyPassword buffer is null.
Michal Srb270a31c2014-11-10 15:32:00 +020039 virtual void getVncAuthPasswd(PlainPasswd *password, PlainPasswd *readOnlyPassword)=0;
Steve Kondika6424622017-07-08 01:49:14 -070040
41 virtual ~VncAuthPasswdGetter() { }
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000042 };
43
Adam Tkac162ac352010-04-23 14:02:43 +000044 class VncAuthPasswdParameter : public VncAuthPasswdGetter, BinaryParameter {
45 public:
46 VncAuthPasswdParameter(const char* name, const char* desc, StringParameter* passwdFile_);
Michal Srb270a31c2014-11-10 15:32:00 +020047 virtual void getVncAuthPasswd(PlainPasswd *password, PlainPasswd *readOnlyPassword);
Adam Tkac162ac352010-04-23 14:02:43 +000048 protected:
49 StringParameter* passwdFile;
50 };
51
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000052 class SSecurityVncAuth : public SSecurity {
53 public:
Adam Tkac162ac352010-04-23 14:02:43 +000054 SSecurityVncAuth(void);
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000055 virtual bool processMsg(SConnection* sc);
56 virtual int getType() const {return secTypeVncAuth;}
57 virtual const char* getUserName() const {return 0;}
Michal Srb270a31c2014-11-10 15:32:00 +020058 virtual SConnection::AccessRights getAccessRights() const { return accessRights; }
Adam Tkac162ac352010-04-23 14:02:43 +000059 static StringParameter vncAuthPasswdFile;
60 static VncAuthPasswdParameter vncAuthPasswd;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000061 private:
Michal Srb270a31c2014-11-10 15:32:00 +020062 bool verifyResponse(const PlainPasswd &password);
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000063 enum {vncAuthChallengeSize = 16};
64 rdr::U8 challenge[vncAuthChallengeSize];
65 rdr::U8 response[vncAuthChallengeSize];
66 bool sentChallenge;
67 int responsePos;
68 VncAuthPasswdGetter* pg;
Michal Srb270a31c2014-11-10 15:32:00 +020069 SConnection::AccessRights accessRights;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000070 };
71}
72#endif