ftp://ftp.smr.ru/pub/0/FreeBSD/releases/distfiles/xscreensaver-3.16.tar.gz
[xscreensaver] / driver / vms-hpwd.c
1 /*
2  *      VAX/VMS Password hashing routines:
3  *
4  *      uses the System Service SYS$HASH_PASSWORD
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation.  No representations are made about the suitability of this
11  * software for any purpose.  It is provided "as is" without express or 
12  * implied warranty.
13  *
14  */
15
16 #include <syidef.h>
17 #include <descrip.h>
18 #include <string.h>
19 #include <starlet.h>
20 /*
21  *      Hashing routine
22  */
23 hash_vms_password(output_buf,input_buf,input_length,username,encryption_type,salt)
24 char *output_buf;
25 char *input_buf;
26 int input_length;
27 char *username;
28 int encryption_type;
29 unsigned short salt;
30 {
31         struct dsc$descriptor_s password;
32         struct dsc$descriptor_s user;
33
34         /*
35          *  Check the VMS Version. If this is V5.4 or later, then
36          *  we can use the new system service SYS$HASH_PASSWORD.  Else
37          *  fail and return garbage.
38          */
39
40         static char VMS_Version[32];
41         struct {
42                 unsigned short int Size;
43                 unsigned short int Code;
44                 char *Buffer;
45                 unsigned short int *Resultant_Size;
46         } Item_List[2]={32, SYI$_VERSION, VMS_Version, 0, 0, 0};
47         struct {int Size; char *Ptr;} Descr1;
48
49         /*
50          *      Get the information
51          */
52         sys$getsyiw(0,0,0,Item_List,0,0,0);
53         /*
54          *      Call the old routine if this isn't V5.4 or later...
55          */
56 #ifndef __DECC
57         if ((VMS_Version[1] < '5') ||
58             ((VMS_Version[1] == '5') && (VMS_Version[3] < '4'))) {
59                 printf("Unsupported OS version\n");
60                 return(1);
61         }
62 #endif /* !__DECC */
63         /*
64          *      Call the SYS$HASH_PASSWORD system service...
65          */
66         password.dsc$b_dtype    = DSC$K_DTYPE_T;
67         password.dsc$b_class    = DSC$K_CLASS_S;
68         password.dsc$w_length   = input_length;
69         password.dsc$a_pointer  = input_buf;
70         user.dsc$b_dtype        = DSC$K_DTYPE_T;
71         user.dsc$b_class        = DSC$K_CLASS_S;
72         user.dsc$w_length       = strlen(username);
73         user.dsc$a_pointer      = username;
74         sys$hash_password (&password, encryption_type, salt, &user, output_buf);
75 }