upstream: make ssh->kex->session_id a sshbuf instead of u_char*/size_t
and use that instead of global variables containing copies of it. feedback/ok markus@ OpenBSD-Commit-ID: a4b1b1ca4afd2e37cb9f64f737b30a6a7f96af68
This commit is contained in:
parent
4ca6a1fac3
commit
39be3dc209
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: auth2-gss.c,v 1.30 2020/10/18 11:32:01 djm Exp $ */
|
/* $OpenBSD: auth2-gss.c,v 1.31 2021/01/27 10:05:28 djm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
|
* Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
|
||||||
|
@ -299,7 +299,7 @@ input_gssapi_mic(int type, u_int32_t plen, struct ssh *ssh)
|
||||||
mic.value = p;
|
mic.value = p;
|
||||||
mic.length = len;
|
mic.length = len;
|
||||||
ssh_gssapi_buildmic(b, authctxt->user, authctxt->service,
|
ssh_gssapi_buildmic(b, authctxt->user, authctxt->service,
|
||||||
"gssapi-with-mic");
|
"gssapi-with-mic", ssh->kex->session_id);
|
||||||
|
|
||||||
if ((gssbuf.value = sshbuf_mutable_ptr(b)) == NULL)
|
if ((gssbuf.value = sshbuf_mutable_ptr(b)) == NULL)
|
||||||
fatal_f("sshbuf_mutable_ptr failed");
|
fatal_f("sshbuf_mutable_ptr failed");
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: auth2-hostbased.c,v 1.45 2021/01/26 05:32:21 dtucker Exp $ */
|
/* $OpenBSD: auth2-hostbased.c,v 1.46 2021/01/27 10:05:28 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -35,6 +35,7 @@
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
#include "ssh2.h"
|
#include "ssh2.h"
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
|
#include "kex.h"
|
||||||
#include "sshbuf.h"
|
#include "sshbuf.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
@ -54,8 +55,6 @@
|
||||||
|
|
||||||
/* import */
|
/* import */
|
||||||
extern ServerOptions options;
|
extern ServerOptions options;
|
||||||
extern u_char *session_id2;
|
|
||||||
extern u_int session_id2_len;
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
userauth_hostbased(struct ssh *ssh)
|
userauth_hostbased(struct ssh *ssh)
|
||||||
|
@ -129,7 +128,7 @@ userauth_hostbased(struct ssh *ssh)
|
||||||
if ((b = sshbuf_new()) == NULL)
|
if ((b = sshbuf_new()) == NULL)
|
||||||
fatal_f("sshbuf_new failed");
|
fatal_f("sshbuf_new failed");
|
||||||
/* reconstruct packet */
|
/* reconstruct packet */
|
||||||
if ((r = sshbuf_put_string(b, session_id2, session_id2_len)) != 0 ||
|
if ((r = sshbuf_put_stringb(b, ssh->kex->session_id)) != 0 ||
|
||||||
(r = sshbuf_put_u8(b, SSH2_MSG_USERAUTH_REQUEST)) != 0 ||
|
(r = sshbuf_put_u8(b, SSH2_MSG_USERAUTH_REQUEST)) != 0 ||
|
||||||
(r = sshbuf_put_cstring(b, authctxt->user)) != 0 ||
|
(r = sshbuf_put_cstring(b, authctxt->user)) != 0 ||
|
||||||
(r = sshbuf_put_cstring(b, authctxt->service)) != 0 ||
|
(r = sshbuf_put_cstring(b, authctxt->service)) != 0 ||
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: auth2-pubkey.c,v 1.105 2021/01/26 00:49:30 djm Exp $ */
|
/* $OpenBSD: auth2-pubkey.c,v 1.106 2021/01/27 10:05:28 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -47,6 +47,7 @@
|
||||||
#include "ssh.h"
|
#include "ssh.h"
|
||||||
#include "ssh2.h"
|
#include "ssh2.h"
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
|
#include "kex.h"
|
||||||
#include "sshbuf.h"
|
#include "sshbuf.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
@ -72,8 +73,6 @@
|
||||||
|
|
||||||
/* import */
|
/* import */
|
||||||
extern ServerOptions options;
|
extern ServerOptions options;
|
||||||
extern u_char *session_id2;
|
|
||||||
extern u_int session_id2_len;
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
format_key(const struct sshkey *key)
|
format_key(const struct sshkey *key)
|
||||||
|
@ -175,11 +174,11 @@ userauth_pubkey(struct ssh *ssh)
|
||||||
if ((b = sshbuf_new()) == NULL)
|
if ((b = sshbuf_new()) == NULL)
|
||||||
fatal_f("sshbuf_new failed");
|
fatal_f("sshbuf_new failed");
|
||||||
if (ssh->compat & SSH_OLD_SESSIONID) {
|
if (ssh->compat & SSH_OLD_SESSIONID) {
|
||||||
if ((r = sshbuf_put(b, session_id2, session_id2_len)) != 0)
|
if ((r = sshbuf_putb(b, ssh->kex->session_id)) != 0)
|
||||||
fatal_fr(r, "put old session id");
|
fatal_fr(r, "put old session id");
|
||||||
} else {
|
} else {
|
||||||
if ((r = sshbuf_put_string(b, session_id2,
|
if ((r = sshbuf_put_stringb(b,
|
||||||
session_id2_len)) != 0)
|
ssh->kex->session_id)) != 0)
|
||||||
fatal_fr(r, "put session id");
|
fatal_fr(r, "put session id");
|
||||||
}
|
}
|
||||||
if (!authctxt->valid || authctxt->user == NULL) {
|
if (!authctxt->valid || authctxt->user == NULL) {
|
||||||
|
|
4
auth2.c
4
auth2.c
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: auth2.c,v 1.159 2020/10/18 11:32:01 djm Exp $ */
|
/* $OpenBSD: auth2.c,v 1.160 2021/01/27 10:05:28 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -61,8 +61,6 @@
|
||||||
|
|
||||||
/* import */
|
/* import */
|
||||||
extern ServerOptions options;
|
extern ServerOptions options;
|
||||||
extern u_char *session_id2;
|
|
||||||
extern u_int session_id2_len;
|
|
||||||
extern struct sshbuf *loginmsg;
|
extern struct sshbuf *loginmsg;
|
||||||
|
|
||||||
/* methods */
|
/* methods */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: clientloop.c,v 1.357 2021/01/27 09:26:54 djm Exp $ */
|
/* $OpenBSD: clientloop.c,v 1.358 2021/01/27 10:05:28 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||||
|
@ -2125,9 +2125,6 @@ client_global_hostkeys_private_confirm(struct ssh *ssh, int type,
|
||||||
|
|
||||||
if ((signdata = sshbuf_new()) == NULL)
|
if ((signdata = sshbuf_new()) == NULL)
|
||||||
fatal_f("sshbuf_new failed");
|
fatal_f("sshbuf_new failed");
|
||||||
/* Don't want to accidentally accept an unbound signature */
|
|
||||||
if (ssh->kex->session_id_len == 0)
|
|
||||||
fatal_f("ssh->kex->session_id_len == 0");
|
|
||||||
/*
|
/*
|
||||||
* Expect a signature for each of the ctx->nnew private keys we
|
* Expect a signature for each of the ctx->nnew private keys we
|
||||||
* haven't seen before. They will be in the same order as the
|
* haven't seen before. They will be in the same order as the
|
||||||
|
@ -2140,8 +2137,8 @@ client_global_hostkeys_private_confirm(struct ssh *ssh, int type,
|
||||||
sshbuf_reset(signdata);
|
sshbuf_reset(signdata);
|
||||||
if ( (r = sshbuf_put_cstring(signdata,
|
if ( (r = sshbuf_put_cstring(signdata,
|
||||||
"hostkeys-prove-00@openssh.com")) != 0 ||
|
"hostkeys-prove-00@openssh.com")) != 0 ||
|
||||||
(r = sshbuf_put_string(signdata, ssh->kex->session_id,
|
(r = sshbuf_put_stringb(signdata,
|
||||||
ssh->kex->session_id_len)) != 0 ||
|
ssh->kex->session_id)) != 0 ||
|
||||||
(r = sshkey_puts(ctx->keys[i], signdata)) != 0)
|
(r = sshkey_puts(ctx->keys[i], signdata)) != 0)
|
||||||
fatal_fr(r, "compose signdata");
|
fatal_fr(r, "compose signdata");
|
||||||
/* Extract and verify signature */
|
/* Extract and verify signature */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: gss-genr.c,v 1.27 2020/10/18 11:32:01 djm Exp $ */
|
/* $OpenBSD: gss-genr.c,v 1.28 2021/01/27 10:05:28 djm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved.
|
* Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved.
|
||||||
|
@ -44,9 +44,6 @@
|
||||||
|
|
||||||
#include "ssh-gss.h"
|
#include "ssh-gss.h"
|
||||||
|
|
||||||
extern u_char *session_id2;
|
|
||||||
extern u_int session_id2_len;
|
|
||||||
|
|
||||||
/* sshbuf_get for gss_buffer_desc */
|
/* sshbuf_get for gss_buffer_desc */
|
||||||
int
|
int
|
||||||
ssh_gssapi_get_buffer_desc(struct sshbuf *b, gss_buffer_desc *g)
|
ssh_gssapi_get_buffer_desc(struct sshbuf *b, gss_buffer_desc *g)
|
||||||
|
@ -259,12 +256,12 @@ ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_t buffer, gss_buffer_t hash)
|
||||||
|
|
||||||
void
|
void
|
||||||
ssh_gssapi_buildmic(struct sshbuf *b, const char *user, const char *service,
|
ssh_gssapi_buildmic(struct sshbuf *b, const char *user, const char *service,
|
||||||
const char *context)
|
const char *context, const struct sshbuf *session_id)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
sshbuf_reset(b);
|
sshbuf_reset(b);
|
||||||
if ((r = sshbuf_put_string(b, session_id2, session_id2_len)) != 0 ||
|
if ((r = sshbuf_put_stringb(b, session_id)) != 0 ||
|
||||||
(r = sshbuf_put_u8(b, SSH2_MSG_USERAUTH_REQUEST)) != 0 ||
|
(r = sshbuf_put_u8(b, SSH2_MSG_USERAUTH_REQUEST)) != 0 ||
|
||||||
(r = sshbuf_put_cstring(b, user)) != 0 ||
|
(r = sshbuf_put_cstring(b, user)) != 0 ||
|
||||||
(r = sshbuf_put_cstring(b, service)) != 0 ||
|
(r = sshbuf_put_cstring(b, service)) != 0 ||
|
||||||
|
|
22
kex.c
22
kex.c
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: kex.c,v 1.164 2021/01/27 09:26:54 djm Exp $ */
|
/* $OpenBSD: kex.c,v 1.165 2021/01/27 10:05:28 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
|
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -637,7 +637,8 @@ kex_new(void)
|
||||||
(kex->peer = sshbuf_new()) == NULL ||
|
(kex->peer = sshbuf_new()) == NULL ||
|
||||||
(kex->my = sshbuf_new()) == NULL ||
|
(kex->my = sshbuf_new()) == NULL ||
|
||||||
(kex->client_version = sshbuf_new()) == NULL ||
|
(kex->client_version = sshbuf_new()) == NULL ||
|
||||||
(kex->server_version = sshbuf_new()) == NULL) {
|
(kex->server_version = sshbuf_new()) == NULL ||
|
||||||
|
(kex->session_id = sshbuf_new()) == NULL) {
|
||||||
kex_free(kex);
|
kex_free(kex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -697,7 +698,7 @@ kex_free(struct kex *kex)
|
||||||
sshbuf_free(kex->client_version);
|
sshbuf_free(kex->client_version);
|
||||||
sshbuf_free(kex->server_version);
|
sshbuf_free(kex->server_version);
|
||||||
sshbuf_free(kex->client_pub);
|
sshbuf_free(kex->client_pub);
|
||||||
free(kex->session_id);
|
sshbuf_free(kex->session_id);
|
||||||
free(kex->failed_choice);
|
free(kex->failed_choice);
|
||||||
free(kex->hostkey_alg);
|
free(kex->hostkey_alg);
|
||||||
free(kex->name);
|
free(kex->name);
|
||||||
|
@ -1015,8 +1016,7 @@ derive_key(struct ssh *ssh, int id, u_int need, u_char *hash, u_int hashlen,
|
||||||
ssh_digest_update_buffer(hashctx, shared_secret) != 0 ||
|
ssh_digest_update_buffer(hashctx, shared_secret) != 0 ||
|
||||||
ssh_digest_update(hashctx, hash, hashlen) != 0 ||
|
ssh_digest_update(hashctx, hash, hashlen) != 0 ||
|
||||||
ssh_digest_update(hashctx, &c, 1) != 0 ||
|
ssh_digest_update(hashctx, &c, 1) != 0 ||
|
||||||
ssh_digest_update(hashctx, kex->session_id,
|
ssh_digest_update_buffer(hashctx, kex->session_id) != 0 ||
|
||||||
kex->session_id_len) != 0 ||
|
|
||||||
ssh_digest_final(hashctx, digest, mdsz) != 0) {
|
ssh_digest_final(hashctx, digest, mdsz) != 0) {
|
||||||
r = SSH_ERR_LIBCRYPTO_ERROR;
|
r = SSH_ERR_LIBCRYPTO_ERROR;
|
||||||
error_f("KEX hash failed");
|
error_f("KEX hash failed");
|
||||||
|
@ -1067,12 +1067,14 @@ kex_derive_keys(struct ssh *ssh, u_char *hash, u_int hashlen,
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
/* save initial hash as session id */
|
/* save initial hash as session id */
|
||||||
if (kex->session_id == NULL) {
|
if ((kex->flags & KEX_INITIAL) != 0) {
|
||||||
kex->session_id_len = hashlen;
|
if ((kex->session_id = sshbuf_new()) == NULL)
|
||||||
kex->session_id = malloc(kex->session_id_len);
|
|
||||||
if (kex->session_id == NULL)
|
|
||||||
return SSH_ERR_ALLOC_FAIL;
|
return SSH_ERR_ALLOC_FAIL;
|
||||||
memcpy(kex->session_id, hash, kex->session_id_len);
|
if ((r = sshbuf_put(kex->session_id, hash, hashlen)) != 0)
|
||||||
|
return r;
|
||||||
|
} else if (sshbuf_len(kex->session_id) == 0) {
|
||||||
|
error_f("no session ID in rekex");
|
||||||
|
return SSH_ERR_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
for (i = 0; i < NKEYS; i++) {
|
for (i = 0; i < NKEYS; i++) {
|
||||||
if ((r = derive_key(ssh, 'A'+i, kex->we_need, hash, hashlen,
|
if ((r = derive_key(ssh, 'A'+i, kex->we_need, hash, hashlen,
|
||||||
|
|
5
kex.h
5
kex.h
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: kex.h,v 1.112 2020/12/29 00:59:15 djm Exp $ */
|
/* $OpenBSD: kex.h,v 1.113 2021/01/27 10:05:28 djm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
|
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
|
||||||
|
@ -132,8 +132,6 @@ struct newkeys {
|
||||||
struct ssh;
|
struct ssh;
|
||||||
|
|
||||||
struct kex {
|
struct kex {
|
||||||
u_char *session_id;
|
|
||||||
size_t session_id_len;
|
|
||||||
struct newkeys *newkeys[MODE_MAX];
|
struct newkeys *newkeys[MODE_MAX];
|
||||||
u_int we_need;
|
u_int we_need;
|
||||||
u_int dh_need;
|
u_int dh_need;
|
||||||
|
@ -149,6 +147,7 @@ struct kex {
|
||||||
struct sshbuf *peer;
|
struct sshbuf *peer;
|
||||||
struct sshbuf *client_version;
|
struct sshbuf *client_version;
|
||||||
struct sshbuf *server_version;
|
struct sshbuf *server_version;
|
||||||
|
struct sshbuf *session_id;
|
||||||
sig_atomic_t done;
|
sig_atomic_t done;
|
||||||
u_int flags;
|
u_int flags;
|
||||||
int hash_alg;
|
int hash_alg;
|
||||||
|
|
49
monitor.c
49
monitor.c
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: monitor.c,v 1.222 2021/01/27 09:26:54 djm Exp $ */
|
/* $OpenBSD: monitor.c,v 1.223 2021/01/27 10:05:28 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||||
* Copyright 2002 Markus Friedl <markus@openbsd.org>
|
* Copyright 2002 Markus Friedl <markus@openbsd.org>
|
||||||
|
@ -104,7 +104,6 @@ static Gssctxt *gsscontext = NULL;
|
||||||
/* Imports */
|
/* Imports */
|
||||||
extern ServerOptions options;
|
extern ServerOptions options;
|
||||||
extern u_int utmp_len;
|
extern u_int utmp_len;
|
||||||
extern u_char session_id[];
|
|
||||||
extern struct sshbuf *loginmsg;
|
extern struct sshbuf *loginmsg;
|
||||||
extern struct sshauthopt *auth_opts; /* XXX move to permanent ssh->authctxt? */
|
extern struct sshauthopt *auth_opts; /* XXX move to permanent ssh->authctxt? */
|
||||||
|
|
||||||
|
@ -1431,7 +1430,9 @@ mm_answer_keyverify(struct ssh *ssh, int sock, struct sshbuf *m)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!valid_data)
|
if (!valid_data)
|
||||||
fatal_f("bad signature data blob");
|
fatal_f("bad %s signature data blob",
|
||||||
|
key_blobtype == MM_USERKEY ? "userkey" :
|
||||||
|
(key_blobtype == MM_HOSTKEY ? "hostkey" : "unknown"));
|
||||||
|
|
||||||
if ((fp = sshkey_fingerprint(key, options.fingerprint_hash,
|
if ((fp = sshkey_fingerprint(key, options.fingerprint_hash,
|
||||||
SSH_FP_DEFAULT)) == NULL)
|
SSH_FP_DEFAULT)) == NULL)
|
||||||
|
@ -1716,28 +1717,34 @@ monitor_apply_keystate(struct ssh *ssh, struct monitor *pmonitor)
|
||||||
fatal_fr(r, "packet_set_state");
|
fatal_fr(r, "packet_set_state");
|
||||||
sshbuf_free(child_state);
|
sshbuf_free(child_state);
|
||||||
child_state = NULL;
|
child_state = NULL;
|
||||||
|
if ((kex = ssh->kex) == NULL)
|
||||||
if ((kex = ssh->kex) != NULL) {
|
fatal_f("internal error: ssh->kex == NULL");
|
||||||
/* XXX set callbacks */
|
if (session_id2_len != sshbuf_len(ssh->kex->session_id)) {
|
||||||
|
fatal_f("incorrect session id length %zu (expected %u)",
|
||||||
|
sshbuf_len(ssh->kex->session_id), session_id2_len);
|
||||||
|
}
|
||||||
|
if (memcmp(sshbuf_ptr(ssh->kex->session_id), session_id2,
|
||||||
|
session_id2_len) != 0)
|
||||||
|
fatal_f("session ID mismatch");
|
||||||
|
/* XXX set callbacks */
|
||||||
#ifdef WITH_OPENSSL
|
#ifdef WITH_OPENSSL
|
||||||
kex->kex[KEX_DH_GRP1_SHA1] = kex_gen_server;
|
kex->kex[KEX_DH_GRP1_SHA1] = kex_gen_server;
|
||||||
kex->kex[KEX_DH_GRP14_SHA1] = kex_gen_server;
|
kex->kex[KEX_DH_GRP14_SHA1] = kex_gen_server;
|
||||||
kex->kex[KEX_DH_GRP14_SHA256] = kex_gen_server;
|
kex->kex[KEX_DH_GRP14_SHA256] = kex_gen_server;
|
||||||
kex->kex[KEX_DH_GRP16_SHA512] = kex_gen_server;
|
kex->kex[KEX_DH_GRP16_SHA512] = kex_gen_server;
|
||||||
kex->kex[KEX_DH_GRP18_SHA512] = kex_gen_server;
|
kex->kex[KEX_DH_GRP18_SHA512] = kex_gen_server;
|
||||||
kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
|
kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
|
||||||
kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
|
kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
|
||||||
# ifdef OPENSSL_HAS_ECC
|
# ifdef OPENSSL_HAS_ECC
|
||||||
kex->kex[KEX_ECDH_SHA2] = kex_gen_server;
|
kex->kex[KEX_ECDH_SHA2] = kex_gen_server;
|
||||||
# endif
|
# endif
|
||||||
#endif /* WITH_OPENSSL */
|
#endif /* WITH_OPENSSL */
|
||||||
kex->kex[KEX_C25519_SHA256] = kex_gen_server;
|
kex->kex[KEX_C25519_SHA256] = kex_gen_server;
|
||||||
kex->kex[KEX_KEM_SNTRUP761X25519_SHA512] = kex_gen_server;
|
kex->kex[KEX_KEM_SNTRUP761X25519_SHA512] = kex_gen_server;
|
||||||
kex->load_host_public_key=&get_hostkey_public_by_type;
|
kex->load_host_public_key=&get_hostkey_public_by_type;
|
||||||
kex->load_host_private_key=&get_hostkey_private_by_type;
|
kex->load_host_private_key=&get_hostkey_private_by_type;
|
||||||
kex->host_key_index=&get_hostkey_index;
|
kex->host_key_index=&get_hostkey_index;
|
||||||
kex->sign = sshd_hostkey_sign;
|
kex->sign = sshd_hostkey_sign;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function requires careful sanity checking */
|
/* This function requires careful sanity checking */
|
||||||
|
|
11
packet.c
11
packet.c
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: packet.c,v 1.298 2020/11/27 00:49:58 djm Exp $ */
|
/* $OpenBSD: packet.c,v 1.299 2021/01/27 10:05:28 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||||
|
@ -2196,9 +2196,7 @@ kex_to_blob(struct sshbuf *m, struct kex *kex)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if ((r = sshbuf_put_string(m, kex->session_id,
|
if ((r = sshbuf_put_u32(m, kex->we_need)) != 0 ||
|
||||||
kex->session_id_len)) != 0 ||
|
|
||||||
(r = sshbuf_put_u32(m, kex->we_need)) != 0 ||
|
|
||||||
(r = sshbuf_put_cstring(m, kex->hostkey_alg)) != 0 ||
|
(r = sshbuf_put_cstring(m, kex->hostkey_alg)) != 0 ||
|
||||||
(r = sshbuf_put_u32(m, kex->hostkey_type)) != 0 ||
|
(r = sshbuf_put_u32(m, kex->hostkey_type)) != 0 ||
|
||||||
(r = sshbuf_put_u32(m, kex->hostkey_nid)) != 0 ||
|
(r = sshbuf_put_u32(m, kex->hostkey_nid)) != 0 ||
|
||||||
|
@ -2207,6 +2205,7 @@ kex_to_blob(struct sshbuf *m, struct kex *kex)
|
||||||
(r = sshbuf_put_stringb(m, kex->peer)) != 0 ||
|
(r = sshbuf_put_stringb(m, kex->peer)) != 0 ||
|
||||||
(r = sshbuf_put_stringb(m, kex->client_version)) != 0 ||
|
(r = sshbuf_put_stringb(m, kex->client_version)) != 0 ||
|
||||||
(r = sshbuf_put_stringb(m, kex->server_version)) != 0 ||
|
(r = sshbuf_put_stringb(m, kex->server_version)) != 0 ||
|
||||||
|
(r = sshbuf_put_stringb(m, kex->session_id)) != 0 ||
|
||||||
(r = sshbuf_put_u32(m, kex->flags)) != 0)
|
(r = sshbuf_put_u32(m, kex->flags)) != 0)
|
||||||
return r;
|
return r;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2359,8 +2358,7 @@ kex_from_blob(struct sshbuf *m, struct kex **kexp)
|
||||||
|
|
||||||
if ((kex = kex_new()) == NULL)
|
if ((kex = kex_new()) == NULL)
|
||||||
return SSH_ERR_ALLOC_FAIL;
|
return SSH_ERR_ALLOC_FAIL;
|
||||||
if ((r = sshbuf_get_string(m, &kex->session_id, &kex->session_id_len)) != 0 ||
|
if ((r = sshbuf_get_u32(m, &kex->we_need)) != 0 ||
|
||||||
(r = sshbuf_get_u32(m, &kex->we_need)) != 0 ||
|
|
||||||
(r = sshbuf_get_cstring(m, &kex->hostkey_alg, NULL)) != 0 ||
|
(r = sshbuf_get_cstring(m, &kex->hostkey_alg, NULL)) != 0 ||
|
||||||
(r = sshbuf_get_u32(m, (u_int *)&kex->hostkey_type)) != 0 ||
|
(r = sshbuf_get_u32(m, (u_int *)&kex->hostkey_type)) != 0 ||
|
||||||
(r = sshbuf_get_u32(m, (u_int *)&kex->hostkey_nid)) != 0 ||
|
(r = sshbuf_get_u32(m, (u_int *)&kex->hostkey_nid)) != 0 ||
|
||||||
|
@ -2369,6 +2367,7 @@ kex_from_blob(struct sshbuf *m, struct kex **kexp)
|
||||||
(r = sshbuf_get_stringb(m, kex->peer)) != 0 ||
|
(r = sshbuf_get_stringb(m, kex->peer)) != 0 ||
|
||||||
(r = sshbuf_get_stringb(m, kex->client_version)) != 0 ||
|
(r = sshbuf_get_stringb(m, kex->client_version)) != 0 ||
|
||||||
(r = sshbuf_get_stringb(m, kex->server_version)) != 0 ||
|
(r = sshbuf_get_stringb(m, kex->server_version)) != 0 ||
|
||||||
|
(r = sshbuf_get_stringb(m, kex->session_id)) != 0 ||
|
||||||
(r = sshbuf_get_u32(m, &kex->flags)) != 0)
|
(r = sshbuf_get_u32(m, &kex->flags)) != 0)
|
||||||
goto out;
|
goto out;
|
||||||
kex->server = 1;
|
kex->server = 1;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: serverloop.c,v 1.224 2020/10/18 11:32:02 djm Exp $ */
|
/* $OpenBSD: serverloop.c,v 1.225 2021/01/27 10:05:28 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||||
|
@ -779,8 +779,8 @@ server_input_hostkeys_prove(struct ssh *ssh, struct sshbuf **respp)
|
||||||
sshkey_type_plain(key->type) == KEY_RSA;
|
sshkey_type_plain(key->type) == KEY_RSA;
|
||||||
if ((r = sshbuf_put_cstring(sigbuf,
|
if ((r = sshbuf_put_cstring(sigbuf,
|
||||||
"hostkeys-prove-00@openssh.com")) != 0 ||
|
"hostkeys-prove-00@openssh.com")) != 0 ||
|
||||||
(r = sshbuf_put_string(sigbuf,
|
(r = sshbuf_put_stringb(sigbuf,
|
||||||
ssh->kex->session_id, ssh->kex->session_id_len)) != 0 ||
|
ssh->kex->session_id)) != 0 ||
|
||||||
(r = sshkey_puts(key, sigbuf)) != 0 ||
|
(r = sshkey_puts(key, sigbuf)) != 0 ||
|
||||||
(r = ssh->kex->sign(ssh, key_prv, key_pub, &sig, &slen,
|
(r = ssh->kex->sign(ssh, key_prv, key_pub, &sig, &slen,
|
||||||
sshbuf_ptr(sigbuf), sshbuf_len(sigbuf),
|
sshbuf_ptr(sigbuf), sshbuf_len(sigbuf),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: ssh-gss.h,v 1.14 2018/07/10 09:13:30 djm Exp $ */
|
/* $OpenBSD: ssh-gss.h,v 1.15 2021/01/27 10:05:28 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
|
* Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -122,7 +122,7 @@ void ssh_gssapi_build_ctx(Gssctxt **);
|
||||||
void ssh_gssapi_delete_ctx(Gssctxt **);
|
void ssh_gssapi_delete_ctx(Gssctxt **);
|
||||||
OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t);
|
OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t);
|
||||||
void ssh_gssapi_buildmic(struct sshbuf *, const char *,
|
void ssh_gssapi_buildmic(struct sshbuf *, const char *,
|
||||||
const char *, const char *);
|
const char *, const char *, const struct sshbuf *);
|
||||||
int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *);
|
int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *);
|
||||||
|
|
||||||
/* In the server */
|
/* In the server */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: ssh_api.c,v 1.25 2021/01/27 09:26:54 djm Exp $ */
|
/* $OpenBSD: ssh_api.c,v 1.26 2021/01/27 10:05:28 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012 Markus Friedl. All rights reserved.
|
* Copyright (c) 2012 Markus Friedl. All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -60,10 +60,6 @@ int mm_sshkey_sign(struct sshkey *, u_char **, u_int *,
|
||||||
DH *mm_choose_dh(int, int, int);
|
DH *mm_choose_dh(int, int, int);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Define these two variables here so that they are part of the library */
|
|
||||||
u_char *session_id2 = NULL;
|
|
||||||
u_int session_id2_len = 0;
|
|
||||||
|
|
||||||
int
|
int
|
||||||
mm_sshkey_sign(struct sshkey *key, u_char **sigp, u_int *lenp,
|
mm_sshkey_sign(struct sshkey *key, u_char **sigp, u_int *lenp,
|
||||||
const u_char *data, u_int datalen, const char *alg,
|
const u_char *data, u_int datalen, const char *alg,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: sshconnect2.c,v 1.345 2021/01/27 09:26:54 djm Exp $ */
|
/* $OpenBSD: sshconnect2.c,v 1.346 2021/01/27 10:05:28 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
||||||
* Copyright (c) 2008 Damien Miller. All rights reserved.
|
* Copyright (c) 2008 Damien Miller. All rights reserved.
|
||||||
|
@ -89,9 +89,6 @@ extern Options options;
|
||||||
* SSH2 key exchange
|
* SSH2 key exchange
|
||||||
*/
|
*/
|
||||||
|
|
||||||
u_char *session_id2 = NULL;
|
|
||||||
u_int session_id2_len = 0;
|
|
||||||
|
|
||||||
static char *xxx_host;
|
static char *xxx_host;
|
||||||
static struct sockaddr *xxx_hostaddr;
|
static struct sockaddr *xxx_hostaddr;
|
||||||
static const struct ssh_conn_info *xxx_conn_info;
|
static const struct ssh_conn_info *xxx_conn_info;
|
||||||
|
@ -298,9 +295,6 @@ ssh_kex2(struct ssh *ssh, char *host, struct sockaddr *hostaddr, u_short port,
|
||||||
if ((r = kex_prop2buf(ssh->kex->my, myproposal)) != 0)
|
if ((r = kex_prop2buf(ssh->kex->my, myproposal)) != 0)
|
||||||
fatal_r(r, "kex_prop2buf");
|
fatal_r(r, "kex_prop2buf");
|
||||||
|
|
||||||
session_id2 = ssh->kex->session_id;
|
|
||||||
session_id2_len = ssh->kex->session_id_len;
|
|
||||||
|
|
||||||
#ifdef DEBUG_KEXDH
|
#ifdef DEBUG_KEXDH
|
||||||
/* send 1st encrypted/maced/compressed message */
|
/* send 1st encrypted/maced/compressed message */
|
||||||
if ((r = sshpkt_start(ssh, SSH2_MSG_IGNORE)) != 0 ||
|
if ((r = sshpkt_start(ssh, SSH2_MSG_IGNORE)) != 0 ||
|
||||||
|
@ -878,7 +872,8 @@ process_gssapi_token(struct ssh *ssh, gss_buffer_t recv_tok)
|
||||||
if ((b = sshbuf_new()) == NULL)
|
if ((b = sshbuf_new()) == NULL)
|
||||||
fatal_f("sshbuf_new failed");
|
fatal_f("sshbuf_new failed");
|
||||||
ssh_gssapi_buildmic(b, authctxt->server_user,
|
ssh_gssapi_buildmic(b, authctxt->server_user,
|
||||||
authctxt->service, "gssapi-with-mic");
|
authctxt->service, "gssapi-with-mic",
|
||||||
|
ssh->kex->session_id);
|
||||||
|
|
||||||
if ((gssbuf.value = sshbuf_mutable_ptr(b)) == NULL)
|
if ((gssbuf.value = sshbuf_mutable_ptr(b)) == NULL)
|
||||||
fatal_f("sshbuf_mutable_ptr failed");
|
fatal_f("sshbuf_mutable_ptr failed");
|
||||||
|
@ -1409,13 +1404,12 @@ sign_and_send_pubkey(struct ssh *ssh, Identity *id)
|
||||||
if ((b = sshbuf_new()) == NULL)
|
if ((b = sshbuf_new()) == NULL)
|
||||||
fatal_f("sshbuf_new failed");
|
fatal_f("sshbuf_new failed");
|
||||||
if (ssh->compat & SSH_OLD_SESSIONID) {
|
if (ssh->compat & SSH_OLD_SESSIONID) {
|
||||||
if ((r = sshbuf_put(b, session_id2,
|
if ((r = sshbuf_putb(b, ssh->kex->session_id)) != 0)
|
||||||
session_id2_len)) != 0)
|
fatal_fr(r, "sshbuf_putb");
|
||||||
fatal_fr(r, "sshbuf_put");
|
|
||||||
} else {
|
} else {
|
||||||
if ((r = sshbuf_put_string(b, session_id2,
|
if ((r = sshbuf_put_stringb(b,
|
||||||
session_id2_len)) != 0)
|
ssh->kex->session_id)) != 0)
|
||||||
fatal_fr(r, "sshbuf_put_string");
|
fatal_fr(r, "sshbuf_put_stringb");
|
||||||
}
|
}
|
||||||
skip = sshbuf_len(b);
|
skip = sshbuf_len(b);
|
||||||
if ((r = sshbuf_put_u8(b, SSH2_MSG_USERAUTH_REQUEST)) != 0 ||
|
if ((r = sshbuf_put_u8(b, SSH2_MSG_USERAUTH_REQUEST)) != 0 ||
|
||||||
|
@ -2172,7 +2166,7 @@ userauth_hostbased(struct ssh *ssh)
|
||||||
error_fr(r, "sshkey_to_blob");
|
error_fr(r, "sshkey_to_blob");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if ((r = sshbuf_put_string(b, session_id2, session_id2_len)) != 0 ||
|
if ((r = sshbuf_put_stringb(b, ssh->kex->session_id)) != 0 ||
|
||||||
(r = sshbuf_put_u8(b, SSH2_MSG_USERAUTH_REQUEST)) != 0 ||
|
(r = sshbuf_put_u8(b, SSH2_MSG_USERAUTH_REQUEST)) != 0 ||
|
||||||
(r = sshbuf_put_cstring(b, authctxt->server_user)) != 0 ||
|
(r = sshbuf_put_cstring(b, authctxt->server_user)) != 0 ||
|
||||||
(r = sshbuf_put_cstring(b, authctxt->service)) != 0 ||
|
(r = sshbuf_put_cstring(b, authctxt->service)) != 0 ||
|
||||||
|
|
12
sshd.c
12
sshd.c
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: sshd.c,v 1.568 2021/01/27 09:26:54 djm Exp $ */
|
/* $OpenBSD: sshd.c,v 1.569 2021/01/27 10:05:28 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||||
|
@ -205,13 +205,6 @@ struct {
|
||||||
static volatile sig_atomic_t received_sighup = 0;
|
static volatile sig_atomic_t received_sighup = 0;
|
||||||
static volatile sig_atomic_t received_sigterm = 0;
|
static volatile sig_atomic_t received_sigterm = 0;
|
||||||
|
|
||||||
/* session identifier, used by RSA-auth */
|
|
||||||
u_char session_id[16];
|
|
||||||
|
|
||||||
/* same for ssh2 */
|
|
||||||
u_char *session_id2 = NULL;
|
|
||||||
u_int session_id2_len = 0;
|
|
||||||
|
|
||||||
/* record remote hostname or ip */
|
/* record remote hostname or ip */
|
||||||
u_int utmp_len = HOST_NAME_MAX+1;
|
u_int utmp_len = HOST_NAME_MAX+1;
|
||||||
|
|
||||||
|
@ -2398,9 +2391,6 @@ do_ssh2_kex(struct ssh *ssh)
|
||||||
|
|
||||||
ssh_dispatch_run_fatal(ssh, DISPATCH_BLOCK, &kex->done);
|
ssh_dispatch_run_fatal(ssh, DISPATCH_BLOCK, &kex->done);
|
||||||
|
|
||||||
session_id2 = kex->session_id;
|
|
||||||
session_id2_len = kex->session_id_len;
|
|
||||||
|
|
||||||
#ifdef DEBUG_KEXDH
|
#ifdef DEBUG_KEXDH
|
||||||
/* send 1st encrypted/maced/compressed message */
|
/* send 1st encrypted/maced/compressed message */
|
||||||
if ((r = sshpkt_start(ssh, SSH2_MSG_IGNORE)) != 0 ||
|
if ((r = sshpkt_start(ssh, SSH2_MSG_IGNORE)) != 0 ||
|
||||||
|
|
Loading…
Reference in New Issue