home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / PSION / MISC / PSI-KEY / SKEY.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-16  |  2.0 KB  |  89 lines

  1. /* psion 3a main program
  2.  * all this does is get user input, and pass it to the md4 alogrithm
  3.  * in the standard C library.
  4.  * Psion users can only have 8-character passwords, hence my own
  5.  * user input loop.
  6.  * once I get the hang of Object-orientated programming I'll produce a 
  7.  * proper user interface replaceing the system password input method
  8.  * [the psion 3/3a has a fully object orientated operating system, came
  9.  *  as wquite a shock ot a DOS/Unix hacker like myself
  10.  
  11.  * please send email to my home email address <richard@illuin.demon.co.uk>
  12.  * IF urgent, to my work address: <R.J.Letts@salford.ac.uk>
  13.  *
  14.  * Richard Letts, Network Manager, University of Salford
  15.  */
  16.  
  17.  
  18. #include <plib.h>
  19. #include "md4.h"
  20.  
  21. void f(char *);
  22. char *btoe(char *);
  23. int skey( int n, char *seed, char *passwd, char *onetime);
  24. int keycrunch(char *key, char* seed, char *passwd);
  25.  
  26. int skey( int n, char *seed, char *passwd, char *onetime)
  27. {
  28.     char key[8];
  29.  
  30.     if(keycrunch(key,seed,passwd) != 0){
  31.         p_scpy(onetime,"key crunch failed");
  32.         return 1;
  33.     }
  34.  
  35.     while (n--)        f(key);
  36.  
  37.     p_scpy(onetime,btoe(key));
  38.     return 0;
  39. }
  40.  
  41. main() 
  42. {
  43.     int i,j;
  44.     char burf[100];
  45.     int n;
  46.     char chal[64];
  47.     char passwd[64];
  48.     char *cp;
  49.  
  50.     p_printf("S/Key generator for Psion Series 3/3a computers");
  51.     p_printf("This version by Richard Letts <richard@illuin.demon.co.uk>\n\n");
  52.         
  53.     p_getl("Enter Challenge: ",burf,100);
  54.     cp=burf;
  55.     if (i=p_stoa(&cp,"%d %s",&n,chal)) {
  56.         p_print("Invalid challenge\r\n");
  57.         p_getch();
  58.         return 1;
  59.         };    
  60.  
  61.     p_print("Enter password: ");
  62.     j=0;
  63.     while (i=p_getch())    {
  64.  
  65.         if (i==8) {
  66.             p_putch(8);
  67.             p_putch(32);
  68.             p_putch(8);
  69.             j--;
  70.         } else {
  71.             p_putch(6);
  72.             passwd[j++]=i;
  73.             }
  74.         if (i==13) break;
  75.         if (j<=0)  j=0;
  76.         if (j>=64) j=63;
  77.         };
  78.  
  79.     passwd[--j]=0;
  80.     p_print("\r\nGenerating response..");
  81.     
  82.     
  83. //    p_getl("Enter Password: ",passwd,64);
  84.     i=skey(n,chal,passwd,burf);
  85.     p_print("\r\nResponse is %s\n\n\n\rPress any key to exit",burf);
  86.     p_getch();
  87.     return 0;
  88. };
  89.