C   116
chkpw
Guest on 17th May 2022 04:37:52 PM


  1. #include <string.h>
  2.  
  3. #include <descrip.h>
  4.  
  5. #include <uaidef.h>
  6.  
  7.  
  8.  
  9. struct itmlst { short length,code;
  10.  
  11.                 long buffer,retlen; };
  12.  
  13.  
  14.  
  15. int sys$getuai();
  16.  
  17. int sys$hash_password();
  18.  
  19.  
  20.  
  21. void chkpw(char *un,char *pw,int *ok)
  22.  
  23. {
  24.  
  25.    long pwd[2],hpwd[2];
  26.  
  27.    short salt;
  28.  
  29.    char encryp;
  30.  
  31.    struct dsc$descriptor_s undesc,pwdesc;
  32.  
  33.    struct itmlst items[4] = { {2,UAI$_SALT,&salt,0} , {1,UAI$_ENCRYPT,&encryp,0} ,
  34.  
  35.                               {8,UAI$_PWD,&pwd,0} , {0,0,0,0} };
  36.  
  37.    undesc.dsc$w_length = strlen(un);
  38.  
  39.    undesc.dsc$b_dtype = DSC$K_DTYPE_T;
  40.  
  41.    undesc.dsc$b_class = DSC$K_CLASS_S;
  42.  
  43.    undesc.dsc$a_pointer = un;
  44.  
  45.    pwdesc.dsc$w_length = strlen(pw);
  46.  
  47.    pwdesc.dsc$b_dtype = DSC$K_DTYPE_T;
  48.  
  49.    pwdesc.dsc$b_class = DSC$K_CLASS_S;
  50.  
  51.    pwdesc.dsc$a_pointer = pw;
  52.  
  53.    sys$getuai(0,0,&undesc,&items,0,0,0);
  54.  
  55.    sys$hash_password(&pwdesc,encryp,salt,&undesc,&hpwd);
  56.  
  57.    *ok = ((pwd[0]==hpwd[0])&&(pwd[1]==hpwd[1]));
  58.  
  59.    return;
  60.  
  61. }

Raw Paste

Login or Register to edit or fork this paste. It's free.