Deleted Added
full compact
kexdhs.c (181110) kexdhs.c (197679)
1/* $OpenBSD: kexdhs.c,v 1.9 2006/11/06 21:25:28 markus Exp $ */
1/* $OpenBSD: kexdhs.c,v 1.10 2009/06/21 07:37:15 dtucker Exp $ */
2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

--- 122 unchanged lines hidden (view full) ---

132 /* save session id := H */
133 if (kex->session_id == NULL) {
134 kex->session_id_len = hashlen;
135 kex->session_id = xmalloc(kex->session_id_len);
136 memcpy(kex->session_id, hash, kex->session_id_len);
137 }
138
139 /* sign H */
2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

--- 122 unchanged lines hidden (view full) ---

132 /* save session id := H */
133 if (kex->session_id == NULL) {
134 kex->session_id_len = hashlen;
135 kex->session_id = xmalloc(kex->session_id_len);
136 memcpy(kex->session_id, hash, kex->session_id_len);
137 }
138
139 /* sign H */
140 PRIVSEP(key_sign(server_host_key, &signature, &slen, hash, hashlen));
140 if (PRIVSEP(key_sign(server_host_key, &signature, &slen, hash,
141 hashlen)) < 0)
142 fatal("kexdh_server: key_sign failed");
141
142 /* destroy_sensitive_data(); */
143
144 /* send server hostkey, DH pubkey 'f' and singed H */
145 packet_start(SSH2_MSG_KEXDH_REPLY);
146 packet_put_string(server_host_key_blob, sbloblen);
147 packet_put_bignum2(dh->pub_key); /* f */
148 packet_put_string(signature, slen);
149 packet_send();
150
151 xfree(signature);
152 xfree(server_host_key_blob);
153 /* have keys, free DH */
154 DH_free(dh);
155
156 kex_derive_keys(kex, hash, hashlen, shared_secret);
157 BN_clear_free(shared_secret);
158 kex_finish(kex);
159}
143
144 /* destroy_sensitive_data(); */
145
146 /* send server hostkey, DH pubkey 'f' and singed H */
147 packet_start(SSH2_MSG_KEXDH_REPLY);
148 packet_put_string(server_host_key_blob, sbloblen);
149 packet_put_bignum2(dh->pub_key); /* f */
150 packet_put_string(signature, slen);
151 packet_send();
152
153 xfree(signature);
154 xfree(server_host_key_blob);
155 /* have keys, free DH */
156 DH_free(dh);
157
158 kex_derive_keys(kex, hash, hashlen, shared_secret);
159 BN_clear_free(shared_secret);
160 kex_finish(kex);
161}