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 @@ ...@@ -137,7 +137,6 @@
"UINT32 length" "const UINT8 *data" "UINT32 length" "const UINT8 *data"
"struct sexp *e") "struct sexp *e")
;; FIXME: Perhaps these methods belong to the algorithm object?
(public_key method (string)) (public_key method (string))
; Returns ( <pub-sig-alg-id> <s-expr>* ), i.e. the same ; Returns ( <pub-sig-alg-id> <s-expr>* ), i.e. the same
...@@ -164,7 +163,6 @@ ...@@ -164,7 +163,6 @@
"int algorithm" "UINT32 length" "const UINT8 *data") "int algorithm" "UINT32 length" "const UINT8 *data")
; Returns a <sig-val> sexp ; Returns a <sig-val> sexp
(sign_spki method (object sexp) (sign_spki method (object sexp)
;; "struct sexp *hash" "struct sexp *principal"
"UINT32 length" "const UINT8 *data") "UINT32 length" "const UINT8 *data")
(get_verifier method (object verifier)))) (get_verifier method (object verifier))))
...@@ -185,10 +183,7 @@ ...@@ -185,10 +183,7 @@
"struct sexp_iterator *i") "struct sexp_iterator *i")
(make_verifier method (object verifier) (make_verifier method (object verifier)
"struct sexp_iterator *i") "struct sexp_iterator *i")))
;; (private2public method (object sexp)
;; "struct sexp_iterator *i")
))
*/ */
#define MAKE_SIGNER(a, i) \ #define MAKE_SIGNER(a, i) \
......
...@@ -59,13 +59,13 @@ ...@@ -59,13 +59,13 @@
(vars (vars
(handler indirect-method (handler indirect-method
;; The method returns the amount of data processed. ; The method returns the amount of data processed.
;; On errors, it can set self to NULL, but only for ; On errors, it can set self to NULL, but only for
;; debugging purposes; it's the responibility of the the ; debugging purposes; it's the responibility of the the
;; exception handler to close the corresponding fd and ; exception handler to close the corresponding fd and
;; make sure that handler is not called again. ' ; 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"))) UINT32 "UINT32 available" "UINT8 *data")))
"struct exception_handler *e"))) "struct exception_handler *e")))
*/ */
......
...@@ -168,7 +168,6 @@ prepare_window_adjust(struct ssh_channel *channel, ...@@ -168,7 +168,6 @@ prepare_window_adjust(struct ssh_channel *channel,
(super exception_handler) (super exception_handler)
(vars (vars
(connection object ssh_connection) (connection object ssh_connection)
;; (table object channel_table)
; Non-zero if the channel has already been deallocated. ; Non-zero if the channel has already been deallocated.
(dead . int) (dead . int)
; Local channel number ; Local channel number
...@@ -1040,9 +1039,6 @@ parse_channel_open(struct simple_buffer *buffer, ...@@ -1040,9 +1039,6 @@ parse_channel_open(struct simple_buffer *buffer,
if (parse_uint8(buffer, &msg_number) if (parse_uint8(buffer, &msg_number)
&& (msg_number == SSH_MSG_CHANNEL_OPEN) && (msg_number == SSH_MSG_CHANNEL_OPEN)
&& parse_string(buffer, &info->type_length, &info->type_data) && 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->remote_channel_number)
&& parse_uint32(buffer, &info->send_window_size) && parse_uint32(buffer, &info->send_window_size)
&& parse_uint32(buffer, &info->send_max_packet)) && parse_uint32(buffer, &info->send_max_packet))
...@@ -1075,14 +1071,8 @@ DEFINE_PACKET_HANDLER(static, channel_open_handler, ...@@ -1075,14 +1071,8 @@ DEFINE_PACKET_HANDLER(static, channel_open_handler,
struct simple_buffer buffer; struct simple_buffer buffer;
struct channel_open_info info; 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); simple_buffer_init(&buffer, packet->length, packet->data);
if (parse_channel_open(&buffer, &info)) if (parse_channel_open(&buffer, &info))
{ {
struct channel_open *open = NULL; struct channel_open *open = NULL;
...@@ -2063,20 +2053,6 @@ format_channel_open_s(struct lsh_string *type, ...@@ -2063,20 +2053,6 @@ format_channel_open_s(struct lsh_string *type,
args); 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 * struct lsh_string *
format_channel_open(int type, UINT32 local_channel_number, format_channel_open(int type, UINT32 local_channel_number,
struct ssh_channel *channel, struct ssh_channel *channel,
......
...@@ -34,15 +34,30 @@ ...@@ -34,15 +34,30 @@
#include "server_pty.h" #include "server_pty.h"
#include "write_buffer.h" #include "write_buffer.h"
/* FIXME: Reorder definitions so that we don't need this forward struct channel_open_info
* declaration. */ {
struct channel_open_info; UINT32 type_length;
#if 0 /* NOTE: This is a pointer into the packet, so if it is needed later
struct channel_request; * it must be copied. */
#endif 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 #define GABA_DECLARE
#include "channel.h.x" #include "channel.h.x"
...@@ -136,8 +151,6 @@ struct channel_request_info; ...@@ -136,8 +151,6 @@ struct channel_request_info;
(eof method void) (eof method void)
; Reply from SSH_MSG_CHANNEL_OPEN_REQUEST ; Reply from SSH_MSG_CHANNEL_OPEN_REQUEST
;; (open_confirm method int)
;; (open_failure method int)
(open_continuation object command_continuation) (open_continuation object command_continuation)
; Queue of channel requests that we expect replies on ; Queue of channel requests that we expect replies on
...@@ -147,9 +160,7 @@ struct channel_request_info; ...@@ -147,9 +160,7 @@ struct channel_request_info;
; in the right order ; in the right order
(active_requests struct object_queue))) (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) \ #define CHANNEL_RECEIVE(s, t, d) \
((s)->receive((s), (t), (d))) ((s)->receive((s), (t), (d)))
...@@ -239,21 +250,6 @@ struct channel_request_info; ...@@ -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))) #define GLOBAL_REQUEST(r, c, t, w, a, n, e) ((r)->handler((r), (c), (t), (w), (a), (n), (e)))
/* SSH_MSG_CHANNEL_OPEN */ /* 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 /* Raised if opening of a channel fails. Used both on the client and
* the server side.*/ * the server side.*/
...@@ -276,9 +272,6 @@ make_channel_open_exception(UINT32 error_code, const char *msg); ...@@ -276,9 +272,6 @@ make_channel_open_exception(UINT32 error_code, const char *msg);
(handler method void (handler method void
"struct ssh_connection *connection" "struct ssh_connection *connection"
"struct channel_open_info *info" "struct channel_open_info *info"
;; "UINT32 type"
;; "UINT32 send_window_size"
;; "UINT32 send_max_packet"
"struct simple_buffer *data" "struct simple_buffer *data"
"struct command_continuation *c" "struct command_continuation *c"
"struct exception_handler *e"))) "struct exception_handler *e")))
...@@ -289,17 +282,6 @@ make_channel_open_exception(UINT32 error_code, const char *msg); ...@@ -289,17 +282,6 @@ make_channel_open_exception(UINT32 error_code, const char *msg);
/* SSH_MSG_CHANNEL_REQUEST */ /* SSH_MSG_CHANNEL_REQUEST */
struct channel_request_info
{
UINT32 type_length;
const UINT8 *type_data;
int type;
int want_reply;
};
/* GABA: /* GABA:
(class (class
(name channel_request) (name channel_request)
...@@ -308,8 +290,6 @@ struct channel_request_info ...@@ -308,8 +290,6 @@ struct channel_request_info
"struct ssh_channel *channel" "struct ssh_channel *channel"
"struct ssh_connection *connection" "struct ssh_connection *connection"
"struct channel_request_info *info" "struct channel_request_info *info"
;; "UINT32 type"
;; "int want_reply"
"struct simple_buffer *args" "struct simple_buffer *args"
"struct command_continuation *c" "struct command_continuation *c"
"struct exception_handler *e"))) "struct exception_handler *e")))
......
...@@ -40,9 +40,9 @@ ...@@ -40,9 +40,9 @@
(name channel_open_command) (name channel_open_command)
(super command) (super command)
(vars (vars
;; This method should return a partially filled in channel, ; This method should return a partially filled in channel,
;; and create a channel open request by calling ; and create a channel open request by calling
;; prepare_channel_open. ; prepare_channel_open.
(new_channel method "struct ssh_channel *" (new_channel method "struct ssh_channel *"
"struct ssh_connection *connection" "struct ssh_connection *connection"
"UINT32 local_channel_number" "UINT32 local_channel_number"
...@@ -63,9 +63,9 @@ void do_channel_open_command(struct command *s, ...@@ -63,9 +63,9 @@ void do_channel_open_command(struct command *s,
(name channel_request_command) (name channel_request_command)
(super command) (super command)
(vars (vars
;; This method should return a formatted request. The ; This method should return a formatted request. The
;; want_reply field in the request should be non_zero iff *c is ; want_reply field in the request should be non_zero iff *c is
;; non-NULL on return. ; non-NULL on return.
(format_request method "struct lsh_string *" (format_request method "struct lsh_string *"
"struct ssh_channel *channel" "struct ssh_channel *channel"
"struct command_continuation **c"))) "struct command_continuation **c")))
......
...@@ -60,8 +60,8 @@ ...@@ -60,8 +60,8 @@
(name command_simple) (name command_simple)
(super command) (super command)
(vars (vars
;; Like call, but returns the value immediately rather than ; Like call, but returns the value immediately rather than
;; using a continuation function ; using a continuation function.
(call_simple method "struct lsh_object *" "struct lsh_object *"))) (call_simple method "struct lsh_object *" "struct lsh_object *")))
*/ */
...@@ -211,11 +211,10 @@ do_catch_report_collect(struct command_simple *s, ...@@ -211,11 +211,10 @@ do_catch_report_collect(struct command_simple *s,
(class (class
(name collect_info_4) (name collect_info_4)
(vars (vars
; No next field
(f method "struct lsh_object *" (f method "struct lsh_object *"
"struct lsh_object *" "struct lsh_object *" "struct lsh_object *" "struct lsh_object *"
"struct lsh_object *" "struct lsh_object *") "struct lsh_object *" "struct lsh_object *")))
;; No next field
))
*/ */
/* GABA: /* GABA:
......
...@@ -179,15 +179,10 @@ do_##NAME(struct packet_handler *s UNUSED, \ ...@@ -179,15 +179,10 @@ do_##NAME(struct packet_handler *s UNUSED, \
; Table of all opened channels ; Table of all opened channels
(table object channel_table) (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_privacy . int)
; (provides_integrity . int) ; (provides_integrity . int)
)) */ ))
*/
#define C_WRITE(c, s) A_WRITE((c)->write, (s) ) #define C_WRITE(c, s) A_WRITE((c)->write, (s) )
......
...@@ -37,13 +37,6 @@ ...@@ -37,13 +37,6 @@
#include "connection_commands.c.x" #include "connection_commands.c.x"
/* ;;GABA:
(class
(name connection_remember_command)
(super command)
(vars
(connection object ssh_connection)))
*/
static void static void
do_connection_remember(struct command *s, do_connection_remember(struct command *s,
......
...@@ -43,9 +43,8 @@ init_dh_instance(struct dh_method *m, ...@@ -43,9 +43,8 @@ init_dh_instance(struct dh_method *m,
mpz_init(self->e); mpz_init(self->e);
mpz_init(self->f); mpz_init(self->f);
mpz_init(self->secret); mpz_init(self->secret);
#if 0
mpz_init(self->K); self->K = NULL;
#endif
self->method = m; self->method = m;
self->hash = MAKE_HASH(m->H); self->hash = MAKE_HASH(m->H);
...@@ -229,16 +228,3 @@ dh_process_server_msg(struct dh_instance *self, ...@@ -229,16 +228,3 @@ dh_process_server_msg(struct dh_instance *self,
return key; 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, ...@@ -199,8 +199,8 @@ make_exception_handler(void (*raise)(struct exception_handler *s,
(name protocol_exception) (name protocol_exception)
(super exception) (super exception)
(vars (vars
;; A reason code that can be passed in a SSH_MSG_DISCONNECT message. ; A reason code that can be passed in a SSH_MSG_DISCONNECT message.
;; Zero means terminate the connection without sending such a message. ; Zero means terminate the connection without sending such a message.
(reason . UINT32))) (reason . UINT32)))
*/ */
......
...@@ -99,7 +99,7 @@ make_gateway_address(char *local_user, char *remote_user, ...@@ -99,7 +99,7 @@ make_gateway_address(char *local_user, char *remote_user,
(class (class
(name gateway) (name gateway)
(vars (vars
;; Where to send packets ; Where to send packets
(local object abstract_write))) (local object abstract_write)))
*/ */
...@@ -165,14 +165,6 @@ do_gateway_channel_open(struct channel_open_command *c, ...@@ -165,14 +165,6 @@ do_gateway_channel_open(struct channel_open_command *c,
&target->super, &target->super,
closure->args); 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; return &target->super;
} }
......
...@@ -150,14 +150,6 @@ DEFINE_COMMAND(gateway_init, a, c, e) ...@@ -150,14 +150,6 @@ DEFINE_COMMAND(gateway_init, a, c, e)
/* (gateway_accept main-connection gateway-connection) */ /* (gateway_accept main-connection gateway-connection) */
/* ;; GABA:
(class
(name gateway_accept_command)
(super command)
(vars
(connection object ssh_connection)))
*/
static void static void
do_gateway_accept(struct command *s, do_gateway_accept(struct command *s,
struct lsh_object *x, struct lsh_object *x,
...@@ -220,11 +212,3 @@ DEFINE_COMMAND_SIMPLE(gateway_setup_command, a) ...@@ -220,11 +212,3 @@ DEFINE_COMMAND_SIMPLE(gateway_setup_command, a)
return &res->super; return &res->super;
} }
#if 0
DEFINE_PACKET_HANDLER(static, forward_channel_open_handler,
connection, packet)
{
}
#endif
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
(super line_handler) (super line_handler)
(vars (vars
(connection object ssh_connection) (connection object ssh_connection)
;; Needed for fallback. ; Needed for fallback.
(fd . int) (fd . int)
(fallback object ssh1_fallback))) (fallback object ssh1_fallback)))
*/ */
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
(random object randomness) (random object randomness)
(algorithms object alist) (algorithms object alist)
;; Used only on the server ; Used only on the server
(fallback object ssh1_fallback))) (fallback object ssh1_fallback)))
*/ */
......
...@@ -86,7 +86,6 @@ extern struct lsh_class io_backend_class; ...@@ -86,7 +86,6 @@ extern struct lsh_class io_backend_class;
; which seems kind of bogus. ; which seems kind of bogus.
(e object exception_handler) (e object exception_handler)
;;(close_reason . int)
; User's close callback ; User's close callback
(close_callback object lsh_callback) (close_callback object lsh_callback)
...@@ -199,9 +198,9 @@ make_listen_value(struct lsh_fd *fd, ...@@ -199,9 +198,9 @@ make_listen_value(struct lsh_fd *fd,
(name io_exception) (name io_exception)
(super exception) (super exception)
(vars (vars
;; NULL if no fd was involved ; NULL if no fd was involved
(fd object lsh_fd) (fd object lsh_fd)
;; errno code, or zero if not available ; errno code, or zero if not available
(error . int)))) (error . int))))
*/ */
......
...@@ -265,74 +265,6 @@ STATIC_COLLECT_2_FINAL(collect_listen_callback); ...@@ -265,74 +265,6 @@ STATIC_COLLECT_2_FINAL(collect_listen_callback);
struct collect_info_1 listen_with_callback = struct collect_info_1 listen_with_callback =
STATIC_COLLECT_1(&collect_info_listen_callback_2); 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: /* GABA:
(class (class
(name connect_continuation) (name connect_continuation)
......
...@@ -85,12 +85,8 @@ extern struct collect_info_1 listen_with_callback; ...@@ -85,12 +85,8 @@ extern struct collect_info_1 listen_with_callback;
#define LISTEN_CALLBACK (&listen_with_callback.super.super.super) #define LISTEN_CALLBACK (&listen_with_callback.super.super.super)
#if 0 #if 0
struct command *