home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 September / PCO_0998.ISO / filesbbs / frei / palmsrc.arj / PALMSRC.ZIP / vncauth.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-06  |  1.3 KB  |  56 lines

  1. /*
  2.  *  Copyright (C) 1997, 1998 Olivetti & Oracle Research Laboratory
  3.  *
  4.  *  This is free software; you can redistribute it and/or modify
  5.  *  it under the terms of the GNU General Public License as published by
  6.  *  the Free Software Foundation; either version 2 of the License, or
  7.  *  (at your option) any later version.
  8.  *
  9.  *  This software is distributed in the hope that it will be useful,
  10.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  *  GNU General Public License for more details.
  13.  *
  14.  *  You should have received a copy of the GNU General Public License
  15.  *  along with this program; if not, write to the Free Software
  16.  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  17.  *  USA.
  18.  */
  19.  
  20. /*
  21.  * vncauth.c - Functions for VNC password management and authentication.
  22.  */
  23.  
  24. #include <Pilot.h>
  25.  
  26. #include <vncauth.h>
  27. #include <d3des.h>
  28.  
  29.  
  30. /*
  31.  * Encrypt CHALLENGESIZE bytes in memory using a password.
  32.  */
  33.  
  34. void
  35. vncEncryptBytes(unsigned char *bytes, char *passwd)
  36. {
  37.     unsigned char key[8];
  38.     int i;
  39.  
  40.     /* key is simply password padded with nulls */
  41.  
  42.     for (i = 0; i < 8; i++) {
  43.     if (i < StrLen(passwd)) {
  44.         key[i] = passwd[i];
  45.     } else {
  46.         key[i] = 0;
  47.     }
  48.     }
  49.  
  50.     deskey(key, EN0);
  51.  
  52.     for (i = 0; i < CHALLENGESIZE; i += 8) {
  53.     des(bytes+i, bytes+i);
  54.     }
  55. }
  56.