-/* $OpenBSD: kexdhs.c,v 1.7 2006/08/03 03:34:42 deraadt Exp $ */
+/* $OpenBSD: kexdhs.c,v 1.10 2009/06/21 07:37:15 dtucker Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
*
#include "includes.h"
#include <sys/types.h>
+
+#include <stdarg.h>
#include <string.h>
#include <signal.h>
DH *dh;
Key *server_host_key;
u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL;
- u_int sbloblen, klen, kout, hashlen;
- u_int slen;
+ u_int sbloblen, klen, hashlen, slen;
+ int kout;
/* generate server DH public key */
switch (kex->kex_type) {
klen = DH_size(dh);
kbuf = xmalloc(klen);
- kout = DH_compute_key(kbuf, dh_client_pub, dh);
+ if ((kout = DH_compute_key(kbuf, dh_client_pub, dh)) < 0)
+ fatal("DH_compute_key: failed");
#ifdef DEBUG_KEXDH
dump_digest("shared secret", kbuf, kout);
#endif
if ((shared_secret = BN_new()) == NULL)
fatal("kexdh_server: BN_new failed");
- BN_bin2bn(kbuf, kout, shared_secret);
+ if (BN_bin2bn(kbuf, kout, shared_secret) == NULL)
+ fatal("kexdh_server: BN_bin2bn failed");
memset(kbuf, 0, klen);
xfree(kbuf);
}
/* sign H */
- PRIVSEP(key_sign(server_host_key, &signature, &slen, hash, hashlen));
+ if (PRIVSEP(key_sign(server_host_key, &signature, &slen, hash,
+ hashlen)) < 0)
+ fatal("kexdh_server: key_sign failed");
/* destroy_sensitive_data(); */