|
|
1.1 root 1:
2: /* $Header: simpleauth.c,v 2.0 85/11/21 07:22:26 jqj Exp $
3:
4: /* this module of authentication support contains:
5: * MakeSimpleCredsAndVerifier
6: */
7:
8: /* $Log: simpleauth.c,v $
9: * Revision 2.0 85/11/21 07:22:26 jqj
10: * 4.3BSD standard release
11: *
12: * Revision 1.1 85/03/26 06:29:11 jqj
13: * Initial revision
14: *
15: * Revision 1.1 85/03/26 06:29:11 jqj
16: * Initial revision
17: *
18: */
19:
20: #include <xnscourier/Authentication2.h>
21: #include <ctype.h>
22:
23: static Cardinal
24: hashpass(hpw)
25: char *hpw;
26: {
27: register unsigned long hash;
28: register char c;
29:
30: hash = 0;
31: while ((c = *hpw++) != '\0') {
32: hash = (hash<<16) + (isupper(c) ? tolower(c) : c);
33: hash %= 65357;
34: }
35: return((Cardinal) hash);
36: }
37:
38:
39: /*
40: * Given an XNS name and password, return the appropriate
41: * credentials and verifier associated with that name.
42: * Per Authentication Protocol, XSIS ....
43: */
44: MakeSimpleCredsAndVerifier(name, pwd, credentials, verifier)
45: Authentication2_Clearinghouse_Name *name;
46: /* the XNS user, in 3 fields */
47: char *pwd; /* password, a UNIX string */
48: Authentication2_Credentials *credentials;
49: /* the simple credentials to be returned */
50: Authentication2_Verifier *verifier;
51: /* associated verifier, i.e. HashedPassword */
52: {
53: Cardinal length;
54: Unspecified *data, *buf, *seq;
55: static Authentication2_Clearinghouse_Name nullname = {"","",""};
56:
57: /* first, validate arguments */
58: if (name == 0) name = &nullname;
59: if (pwd == 0) pwd="";
60: /* note we do NOT check that things are of appropriate types */
61:
62: if (credentials != 0) {
63: credentials->type = Authentication2_simpleCredentials;
64: length = sizeof_Authentication2_Clearinghouse_Name(name);
65: data = Allocate(length);
66: (void) externalize_Authentication2_Clearinghouse_Name(name,data);
67: seq = credentials->value.sequence = Allocate(length);
68: credentials->value.length = length;
69: buf = data;
70: for ( ; length > 0; length--, seq++)
71: buf += internalize_Unspecified(seq, buf);
72: free(data);
73: }
74: if (verifier != 0) {
75: verifier->length = 1;
76: verifier->sequence = Allocate(sizeof_Unspecified(0));
77: verifier->sequence[0] = (Unspecified) hashpass(pwd);
78: }
79: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.