summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2010-01-08 16:53:31 +1100
committerDarren Tucker <dtucker@zip.com.au>2010-01-08 16:53:31 +1100
commite730118bf41c70bd519e595a7dda39df551852eb (patch)
tree7e9373bf8e88354d941fd94289bee3b3d1849703
parentf9e6eb8f226675389c79fb9c44fcc29038ab9ff7 (diff)
- andreas@cvs.openbsd.org 2009/10/24 11:22:37
[roaming_common.c] Do the actual suspend/resume in the client. This won't be useful until the server side supports roaming. Most code from Martin Forssen, maf at appgate dot com. Some changes by me and markus@ ok markus@
-rw-r--r--ChangeLog7
-rw-r--r--roaming_common.c47
2 files changed, 53 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 3ee863580..d45a896bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,13 @@
18 [ssh2.h] 18 [ssh2.h]
19 Define the KEX messages used when resuming a suspended connection. 19 Define the KEX messages used when resuming a suspended connection.
20 ok markus@ 20 ok markus@
21 - andreas@cvs.openbsd.org 2009/10/24 11:22:37
22 [roaming_common.c]
23 Do the actual suspend/resume in the client. This won't be useful until
24 the server side supports roaming.
25 Most code from Martin Forssen, maf at appgate dot com. Some changes by
26 me and markus@
27 ok markus@
21 28
2220091226 2920091226
23 - (tim) [contrib/cygwin/Makefile] Install ssh-copy-id and ssh-copy-id.1 30 - (tim) [contrib/cygwin/Makefile] Install ssh-copy-id and ssh-copy-id.1
diff --git a/roaming_common.c b/roaming_common.c
index 73db09d79..272deade3 100644
--- a/roaming_common.c
+++ b/roaming_common.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: roaming_common.c,v 1.5 2009/06/27 09:32:43 andreas Exp $ */ 1/* $OpenBSD: roaming_common.c,v 1.6 2009/10/24 11:22:37 andreas Exp $ */
2/* 2/*
3 * Copyright (c) 2004-2009 AppGate Network Security AB 3 * Copyright (c) 2004-2009 AppGate Network Security AB
4 * 4 *
@@ -147,6 +147,16 @@ roaming_write(int fd, const void *buf, size_t count, int *cont)
147 } 147 }
148 debug3("Wrote %ld bytes for a total of %llu", (long)ret, 148 debug3("Wrote %ld bytes for a total of %llu", (long)ret,
149 (unsigned long long)write_bytes); 149 (unsigned long long)write_bytes);
150 if (out_buf_size > 0 &&
151 (ret == 0 || (ret == -1 && errno == EPIPE))) {
152 if (wait_for_roaming_reconnect() != 0) {
153 ret = 0;
154 *cont = 1;
155 } else {
156 ret = -1;
157 errno = EAGAIN;
158 }
159 }
150 return ret; 160 return ret;
151} 161}
152 162
@@ -158,6 +168,15 @@ roaming_read(int fd, void *buf, size_t count, int *cont)
158 if (!resume_in_progress) { 168 if (!resume_in_progress) {
159 read_bytes += ret; 169 read_bytes += ret;
160 } 170 }
171 } else if (out_buf_size > 0 &&
172 (ret == 0 || (ret == -1 && (errno == ECONNRESET
173 || errno == ECONNABORTED || errno == ETIMEDOUT
174 || errno == EHOSTUNREACH)))) {
175 debug("roaming_read failed for %d ret=%ld errno=%d",
176 fd, (long)ret, errno);
177 ret = 0;
178 if (wait_for_roaming_reconnect() == 0)
179 *cont = 1;
161 } 180 }
162 return ret; 181 return ret;
163} 182}
@@ -199,3 +218,29 @@ resend_bytes(int fd, u_int64_t *offset)
199 atomicio(vwrite, fd, out_buf + (out_last - needed), needed); 218 atomicio(vwrite, fd, out_buf + (out_last - needed), needed);
200 } 219 }
201} 220}
221
222/*
223 * Caclulate a new key after a reconnect
224 */
225void
226calculate_new_key(u_int64_t *key, u_int64_t cookie, u_int64_t challenge)
227{
228 const EVP_MD *md = EVP_sha1();
229 EVP_MD_CTX ctx;
230 char hash[EVP_MAX_MD_SIZE];
231 Buffer b;
232
233 buffer_init(&b);
234 buffer_put_int64(&b, *key);
235 buffer_put_int64(&b, cookie);
236 buffer_put_int64(&b, challenge);
237
238 EVP_DigestInit(&ctx, md);
239 EVP_DigestUpdate(&ctx, buffer_ptr(&b), buffer_len(&b));
240 EVP_DigestFinal(&ctx, hash, NULL);
241
242 buffer_clear(&b);
243 buffer_append(&b, hash, EVP_MD_size(md));
244 *key = buffer_get_int64(&b);
245 buffer_free(&b);
246}