*/
#include "includes.h"
-RCSID("$OpenBSD: sshd.c,v 1.137 2000/12/12 21:45:21 markus Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.147 2001/01/10 19:43:20 deraadt Exp $");
#include "xmalloc.h"
#include "rsa.h"
int received_sighup = 0;
/* session identifier, used by RSA-auth */
-unsigned char session_id[16];
+u_char session_id[16];
/* same for ssh2 */
-unsigned char *session_id2 = NULL;
+u_char *session_id2 = NULL;
int session_id2_len = 0;
/* record remote hostname or ip */
-unsigned int utmp_len = MAXHOSTNAMELEN;
+u_int utmp_len = MAXHOSTNAMELEN;
/* Prototypes for various functions defined later in this file. */
-void do_ssh1_kex();
-void do_ssh2_kex();
+void do_ssh1_kex(void);
+void do_ssh2_kex(void);
void ssh_dh1_server(Kex *, Buffer *_kexinit, Buffer *);
void ssh_dhgex_server(Kex *, Buffer *_kexinit, Buffer *);
* do anything with the private key or random state before forking.
* Thus there should be no concurrency control/asynchronous execution
* problems.
+ * XXX calling log() is not safe from races.
*/
-/* XXX do we really want this work to be done in a signal handler ? -m */
void
generate_empheral_server_key(void)
{
arc4random_stir();
log("RSA key generation complete.");
}
+
void
key_regeneration_alarm(int sig)
{
fprintf(stderr, " -f file Configuration file (default %s)\n", SERVER_CONFIG_FILE);
fprintf(stderr, " -d Debugging mode (multiple -d means more debugging)\n");
fprintf(stderr, " -i Started from inetd\n");
+ fprintf(stderr, " -D Do not fork into daemon mode\n");
fprintf(stderr, " -q Quiet (no logging)\n");
fprintf(stderr, " -p port Listen on the specified port (default: 22)\n");
fprintf(stderr, " -k seconds Regenerate server key every this many seconds (default: 3600)\n");
- fprintf(stderr, " -g seconds Grace period for authentication (default: 300)\n");
+ fprintf(stderr, " -g seconds Grace period for authentication (default: 600)\n");
fprintf(stderr, " -b bits Size of server RSA key (default: 768 bits)\n");
fprintf(stderr, " -h file File from which to read host key (default: %s)\n",
HOST_KEY_FILE);
* key (unless started from inetd)
*/
log_init(__progname,
- options.log_level == -1 ? SYSLOG_LEVEL_INFO : options.log_level,
+ options.log_level == -1 ? SYSLOG_LEVEL_NOTICE : options.log_level,
options.log_facility == -1 ? SYSLOG_FACILITY_AUTH : options.log_facility,
!silent && !inetd_flag);
/* load private host keys */
sensitive_data.host_keys = xmalloc(options.num_host_key_files*sizeof(Key*));
+ for(i = 0; i < options.num_host_key_files; i++)
+ sensitive_data.host_keys[i] = NULL;
sensitive_data.server_key = NULL;
sensitive_data.ssh1_host_key = NULL;
sensitive_data.have_ssh1_key = 0;
*/
f = fopen(options.pid_file, "wb");
if (f) {
- fprintf(f, "%u\n", (unsigned int) getpid());
+ fprintf(f, "%u\n", (u_int) getpid());
fclose(f);
}
}
/*
* the read end of the pipe is ready
* if the child has closed the pipe
- * after successfull authentication
+ * after successful authentication
* or if the child has died
*/
close(startup_pipes[i]);
* SSH1 key exchange
*/
void
-do_ssh1_kex()
+do_ssh1_kex(void)
{
int i, len;
int plen, slen;
BIGNUM *session_key_int;
- unsigned char session_key[SSH_SESSION_KEY_LENGTH];
- unsigned char cookie[8];
- unsigned int cipher_type, auth_mask, protocol_flags;
+ u_char session_key[SSH_SESSION_KEY_LENGTH];
+ u_char cookie[8];
+ u_int cipher_type, auth_mask, protocol_flags;
u_int32_t rand = 0;
/*
* SSH2 key exchange: diffie-hellman-group1-sha1
*/
void
-do_ssh2_kex()
+do_ssh2_kex(void)
{
Buffer *server_kexinit;
Buffer *client_kexinit;
#endif
int payload_len, dlen;
int slen;
- unsigned char *signature = NULL;
- unsigned char *server_host_key_blob = NULL;
- unsigned int sbloblen;
- unsigned int klen, kout;
- unsigned char *kbuf;
- unsigned char *hash;
+ u_char *signature = NULL;
+ u_char *server_host_key_blob = NULL;
+ u_int sbloblen;
+ u_int klen, kout;
+ u_char *kbuf;
+ u_char *hash;
BIGNUM *shared_secret = 0;
DH *dh;
BIGNUM *dh_client_pub = 0;
fatal("Unsupported hostkey type %d", kex->hostkey_type);
/* KEXDH */
+ /* generate DH key */
+ dh = dh_new_group1(); /* XXX depends on 'kex' */
+ dh_gen_key(dh);
+
debug("Wait SSH2_MSG_KEXDH_INIT.");
packet_read_expect(&payload_len, SSH2_MSG_KEXDH_INIT);
debug("bits %d", BN_num_bits(dh_client_pub));
#endif
- /* generate DH key */
- dh = dh_new_group1(); /* XXX depends on 'kex' */
-
#ifdef DEBUG_KEXDH
fprintf(stderr, "\np= ");
BN_print_fp(stderr, dh->p);
#endif
int payload_len, dlen;
int slen, nbits;
- unsigned char *signature = NULL;
- unsigned char *server_host_key_blob = NULL;
- unsigned int sbloblen;
- unsigned int klen, kout;
- unsigned char *kbuf;
- unsigned char *hash;
+ u_char *signature = NULL;
+ u_char *server_host_key_blob = NULL;
+ u_int sbloblen;
+ u_int klen, kout;
+ u_char *kbuf;
+ u_char *hash;
BIGNUM *shared_secret = 0;
DH *dh;
BIGNUM *dh_client_pub = 0;
packet_send();
packet_write_wait();
+ /* Compute our exchange value in parallel with the client */
+
+ dh_gen_key(dh);
+
debug("Wait SSH2_MSG_KEX_DH_GEX_INIT.");
packet_read_expect(&payload_len, SSH2_MSG_KEX_DH_GEX_INIT);