2 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 #pragma ident "%Z%%M% %I% %E% SMI"
9 * Miscellaneous routines needed by the telnet client for authentication
10 * and / or encryption.
14 * Copyright (c) 1991, 1993
15 * The Regents of the University of California. All rights reserved.
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 * 3. All advertising materials mentioning features or use of this software
26 * must display the following acknowledgement:
27 * This product includes software developed by the University of
28 * California, Berkeley and its contributors.
29 * 4. Neither the name of the University nor the names of its contributors
30 * may be used to endorse or promote products derived from this software
31 * without specific prior written permission.
33 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
34 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
35 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
36 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
37 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
41 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
42 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 static char sccsid
[] = "@(#)authenc.c 8.1 (Berkeley) 6/6/93";
50 #include <sys/types.h>
51 #include <arpa/telnet.h>
59 char *RemoteHostName
= NULL
;
60 char *UserNameRequested
= NULL
;
65 * Get ready to do authentication and encryption by calling their
66 * init routines, and clearing the user name variable
70 auth_encrypt_init(char *local
, char *remote
, char *name
)
72 RemoteHostName
= remote
;
78 if (UserNameRequested
) {
79 free(UserNameRequested
);
80 UserNameRequested
= NULL
;
85 * Set the user name variable. This is the user name used from now
86 * on for authentication and encryption
89 auth_encrypt_user(char *name
)
91 if (UserNameRequested
)
92 free(UserNameRequested
);
93 UserNameRequested
= name
? strdup(name
) : NULL
;
97 net_write(unsigned char *str
, int len
)
99 if (NETROOM() > len
) {
100 ring_supply_data(&netoring
, str
, len
);
101 if (str
[0] == IAC
&& str
[1] == SE
)
102 printsub('>', &str
[2], len
- 2);
112 ring_encrypt(&netoring
, encrypt_output
);
114 ring_clearto(&netoring
);
118 * Spin to wait for authentication to complete
119 * This allows for a timeout
124 extern boolean_t scheduler_lockout_tty
;
126 scheduler_lockout_tty
= B_TRUE
;
128 scheduler_lockout_tty
= B_FALSE
;
133 * Used to print out unsigned chars as decimals for debugging options
136 printd(unsigned char *data
, int cnt
)
138 cnt
= (cnt
< MAXNETDATA
) ? cnt
:MAXNETDATA
;
140 (void) printf(" %02x", *data
++);