1 /*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)misc.c 8.1 (Berkeley) 6/4/93
30 * $FreeBSD: src/crypto/telnet/libtelnet/misc.c,v 1.2.8.2 2002/04/13 10:59:07 markm Exp $
31 */
32
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36
37 #include "misc.h"
38 #ifdef AUTHENTICATION
39 #include "auth.h"
40 #endif
41 #ifdef ENCRYPTION
42 #include "encrypt.h"
43 #endif /* ENCRYPTION */
44
45 char *RemoteHostName;
46 char *LocalHostName;
47 char *UserNameRequested = NULL;
48 int ConnectedCount = 0;
49
50 #ifndef AUTHENTICATION
51 #define undef1 __unused
52 #else
53 #define undef1
54 #endif
55
56 void
auth_encrypt_init(char * local,char * remote,const char * name undef1,int server undef1)57 auth_encrypt_init(char *local, char *remote, const char *name undef1, int server undef1)
58 {
59 RemoteHostName = remote;
60 LocalHostName = local;
61 #ifdef AUTHENTICATION
62 auth_init(name, server);
63 #endif
64 #ifdef ENCRYPTION
65 encrypt_init(name, server);
66 #endif /* ENCRYPTION */
67 if (UserNameRequested) {
68 free(UserNameRequested);
69 UserNameRequested = NULL;
70 }
71 }
72
73 #ifdef ENCRYPTION
74 void
auth_encrypt_user(char * name)75 auth_encrypt_user(char *name)
76 {
77 if (UserNameRequested)
78 free(UserNameRequested);
79 UserNameRequested = name ? strdup(name) : NULL;
80 }
81
82 void
auth_encrypt_connect(int cnt __unused)83 auth_encrypt_connect(int cnt __unused)
84 {
85 }
86 #endif /* ENCRYPTION */
87
88 void
printd(const unsigned char * data,int cnt)89 printd(const unsigned char *data, int cnt)
90 {
91 if (cnt > 16)
92 cnt = 16;
93 while (cnt-- > 0) {
94 printf(" %02x", *data);
95 ++data;
96 }
97 }
98