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/Authentication1.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:     Authentication1_ClearinghouseName *name;
  46:                 /* the XNS user, in 3 fields */
  47:     char *pwd;      /* password, a UNIX string */
  48:     Authentication1_Credentials *credentials;
  49:                 /* the simple credentials to be returned */
  50:     Authentication1_Verifier *verifier;
  51:                 /* associated verifier, i.e. HashedPassword */
  52: {
  53:     Cardinal length;
  54:     Unspecified *data, *buf, *seq;
  55:     static Authentication1_ClearinghouseName 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 = Authentication1_simpleCredentials;
  64:         length = sizeof_Authentication1_ClearinghouseName(name);
  65:         data = Allocate(length);
  66:         (void) externalize_Authentication1_ClearinghouseName(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: }

Defined functions

MakeSimpleCredsAndVerifier defined in line 44; never used
hashpass defined in line 23; used 1 times
  • in line 77
Last modified: 1986-03-13
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 836
Valid CSS Valid XHTML 1.0 Strict