Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 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 | |
| 24 | #ifndef __RFB_SSECURITYVNCAUTH_H__ |
| 25 | #define __RFB_SSECURITYVNCAUTH_H__ |
| 26 | |
Adam Tkac | 162ac35 | 2010-04-23 14:02:43 +0000 | [diff] [blame] | 27 | #include <rfb/Configuration.h> |
Michal Srb | 270a31c | 2014-11-10 15:32:00 +0200 | [diff] [blame] | 28 | #include <rfb/Password.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 29 | #include <rfb/SSecurity.h> |
Adam Tkac | 5a0caed | 2010-04-23 13:58:10 +0000 | [diff] [blame] | 30 | #include <rfb/Security.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 31 | #include <rdr/types.h> |
| 32 | |
| 33 | namespace rfb { |
| 34 | |
| 35 | class VncAuthPasswdGetter { |
| 36 | public: |
Michal Srb | 519784a | 2014-11-24 13:53:23 +0200 | [diff] [blame] | 37 | // getVncAuthPasswd() fills buffer of given password and readOnlyPassword. |
| 38 | // If there was no read only password in the file, readOnlyPassword buffer is null. |
Michal Srb | 270a31c | 2014-11-10 15:32:00 +0200 | [diff] [blame] | 39 | virtual void getVncAuthPasswd(PlainPasswd *password, PlainPasswd *readOnlyPassword)=0; |
Steve Kondik | a642462 | 2017-07-08 01:49:14 -0700 | [diff] [blame] | 40 | |
| 41 | virtual ~VncAuthPasswdGetter() { } |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 42 | }; |
| 43 | |
Adam Tkac | 162ac35 | 2010-04-23 14:02:43 +0000 | [diff] [blame] | 44 | class VncAuthPasswdParameter : public VncAuthPasswdGetter, BinaryParameter { |
| 45 | public: |
| 46 | VncAuthPasswdParameter(const char* name, const char* desc, StringParameter* passwdFile_); |
Michal Srb | 270a31c | 2014-11-10 15:32:00 +0200 | [diff] [blame] | 47 | virtual void getVncAuthPasswd(PlainPasswd *password, PlainPasswd *readOnlyPassword); |
Adam Tkac | 162ac35 | 2010-04-23 14:02:43 +0000 | [diff] [blame] | 48 | protected: |
| 49 | StringParameter* passwdFile; |
| 50 | }; |
| 51 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 52 | class SSecurityVncAuth : public SSecurity { |
| 53 | public: |
Adam Tkac | 162ac35 | 2010-04-23 14:02:43 +0000 | [diff] [blame] | 54 | SSecurityVncAuth(void); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 55 | virtual bool processMsg(SConnection* sc); |
| 56 | virtual int getType() const {return secTypeVncAuth;} |
| 57 | virtual const char* getUserName() const {return 0;} |
Michal Srb | 270a31c | 2014-11-10 15:32:00 +0200 | [diff] [blame] | 58 | virtual SConnection::AccessRights getAccessRights() const { return accessRights; } |
Adam Tkac | 162ac35 | 2010-04-23 14:02:43 +0000 | [diff] [blame] | 59 | static StringParameter vncAuthPasswdFile; |
| 60 | static VncAuthPasswdParameter vncAuthPasswd; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 61 | private: |
Michal Srb | 270a31c | 2014-11-10 15:32:00 +0200 | [diff] [blame] | 62 | bool verifyResponse(const PlainPasswd &password); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 63 | enum {vncAuthChallengeSize = 16}; |
| 64 | rdr::U8 challenge[vncAuthChallengeSize]; |
| 65 | rdr::U8 response[vncAuthChallengeSize]; |
| 66 | bool sentChallenge; |
| 67 | int responsePos; |
| 68 | VncAuthPasswdGetter* pg; |
Michal Srb | 270a31c | 2014-11-10 15:32:00 +0200 | [diff] [blame] | 69 | SConnection::AccessRights accessRights; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 70 | }; |
| 71 | } |
| 72 | #endif |