summaryrefslogtreecommitdiffstats
path: root/crypto/openssh/sshd.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2014-03-25 11:05:34 +0000
committerdes <des@FreeBSD.org>2014-03-25 11:05:34 +0000
commitae82763de4683ce610990c6d07ce39f518dd8505 (patch)
tree5f5bce301eb69c1bba7123161572915c7e55375b /crypto/openssh/sshd.c
parent144450f3a924f7cbb9c11bfe0c90b21044097086 (diff)
parentab9e0bc08282397f61df5d0ea89a81a2322ec040 (diff)
downloadFreeBSD-src-ae82763de4683ce610990c6d07ce39f518dd8505.zip
FreeBSD-src-ae82763de4683ce610990c6d07ce39f518dd8505.tar.gz
Upgrade to OpenSSH 6.6p1.
Diffstat (limited to 'crypto/openssh/sshd.c')
-rw-r--r--crypto/openssh/sshd.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/crypto/openssh/sshd.c b/crypto/openssh/sshd.c
index 732d317..ce7fa65 100644
--- a/crypto/openssh/sshd.c
+++ b/crypto/openssh/sshd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshd.c,v 1.414 2014/01/09 23:26:48 djm Exp $ */
+/* $OpenBSD: sshd.c,v 1.420 2014/02/26 21:53:37 markus Exp $ */
/* $FreeBSD$ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -77,7 +77,6 @@ __RCSID("$FreeBSD$");
#include <openssl/dh.h>
#include <openssl/bn.h>
-#include <openssl/md5.h>
#include <openssl/rand.h>
#include "openbsd-compat/openssl-compat.h"
@@ -108,6 +107,7 @@ __RCSID("$FreeBSD$");
#include "uidswap.h"
#include "compat.h"
#include "cipher.h"
+#include "digest.h"
#include "key.h"
#include "kex.h"
#include "dh.h"
@@ -592,7 +592,7 @@ destroy_sensitive_data(void)
}
}
sensitive_data.ssh1_host_key = NULL;
- memset(sensitive_data.ssh1_cookie, 0, SSH_SESSION_KEY_LENGTH);
+ explicit_bzero(sensitive_data.ssh1_cookie, SSH_SESSION_KEY_LENGTH);
}
/* Demote private to public keys for network child */
@@ -631,10 +631,16 @@ privsep_preauth_child(void)
/* Enable challenge-response authentication for privilege separation */
privsep_challenge_enable();
+#ifdef GSSAPI
+ /* Cache supported mechanism OIDs for later use */
+ if (options.gss_authentication)
+ ssh_gssapi_prepare_supported_oids();
+#endif
+
arc4random_stir();
arc4random_buf(rnd, sizeof(rnd));
RAND_seed(rnd, sizeof(rnd));
- bzero(rnd, sizeof(rnd));
+ explicit_bzero(rnd, sizeof(rnd));
/* Demote the private keys to public keys. */
demote_sensitive_data();
@@ -769,7 +775,7 @@ privsep_postauth(Authctxt *authctxt)
arc4random_stir();
arc4random_buf(rnd, sizeof(rnd));
RAND_seed(rnd, sizeof(rnd));
- bzero(rnd, sizeof(rnd));
+ explicit_bzero(rnd, sizeof(rnd));
/* Drop privileges */
do_setusercontext(authctxt->pw);
@@ -1381,7 +1387,7 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s)
arc4random_stir();
arc4random_buf(rnd, sizeof(rnd));
RAND_seed(rnd, sizeof(rnd));
- bzero(rnd, sizeof(rnd));
+ explicit_bzero(rnd, sizeof(rnd));
}
/* child process check (or debug mode) */
@@ -1687,7 +1693,8 @@ main(int ac, char **av)
fatal("Privilege separation user %s does not exist",
SSH_PRIVSEP_USER);
} else {
- memset(privsep_pw->pw_passwd, 0, strlen(privsep_pw->pw_passwd));
+ explicit_bzero(privsep_pw->pw_passwd,
+ strlen(privsep_pw->pw_passwd));
privsep_pw = pwcopy(privsep_pw);
free(privsep_pw->pw_passwd);
privsep_pw->pw_passwd = xstrdup("*");
@@ -2401,7 +2408,7 @@ do_ssh1_kex(void)
get_remote_ipaddr(), len, (u_long)sizeof(session_key));
rsafail++;
} else {
- memset(session_key, 0, sizeof(session_key));
+ explicit_bzero(session_key, sizeof(session_key));
BN_bn2bin(session_key_int,
session_key + sizeof(session_key) - len);
@@ -2420,20 +2427,26 @@ do_ssh1_kex(void)
if (rsafail) {
int bytes = BN_num_bytes(session_key_int);
u_char *buf = xmalloc(bytes);
- MD5_CTX md;
+ struct ssh_digest_ctx *md;
logit("do_connection: generating a fake encryption key");
BN_bn2bin(session_key_int, buf);
- MD5_Init(&md);
- MD5_Update(&md, buf, bytes);
- MD5_Update(&md, sensitive_data.ssh1_cookie, SSH_SESSION_KEY_LENGTH);
- MD5_Final(session_key, &md);
- MD5_Init(&md);
- MD5_Update(&md, session_key, 16);
- MD5_Update(&md, buf, bytes);
- MD5_Update(&md, sensitive_data.ssh1_cookie, SSH_SESSION_KEY_LENGTH);
- MD5_Final(session_key + 16, &md);
- memset(buf, 0, bytes);
+ if ((md = ssh_digest_start(SSH_DIGEST_MD5)) == NULL ||
+ ssh_digest_update(md, buf, bytes) < 0 ||
+ ssh_digest_update(md, sensitive_data.ssh1_cookie,
+ SSH_SESSION_KEY_LENGTH) < 0 ||
+ ssh_digest_final(md, session_key, sizeof(session_key)) < 0)
+ fatal("%s: md5 failed", __func__);
+ ssh_digest_free(md);
+ if ((md = ssh_digest_start(SSH_DIGEST_MD5)) == NULL ||
+ ssh_digest_update(md, session_key, 16) < 0 ||
+ ssh_digest_update(md, sensitive_data.ssh1_cookie,
+ SSH_SESSION_KEY_LENGTH) < 0 ||
+ ssh_digest_final(md, session_key + 16,
+ sizeof(session_key) - 16) < 0)
+ fatal("%s: md5 failed", __func__);
+ ssh_digest_free(md);
+ explicit_bzero(buf, bytes);
free(buf);
for (i = 0; i < 16; i++)
session_id[i] = session_key[i] ^ session_key[i + 16];
@@ -2451,7 +2464,7 @@ do_ssh1_kex(void)
packet_set_encryption_key(session_key, SSH_SESSION_KEY_LENGTH, cipher_type);
/* Destroy our copy of the session key. It is no longer needed. */
- memset(session_key, 0, sizeof(session_key));
+ explicit_bzero(session_key, sizeof(session_key));
debug("Received session key; encryption turned on.");
OpenPOWER on IntegriCloud