plan 9 kernel history: overview | file list | diff list

1993/0428/port/auth.c (diff list | history)

1993/0427/sys/src/9/port/auth.c:150,1561993/0428/sys/src/9/port/auth.c:150,155 (short | long | prev | next)
1993/0407    
			poperror(); 
			if(convM2S(buf, &f, n) == 0){ 
1993/0411    
				unlock(&s->send); 
1993/0427    
print("error converting %d bytes %ux %ux %ux\n", n, buf[0], buf[1], buf[2]); 
1993/0407    
				error(Emountrpc); 
			} 
			switch(f.type){ 
1993/0427/sys/src/9/port/auth.c:164,1701993/0428/sys/src/9/port/auth.c:163,168
1993/0407    
				error(f.ename); 
			default: 
1993/0411    
				unlock(&s->send); 
1993/0427    
print("error using %d bytes %ux %ux %ux\n", n, buf[0], buf[1], buf[2]); 
1993/0407    
				error(Emountrpc); 
			} 
1993/0330    
		} 
1993/0427/sys/src/9/port/auth.c:363,3701993/0428/sys/src/9/port/auth.c:361,368
1993/0330    
 * 
 *  The protocol is 
 *	1) read ticket request from #c/authenticate 
 *	2) write ticket to #c/authenticate. if it matchs the challenge the 
 *	  user is changed to the suid field of the ticket 
1993/0428    
 *	2) write ticket+authenticator to #c/authenticate. if it matches 
 *	  the challenge the user is changed to the suid field of the ticket 
1993/0330    
 *	3) read authenticator (to confirm this is the server advertised) 
 */ 
long 
1993/0427/sys/src/9/port/auth.c:382,3871993/0428/sys/src/9/port/auth.c:380,386
1993/0330    
			error(Ebadarg); 
		c->aux = newcrypt(); 
		cp = c->aux; 
1993/0428    
 
1993/0330    
		memset(&tr, 0, sizeof(tr)); 
		tr.type = AuthTreq; 
		strcpy(tr.hostid, eve); 
1993/0427/sys/src/9/port/auth.c:399,4081993/0428/sys/src/9/port/auth.c:398,410
1993/0330    
		if(n != AUTHENTLEN) 
			error(Ebadarg); 
		cp = c->aux; 
1993/0428    
 
1993/0330    
		cp->a.num = AuthAs; 
		memmove(cp->a.chal, cp->t.chal, CHALLEN); 
		cp->a.id = 0; 
		convA2M(&cp->a, a, cp->t.key); 
1993/0428    
		convA2M(&cp->a, cp->tbuf, cp->t.key); 
		memmove(a, cp->tbuf, AUTHENTLEN); 
 
1993/0330    
		freecrypt(cp); 
		c->aux = 0; 
	} 
1993/0427/sys/src/9/port/auth.c:414,4271993/0428/sys/src/9/port/auth.c:416,437
1993/0330    
{ 
	Crypt *cp; 
 
	if(n != TICKETLEN) 
1993/0428    
	if(n != TICKETLEN+AUTHENTLEN) 
1993/0330    
		error(Ebadarg); 
	if(c->aux == 0) 
		error(Ebadarg); 
	cp = c->aux; 
	convM2T(a, &cp->t, evekey); 
1993/0428    
 
	memmove(cp->tbuf, a, TICKETLEN); 
	convM2T(cp->tbuf, &cp->t, evekey); 
1993/0330    
	if(cp->t.num != AuthTs || memcmp(cp->a.chal, cp->t.chal, CHALLEN)) 
		error(Eperm); 
1993/0428    
 
	memmove(cp->tbuf, a+TICKETLEN, AUTHENTLEN); 
	convM2A(cp->tbuf, &cp->a, cp->t.key); 
	if(cp->a.num != AuthAc || memcmp(cp->a.chal, cp->t.chal, CHALLEN)) 
		error(Eperm); 
 
1993/0330    
	memmove(u->p->user, cp->t.suid, NAMELEN); 
	return n; 
} 
1993/0427/sys/src/9/port/auth.c:441,4541993/0428/sys/src/9/port/auth.c:451,514
1993/0330    
	if(c->aux == 0) 
		c->aux = newcrypt(); 
	cp = c->aux; 
	convM2T(a, &cp->t, evekey); 
1993/0428    
 
	memmove(cp->tbuf, a, TICKETLEN); 
	convM2T(cp->tbuf, &cp->t, evekey); 
1993/0402    
	if(cp->t.num != AuthTc) 
1993/0330    
		error(Ebadarg); 
1993/0402    
	if(strcmp(u->p->user, cp->t.cuid)) 
		error(cp->t.cuid); 
1993/0330    
	convM2A(a+TICKETLEN, &cp->a, cp->t.key); 
1993/0428    
 
	memmove(cp->tbuf, a+TICKETLEN, AUTHENTLEN); 
	convM2A(cp->tbuf, &cp->a, cp->t.key); 
1993/0330    
	if(cp->a.num != AuthAs || memcmp(cp->t.chal, cp->a.chal, CHALLEN)) 
		error(Eperm); 
1993/0428    
 
	return n; 
} 
 
/* 
 *  called by devcons() for #c/authenticator 
 * 
 *  a read after a write of a ticket returns an authenticator 
 *  for that ticket. 
 */ 
long 
authentwrite(Chan *c, char *a, int n) 
{ 
	Crypt *cp; 
 
	if(n != TICKETLEN) 
		error(Ebadarg); 
	if(c->aux == 0) 
		c->aux = newcrypt(); 
	cp = c->aux; 
 
	memmove(cp->tbuf, a, TICKETLEN); 
	convM2T(cp->tbuf, &cp->t, evekey); 
	if(cp->t.num != AuthTc || strcmp(cp->t.cuid, u->p->user)){ 
		freecrypt(cp); 
		c->aux = 0; 
		error(Ebadarg); 
	} 
 
	return n; 
} 
long 
authentread(Chan *c, char *a, int n) 
{ 
	Crypt *cp; 
 
	cp = c->aux; 
	if(cp == 0) 
		error("authenticator read must follow a write"); 
 
	cp->a.num = AuthAc; 
	memmove(cp->a.chal, cp->t.chal, CHALLEN); 
	cp->a.id = 0; 
	convA2M(&cp->a, cp->tbuf, cp->t.key); 
	memmove(a, cp->tbuf, AUTHENTLEN); 
 
1993/0330    
	return n; 
} 
 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)