129088Smarkm/*-
229088Smarkm * Copyright (c) 1991, 1993
329088Smarkm *	The Regents of the University of California.  All rights reserved.
429088Smarkm *
529088Smarkm * Redistribution and use in source and binary forms, with or without
629088Smarkm * modification, are permitted provided that the following conditions
729088Smarkm * are met:
829088Smarkm * 1. Redistributions of source code must retain the above copyright
929088Smarkm *    notice, this list of conditions and the following disclaimer.
1029088Smarkm * 2. Redistributions in binary form must reproduce the above copyright
1129088Smarkm *    notice, this list of conditions and the following disclaimer in the
1229088Smarkm *    documentation and/or other materials provided with the distribution.
1329088Smarkm * 3. All advertising materials mentioning features or use of this software
1429088Smarkm *    must display the following acknowledgement:
1529088Smarkm *	This product includes software developed by the University of
1629088Smarkm *	California, Berkeley and its contributors.
1729088Smarkm * 4. Neither the name of the University nor the names of its contributors
1829088Smarkm *    may be used to endorse or promote products derived from this software
1929088Smarkm *    without specific prior written permission.
2029088Smarkm *
2129088Smarkm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2229088Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2329088Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2429088Smarkm * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2529088Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2629088Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2729088Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2829088Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2929088Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3029088Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3129088Smarkm * SUCH DAMAGE.
3229088Smarkm */
3329088Smarkm
34114630Sobrien#if 0
3529088Smarkm#ifndef lint
3629181Smarkmstatic const char sccsid[] = "@(#)authenc.c	8.1 (Berkeley) 6/6/93";
3763248Speter#endif
38114630Sobrien#endif
39114630Sobrien#include <sys/cdefs.h>
40114630Sobrien__FBSDID("$FreeBSD$");
4129088Smarkm
4287139Smarkm#ifdef	AUTHENTICATION
4387139Smarkm#ifdef	ENCRYPTION
4429088Smarkm#include <sys/types.h>
4529088Smarkm#include <arpa/telnet.h>
4687139Smarkm#include <pwd.h>
4787139Smarkm#include <unistd.h>
4829088Smarkm#include <libtelnet/encrypt.h>
4929088Smarkm#include <libtelnet/misc.h>
5029088Smarkm
5129088Smarkm#include "general.h"
5229088Smarkm#include "ring.h"
5329088Smarkm#include "externs.h"
5429088Smarkm#include "defines.h"
5529088Smarkm#include "types.h"
5629088Smarkm
5787139Smarkmint
5887139Smarkmnet_write(unsigned char *str, int len)
5929088Smarkm{
6029088Smarkm	if (NETROOM() > len) {
6129088Smarkm		ring_supply_data(&netoring, str, len);
6229088Smarkm		if (str[0] == IAC && str[1] == SE)
6329088Smarkm			printsub('>', &str[2], len-2);
6429088Smarkm		return(len);
6529088Smarkm	}
6629088Smarkm	return(0);
6729088Smarkm}
6829088Smarkm
6987139Smarkmvoid
7087139Smarkmnet_encrypt(void)
7129088Smarkm{
7229088Smarkm#ifdef	ENCRYPTION
7329088Smarkm	if (encrypt_output)
7429088Smarkm		ring_encrypt(&netoring, encrypt_output);
7529088Smarkm	else
7629088Smarkm		ring_clearto(&netoring);
7729088Smarkm#endif	/* ENCRYPTION */
7829088Smarkm}
7929088Smarkm
8087139Smarkmint
8187139Smarkmtelnet_spin(void)
8229088Smarkm{
8329088Smarkm	return(-1);
8429088Smarkm}
8529088Smarkm
8687139Smarkmchar *
8787139Smarkmtelnet_getenv(char *val)
8829088Smarkm{
8929088Smarkm	return((char *)env_getvalue((unsigned char *)val));
9029088Smarkm}
9129088Smarkm
9287139Smarkmchar *
9387139Smarkmtelnet_gets(const char *prom, char *result, int length, int echo)
9429088Smarkm{
9529088Smarkm	extern int globalmode;
9629088Smarkm	int om = globalmode;
9729088Smarkm	char *res;
9829088Smarkm
9929088Smarkm	TerminalNewMode(-1);
10029088Smarkm	if (echo) {
10187139Smarkm		printf("%s", prom);
10229088Smarkm		res = fgets(result, length, stdin);
10387139Smarkm	} else if ((res = getpass(prom))) {
10429088Smarkm		strncpy(result, res, length);
10529088Smarkm		res = result;
10629088Smarkm	}
10729088Smarkm	TerminalNewMode(om);
10829088Smarkm	return(res);
10929088Smarkm}
11087139Smarkm#endif	/* ENCRYPTION */
11187139Smarkm#endif	/* AUTHENTICATION */
112