Commit 16c719b4 authored by Niels Möller's avatar Niels Möller

* src/abstract_crypto.h: Some cleanup.

* src/abstract_io.h: Likewise.
* src/channel.c: Likewise.
* src/channel.h: Likewise.
* src/channel_commands.h: Likewise.
* src/connection.h: Likewise.
* src/connection_commands.c: Likewise.
* src/dh_exchange.c: Likewise.
* src/exception.h: Likewise.
* src/gateway.c: Likewise.
* src/gateway_channel.c: Likewise.
* src/gateway_commands.c: Likewise.
* src/handshake.c: Likewise.
* src/handshake.h: Likewise.
* src/io.h: Likewise.
* src/io_commands.c: Likewise.
* src/io_commands.h: Likewise.
* src/keyexchange.h: Likewise.
* src/lsh.c: Likewise.
* src/lsh_proxy.c: Likewise.
* src/lshg.c: Likewise.
* src/publickey_crypto.h: Likewise.
* src/randomness.c: Likewise.
* src/randomness.h: Likewise.
* src/read_packet.c: Likewise.
* src/rsa.c: Likewise.
* src/server_pty.h: Likewise.
* src/server_session.c: Likewise.
* src/sexp.h: Likewise.
* src/sexp_parser.c: Likewise.
* src/sexp_streamed_parser.c: Likewise.
* src/sexp_test.c: Likewise.
* src/spki_commands.c: Likewise.
* src/spki_commands.h: Likewise.
* src/ssh1_fallback.c: Likewise.
* src/tcpforward.c: Likewise.
* src/unix_random.c: Likewise.
* src/zlib.c: Likewise.

Rev: src/abstract_crypto.h:1.34
Rev: src/abstract_io.h:1.33
Rev: src/channel.c:1.89
Rev: src/channel.h:1.63
Rev: src/channel_commands.h:1.18
Rev: src/command.h:1.48
Rev: src/connection.h:1.58
Rev: src/connection_commands.c:1.34
Rev: src/dh_exchange.c:1.11
Rev: src/exception.h:1.24
Rev: src/gateway.c:1.4
Rev: src/gateway_channel.c:1.6
Rev: src/gateway_commands.c:1.7
Rev: src/handshake.c:1.2
Rev: src/handshake.h:1.2
Rev: src/io.h:1.70
Rev: src/io_commands.c:1.35
Rev: src/io_commands.h:1.15
Rev: src/keyexchange.h:1.49
Rev: src/lsh.c:1.128
Rev: src/lsh_proxy.c:1.20
Rev: src/lshg.c:1.5
Rev: src/publickey_crypto.h:1.43
Rev: src/randomness.c:1.22
Rev: src/randomness.h:1.13
Rev: src/read_packet.c:1.49
Rev: src/rsa.c:1.12
Rev: src/server_pty.h:1.12
Rev: src/server_session.c:1.56
Rev: src/sexp.h:1.32
Rev: src/sexp_parser.c:1.19
Rev: src/sexp_streamed_parser.c:1.28
Rev: src/sexp_test.c:1.15
Rev: src/spki_commands.c:1.15
Rev: src/spki_commands.h:1.9
Rev: src/ssh1_fallback.c:1.10
Rev: src/tcpforward.c:1.56
Rev: src/unix_random.c:1.4
Rev: src/zlib.c:1.29
parent 1f2b70e7
......@@ -137,7 +137,6 @@
"UINT32 length" "const UINT8 *data"
"struct sexp *e")
;; FIXME: Perhaps these methods belong to the algorithm object?
(public_key method (string))
; Returns ( <pub-sig-alg-id> <s-expr>* ), i.e. the same
......@@ -164,7 +163,6 @@
"int algorithm" "UINT32 length" "const UINT8 *data")
; Returns a <sig-val> sexp
(sign_spki method (object sexp)
;; "struct sexp *hash" "struct sexp *principal"
"UINT32 length" "const UINT8 *data")
(get_verifier method (object verifier))))
......@@ -185,10 +183,7 @@
"struct sexp_iterator *i")
(make_verifier method (object verifier)
"struct sexp_iterator *i")
;; (private2public method (object sexp)
;; "struct sexp_iterator *i")
))
"struct sexp_iterator *i")))
*/
#define MAKE_SIGNER(a, i) \
......
......@@ -59,13 +59,13 @@
(vars
(handler indirect-method
;; The method returns the amount of data processed.
;; On errors, it can set self to NULL, but only for
;; debugging purposes; it's the responibility of the the
;; exception handler to close the corresponding fd and
;; make sure that handler is not called again. '
; The method returns the amount of data processed.
; On errors, it can set self to NULL, but only for
; debugging purposes; it's the responibility of the the
; exception handler to close the corresponding fd and
; make sure that handler is not called again. '
;; Available is 0 iff we have got EOF.
; Available is 0 iff we have got EOF.
UINT32 "UINT32 available" "UINT8 *data")))
"struct exception_handler *e")))
*/
......
......@@ -168,7 +168,6 @@ prepare_window_adjust(struct ssh_channel *channel,
(super exception_handler)
(vars
(connection object ssh_connection)
;; (table object channel_table)
; Non-zero if the channel has already been deallocated.
(dead . int)
; Local channel number
......@@ -1040,9 +1039,6 @@ parse_channel_open(struct simple_buffer *buffer,
if (parse_uint8(buffer, &msg_number)
&& (msg_number == SSH_MSG_CHANNEL_OPEN)
&& parse_string(buffer, &info->type_length, &info->type_data)
#if 0
&& parse_atom(&buffer, &type)
#endif
&& parse_uint32(buffer, &info->remote_channel_number)
&& parse_uint32(buffer, &info->send_window_size)
&& parse_uint32(buffer, &info->send_max_packet))
......@@ -1075,14 +1071,8 @@ DEFINE_PACKET_HANDLER(static, channel_open_handler,
struct simple_buffer buffer;
struct channel_open_info info;
#if 0
unsigned msg_number;
int type;
UINT32 remote_channel_number;
UINT32 window_size;
UINT32 max_packet;
#endif
simple_buffer_init(&buffer, packet->length, packet->data);
if (parse_channel_open(&buffer, &info))
{
struct channel_open *open = NULL;
......@@ -2063,20 +2053,6 @@ format_channel_open_s(struct lsh_string *type,
args);
}
#if 0
struct lsh_string *
format_channel_open_a(int type,
UINT32 local_channel_number,
struct ssh_channel *channel,
struct lsh_string *args)
{
return ssh_format("%c%a%i%i%i%lS", SSH_MSG_CHANNEL_OPEN,
type, local_channel_number,
channel->rec_window_size, channel->rec_max_packet,
args);
}
#endif
struct lsh_string *
format_channel_open(int type, UINT32 local_channel_number,
struct ssh_channel *channel,
......
......@@ -34,15 +34,30 @@
#include "server_pty.h"
#include "write_buffer.h"
/* FIXME: Reorder definitions so that we don't need this forward
* declaration. */
struct channel_open_info;
struct channel_open_info
{
UINT32 type_length;
#if 0
struct channel_request;
#endif
/* NOTE: This is a pointer into the packet, so if it is needed later
* it must be copied. */
const UINT8 *type_data;
int type;
UINT32 remote_channel_number;
UINT32 send_window_size;
UINT32 send_max_packet;
};
struct channel_request_info;
struct channel_request_info
{
UINT32 type_length;
const UINT8 *type_data;
int type;
int want_reply;
};
#define GABA_DECLARE
#include "channel.h.x"
......@@ -136,8 +151,6 @@ struct channel_request_info;
(eof method void)
; Reply from SSH_MSG_CHANNEL_OPEN_REQUEST
;; (open_confirm method int)
;; (open_failure method int)
(open_continuation object command_continuation)
; Queue of channel requests that we expect replies on
......@@ -147,9 +160,7 @@ struct channel_request_info;
; in the right order
(active_requests struct object_queue)))
; Reply from SSH_MSG_CHANNEL_REQUEST
;; (channel_success method int)
;; (channel_failure method int))) */
*/
#define CHANNEL_RECEIVE(s, t, d) \
((s)->receive((s), (t), (d)))
......@@ -239,21 +250,6 @@ struct channel_request_info;
#define GLOBAL_REQUEST(r, c, t, w, a, n, e) ((r)->handler((r), (c), (t), (w), (a), (n), (e)))
/* SSH_MSG_CHANNEL_OPEN */
struct channel_open_info
{
UINT32 type_length;
/* NOTE: This is a pointer into the packet, so if it is needed later
* it must be copied. */
const UINT8 *type_data;
int type;
UINT32 remote_channel_number;
UINT32 send_window_size;
UINT32 send_max_packet;
};
/* Raised if opening of a channel fails. Used both on the client and
* the server side.*/
......@@ -276,9 +272,6 @@ make_channel_open_exception(UINT32 error_code, const char *msg);
(handler method void
"struct ssh_connection *connection"
"struct channel_open_info *info"
;; "UINT32 type"
;; "UINT32 send_window_size"
;; "UINT32 send_max_packet"
"struct simple_buffer *data"
"struct command_continuation *c"
"struct exception_handler *e")))
......@@ -289,17 +282,6 @@ make_channel_open_exception(UINT32 error_code, const char *msg);
/* SSH_MSG_CHANNEL_REQUEST */
struct channel_request_info
{
UINT32 type_length;
const UINT8 *type_data;
int type;
int want_reply;
};
/* GABA:
(class
(name channel_request)
......@@ -308,8 +290,6 @@ struct channel_request_info
"struct ssh_channel *channel"
"struct ssh_connection *connection"
"struct channel_request_info *info"
;; "UINT32 type"
;; "int want_reply"
"struct simple_buffer *args"
"struct command_continuation *c"
"struct exception_handler *e")))
......
......@@ -40,9 +40,9 @@
(name channel_open_command)
(super command)
(vars
;; This method should return a partially filled in channel,
;; and create a channel open request by calling
;; prepare_channel_open.
; This method should return a partially filled in channel,
; and create a channel open request by calling
; prepare_channel_open.
(new_channel method "struct ssh_channel *"
"struct ssh_connection *connection"
"UINT32 local_channel_number"
......@@ -63,9 +63,9 @@ void do_channel_open_command(struct command *s,
(name channel_request_command)
(super command)
(vars
;; This method should return a formatted request. The
;; want_reply field in the request should be non_zero iff *c is
;; non-NULL on return.
; This method should return a formatted request. The
; want_reply field in the request should be non_zero iff *c is
; non-NULL on return.
(format_request method "struct lsh_string *"
"struct ssh_channel *channel"
"struct command_continuation **c")))
......
......@@ -60,8 +60,8 @@
(name command_simple)
(super command)
(vars
;; Like call, but returns the value immediately rather than
;; using a continuation function
; Like call, but returns the value immediately rather than
; using a continuation function.
(call_simple method "struct lsh_object *" "struct lsh_object *")))
*/
......@@ -211,11 +211,10 @@ do_catch_report_collect(struct command_simple *s,
(class
(name collect_info_4)
(vars
; No next field
(f method "struct lsh_object *"
"struct lsh_object *" "struct lsh_object *"
"struct lsh_object *" "struct lsh_object *")
;; No next field
))
"struct lsh_object *" "struct lsh_object *")))
*/
/* GABA:
......
......@@ -179,15 +179,10 @@ do_##NAME(struct packet_handler *s UNUSED, \
; Table of all opened channels
(table object channel_table)
;; ; Shared handlers
;; (ignore object packet_handler)
;; (unimplemented object packet_handler)
;; (fail object packet_handler)
;; (forward object packet_handler)
; (provides_privacy . int)
; (provides_integrity . int)
)) */
))
*/
#define C_WRITE(c, s) A_WRITE((c)->write, (s) )
......
......@@ -37,13 +37,6 @@
#include "connection_commands.c.x"
/* ;;GABA:
(class
(name connection_remember_command)
(super command)
(vars
(connection object ssh_connection)))
*/
static void
do_connection_remember(struct command *s,
......
......@@ -43,9 +43,8 @@ init_dh_instance(struct dh_method *m,
mpz_init(self->e);
mpz_init(self->f);
mpz_init(self->secret);
#if 0
mpz_init(self->K);
#endif
self->K = NULL;
self->method = m;
self->hash = MAKE_HASH(m->H);
......@@ -229,16 +228,3 @@ dh_process_server_msg(struct dh_instance *self,
return key;
}
#if 0
int
dh_verify_server_msg(struct dh_instance *self,
struct verifier *v)
{
dh_hash_digest(self);
return VERIFY(v,
self->hash->hash_size, self->exchange_hash->data,
self->signature->length, self->signature->data);
}
#endif
......@@ -199,8 +199,8 @@ make_exception_handler(void (*raise)(struct exception_handler *s,
(name protocol_exception)
(super exception)
(vars
;; A reason code that can be passed in a SSH_MSG_DISCONNECT message.
;; Zero means terminate the connection without sending such a message.
; A reason code that can be passed in a SSH_MSG_DISCONNECT message.
; Zero means terminate the connection without sending such a message.
(reason . UINT32)))
*/
......
......@@ -99,7 +99,7 @@ make_gateway_address(char *local_user, char *remote_user,
(class
(name gateway)
(vars
;; Where to send packets
; Where to send packets
(local object abstract_write)))
*/
......@@ -165,14 +165,6 @@ do_gateway_channel_open(struct channel_open_command *c,
&target->super,
closure->args);
#if 0
if (closure->args)
*request = format_channel_open(closure->type, local_channel_number,
&target->super, "%lS", closure->args);
else
*request = format_channel_open(closure->type, local_channel_number,
&target->super, "");
#endif
return &target->super;
}
......
......@@ -150,14 +150,6 @@ DEFINE_COMMAND(gateway_init, a, c, e)
/* (gateway_accept main-connection gateway-connection) */
/* ;; GABA:
(class
(name gateway_accept_command)
(super command)
(vars
(connection object ssh_connection)))
*/
static void
do_gateway_accept(struct command *s,
struct lsh_object *x,
......@@ -220,11 +212,3 @@ DEFINE_COMMAND_SIMPLE(gateway_setup_command, a)
return &res->super;
}
#if 0
DEFINE_PACKET_HANDLER(static, forward_channel_open_handler,
connection, packet)
{
}
#endif
......@@ -53,7 +53,7 @@
(super line_handler)
(vars
(connection object ssh_connection)
;; Needed for fallback.
; Needed for fallback.
(fd . int)
(fallback object ssh1_fallback)))
*/
......
......@@ -48,7 +48,7 @@
(random object randomness)
(algorithms object alist)
;; Used only on the server
; Used only on the server
(fallback object ssh1_fallback)))
*/
......
......@@ -86,7 +86,6 @@ extern struct lsh_class io_backend_class;
; which seems kind of bogus.
(e object exception_handler)
;;(close_reason . int)
; User's close callback
(close_callback object lsh_callback)
......@@ -199,9 +198,9 @@ make_listen_value(struct lsh_fd *fd,
(name io_exception)
(super exception)
(vars
;; NULL if no fd was involved
; NULL if no fd was involved
(fd object lsh_fd)
;; errno code, or zero if not available
; errno code, or zero if not available
(error . int))))
*/
......
......@@ -265,74 +265,6 @@ STATIC_COLLECT_2_FINAL(collect_listen_callback);
struct collect_info_1 listen_with_callback =
STATIC_COLLECT_1(&collect_info_listen_callback_2);
#if 0
/* A listen function taking three arguments:
* (listen backend connection port).
*
* Suitable for handling forwarding requests. Adds all fd:s to the
* connection's resource list automatically.
*
* NOTE: On second thought, this is not terribly useful, because
* accepted fd:s should usually be registered on a channels's resource
* list, not on the connection's. */
/* ;; GABA:
(class
(name listen_with_connection)
(super command)
(vars
(connection object ssh_connection)
(backend object io_backend)))
*/
static void
do_listen_with_connection(struct command *s,
struct lsh_object *x,
struct command_continuation *c,
struct exception_handler *e)
{
CAST(listen_with_connection, self, s);
CAST(address_info, address, x);
/* No dns lookups */
do_listen(self->backend, address, 0,
self->connection->resources,
NULL,
c, e);
}
struct command *
make_listen_with_connection(struct io_backend *backend,
struct ssh_connection *connection)
{
NEW(listen_with_connection, self);
self->connection = connection;
self->backend = backend;
self->super.call = do_listen_with_connection;
return &self->super;
}
static struct lsh_object *
collect_listen_connection(struct collect_info_2 *info,
struct lsh_object *a,
struct lsh_object *b)
{
CAST(io_backend, backend, a);
CAST(ssh_connection, connection, b);
assert(!info->next);
return &make_listen_with_connection(backend, connection)->super;
}
static struct collect_info_2 collect_info_listen_connection_2 =
STATIC_COLLECT_2_FINAL(collect_listen_connection);
struct collect_info_1 listen_with_connection =
STATIC_COLLECT_1(&collect_info_listen_connection_2);
#endif
/* GABA:
(class
(name connect_continuation)
......
......@@ -85,12 +85,8 @@ extern struct collect_info_1 listen_with_callback;
#define LISTEN_CALLBACK (&listen_with_callback.super.super.super)
#if 0
struct command *
make_listen_with_connection(struct io_backend *backend,
struct ssh_connection *connection);
#endif
#define LISTEN_CONNECTION (&listen_with_connection.super.super.super)
#endif
extern struct collect_info_1 connect_with_port;
#define CONNECT_PORT (&connect_with_port.super.super.super)
......
......@@ -71,6 +71,7 @@
(vars
;; FIXME: Add some method or attribute describing
;; the requirements on the hostkey algorithm.
; Algorithms is an array indexed by the KEX_* values above
(init method void
"struct ssh_connection *connection"
......@@ -94,7 +95,7 @@
(languages_client_to_server object int_list)
(languages_server_to_client object int_list)
(first_kex_packet_follows . int)
;; Used may be NULL. Used only for sending.
; May be NULL. Used only for sending.
(first_kex_packet string)))
*/
......
......@@ -72,11 +72,6 @@
#include "lsh_argp.h"
/* Forward declarations */
#if 0
struct command_simple options2remote;
#define OPTIONS2REMOTE (&options2remote.super.super)
#endif
struct command_simple lsh_verifier_command;
#define OPTIONS2VERIFIER (&lsh_verifier_command.super.super)
......@@ -116,26 +111,12 @@ STATIC_REQUEST_SERVICE(ATOM_SSH_CONNECTION);
(super client_options)
(vars
(algorithms object algorithms_options)
;; (backend object io_backend)
(random object randomness_with_poll)
;; (tty object interact)
(signature_algorithms object alist)
(home . "const char *")
; For i/o exceptions
;; (handler object exception_handler)
;; (exit_code . "int *")
;; (not . int)
;; (port . "char *")
;; (remote object address_info)
;; (local_user . "char *")
;; (user . "char *")
(identity . "char *")
(with_publickey . int)
......@@ -157,30 +138,7 @@ STATIC_REQUEST_SERVICE(ATOM_SSH_CONNECTION);
(known_hosts . "const char *")
; -1 means default behaviour
;; (with_pty . int)
;; (with_remote_peers . int)
; Session modifiers
;; (stdin_file . "const char *")
;; (stdout_file . "const char *")
;; (stderr_file . "const char *")
; fork() extra processes for handling stdio file-descriptors,
; to avoid setting them in non-blocking mode.
;; (stdin_fork . int)
;; (stdout_fork . int)
;; (stderr_fork . int)
; True if the process's stdin or pty (respectively) has been used.
;; (used_stdin . int)
;; (used_pty . int)
;; (start_shell . int)
(start_gateway . int)
(remote_forward . int)))
;; (actions struct object_queue)))
(start_gateway . int)))
*/
......@@ -194,13 +152,6 @@ make_options(struct io_backend *backend,
self->algorithms
= make_algorithms_options(all_symmetric_algorithms());
#if 0
init_algorithms_options(&self->super, all_symmetric_algorithms());
self->backend = backend;
self->tty = make_unix_interact(backend);
#endif
self->random = make_default_random(NULL, handler);
......@@ -208,45 +159,14 @@ make_options(struct io_backend *backend,
self->signature_algorithms = all_signature_algorithms(&self->random->super);
#if 0
self->handler = handler;
self->exit_code = exit_code;
self->not = 0;
self->remote = NULL;
self->local_user = self->user = getenv("LOGNAME");
/* Default behaviour is to lookup the "ssh" service, and fall back
* to port 22 if that fails. */
self->port = NULL;
#endif
self->sloppy = 0;
self->capture = NULL;
self->capture_file = NULL;
self->known_hosts = NULL;
/* self->known_hosts_file = NULL; */
#if 0
self->stdin_file = NULL;
self->stdout_file = NULL;
self->stderr_file = NULL;
self->used_stdin = 0;
self->stdin_fork = 0;
self->stdout_fork = 0;
self->stderr_fork = 0;
self->with_pty = -1;
self->start_shell = 1;
self->with_remote_peers = 0;
#endif
self->start_gateway = 0;
#if 0
object_queue_init(&self->actions);
#endif
self->with_publickey = 1;
self->with_srp_keyexchange = 0;
......@@ -261,14 +181,6 @@ make_options(struct io_backend *backend,
return self;
}
#if 0
/* Host to connect to */
DEFINE_COMMAND_SIMPLE(options2remote, a)
{
CAST(lsh_options, options, a);