vncPasswd.h
Upload User: sbftbdw
Upload Date: 2007-01-03
Package Size: 379k
Code Size: 3k
Category:

Remote Control

Development Platform:

Visual C++

  1. //  Copyright (C) 1997, 1998 Olivetti & Oracle Research Laboratory
  2. //
  3. //  This file is part of the VNC system.
  4. //
  5. //  The VNC system is free software; you can redistribute it and/or modify
  6. //  it under the terms of the GNU General Public License as published by
  7. //  the Free Software Foundation; either version 2 of the License, or
  8. //  (at your option) any later version.
  9. //
  10. //  This program is distributed in the hope that it will be useful,
  11. //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. //  GNU General Public License for more details.
  14. //
  15. //  You should have received a copy of the GNU General Public License
  16. //  along with this program; if not, write to the Free Software
  17. //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  18. //  USA.
  19. //
  20. // If the source code for the VNC system is not available from the place 
  21. // whence you received this file, check http://www.orl.co.uk/vnc or contact
  22. // the authors on vnc@orl.co.uk for information on obtaining it.
  23. // vncPasswd
  24. // This header provides helpers for handling encrypted password data.
  25. // The password handling routines found in vncauth.h should not be used directly
  26. class vncPasswd;
  27. #if (!defined(_WINVNC_VNCPASSWD))
  28. #define _WINVNC_VNCPASSWD
  29. #include "stdhdrs.h"
  30. extern "C" {
  31. #include "vncauth.h"
  32. }
  33. // Password handling helper class
  34. class vncPasswd
  35. {
  36. public:
  37.     // Password decryptor!
  38.     class ToText
  39.     {
  40.     public:
  41. inline ToText(const char encrypted[MAXPWLEN])
  42. {
  43.     log.Print(LL_INTINFO, VNCLOG("PASSWD : ToText calledn"));
  44.     plaintext = vncDecryptPasswd((char *)encrypted);
  45. }
  46. inline ~ToText()
  47. {
  48.     if (plaintext != NULL)
  49.     {
  50. ZeroMemory(plaintext, strlen(plaintext));
  51. free(plaintext);
  52.     }
  53. }
  54. inline operator const char*() const {return plaintext;};
  55.     private:
  56. char *plaintext;
  57.     };
  58.     class FromText
  59.     {
  60.     public:
  61. inline FromText(char *unencrypted)
  62. {
  63.     log.Print(LL_INTINFO, VNCLOG("PASSWD : FromText calledn"));
  64.     vncEncryptPasswd(unencrypted, encrypted);
  65.     ZeroMemory(unencrypted, strlen(unencrypted));
  66. }
  67. inline ~FromText()
  68. {
  69. }
  70. inline operator const char*() const {return encrypted;};
  71.     private:
  72. char encrypted[MAXPWLEN];
  73.     };
  74.     class FromClear
  75.     {
  76.     public:
  77. inline FromClear()
  78. {
  79.     log.Print(LL_INTINFO, VNCLOG("PASSWD : FromClear calledn"));
  80.     vncEncryptPasswd("", encrypted);
  81. }
  82. inline ~FromClear()
  83. {
  84. }
  85. inline operator const char*() const {return encrypted;};
  86.     private:
  87. char encrypted[MAXPWLEN];
  88.     };
  89. };
  90. #endif