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. 13351432Semaste * 3. Neither the name of the University nor the names of its contributors 1429088Smarkm * may be used to endorse or promote products derived from this software 1529088Smarkm * without specific prior written permission. 1629088Smarkm * 1729088Smarkm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1829088Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1929088Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2029088Smarkm * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2129088Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2229088Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2329088Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2429088Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2529088Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2629088Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2729088Smarkm * SUCH DAMAGE. 2829088Smarkm */ 2929088Smarkm 3084305Smarkm#include <sys/cdefs.h> 3187139Smarkm 3284305Smarkm__FBSDID("$FreeBSD: stable/11/contrib/telnet/libtelnet/misc.c 351432 2019-08-23 17:40:47Z emaste $"); 3384305Smarkm 3429088Smarkm#ifndef lint 3563248Speter#if 0 3629181Smarkmstatic const char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/4/93"; 3763248Speter#endif 3829088Smarkm#endif /* not lint */ 3929088Smarkm 4029181Smarkm#include <stdio.h> 4129181Smarkm#include <stdlib.h> 4287139Smarkm#include <string.h> 4387139Smarkm 4429088Smarkm#include "misc.h" 4587139Smarkm#ifdef AUTHENTICATION 4629181Smarkm#include "auth.h" 4781965Smarkm#endif 4881965Smarkm#ifdef ENCRYPTION 4929181Smarkm#include "encrypt.h" 5081965Smarkm#endif /* ENCRYPTION */ 5129088Smarkm 5229088Smarkmchar *RemoteHostName; 5329088Smarkmchar *LocalHostName; 5429088Smarkmchar *UserNameRequested = 0; 5529088Smarkmint ConnectedCount = 0; 5629088Smarkm 5787139Smarkm#ifndef AUTHENTICATION 5887139Smarkm#define undef1 __unused 5987139Smarkm#else 6087139Smarkm#define undef1 6187139Smarkm#endif 6287139Smarkm 6387139Smarkmvoid 6487139Smarkmauth_encrypt_init(char *local, char *remote, const char *name undef1, int server undef1) 6529088Smarkm{ 6629088Smarkm RemoteHostName = remote; 6729088Smarkm LocalHostName = local; 6887139Smarkm#ifdef AUTHENTICATION 6929088Smarkm auth_init(name, server); 7029088Smarkm#endif 7129088Smarkm#ifdef ENCRYPTION 7229088Smarkm encrypt_init(name, server); 7329088Smarkm#endif /* ENCRYPTION */ 7429088Smarkm if (UserNameRequested) { 7529088Smarkm free(UserNameRequested); 7629088Smarkm UserNameRequested = 0; 7729088Smarkm } 7829088Smarkm} 7929088Smarkm 8087139Smarkm#ifdef ENCRYPTION 8187139Smarkmvoid 8287139Smarkmauth_encrypt_user(char *name) 8329088Smarkm{ 8429088Smarkm if (UserNameRequested) 8529088Smarkm free(UserNameRequested); 8629088Smarkm UserNameRequested = name ? strdup(name) : 0; 8729088Smarkm} 8829088Smarkm 8998882Smarkm/* ARGSUSED */ 9087139Smarkmvoid 9187139Smarkmauth_encrypt_connect(int cnt __unused) 9229088Smarkm{ 9329088Smarkm} 9487139Smarkm#endif /* ENCRYPTION */ 9529088Smarkm 9687139Smarkmvoid 9787139Smarkmprintd(const unsigned char *data, int cnt) 9829088Smarkm{ 9929088Smarkm if (cnt > 16) 10029088Smarkm cnt = 16; 10129088Smarkm while (cnt-- > 0) { 10229088Smarkm printf(" %02x", *data); 10329088Smarkm ++data; 10429088Smarkm } 10529088Smarkm} 106