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
3484305Smarkm#include <sys/cdefs.h>
3587139Smarkm
3684305Smarkm__FBSDID("$FreeBSD$");
3784305Smarkm
3829088Smarkm#ifndef lint
3963248Speter#if 0
4029181Smarkmstatic const char sccsid[] = "@(#)misc.c	8.1 (Berkeley) 6/4/93";
4163248Speter#endif
4229088Smarkm#endif /* not lint */
4329088Smarkm
4429181Smarkm#include <stdio.h>
4529181Smarkm#include <stdlib.h>
4687139Smarkm#include <string.h>
4787139Smarkm
4829088Smarkm#include "misc.h"
4987139Smarkm#ifdef	AUTHENTICATION
5029181Smarkm#include "auth.h"
5181965Smarkm#endif
5281965Smarkm#ifdef	ENCRYPTION
5329181Smarkm#include "encrypt.h"
5481965Smarkm#endif	/* ENCRYPTION */
5529088Smarkm
5629088Smarkmchar *RemoteHostName;
5729088Smarkmchar *LocalHostName;
5829088Smarkmchar *UserNameRequested = 0;
5929088Smarkmint ConnectedCount = 0;
6029088Smarkm
6187139Smarkm#ifndef AUTHENTICATION
6287139Smarkm#define undef1 __unused
6387139Smarkm#else
6487139Smarkm#define undef1
6587139Smarkm#endif
6687139Smarkm
6787139Smarkmvoid
6887139Smarkmauth_encrypt_init(char *local, char *remote, const char *name undef1, int server undef1)
6929088Smarkm{
7029088Smarkm	RemoteHostName = remote;
7129088Smarkm	LocalHostName = local;
7287139Smarkm#ifdef	AUTHENTICATION
7329088Smarkm	auth_init(name, server);
7429088Smarkm#endif
7529088Smarkm#ifdef	ENCRYPTION
7629088Smarkm	encrypt_init(name, server);
7729088Smarkm#endif	/* ENCRYPTION */
7829088Smarkm	if (UserNameRequested) {
7929088Smarkm		free(UserNameRequested);
8029088Smarkm		UserNameRequested = 0;
8129088Smarkm	}
8229088Smarkm}
8329088Smarkm
8487139Smarkm#ifdef	ENCRYPTION
8587139Smarkmvoid
8687139Smarkmauth_encrypt_user(char *name)
8729088Smarkm{
8829088Smarkm	if (UserNameRequested)
8929088Smarkm		free(UserNameRequested);
9029088Smarkm	UserNameRequested = name ? strdup(name) : 0;
9129088Smarkm}
9229088Smarkm
9398882Smarkm/* ARGSUSED */
9487139Smarkmvoid
9587139Smarkmauth_encrypt_connect(int cnt __unused)
9629088Smarkm{
9729088Smarkm}
9887139Smarkm#endif	/* ENCRYPTION */
9929088Smarkm
10087139Smarkmvoid
10187139Smarkmprintd(const unsigned char *data, int cnt)
10229088Smarkm{
10329088Smarkm	if (cnt > 16)
10429088Smarkm		cnt = 16;
10529088Smarkm	while (cnt-- > 0) {
10629088Smarkm		printf(" %02x", *data);
10729088Smarkm		++data;
10829088Smarkm	}
10929088Smarkm}
110