/*
* Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
/*
* May 22, 2015
* In version 6.8 a new packet interface has been introduced to OpenSSH,
* while the old packet API has been provided in opacket.c.
* At this moment we are not rewritting GSS-API key exchange code to the new
* API, just adjusting it to still work with new struct ssh.
* Rewritting to the new API can be considered in the future.
*/
#include "includes.h"
#ifdef GSSAPI
#include <string.h>
#include "xmalloc.h"
#include "buffer.h"
#include "ssh2.h"
#include "key.h"
#include "cipher.h"
#include "digest.h"
#include "kex.h"
#include "log.h"
#include "packet.h"
#include "dh.h"
#include "ssh-gss.h"
#include "monitor_wrap.h"
int
{
/*
* Some GSSAPI implementations use the input value of ret_flags (an
* output variable) as a means of triggering mechanism specific
* features. Initializing it to zero avoids inadvertently
* activating this non-standard behaviour.
*/
int type = 0;
char *mechs;
int r;
/* Initialise GSSAPI */
/*
* If we're rekeying, privsep means that some of the private structures
* in the GSSAPI code are no longer available. This kludges them back
* into life
*/
if (!ssh_gssapi_oid_table_ok())
if ((mechs = ssh_gssapi_server_mechanisms()))
if (oid == GSS_C_NO_OID)
fatal("Unknown gssapi mechanism");
fatal("Unable to acquire credentials for the server");
case KEX_GSS_GRP1_SHA1:
break;
case KEX_GSS_GRP14_SHA1:
break;
case KEX_GSS_GEX_SHA1:
debug("Doing group exchange");
fatal("GSS_GEX, bad parameters: %d !< %d !< %d",
packet_disconnect("Protocol error:"
" no matching group found");
packet_send();
break;
default:
}
do {
debug("Wait SSH2_MSG_GSSAPI_INIT");
type = packet_read();
switch (type) {
case SSH2_MSG_KEXGSS_INIT:
if (dh_client_pub != NULL)
fatal("Received KEXGSS_INIT after"
" initialising");
fatal("dh_client_pub == NULL");
/* Send SSH_MSG_KEXGSS_HOSTKEY here, if we want */
break;
case SSH2_MSG_KEXGSS_CONTINUE:
break;
default:
"Protocol error: didn't expect packet type %d",
type);
}
fatal("Zero length token output when incomplete");
if (dh_client_pub == NULL)
fatal("No client public key");
if (maj_status & GSS_S_CONTINUE_NEEDED) {
debug("Sending GSSAPI_CONTINUE");
packet_send();
}
} while (maj_status & GSS_S_CONTINUE_NEEDED);
if (GSS_ERROR(maj_status)) {
packet_send();
}
fatal("accept_ctx died");
}
if (!(ret_flags & GSS_C_MUTUAL_FLAG))
fatal("Mutual Authentication flag wasn't set");
if (!(ret_flags & GSS_C_INTEG_FLAG))
fatal("Integrity flag wasn't set");
packet_disconnect("bad client public DH value");
if (kout < 0)
fatal("DH_compute_key: failed");
shared_secret = BN_new();
if (shared_secret == NULL)
fatal("kexgss_server: BN_new failed");
fatal("kexgss_server: BN_bin2bn failed");
case KEX_GSS_GRP1_SHA1:
case KEX_GSS_GRP14_SHA1:
NULL, 0, /* Change this if we start sending host keys */
break;
case KEX_GSS_GEX_SHA1:
NULL, 0,
break;
default:
}
}
fatal("Couldn't get MIC");
} else {
packet_put_char(0); /* false */
}
packet_send();
if (gss_kex_context == NULL)
else
r = kex_send_newkeys(ssh);
return (r);
}
#endif /* GSSAPI */