Commit 576598ef authored by Niels Möller's avatar Niels Möller

Minor bugfixes, to make the code compile.

Rev: doc/HACKING:1.2
Rev: src/Makefile.in:1.9
Rev: src/abstract_crypto.h:1.7
Rev: src/atoms.c:1.2
Rev: src/atoms.h:1.2
Rev: src/bignum.c:1.6
Rev: src/bignum.h:1.6
Rev: src/client.c:1.9
Rev: src/format.c:1.9
Rev: src/getopt.c:1.2
Rev: src/keyexchange.c:1.4
Rev: src/keyexchange.h:1.6
Rev: src/pad.c:1.10
Rev: src/parse.c:1.11
Rev: src/publickey_crypto.c:1.4
Rev: src/publickey_crypto.h:1.3
Rev: src/randomness.c:1.2
Rev: src/unpad.c:1.9
parent dd5f2a31
......@@ -83,7 +83,7 @@ implementation of this type looks as follows:
lsh_string_free(packet);
return A_WRITE(closure->super.next, new);
return A_WRITE(closure->next, new);
}
Note the last line; the function passes a newly created packet on to
......
......@@ -34,8 +34,10 @@ binprefix =
LOADLIBES = $(LIBS) lib/algorithms.a
COMMON_SRCS = atoms.c bignum.c connection.c crypto.c \
debug.c encrypt.c format.c io.c packet_dispatch.c \
pad.c parse.c read_data.c read_line.c read_packet.c \
debug.c encrypt.c format.c getopt.c io.c keyexchange.c \
packet_dispatch.c pad.c parse.c publickey_crypto.c \
randomness.c \
read_data.c read_line.c read_packet.c \
server_keyexchange.c unpad.c void.c \
werror.c write_buffer.c xalloc.c
......
......@@ -102,16 +102,14 @@ struct verifier
struct signature_algorithm
{
struct signer *
(struct make_signer *)(struct signature_algorithm *closure,
UINT32 public_length,
UINT8 *public,
UINT32 secret_length,
UINT8 *secret);
struct verifier *
(struct make_verifier *)(struct signature_algorithm *closure,
UINT32 public_length,
UINT8 *public);
struct signer * (*make_signer)(struct signature_algorithm *closure,
UINT32 public_length,
UINT8 *public,
UINT32 secret_length,
UINT8 *secret);
struct verifier * (*make_verifier)(struct signature_algorithm *closure,
UINT32 public_length,
UINT8 *public);
};
#endif /* LSH_ABSTRACT_CRYPTO_H_INCLUDED */
......@@ -22,7 +22,7 @@ UINT32 get_atom_length(int atom)
UINT8 *get_atom_name(int atom)
{ return atom_table[atom].name; }
UINT32 lookup_atom(UINT8 *name, UINT32 length)
UINT32 lookup_atom(UINT32 length, UINT8 *name)
{
struct atom_assoc *pair = gperf_atom(name, length);
......
......@@ -10,6 +10,6 @@
UINT32 get_atom_length(int atom);
UINT8 *get_atom_name(int atom);
UINT32 lookup_atom(UINT8 *name, UINT32 length);
UINT32 lookup_atom(UINT32 length, UINT8 *name);
#endif /* LSH_ATOMS_H_INCLUDED */
......@@ -181,7 +181,7 @@ UINT32 bignum_format_u(mpz_t n, UINT8 *data)
void bignum_random(mpz_t x, struct randomness *random, mpz_t n)
{
/* Add a few bits extra */
int length = (mpz_sizeinbase(n) + 17) / 8;
int length = (mpz_sizeinbase(n, 2) + 17) / 8;
UINT8 *data = alloca(length);
RANDOM(random, length, data);
......
......@@ -11,9 +11,14 @@
#include "lsh_types.h"
#include "randomness.h"
void bignum_parse(mpz_t n, UINT32 length, UINT8 *data);
UINT32 bignum_format_length(mpz_t n);
UINT32 bignum_format(mpz_t n, UINT8 *data);
void bignum_parse_s(mpz_t n, UINT32 length, UINT8 *data);
void bignum_parse_u(mpz_t n, UINT32 length, UINT8 *data);
UINT32 bignum_format_s(mpz_t n, UINT8 *data);
UINT32 bignum_format_s_length(mpz_t n);
UINT32 bignum_format_u(mpz_t n, UINT8 *data);
UINT32 bignum_format_u_length(mpz_t n);
/* Generates a random number in the interval 0 <= x < n */
void bignum_random(mpz_t x, struct randomness *random, mpz_t n);
......
......@@ -60,6 +60,11 @@ struct client_line_handler
struct ssh_connection *connection;
};
struct abstract_write *make_client_dispatch(struct ssh_connection *c)
{ /* FIXME: HERE */
return make_packet_void();
}
static struct read_handler *do_line(struct line_handler **h,
UINT32 length,
UINT8 *line)
......@@ -76,7 +81,7 @@ static struct read_handler *do_line(struct line_handler **h,
struct read_handler *new
= make_read_packet
(make_packet_debug
(make_packet_unpad(make_client_dispatch(connection)),
(make_packet_unpad(make_client_dispatch(closure->connection)),
stderr),
closure->connection->max_packet);
......
......@@ -118,9 +118,10 @@ UINT32 ssh_vformat_length(char *f, va_list args)
case 'A':
{
int *atom = va_arg(args, int *);
int i;
while (*atom > 0)
length += get_atom_length(atom++) + 1;
for(i = 0; atom[i] > 0; i++)
length += get_atom_length(atom[i]) + 1;
/* One ','-character less than the number of atoms */
length--;
......@@ -149,10 +150,10 @@ UINT32 ssh_vformat_length(char *f, va_list args)
#endif
case 'n':
{
bignum *n = va_arg(args, bignum *);
MP_INT *n = va_arg(args, MP_INT*);
/* Calculate length of written number */
length += bignum_format_length(n);
length += bignum_format_s_length(n);
if (!literal)
length += 4;
......@@ -296,8 +297,9 @@ void ssh_vformat(char *f, UINT8 *buffer, va_list args)
memcpy(buffer, get_atom_name(atom), length);
buffer += length;
f++;
break;
}
break;
#if 0
case 'A':
{
int atom;
......@@ -330,29 +332,29 @@ void ssh_vformat(char *f, UINT8 *buffer, va_list args)
f++;
break;
}
#if 0
#endif
case 'A':
{
int *atom = va_arg(args, int *);
UINT8 *start = buffer; /* Where to store the length */
int i;
if (!literal)
buffer += 4;
if (*atom > 0)
if (atom[0] > 0)
{
UINT32 length = get_atom_length(*atom);
memcpy(buffer, get_atom_name(*atom), length);
buffer += length;
atom ++;
while (*atom > 0)
for (i = 1; atom[i] > 0; i++)
{
*buffer++ = ',';
length = get_atom_length(atom);
memcpy(buffer, get_atom_name(atom), length);
length = get_atom_length(atom[i]);
memcpy(buffer, get_atom_name(atom[i]), length);
buffer += length;
atom++;
}
}
......@@ -364,11 +366,10 @@ void ssh_vformat(char *f, UINT8 *buffer, va_list args)
f++;
break;
}
#endif
case 'n':
{
bignum *n = va_arg(args, bignum *);
UINT32 length = bignum_format(n, buffer);
MP_INT *n = va_arg(args, MP_INT *);
UINT32 length = bignum_format_s(n, buffer);
buffer += length;
......
......@@ -688,6 +688,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
else
{
if (opterr)
{
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
......@@ -698,7 +699,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
fprintf (stderr,
_("%s: option `%c%s' doesn't allow an argument\n"),
argv[0], argv[optind - 1][0], pfound->name);
}
nextchar += strlen (nextchar);
optopt = pfound->val;
......
......@@ -2,9 +2,13 @@
*
*/
#include "abstract_io.h"
#include "connection.h"
#include "format.h"
#include "keyexchange.h"
#include "parse.h"
#include "ssh.h"
#include "xalloc.h"
#define NLISTS 10
......@@ -25,9 +29,9 @@ struct kexinit *parse_kexinit(struct lsh_string *packet)
|| (msg_number != SSH_MSG_KEXINIT) )
return 0;
res = xalloc(sizeof(keyexinit));
res = xalloc(sizeof(struct kexinit));
if (!parse_octets(&buffer, 16, &res->cookie))
if (!parse_octets(&buffer, 16, res->cookie))
{
lsh_free(res);
return NULL;
......@@ -53,16 +57,16 @@ struct kexinit *parse_kexinit(struct lsh_string *packet)
return NULL;
}
res->kex_algorithms = list[0];
res->kex_algorithms = lists[0];
res->server_host_key_algorithms = lists[1];
res->encryption_algorithms_client_to_server = list[2];
res->encryption_algorithms_server_to_client = list[3];
res->mac_algorithms_client_to_server = list[4];
res->mac_algorithms_server_to_client = list[5];
res->compression_algorithms_client_to_server = list[6];
res->compression_algorithms_server_to_client = list[7];
res->languages_client_to_server = list[8];
res->languages_server_to_client = list[9];
res->encryption_algorithms_client_to_server = lists[2];
res->encryption_algorithms_server_to_client = lists[3];
res->mac_algorithms_client_to_server = lists[4];
res->mac_algorithms_server_to_client = lists[5];
res->compression_algorithms_client_to_server = lists[6];
res->compression_algorithms_server_to_client = lists[7];
res->languages_client_to_server = lists[8];
res->languages_server_to_client = lists[9];
return res;
}
......
......@@ -6,6 +6,7 @@
#define LSH_KEYEXCHANGE_H_INCLUDED
#include "lsh_types.h"
#include "abstract_io.h"
struct kexinit
{
......@@ -22,13 +23,13 @@ struct kexinit
int *languages_client_to_server;
int *languages_server_to_client;
int first_kex_packet_follows;
}
};
struct handle_kexinit
{
int (*f)(struct handle_kexinit *closure,
struct kexinit *msg);
}
};
#define HANDLE_KEXINIT(handler, msg) ((handler)->f((handler), (msg)))
......
......@@ -2,9 +2,11 @@
*
*/
#include <assert.h>
#include "pad.h"
#include "randomness.h"
#include "xalloc.h"
#include <assert.h>
static int do_pad(struct abstract_write **w,
struct lsh_string *packet)
......
......@@ -2,9 +2,10 @@
*
*/
#include "format.h"
#include "parse.h"
#include "werror.h"
#include "xalloc.h"
#include "format.h"
void simple_buffer_init(struct simple_buffer *buffer,
UINT32 capacity, UINT8 *data)
......@@ -60,7 +61,7 @@ struct lsh_string *parse_string_copy(struct simple_buffer *buffer)
UINT32 length;
UINT8 *start;
if (!parse_string(buffer, &length, &data))
if (!parse_string(buffer, &length, &start))
return NULL;
return ssh_format("%ls", length, start);
......@@ -107,7 +108,7 @@ int parse_bignum(struct simple_buffer *buffer, mpz_t result)
if (!parse_string(buffer, &length, &digits))
return 0;
bignum_parse(result, length, digits);
bignum_parse_s(result, length, digits);
return 1;
}
......@@ -121,7 +122,7 @@ int parse_atom(struct simple_buffer *buffer, int *result)
|| length > 64)
return 0;
*result = lookup_atom(data, start);
*result = lookup_atom(length, start);
return 1;
}
......@@ -148,7 +149,7 @@ int parse_next_atom(struct simple_buffer *buffer, int *result)
return 0;
}
*result = lookup_atom(HERE, i);
*result = lookup_atom(i, HERE);
ADVANCE(i+1); /* If the atom was terminated at the end of the
* buffer, rather than by a comma, this points beyond
* the end of the buffer */
......
This diff is collapsed.
......@@ -6,8 +6,9 @@
#define LSH_PUBLICKEY_CRYPTO_H_INCLUDED
#include "abstract_crypto.h"
#include "connection.h"
struct make_dss_algorithm(struct randomness *random);
struct signature_algorithm *make_dss_algorithm(struct randomness *random);
/* Groups. For now, assume that all group elements are represented by
* bignums. */
......@@ -28,7 +29,7 @@ struct group
#define GROUP_COMBINE(group, res, a, b) \
((group)->combine((group), (res), (a), (b)))
#define GROUP_POWER(group, res, g, e) \
((group)->POWER((group), (res), (g), (e)))
((group)->power((group), (res), (g), (e)))
/* DH key exchange, with authentication */
struct diffie_hellman_method
......@@ -64,7 +65,7 @@ void dh_hash_update(struct diffie_hellman_instance *self,
/* Creates server message */
struct lsh_string *dh_make_server_msg(struct diffie_hellman_instance *self,
struct signer s);
struct signer *s);
/* Decodes server message, but does not verify its signature */
int dh_process_server_msg(struct diffie_hellman_instance *self,
......@@ -81,8 +82,10 @@ make_diffie_hellman_method(struct group *group,
struct randomness *r);
#endif
struct diffie_hellman_method *make_dh1(struct randomness *r);
struct diffie_hellman_instance *
make_diffie_hellman_instance(struct diffie_hellman_method *m,
struct connection *c);
struct ssh_connection *c);
#endif /* LSH_PUBLICKEY_CRYPTO_H_INCLUDED */
......@@ -2,8 +2,13 @@
*
*/
#include <sys/types.h>
#include <time.h>
#include "randomness.h"
#include "abstract_crypto.h"
#include "xalloc.h"
/* Random */
struct poor_random
......
......@@ -33,13 +33,14 @@ static int do_unpad(struct abstract_write **w,
lsh_string_free(packet);
return A_WRITE(closure->super.next, new);
return A_WRITE(closure->next, new);
}
struct abstract_write *
make_packet_unpad(struct abstract_write *continuation)
{
struct packet_unpad *closure = xalloc(sizeof(struct packet_unpad));
struct abstract_write_pipe *closure =
xalloc(sizeof(struct abstract_write_pipe));
closure->super.write = do_unpad;
closure->next = continuation;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment