File:  [CSRG BSD Unix] / 43BSD / contrib / xns / morexnslib / auth / simpleauth.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:54 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3


/* $Header: /var/lib/cvsd/repos/CSRG/43BSD/contrib/xns/morexnslib/auth/simpleauth.c,v 1.1.1.1 2018/04/24 16:12:54 root Exp $

/* this module of authentication support contains:
 * MakeSimpleCredsAndVerifier
 */

/* $Log: simpleauth.c,v $
/* Revision 1.1.1.1  2018/04/24 16:12:54  root
/* BSD 4.3
/*
 * Revision 2.0  85/11/21  07:22:26  jqj
 * 4.3BSD standard release
 * 
 * Revision 1.1  85/03/26  06:29:11  jqj
 * Initial revision
 * 
 * Revision 1.1  85/03/26  06:29:11  jqj
 * Initial revision
 * 
 */

#include <xnscourier/Authentication1.h>
#include <ctype.h>

static Cardinal
hashpass(hpw)
	char *hpw;
{
	register unsigned long hash;
	register char c;

	hash = 0;
	while ((c = *hpw++) != '\0') {
		hash = (hash<<16) + (isupper(c) ? tolower(c) : c);
		hash %= 65357;
	}
	return((Cardinal) hash);
}


/*
 * Given an XNS name and password, return the appropriate
 * credentials and verifier associated with that name.
 * Per Authentication Protocol, XSIS ....
 */
MakeSimpleCredsAndVerifier(name, pwd, credentials, verifier)
	Authentication1_ClearinghouseName *name;
				/* the XNS user, in 3 fields */
	char *pwd;		/* password, a UNIX string */
	Authentication1_Credentials *credentials;
				/* the simple credentials to be returned */
	Authentication1_Verifier *verifier;
				/* associated verifier, i.e. HashedPassword */
{
	Cardinal length;
	Unspecified *data, *buf, *seq;
	static Authentication1_ClearinghouseName nullname = {"","",""};

	/* first, validate arguments */
	if (name == 0) name = &nullname;
	if (pwd == 0) pwd="";
	/* note we do NOT check that things are of appropriate types */

	if (credentials != 0) {
		credentials->type = Authentication1_simpleCredentials;
		length = sizeof_Authentication1_ClearinghouseName(name);
		data = Allocate(length);
		(void) externalize_Authentication1_ClearinghouseName(name,data);
		seq = credentials->value.sequence = Allocate(length);
		credentials->value.length = length;
		buf = data;
		for ( ; length > 0; length--, seq++)
		    buf += internalize_Unspecified(seq, buf);
		free(data);
	}
	if (verifier != 0) {
		verifier->length = 1;
		verifier->sequence = Allocate(sizeof_Unspecified(0));
		verifier->sequence[0] = (Unspecified) hashpass(pwd);
	}
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.