summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3428
-rw-r--r--LICENCE1
-rw-r--r--Makefile.in51
-rw-r--r--PROTOCOL61
-rw-r--r--PROTOCOL.agent44
-rw-r--r--PROTOCOL.certkeys89
-rw-r--r--PROTOCOL.mux26
-rw-r--r--README4
-rw-r--r--atomicio.c33
-rw-r--r--atomicio.h8
-rw-r--r--audit-bsm.c6
-rw-r--r--audit-linux.c126
-rw-r--r--audit.c10
-rw-r--r--audit.h9
-rw-r--r--auth-options.c10
-rw-r--r--auth-rsa.c9
-rw-r--r--auth.c32
-rw-r--r--auth1.c6
-rw-r--r--auth2-jpake.c7
-rw-r--r--auth2-pubkey.c4
-rw-r--r--auth2.c10
-rw-r--r--authfd.c22
-rw-r--r--authfile.c474
-rw-r--r--bufaux.c35
-rw-r--r--bufec.c146
-rw-r--r--buffer.h13
-rw-r--r--canohost.c2
-rw-r--r--channels.c5
-rw-r--r--cipher-3des1.c5
-rw-r--r--cipher-acss.c3
-rw-r--r--cipher-aes.c2
-rw-r--r--cipher-bf1.c8
-rw-r--r--cipher-ctr.c12
-rw-r--r--clientloop.c40
-rw-r--r--compress.c5
-rw-r--r--config.h.in36
-rwxr-xr-xconfigure1088
-rw-r--r--configure.ac153
-rw-r--r--contrib/caldera/openssh.spec12
-rw-r--r--contrib/redhat/openssh.spec2
-rwxr-xr-xcontrib/redhat/sshd.init2
-rw-r--r--contrib/suse/openssh.spec2
-rw-r--r--defines.h48
-rw-r--r--dns.c3
-rw-r--r--entropy.c2
-rw-r--r--hostfile.c302
-rw-r--r--hostfile.h30
-rw-r--r--includes.h2
-rw-r--r--jpake.c9
-rw-r--r--kex.c40
-rw-r--r--kex.h25
-rw-r--r--kexdhc.c4
-rw-r--r--kexdhs.c4
-rw-r--r--kexecdh.c117
-rw-r--r--kexecdhc.c168
-rw-r--r--kexecdhs.c173
-rw-r--r--kexgexc.c4
-rw-r--r--kexgexs.c4
-rw-r--r--key.c673
-rw-r--r--key.h33
-rw-r--r--loginrec.c28
-rw-r--r--loginrec.h12
-rw-r--r--misc.c139
-rw-r--r--misc.h14
-rw-r--r--moduli.01
-rw-r--r--moduli.c10
-rw-r--r--monitor.c9
-rw-r--r--monitor_wrap.c3
-rw-r--r--mux.c60
-rw-r--r--myproposal.h51
-rw-r--r--openbsd-compat/Makefile.in4
-rw-r--r--openbsd-compat/bindresvport.c2
-rw-r--r--openbsd-compat/bsd-misc.c7
-rw-r--r--openbsd-compat/bsd-misc.h6
-rw-r--r--openbsd-compat/charclass.h31
-rw-r--r--openbsd-compat/glob.c306
-rw-r--r--openbsd-compat/glob.h13
-rw-r--r--openbsd-compat/openbsd-compat.h6
-rw-r--r--openbsd-compat/openssl-compat.c76
-rw-r--r--openbsd-compat/openssl-compat.h26
-rw-r--r--openbsd-compat/port-linux.c57
-rw-r--r--openbsd-compat/port-solaris.c32
-rw-r--r--openbsd-compat/port-solaris.h5
-rw-r--r--openbsd-compat/timingsafe_bcmp.c34
-rwxr-xr-xopensshd.init.in4
-rw-r--r--packet.c53
-rw-r--r--packet.h14
-rw-r--r--pathnames.h4
-rw-r--r--platform.c132
-rw-r--r--platform.h7
-rw-r--r--readconf.c51
-rw-r--r--readconf.h5
-rw-r--r--readpass.c27
-rw-r--r--regress/Makefile69
-rw-r--r--regress/agent-getpeereid.sh9
-rw-r--r--regress/agent-ptrace.sh2
-rw-r--r--regress/cert-hostkey.sh31
-rw-r--r--regress/cert-userkey.sh25
-rw-r--r--regress/host-expand.sh18
-rw-r--r--regress/kextype.sh30
-rw-r--r--regress/keytype.sh55
-rw-r--r--regress/multiplex.sh3
-rw-r--r--regress/sftp-cmds.sh10
-rw-r--r--regress/sftp-glob.sh23
-rw-r--r--regress/test-exec.sh11
-rw-r--r--schnorr.c38
-rw-r--r--scp.012
-rw-r--r--scp.116
-rw-r--r--scp.c241
-rw-r--r--servconf.c61
-rw-r--r--servconf.h5
-rw-r--r--session.c80
-rw-r--r--sftp-client.c259
-rw-r--r--sftp-client.h7
-rw-r--r--sftp-server.02
-rw-r--r--sftp-server.c42
-rw-r--r--sftp.023
-rw-r--r--sftp.129
-rw-r--r--sftp.c141
-rw-r--r--ssh-add.016
-rw-r--r--ssh-add.117
-rw-r--r--ssh-add.c7
-rw-r--r--ssh-agent.035
-rw-r--r--ssh-agent.119
-rw-r--r--ssh-agent.c67
-rw-r--r--ssh-dss.c4
-rw-r--r--ssh-ecdsa.c168
-rw-r--r--ssh-keygen.065
-rw-r--r--ssh-keygen.148
-rw-r--r--ssh-keygen.c62
-rw-r--r--ssh-keyscan.015
-rw-r--r--ssh-keyscan.120
-rw-r--r--ssh-keyscan.c18
-rw-r--r--ssh-keysign.010
-rw-r--r--ssh-keysign.816
-rw-r--r--ssh-keysign.c4
-rw-r--r--ssh-rsa.c4
-rw-r--r--ssh.068
-rw-r--r--ssh.185
-rw-r--r--ssh.c96
-rw-r--r--ssh2.h6
-rw-r--r--ssh_config.058
-rw-r--r--ssh_config.577
-rw-r--r--sshconnect.c322
-rw-r--r--sshconnect.h12
-rw-r--r--sshconnect2.c65
-rw-r--r--sshd.032
-rw-r--r--sshd.873
-rw-r--r--sshd.c14
-rw-r--r--sshd_config3
-rw-r--r--sshd_config.047
-rw-r--r--sshd_config.561
-rw-r--r--sshlogin.c2
-rw-r--r--uuencode.c4
-rw-r--r--uuencode.h4
-rw-r--r--version.h4
156 files changed, 7314 insertions, 4467 deletions
diff --git a/ChangeLog b/ChangeLog
index e3ac6a925..0356a33c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,688 @@
120110122
2 - (dtucker) [configure.ac openbsd-compat/openssl-compat.{c,h}] Add
3 RSA_get_default_method() for the benefit of openssl versions that don't
4 have it (at least openssl-engine-0.9.6b). Found and tested by Kevin Brott,
5 ok djm@.
6 - OpenBSD CVS Sync
7 - djm@cvs.openbsd.org 2011/01/22 09:18:53
8 [version.h]
9 crank to OpenSSH-5.7
10 - (djm) [README contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
11 [contrib/suse/openssh.spec] update versions in docs and spec files.
12 - (djm) Release 5.7p1
13
1420110119
15 - (tim) [contrib/caldera/openssh.spec] Use CFLAGS from Makefile instead
16 of RPM so build completes. Signatures were changed to .asc since 4.1p1.
17 - (djm) [configure.ac] Disable ECC on OpenSSL <0.9.8g. Releases prior to
18 0.9.8 lacked it, and 0.9.8a through 0.9.8d have proven buggy in pre-
19 release testing (random crashes and failure to load ECC keys).
20 ok dtucker@
21
2220110117
23 - (djm) [regress/Makefile] use $TEST_SSH_KEYGEN instead of the one in
24 $PATH, fix cleanup of droppings; reported by openssh AT
25 roumenpetrov.info; ok dtucker@
26 - (djm) [regress/agent-ptrace.sh] Fix false failure on OS X by adding
27 its unique snowflake of a gdb error to the ones we look for.
28 - (djm) [regress/agent-getpeereid.sh] leave stdout attached when running
29 ssh-add to avoid $SUDO failures on Linux
30 - (dtucker) [openbsd-compat/port-linux.c] Bug #1838: Add support for the new
31 Linux OOM-killer magic values that changed in 2.6.36 kernels, with fallback
32 to the old values. Feedback from vapier at gentoo org and djm, ok djm.
33 - (djm) [configure.ac regress/agent-getpeereid.sh regress/multiplex.sh]
34 [regress/sftp-glob.sh regress/test-exec.sh] Rework how feature tests are
35 disabled on platforms that do not support them; add a "config_defined()"
36 shell function that greps for defines in config.h and use them to decide
37 on feature tests.
38 Convert a couple of existing grep's over config.h to use the new function
39 Add a define "FILESYSTEM_NO_BACKSLASH" for filesystem that can't represent
40 backslash characters in filenames, enable it for Cygwin and use it to turn
41 of tests for quotes backslashes in sftp-glob.sh.
42 based on discussion with vinschen AT redhat.com and dtucker@; ok dtucker@
43 - (tim) [regress/agent-getpeereid.sh] shell portability fix.
44 - (dtucker) [openbsd-compat/port-linux.c] Fix minor bug caught by -Werror on
45 the tinderbox.
46 - (dtucker) [LICENCE Makefile.in audit-bsm.c audit-linux.c audit.c audit.h
47 configure.ac defines.h loginrec.c] Bug #1402: add linux audit subsystem
48 support, based on patches from Tomas Mraz and jchadima at redhat.
49
5020110116
51 - (dtucker) [Makefile.in configure.ac regress/kextype.sh] Skip sha256-based
52 on configurations that don't have it.
53 - OpenBSD CVS Sync
54 - djm@cvs.openbsd.org 2011/01/16 11:50:05
55 [clientloop.c]
56 Use atomicio when flushing protocol 1 std{out,err} buffers at
57 session close. This was a latent bug exposed by setting a SIGCHLD
58 handler and spotted by kevin.brott AT gmail.com; ok dtucker@
59 - djm@cvs.openbsd.org 2011/01/16 11:50:36
60 [sshconnect.c]
61 reset the SIGPIPE handler when forking to execute child processes;
62 ok dtucker@
63 - djm@cvs.openbsd.org 2011/01/16 12:05:59
64 [clientloop.c]
65 a couple more tweaks to the post-close protocol 1 stderr/stdout flush:
66 now that we use atomicio(), convert them from while loops to if statements
67 add test and cast to compile cleanly with -Wsigned
68
6920110114
70 - OpenBSD CVS Sync
71 - djm@cvs.openbsd.org 2011/01/13 21:54:53
72 [mux.c]
73 correct error messages; patch from bert.wesarg AT googlemail.com
74 - djm@cvs.openbsd.org 2011/01/13 21:55:25
75 [PROTOCOL.mux]
76 correct protocol names and add a couple of missing protocol number
77 defines; patch from bert.wesarg AT googlemail.com
78 - (djm) [Makefile.in] Use shell test to disable ecdsa key generating in
79 host-key-force target rather than a substitution that is replaced with a
80 comment so that the Makefile.in is still a syntactically valid Makefile
81 (useful to run the distprep target)
82 - (tim) [regress/cert-hostkey.sh] Typo. Missing $ on variable name.
83 - (tim) [regress/cert-hostkey.sh] Add missing TEST_SSH_ECC guard around some
84 ecdsa bits.
85
8620110113
87 - (djm) [misc.c] include time.h for nanosleep() prototype
88 - (tim) [Makefile.in] test the ECC bits if we have the capability. ok djm
89 - (tim) [Makefile.in configure.ac opensshd.init.in] Add support for generating
90 ecdsa keys. ok djm.
91 - (djm) [entropy.c] cast OPENSSL_VERSION_NUMBER to u_long to avoid
92 gcc warning on platforms where it defaults to int
93 - (djm) [regress/Makefile] add a few more generated files to the clean
94 target
95 - (djm) [myproposal.h] Fix reversed OPENSSL_VERSION_NUMBER test and bad
96 #define that was causing diffie-hellman-group-exchange-sha256 to be
97 incorrectly disabled
98 - (djm) [regress/kextype.sh] Testing diffie-hellman-group-exchange-sha256
99 should not depend on ECC support
100
10120110112
102 - OpenBSD CVS Sync
103 - nicm@cvs.openbsd.org 2010/10/08 21:48:42
104 [openbsd-compat/glob.c]
105 Extend GLOB_LIMIT to cover readdir and stat and bump the malloc limit
106 from ARG_MAX to 64K.
107 Fixes glob-using programs (notably ftp) able to be triggered to hit
108 resource limits.
109 Idea from a similar NetBSD change, original problem reported by jasper@.
110 ok millert tedu jasper
111 - djm@cvs.openbsd.org 2011/01/12 01:53:14
112 avoid some integer overflows mostly with GLOB_APPEND and GLOB_DOOFFS
113 and sanity check arguments (these will be unnecessary when we switch
114 struct glob members from being type into to size_t in the future);
115 "looks ok" tedu@ feedback guenther@
116 - (djm) [configure.ac] Turn on -Wno-unused-result for gcc >= 4.4 to avoid
117 silly warnings on write() calls we don't care succeed or not.
118 - (djm) [configure.ac] Fix broken test for gcc >= 4.4 with per-compiler
119 flag tests that don't depend on gcc version at all; suggested by and
120 ok dtucker@
121
12220110111
123 - (tim) [regress/host-expand.sh] Fix for building outside of read only
124 source tree.
125 - (djm) [platform.c] Some missing includes that show up under -Werror
126 - OpenBSD CVS Sync
127 - djm@cvs.openbsd.org 2011/01/08 10:51:51
128 [clientloop.c]
129 use host and not options.hostname, as the latter may have unescaped
130 substitution characters
131 - djm@cvs.openbsd.org 2011/01/11 06:06:09
132 [sshlogin.c]
133 fd leak on error paths; from zinovik@
134 NB. Id sync only; we use loginrec.c that was also audited and fixed
135 recently
136 - djm@cvs.openbsd.org 2011/01/11 06:13:10
137 [clientloop.c ssh-keygen.c sshd.c]
138 some unsigned long long casts that make things a bit easier for
139 portable without resorting to dropping PRIu64 formats everywhere
140
14120110109
142 - (djm) [Makefile.in] list ssh_host_ecdsa key in PATHSUBS; spotted by
143 openssh AT roumenpetrov.info
144
14520110108
146 - (djm) [regress/keytype.sh] s/echo -n/echon/ to repair failing regress
147 test on OSX and others. Reported by imorgan AT nas.nasa.gov
148
14920110107
150 - (djm) [regress/cert-hostkey.sh regress/cert-userkey.sh] fix shell test
151 for no-ECC case. Patch from cristian.ionescu-idbohrn AT axis.com
152 - djm@cvs.openbsd.org 2011/01/06 22:23:53
153 [ssh.c]
154 unbreak %n expansion in LocalCommand; patch from bert.wesarg AT
155 googlemail.com; ok markus@
156 - djm@cvs.openbsd.org 2011/01/06 22:23:02
157 [clientloop.c]
158 when exiting due to ServerAliveTimeout, mention the hostname that caused
159 it (useful with backgrounded controlmaster)
160 - djm@cvs.openbsd.org 2011/01/06 22:46:21
161 [regress/Makefile regress/host-expand.sh]
162 regress test for LocalCommand %n expansion from bert.wesarg AT
163 googlemail.com; ok markus@
164 - djm@cvs.openbsd.org 2011/01/06 23:01:35
165 [sshconnect.c]
166 reset SIGCHLD handler to SIG_DFL when execuring LocalCommand;
167 ok markus@
168
16920110106
170 - (djm) OpenBSD CVS Sync
171 - markus@cvs.openbsd.org 2010/12/08 22:46:03
172 [scp.1 scp.c]
173 add a new -3 option to scp: Copies between two remote hosts are
174 transferred through the local host. Without this option the data
175 is copied directly between the two remote hosts. ok djm@ (bugzilla #1837)
176 - jmc@cvs.openbsd.org 2010/12/09 14:13:33
177 [scp.1 scp.c]
178 scp.1: grammer fix
179 scp.c: add -3 to usage()
180 - markus@cvs.openbsd.org 2010/12/14 11:59:06
181 [sshconnect.c]
182 don't mention key type in key-changed-warning, since we also print
183 this warning if a new key type appears. ok djm@
184 - djm@cvs.openbsd.org 2010/12/15 00:49:27
185 [readpass.c]
186 fix ControlMaster=ask regression
187 reset SIGCHLD handler before fork (and restore it after) so we don't miss
188 the the askpass child's exit status. Correct test for exit status/signal to
189 account for waitpid() failure; with claudio@ ok claudio@ markus@
190 - djm@cvs.openbsd.org 2010/12/24 21:41:48
191 [auth-options.c]
192 don't send the actual forced command in a debug message; ok markus deraadt
193 - otto@cvs.openbsd.org 2011/01/04 20:44:13
194 [ssh-keyscan.c]
195 handle ecdsa-sha2 with various key lengths; hint and ok djm@
196
19720110104
198 - (djm) [configure.ac Makefile.in] Use mandoc as preferred manpage
199 formatter if it is present, followed by nroff and groff respectively.
200 Fixes distprep target on OpenBSD (which has bumped groff/nroff to ports
201 in favour of mandoc). feedback and ok tim
202
20320110103
204 - (djm) [Makefile.in] revert local hack I didn't intend to commit
205
20620110102
207 - (djm) [loginrec.c] Fix some fd leaks on error paths. ok dtucker
208 - (djm) [configure.ac] Check whether libdes is needed when building
209 with Heimdal krb5 support. On OpenBSD this library no longer exists,
210 so linking it unconditionally causes a build failure; ok dtucker
211
21220101226
213 - (dtucker) OpenBSD CVS Sync
214 - djm@cvs.openbsd.org 2010/12/08 04:02:47
215 [ssh_config.5 sshd_config.5]
216 explain that IPQoS arguments are separated by whitespace; iirc requested
217 by jmc@ a while back
218
21920101205
220 - (dtucker) openbsd-compat/openssl-compat.c] remove sleep leftover from
221 debugging. Spotted by djm.
222 - (dtucker) OpenBSD CVS Sync
223 - djm@cvs.openbsd.org 2010/12/03 23:49:26
224 [schnorr.c]
225 check that g^x^q === 1 mod p; recommended by JPAKE author Feng Hao
226 (this code is still disabled, but apprently people are treating it as
227 a reference implementation)
228 - djm@cvs.openbsd.org 2010/12/03 23:55:27
229 [auth-rsa.c]
230 move check for revoked keys to run earlier (in auth_rsa_key_allowed)
231 bz#1829; patch from ldv AT altlinux.org; ok markus@
232 - djm@cvs.openbsd.org 2010/12/04 00:18:01
233 [sftp-server.c sftp.1 sftp-client.h sftp.c PROTOCOL sftp-client.c]
234 add a protocol extension to support a hard link operation. It is
235 available through the "ln" command in the client. The old "ln"
236 behaviour of creating a symlink is available using its "-s" option
237 or through the preexisting "symlink" command; based on a patch from
238 miklos AT szeredi.hu in bz#1555; ok markus@
239 - djm@cvs.openbsd.org 2010/12/04 13:31:37
240 [hostfile.c]
241 fix fd leak; spotted and ok dtucker
242 - djm@cvs.openbsd.org 2010/12/04 00:21:19
243 [regress/sftp-cmds.sh]
244 adjust for hard-link support
245 - (dtucker) [regress/Makefile] Id sync.
246
24720101204
248 - (djm) [openbsd-compat/bindresvport.c] Use arc4random_uniform(range)
249 instead of (arc4random() % range)
250 - (dtucker) [configure.ac moduli.c openbsd-compat/openssl-compat.{c,h}] Add
251 shims for the new, non-deprecated OpenSSL key generation functions for
252 platforms that don't have the new interfaces.
253
25420101201
255 - OpenBSD CVS Sync
256 - deraadt@cvs.openbsd.org 2010/11/20 05:12:38
257 [auth2-pubkey.c]
258 clean up cases of ;;
259 - djm@cvs.openbsd.org 2010/11/21 01:01:13
260 [clientloop.c misc.c misc.h ssh-agent.1 ssh-agent.c]
261 honour $TMPDIR for client xauth and ssh-agent temporary directories;
262 feedback and ok markus@
263 - djm@cvs.openbsd.org 2010/11/21 10:57:07
264 [authfile.c]
265 Refactor internals of private key loading and saving to work on memory
266 buffers rather than directly on files. This will make a few things
267 easier to do in the future; ok markus@
268 - djm@cvs.openbsd.org 2010/11/23 02:35:50
269 [auth.c]
270 use strict_modes already passed as function argument over referencing
271 global options.strict_modes
272 - djm@cvs.openbsd.org 2010/11/23 23:57:24
273 [clientloop.c]
274 avoid NULL deref on receiving a channel request on an unknown or invalid
275 channel; report bz#1842 from jchadima AT redhat.com; ok dtucker@
276 - djm@cvs.openbsd.org 2010/11/24 01:24:14
277 [channels.c]
278 remove a debug() that pollutes stderr on client connecting to a server
279 in debug mode (channel_close_fds is called transitively from the session
280 code post-fork); bz#1719, ok dtucker
281 - djm@cvs.openbsd.org 2010/11/25 04:10:09
282 [session.c]
283 replace close() loop for fds 3->64 with closefrom();
284 ok markus deraadt dtucker
285 - djm@cvs.openbsd.org 2010/11/26 05:52:49
286 [scp.c]
287 Pass through ssh command-line flags and options when doing remote-remote
288 transfers, e.g. to enable agent forwarding which is particularly useful
289 in this case; bz#1837 ok dtucker@
290 - markus@cvs.openbsd.org 2010/11/29 18:57:04
291 [authfile.c]
292 correctly load comment for encrypted rsa1 keys;
293 report/fix Joachim Schipper; ok djm@
294 - djm@cvs.openbsd.org 2010/11/29 23:45:51
295 [auth.c hostfile.c hostfile.h ssh.c ssh_config.5 sshconnect.c]
296 [sshconnect.h sshconnect2.c]
297 automatically order the hostkeys requested by the client based on
298 which hostkeys are already recorded in known_hosts. This avoids
299 hostkey warnings when connecting to servers with new ECDSA keys
300 that are preferred by default; with markus@
301
30220101124
303 - (dtucker) [platform.c session.c] Move the getluid call out of session.c and
304 into the platform-specific code Only affects SCO, tested by and ok tim@.
305 - (djm) [loginrec.c] Relax permission requirement on btmp logs to allow
306 group read/write. ok dtucker@
307 - (dtucker) [packet.c] Remove redundant local declaration of "int tos".
308 - (djm) [defines.h] Add IP DSCP defines
309
31020101122
311 - (dtucker) Bug #1840: fix warning when configuring --with-ssl-engine, patch
312 from vapier at gentoo org.
313
31420101120
315 - OpenBSD CVS Sync
316 - djm@cvs.openbsd.org 2010/11/05 02:46:47
317 [packet.c]
318 whitespace KNF
319 - djm@cvs.openbsd.org 2010/11/10 01:33:07
320 [kexdhc.c kexdhs.c kexgexc.c kexgexs.c key.c moduli.c]
321 use only libcrypto APIs that are retained with OPENSSL_NO_DEPRECATED.
322 these have been around for years by this time. ok markus
323 - djm@cvs.openbsd.org 2010/11/13 23:27:51
324 [clientloop.c misc.c misc.h packet.c packet.h readconf.c readconf.h]
325 [servconf.c servconf.h session.c ssh.c ssh_config.5 sshd_config.5]
326 allow ssh and sshd to set arbitrary TOS/DSCP/QoS values instead of
327 hardcoding lowdelay/throughput.
328
329 bz#1733 patch from philipp AT redfish-solutions.com; ok markus@ deraadt@
330 - jmc@cvs.openbsd.org 2010/11/15 07:40:14
331 [ssh_config.5]
332 libary -> library;
333 - jmc@cvs.openbsd.org 2010/11/18 15:01:00
334 [scp.1 sftp.1 ssh.1 sshd_config.5]
335 add IPQoS to the various -o lists, and zap some trailing whitespace;
336
33720101111
338 - (djm) [servconf.c ssh-add.c ssh-keygen.c] don't look for ECDSA keys on
339 platforms that don't support ECC. Fixes some spurious warnings reported
340 by tim@
341
34220101109
343 - (tim) [regress/kextype.sh] Not all platforms have time in /usr/bin.
344 Feedback from dtucker@
345 - (tim) [configure.ac openbsd-compat/bsd-misc.h openbsd-compat/bsd-misc.c] Add
346 support for platforms missing isblank(). ok djm@
347
34820101108
349 - (tim) [regress/Makefile] Fixes to allow building/testing outside source
350 tree.
351 - (tim) [regress/kextype.sh] Shell portability fix.
352
35320101107
354 - (dtucker) [platform.c] includes.h instead of defines.h so that we get
355 the correct typedefs.
356
35720101105
358 - (djm) [loginrec.c loginrec.h] Use correct uid_t/pid_t types instead of
359 int. Should fix bz#1817 cleanly; ok dtucker@
360 - OpenBSD CVS Sync
361 - djm@cvs.openbsd.org 2010/09/22 12:26:05
362 [regress/Makefile regress/kextype.sh]
363 regress test for each of the key exchange algorithms that we support
364 - djm@cvs.openbsd.org 2010/10/28 11:22:09
365 [authfile.c key.c key.h ssh-keygen.c]
366 fix a possible NULL deref on loading a corrupt ECDH key
367
368 store ECDH group information in private keys files as "named groups"
369 rather than as a set of explicit group parameters (by setting
370 the OPENSSL_EC_NAMED_CURVE flag). This makes for shorter key files and
371 retrieves the group's OpenSSL NID that we need for various things.
372 - jmc@cvs.openbsd.org 2010/10/28 18:33:28
373 [scp.1 ssh-add.1 ssh-keygen.1 ssh.1 ssh_config.5 sshd.8 sshd_config.5]
374 knock out some "-*- nroff -*-" lines;
375 - djm@cvs.openbsd.org 2010/11/04 02:45:34
376 [sftp-server.c]
377 umask should be parsed as octal. reported by candland AT xmission.com;
378 ok markus@
379 - (dtucker) [configure.ac platform.{c,h} session.c
380 openbsd-compat/port-solaris.{c,h}] Bug #1824: Add Solaris Project support.
381 Patch from cory.erickson at csu mnscu edu with a bit of rework from me.
382 ok djm@
383 - (dtucker) [platform.c platform.h session.c] Add a platform hook to run
384 after the user's groups are established and move the selinux calls into it.
385 - (dtucker) [platform.c session.c] Move the AIX setpcred+chroot hack into
386 platform.c
387 - (dtucker) [platform.c session.c] Move the BSDI setpgrp into platform.c.
388 - (dtucker) [platform.c] Only call setpgrp on BSDI if running as root to
389 retain previous behavior.
390 - (dtucker) [platform.c session.c] Move the PAM credential establishment for
391 the LOGIN_CAP case into platform.c.
392 - (dtucker) platform.c session.c] Move the USE_LIBIAF fragment into
393 platform.c
394 - (dtucker) [platform.c session.c] Move aix_usrinfo frament into platform.c.
395 - (dtucker) [platform.c session.c] Move irix setusercontext fragment into
396 platform.c.
397 - (dtucker) [platform.c session.c] Move PAM credential establishment for the
398 non-LOGIN_CAP case into platform.c.
399 - (dtucker) [platform.c platform.h session.c] Move the Cygwin special-case
400 check into platform.c
401 - (dtucker) [regress/keytype.sh] Import new test.
402 - (dtucker) [Makefile configure.ac regress/Makefile regress/keytype.sh]
403 Import recent changes to regress/Makefile, pass a flag to enable ECC tests
404 from configure through to regress/Makefile and use it in the tests.
405 - (dtucker) [regress/kextype.sh] Add missing "test".
406 - (dtucker) [regress/kextype.sh] Make sha256 test depend on ECC. This is not
407 strictly correct since while ECC requires sha256 the reverse is not true
408 however it does prevent spurious test failures.
409 - (dtucker) [platform.c] Need servconf.h and extern options.
410
41120101025
412 - (tim) [openbsd-compat/glob.h] Remove sys/cdefs.h include that came with
413 1.12 to unbreak Solaris build.
414 ok djm@
415 - (dtucker) [defines.h] Use SIZE_T_MAX for SIZE_MAX for platforms that have a
416 native one.
417
41820101024
419 - (dtucker) [includes.h] Add missing ifdef GLOB_HAS_GL_STATV to fix build.
420 - (dtucker) [regress/cert-hostkey.sh] Disable ECC-based tests on platforms
421 which don't have ECC support in libcrypto.
422 - (dtucker) [regress/cert-userkey.sh] Disable ECC-based tests on platforms
423 which don't have ECC support in libcrypto.
424 - (dtucker) [defines.h] Add SIZE_MAX for the benefit of platforms that don't
425 have it.
426 - (dtucker) OpenBSD CVS Sync
427 - sthen@cvs.openbsd.org 2010/10/23 22:06:12
428 [sftp.c]
429 escape '[' in filename tab-completion; fix a type while there.
430 ok djm@
431
43220101021
433 - OpenBSD CVS Sync
434 - dtucker@cvs.openbsd.org 2010/10/12 02:22:24
435 [mux.c]
436 Typo in confirmation message. bz#1827, patch from imorgan at
437 nas nasa gov
438 - djm@cvs.openbsd.org 2010/08/31 12:24:09
439 [regress/cert-hostkey.sh regress/cert-userkey.sh]
440 tests for ECDSA certificates
441
44220101011
443 - (djm) [canohost.c] Zero a4 instead of addr to better match type.
444 bz#1825, reported by foo AT mailinator.com
445 - (djm) [sshconnect.c] Need signal.h for prototype for kill(2)
446
44720101011
448 - (djm) [configure.ac] Use = instead of == in shell tests. Patch from
449 dr AT vasco.com
450
45120101007
452 - (djm) [ssh-agent.c] Fix type for curve name.
453 - (djm) OpenBSD CVS Sync
454 - matthew@cvs.openbsd.org 2010/09/24 13:33:00
455 [misc.c misc.h configure.ac openbsd-compat/openbsd-compat.h]
456 [openbsd-compat/timingsafe_bcmp.c]
457 Add timingsafe_bcmp(3) to libc, mention that it's already in the
458 kernel in kern(9), and remove it from OpenSSH.
459 ok deraadt@, djm@
460 NB. re-added under openbsd-compat/ for portable OpenSSH
461 - djm@cvs.openbsd.org 2010/09/25 09:30:16
462 [sftp.c configure.ac openbsd-compat/glob.c openbsd-compat/glob.h]
463 make use of new glob(3) GLOB_KEEPSTAT extension to save extra server
464 rountrips to fetch per-file stat(2) information.
465 NB. update openbsd-compat/ glob(3) implementation from OpenBSD libc to
466 match.
467 - djm@cvs.openbsd.org 2010/09/26 22:26:33
468 [sftp.c]
469 when performing an "ls" in columnated (short) mode, only call
470 ioctl(TIOCGWINSZ) once to get the window width instead of per-
471 filename
472 - djm@cvs.openbsd.org 2010/09/30 11:04:51
473 [servconf.c]
474 prevent free() of string in .rodata when overriding AuthorizedKeys in
475 a Match block; patch from rein AT basefarm.no
476 - djm@cvs.openbsd.org 2010/10/01 23:05:32
477 [cipher-3des1.c cipher-bf1.c cipher-ctr.c openbsd-compat/openssl-compat.h]
478 adapt to API changes in openssl-1.0.0a
479 NB. contains compat code to select correct API for older OpenSSL
480 - djm@cvs.openbsd.org 2010/10/05 05:13:18
481 [sftp.c sshconnect.c]
482 use default shell /bin/sh if $SHELL is ""; ok markus@
483 - djm@cvs.openbsd.org 2010/10/06 06:39:28
484 [clientloop.c ssh.c sshconnect.c sshconnect.h]
485 kill proxy command on fatal() (we already kill it on clean exit);
486 ok markus@
487 - djm@cvs.openbsd.org 2010/10/06 21:10:21
488 [sshconnect.c]
489 swapped args to kill(2)
490 - (djm) [openbsd-compat/glob.c] restore ARG_MAX compat code.
491 - (djm) [cipher-acss.c] Add missing header.
492 - (djm) [openbsd-compat/Makefile.in] Actually link timingsafe_bcmp
493
49420100924
495 - (djm) OpenBSD CVS Sync
496 - naddy@cvs.openbsd.org 2010/09/10 15:19:29
497 [ssh-keygen.1]
498 * mention ECDSA in more places
499 * less repetition in FILES section
500 * SSHv1 keys are still encrypted with 3DES
501 help and ok jmc@
502 - djm@cvs.openbsd.org 2010/09/11 21:44:20
503 [ssh.1]
504 mention RFC 5656 for ECC stuff
505 - jmc@cvs.openbsd.org 2010/09/19 21:30:05
506 [sftp.1]
507 more wacky macro fixing;
508 - djm@cvs.openbsd.org 2010/09/20 04:41:47
509 [ssh.c]
510 install a SIGCHLD handler to reap expiried child process; ok markus@
511 - djm@cvs.openbsd.org 2010/09/20 04:50:53
512 [jpake.c schnorr.c]
513 check that received values are smaller than the group size in the
514 disabled and unfinished J-PAKE code.
515 avoids catastrophic security failure found by Sebastien Martini
516 - djm@cvs.openbsd.org 2010/09/20 04:54:07
517 [jpake.c]
518 missing #include
519 - djm@cvs.openbsd.org 2010/09/20 07:19:27
520 [mux.c]
521 "atomically" create the listening mux socket by binding it on a temorary
522 name and then linking it into position after listen() has succeeded.
523 this allows the mux clients to determine that the server socket is
524 either ready or stale without races. stale server sockets are now
525 automatically removed
526 ok deraadt
527 - djm@cvs.openbsd.org 2010/09/22 05:01:30
528 [kex.c kex.h kexecdh.c kexecdhc.c kexecdhs.c readconf.c readconf.h]
529 [servconf.c servconf.h ssh_config.5 sshconnect2.c sshd.c sshd_config.5]
530 add a KexAlgorithms knob to the client and server configuration to allow
531 selection of which key exchange methods are used by ssh(1) and sshd(8)
532 and their order of preference.
533 ok markus@
534 - jmc@cvs.openbsd.org 2010/09/22 08:30:08
535 [ssh.1 ssh_config.5]
536 ssh.1: add kexalgorithms to the -o list
537 ssh_config.5: format the kexalgorithms in a more consistent
538 (prettier!) way
539 ok djm
540 - djm@cvs.openbsd.org 2010/09/22 22:58:51
541 [atomicio.c atomicio.h misc.c misc.h scp.c sftp-client.c]
542 [sftp-client.h sftp.1 sftp.c]
543 add an option per-read/write callback to atomicio
544
545 factor out bandwidth limiting code from scp(1) into a generic bandwidth
546 limiter that can be attached using the atomicio callback mechanism
547
548 add a bandwidth limit option to sftp(1) using the above
549 "very nice" markus@
550 - jmc@cvs.openbsd.org 2010/09/23 13:34:43
551 [sftp.c]
552 add [-l limit] to usage();
553 - jmc@cvs.openbsd.org 2010/09/23 13:36:46
554 [scp.1 sftp.1]
555 add KexAlgorithms to the -o list;
556
55720100910
558 - (dtucker) [openbsd-compat/port-linux.c] Check is_selinux_enabled for exact
559 return code since it can apparently return -1 under some conditions. From
560 openssh bugs werbittewas de, ok djm@
561 - OpenBSD CVS Sync
562 - djm@cvs.openbsd.org 2010/08/31 12:33:38
563 [ssh-add.c ssh-agent.c ssh-keygen.c ssh-keysign.c ssh.c sshd.c]
564 reintroduce commit from tedu@, which I pulled out for release
565 engineering:
566 OpenSSL_add_all_algorithms is the name of the function we have a
567 man page for, so use that. ok djm
568 - jmc@cvs.openbsd.org 2010/08/31 17:40:54
569 [ssh-agent.1]
570 fix some macro abuse;
571 - jmc@cvs.openbsd.org 2010/08/31 21:14:58
572 [ssh.1]
573 small text tweak to accommodate previous;
574 - naddy@cvs.openbsd.org 2010/09/01 15:21:35
575 [servconf.c]
576 pick up ECDSA host key by default; ok djm@
577 - markus@cvs.openbsd.org 2010/09/02 16:07:25
578 [ssh-keygen.c]
579 permit -b 256, 384 or 521 as key size for ECDSA; ok djm@
580 - markus@cvs.openbsd.org 2010/09/02 16:08:39
581 [ssh.c]
582 unbreak ControlPersist=yes for ControlMaster=yes; ok djm@
583 - naddy@cvs.openbsd.org 2010/09/02 17:21:50
584 [ssh-keygen.c]
585 Switch ECDSA default key size to 256 bits, which according to RFC5656
586 should still be better than our current RSA-2048 default.
587 ok djm@, markus@
588 - jmc@cvs.openbsd.org 2010/09/03 11:09:29
589 [scp.1]
590 add an EXIT STATUS section for /usr/bin;
591 - jmc@cvs.openbsd.org 2010/09/04 09:38:34
592 [ssh-add.1 ssh.1]
593 two more EXIT STATUS sections;
594 - naddy@cvs.openbsd.org 2010/09/06 17:10:19
595 [sshd_config]
596 add ssh_host_ecdsa_key to /etc; from Mattieu Baptiste
597 <mattieu.b@gmail.com>
598 ok deraadt@
599 - djm@cvs.openbsd.org 2010/09/08 03:54:36
600 [authfile.c]
601 typo
602 - deraadt@cvs.openbsd.org 2010/09/08 04:13:31
603 [compress.c]
604 work around name-space collisions some buggy compilers (looking at you
605 gcc, at least in earlier versions, but this does not forgive your current
606 transgressions) seen between zlib and openssl
607 ok djm
608 - djm@cvs.openbsd.org 2010/09/09 10:45:45
609 [kex.c kex.h kexecdh.c key.c key.h monitor.c ssh-ecdsa.c]
610 ECDH/ECDSA compliance fix: these methods vary the hash function they use
611 (SHA256/384/512) depending on the length of the curve in use. The previous
612 code incorrectly used SHA256 in all cases.
613
614 This fix will cause authentication failure when using 384 or 521-bit curve
615 keys if one peer hasn't been upgraded and the other has. (256-bit curve
616 keys work ok). In particular you may need to specify HostkeyAlgorithms
617 when connecting to a server that has not been upgraded from an upgraded
618 client.
619
620 ok naddy@
621 - (djm) [authfd.c authfile.c bufec.c buffer.h configure.ac kex.h kexecdh.c]
622 [kexecdhc.c kexecdhs.c key.c key.h myproposal.h packet.c readconf.c]
623 [ssh-agent.c ssh-ecdsa.c ssh-keygen.c ssh.c] Disable ECDH and ECDSA on
624 platforms that don't have the requisite OpenSSL support. ok dtucker@
625 - (dtucker) [kex.h key.c packet.h ssh-agent.c ssh.c] A few more ECC ifdefs
626 for missing headers and compiler warnings.
627
62820100831
629 - OpenBSD CVS Sync
630 - jmc@cvs.openbsd.org 2010/08/08 19:36:30
631 [ssh-keysign.8 ssh.1 sshd.8]
632 use the same template for all FILES sections; i.e. -compact/.Pp where we
633 have multiple items, and .Pa for path names;
634 - tedu@cvs.openbsd.org 2010/08/12 23:34:39
635 [ssh-add.c ssh-agent.c ssh-keygen.c ssh-keysign.c ssh.c sshd.c]
636 OpenSSL_add_all_algorithms is the name of the function we have a man page
637 for, so use that. ok djm
638 - djm@cvs.openbsd.org 2010/08/16 04:06:06
639 [ssh-add.c ssh-agent.c ssh-keygen.c ssh-keysign.c ssh.c sshd.c]
640 backout previous temporarily; discussed with deraadt@
641 - djm@cvs.openbsd.org 2010/08/31 09:58:37
642 [auth-options.c auth1.c auth2.c bufaux.c buffer.h kex.c key.c packet.c]
643 [packet.h ssh-dss.c ssh-rsa.c]
644 Add buffer_get_cstring() and related functions that verify that the
645 string extracted from the buffer contains no embedded \0 characters*
646 This prevents random (possibly malicious) crap from being appended to
647 strings where it would not be noticed if the string is used with
648 a string(3) function.
649
650 Use the new API in a few sensitive places.
651
652 * actually, we allow a single one at the end of the string for now because
653 we don't know how many deployed implementations get this wrong, but don't
654 count on this to remain indefinitely.
655 - djm@cvs.openbsd.org 2010/08/31 11:54:45
656 [PROTOCOL PROTOCOL.agent PROTOCOL.certkeys auth2-jpake.c authfd.c]
657 [authfile.c buffer.h dns.c kex.c kex.h key.c key.h monitor.c]
658 [monitor_wrap.c myproposal.h packet.c packet.h pathnames.h readconf.c]
659 [ssh-add.1 ssh-add.c ssh-agent.1 ssh-agent.c ssh-keygen.1 ssh-keygen.c]
660 [ssh-keyscan.1 ssh-keyscan.c ssh-keysign.8 ssh.1 ssh.c ssh2.h]
661 [ssh_config.5 sshconnect.c sshconnect2.c sshd.8 sshd.c sshd_config.5]
662 [uuencode.c uuencode.h bufec.c kexecdh.c kexecdhc.c kexecdhs.c ssh-ecdsa.c]
663 Implement Elliptic Curve Cryptography modes for key exchange (ECDH) and
664 host/user keys (ECDSA) as specified by RFC5656. ECDH and ECDSA offer
665 better performance than plain DH and DSA at the same equivalent symmetric
666 key length, as well as much shorter keys.
667
668 Only the mandatory sections of RFC5656 are implemented, specifically the
669 three REQUIRED curves nistp256, nistp384 and nistp521 and only ECDH and
670 ECDSA. Point compression (optional in RFC5656 is NOT implemented).
671
672 Certificate host and user keys using the new ECDSA key types are supported.
673
674 Note that this code has not been tested for interoperability and may be
675 subject to change.
676
677 feedback and ok markus@
678 - (djm) [Makefile.in] Add new ECC files
679 - (djm) [bufec.c kexecdh.c kexecdhc.c kexecdhs.c ssh-ecdsa.c] include
680 includes.h
681
68220100827
683 - (dtucker) [contrib/redhat/sshd.init] Bug #1810: initlog is deprecated,
684 remove. Patch from martynas at venck us
685
120100823 68620100823
2 - (djm) Release OpenSSH-5.6p1 687 - (djm) Release OpenSSH-5.6p1
3 688
@@ -517,2746 +1202,3 @@
517 1202
518 ok markus@ 1203 ok markus@
519 1204
52020100410
521 - (dtucker) [configure.ac] Put the check for the existence of getaddrinfo
522 back so we disable the IPv6 tests if we don't have it.
523
52420100409
525 - (dtucker) [contrib/cygwin/Makefile] Don't overwrite files with the wrong
526 ones. Based on a patch from Roumen Petrov.
527 - (dtucker) [configure.ac] Bug #1744: use pkg-config for libedit flags if we
528 have it and the path is not provided to --with-libedit. Based on a patch
529 from Iain Morgan.
530 - (dtucker) [configure.ac defines.h loginrec.c logintest.c] Bug #1732: enable
531 utmpx support on FreeBSD where possible. Patch from Ed Schouten, ok djm@
532
53320100326
534 - (djm) [openbsd-compat/bsd-arc4random.c] Fix preprocessor detection
535 for arc4random_buf() and arc4random_uniform(); from Josh Gilkerson
536 - (dtucker) [configure.ac] Bug #1741: Add section for Haiku, patch originally
537 by Ingo Weinhold via Scott McCreary, ok djm@
538 - (djm) OpenBSD CVS Sync
539 - djm@cvs.openbsd.org 2010/03/25 23:38:28
540 [servconf.c]
541 from portable: getcwd(NULL, 0) doesn't work on all platforms, so
542 use a stack buffer; ok dtucker@
543 - djm@cvs.openbsd.org 2010/03/26 00:26:58
544 [ssh.1]
545 mention that -S none disables connection sharing; from Colin Watson
546 - (djm) [session.c] Allow ChrootDirectory to work on SELinux platforms -
547 set up SELinux execution context before chroot() call. From Russell
548 Coker via Colin watson; bz#1726 ok dtucker@
549 - (djm) [channels.c] Check for EPFNOSUPPORT as a socket() errno; bz#1721
550 ok dtucker@
551 - (dtucker) Bug #1725: explicitly link libX11 into gnome-ssh-askpass2 using
552 pkg-config, patch from Colin Watson. Needed for newer linkers (ie gold).
553 - (djm) [contrib/ssh-copy-id] Don't blow up when the agent has no keys;
554 bz#1723 patch from Adeodato Simóvia Colin Watson; ok dtucker@
555 - (dtucker) OpenBSD CVS Sync
556 - dtucker@cvs.openbsd.org 2010/03/26 01:06:13
557 [ssh_config.5]
558 Reformat default value of PreferredAuthentications entry (current
559 formatting implies ", " is acceptable as a separator, which it's not.
560 ok djm@
561
56220100324
563 - (dtucker) [contrib/cygwin/ssh-host-config] Mount the Windows directory
564 containing the services file explicitely case-insensitive. This allows to
565 tweak the Windows services file reliably. Patch from vinschen at redhat.
566
56720100321
568 - (djm) OpenBSD CVS Sync
569 - jmc@cvs.openbsd.org 2010/03/08 09:41:27
570 [ssh-keygen.1]
571 sort the list of constraints (to -O); ok djm
572 - jmc@cvs.openbsd.org 2010/03/10 07:40:35
573 [ssh-keygen.1]
574 typos; from Ross Richardson
575 closes prs 6334 and 6335
576 - djm@cvs.openbsd.org 2010/03/10 23:27:17
577 [auth2-pubkey.c]
578 correct certificate logging and make it more consistent between
579 authorized_keys and TrustedCAKeys; ok markus@
580 - djm@cvs.openbsd.org 2010/03/12 01:06:25
581 [servconf.c]
582 unbreak AuthorizedKeys option with a $HOME-relative path; reported by
583 vinschen AT redhat.com, ok dtucker@
584 - markus@cvs.openbsd.org 2010/03/12 11:37:40
585 [servconf.c]
586 do not prepend AuthorizedKeysFile with getcwd(), unbreaks relative paths
587 free() (not xfree()) the buffer returned by getcwd()
588 - djm@cvs.openbsd.org 2010/03/13 21:10:38
589 [clientloop.c]
590 protocol conformance fix: send language tag when disconnecting normally;
591 spotted by 1.41421 AT gmail.com, ok markus@ deraadt@
592 - djm@cvs.openbsd.org 2010/03/13 21:45:46
593 [ssh-keygen.1]
594 Certificates are named *-cert.pub, not *_cert.pub; committing a diff
595 from stevesk@ ok me
596 - jmc@cvs.openbsd.org 2010/03/13 23:38:13
597 [ssh-keygen.1]
598 fix a formatting error (args need quoted); noted by stevesk
599 - stevesk@cvs.openbsd.org 2010/03/15 19:40:02
600 [key.c key.h ssh-keygen.c]
601 also print certificate type (user or host) for ssh-keygen -L
602 ok djm kettenis
603 - stevesk@cvs.openbsd.org 2010/03/16 15:46:52
604 [auth-options.c]
605 spelling in error message. ok djm kettenis
606 - djm@cvs.openbsd.org 2010/03/16 16:36:49
607 [version.h]
608 crank version to openssh-5.5 since we have a few fixes since 5.4;
609 requested deraadt@ kettenis@
610 - (djm) [README contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
611 [contrib/suse/openssh.spec] Crank version numbers
612
61320100314
614 - (djm) [ssh-pkcs11-helper.c] Move #ifdef to after #defines to fix
615 compilation failure when !HAVE_DLOPEN. Reported by felix-mindrot
616 AT fefe.de
617 - (djm) [Makefile.in] Respecify -lssh after -lopenbsd-compat for
618 ssh-pkcs11-helper to repair static builds (we do the same for
619 ssh-keyscan). Reported by felix-mindrot AT fefe.de
620
62120100312
622 - (tim) [Makefile.in] Now that scard is gone, no need to make $(datadir)
623 - (tim) [Makefile.in] Add missing $(EXEEXT) to install targets.
624 Patch from Corinna Vinschen.
625 - (tim) [contrib/cygwin/Makefile] Fix list of documentation files to install
626 on a Cygwin installation. Patch from Corinna Vinschen.
627
62820100311
629 - (tim) [contrib/suse/openssh.spec] crank version number here too.
630 report by imorgan AT nas.nasa.gov
631
63220100309
633 - (dtucker) [configure.ac] Use a proper AC_CHECK_DECL for BROKEN_GETADDRINFO
634 so setting it in CFLAGS correctly skips IPv6 tests.
635
63620100308
637 - (djm) OpenBSD CVS Sync
638 - djm@cvs.openbsd.org 2010/03/07 22:16:01
639 [ssh-keygen.c]
640 make internal strptime string match strftime format;
641 suggested by vinschen AT redhat.com and markus@
642 - djm@cvs.openbsd.org 2010/03/08 00:28:55
643 [ssh-keygen.1]
644 document permit-agent-forwarding certificate constraint; patch from
645 stevesk@
646 - djm@cvs.openbsd.org 2010/03/07 22:01:32
647 [version.h]
648 openssh-5.4
649 - (djm) [README contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
650 crank version numbers
651 - (djm) Release OpenSSH-5.4p1
652
65320100307
654 - (dtucker) [auth.c] Bug #1710: call setauthdb on AIX before getpwuid so that
655 it gets the passwd struct from the LAM that knows about the user which is
656 not necessarily the default. Patch from Alexandre Letourneau.
657 - (dtucker) [session.c] Bug #1567: move setpcred call to before chroot and
658 do not set real uid, since that's needed for the chroot, and will be set
659 by permanently_set_uid.
660 - (dtucker) [session.c] Also initialize creds to NULL for handing to
661 setpcred.
662 - (dtucker) OpenBSD CVS Sync
663 - dtucker@cvs.openbsd.org 2010/03/07 11:57:13
664 [auth-rhosts.c monitor.c monitor_wrap.c session.c auth-options.c sshd.c]
665 Hold authentication debug messages until after successful authentication.
666 Fixes an info leak of environment variables specified in authorized_keys,
667 reported by Jacob Appelbaum. ok djm@
668
66920100305
670 - OpenBSD CVS Sync
671 - jmc@cvs.openbsd.org 2010/03/04 12:51:25
672 [ssh.1 sshd_config.5]
673 tweak previous;
674 - djm@cvs.openbsd.org 2010/03/04 20:35:08
675 [ssh-keygen.1 ssh-keygen.c]
676 Add a -L flag to print the contents of a certificate; ok markus@
677 - jmc@cvs.openbsd.org 2010/03/04 22:52:40
678 [ssh-keygen.1]
679 fix Bk/Ek;
680 - djm@cvs.openbsd.org 2010/03/04 23:17:25
681 [sshd_config.5]
682 missing word; spotted by jmc@
683 - djm@cvs.openbsd.org 2010/03/04 23:19:29
684 [ssh.1 sshd.8]
685 move section on CA and revoked keys from ssh.1 to sshd.8's known hosts
686 format section and rework it a bit; requested by jmc@
687 - djm@cvs.openbsd.org 2010/03/04 23:27:25
688 [auth-options.c ssh-keygen.c]
689 "force-command" is not spelled "forced-command"; spotted by
690 imorgan AT nas.nasa.gov
691 - djm@cvs.openbsd.org 2010/03/05 02:58:11
692 [auth.c]
693 make the warning for a revoked key louder and more noticable
694 - jmc@cvs.openbsd.org 2010/03/05 06:50:35
695 [ssh.1 sshd.8]
696 tweak previous;
697 - jmc@cvs.openbsd.org 2010/03/05 08:31:20
698 [ssh.1]
699 document certificate authentication; help/ok djm
700 - djm@cvs.openbsd.org 2010/03/05 10:28:21
701 [ssh-add.1 ssh.1 ssh_config.5]
702 mention loading of certificate files from [private]-cert.pub when
703 they are present; feedback and ok jmc@
704 - (tim) [ssh-pkcs11.c] Fix "non-constant initializer" errors in older
705 compilers. OK djm@
706 - (djm) [ssh-rand-helper.c] declare optind, avoiding compilation failure
707 on some platforms
708 - (djm) [configure.ac] set -fno-strict-aliasing for gcc4; ok dtucker@
709
71020100304
711 - (djm) [ssh-keygen.c] Use correct local variable, instead of
712 maybe-undefined global "optarg"
713 - (djm) [contrib/redhat/openssh.spec] Replace obsolete BuildPreReq
714 on XFree86-devel with neutral /usr/include/X11/Xlib.h;
715 imorgan AT nas.nasa.gov in bz#1731
716 - (djm) [.cvsignore] Ignore ssh-pkcs11-helper
717 - (djm) [regress/Makefile] Cleanup sshd_proxy_orig
718 - OpenBSD CVS Sync
719 - djm@cvs.openbsd.org 2010/03/03 01:44:36
720 [auth-options.c key.c]
721 reject strings with embedded ASCII nul chars in certificate key IDs,
722 principal names and constraints
723 - djm@cvs.openbsd.org 2010/03/03 22:49:50
724 [sshd.8]
725 the authorized_keys option for CA keys is "cert-authority", not
726 "from=cert-authority". spotted by imorgan AT nas.nasa.gov
727 - djm@cvs.openbsd.org 2010/03/03 22:50:40
728 [PROTOCOL.certkeys]
729 s/similar same/similar/; from imorgan AT nas.nasa.gov
730 - djm@cvs.openbsd.org 2010/03/04 01:44:57
731 [key.c]
732 use buffer_get_string_ptr_ret() where we are checking the return
733 value explicitly instead of the fatal()-causing buffer_get_string_ptr()
734 - djm@cvs.openbsd.org 2010/03/04 10:36:03
735 [auth-rh-rsa.c auth-rsa.c auth.c auth.h auth2-hostbased.c auth2-pubkey.c]
736 [authfile.c authfile.h hostfile.c hostfile.h servconf.c servconf.h]
737 [ssh-keygen.c ssh.1 sshconnect.c sshd_config.5]
738 Add a TrustedUserCAKeys option to sshd_config to specify CA keys that
739 are trusted to authenticate users (in addition than doing it per-user
740 in authorized_keys).
741
742 Add a RevokedKeys option to sshd_config and a @revoked marker to
743 known_hosts to allow keys to me revoked and banned for user or host
744 authentication.
745
746 feedback and ok markus@
747 - djm@cvs.openbsd.org 2010/03/03 00:47:23
748 [regress/cert-hostkey.sh regress/cert-userkey.sh]
749 add an extra test to ensure that authentication with the wrong
750 certificate fails as it should (and it does)
751 - djm@cvs.openbsd.org 2010/03/04 10:38:23
752 [regress/cert-hostkey.sh regress/cert-userkey.sh]
753 additional regression tests for revoked keys and TrustedUserCAKeys
754
75520100303
756 - (djm) [PROTOCOL.certkeys] Add RCS Ident
757 - OpenBSD CVS Sync
758 - jmc@cvs.openbsd.org 2010/02/26 22:09:28
759 [ssh-keygen.1 ssh.1 sshd.8]
760 tweak previous;
761 - otto@cvs.openbsd.org 2010/03/01 11:07:06
762 [ssh-add.c]
763 zap what seems to be a left-over debug message; ok markus@
764 - djm@cvs.openbsd.org 2010/03/02 23:20:57
765 [ssh-keygen.c]
766 POSIX strptime is stricter than OpenBSD's so do a little dance to
767 appease it.
768 - (djm) [regress/cert-userkey.sh] s/echo -n/echon/ here too
769
77020100302
771 - (tim) [config.guess config.sub] Bug 1722: Update to latest versions from
772 http://git.savannah.gnu.org/gitweb/ (2009-12-30 and 2010-01-22
773 respectively).
774
77520100301
776 - (dtucker) [regress/{cert-hostkey,cfgmatch,cipher-speed}.sh} Replace
777 "echo -n" with "echon" for portability.
778 - (dtucker) [openbsd-compat/port-linux.c] Make failure to write to the OOM
779 adjust log at verbose only, since according to cjwatson in bug #1470
780 some virtualization platforms don't allow writes.
781
78220100228
783 - (djm) [auth.c] On Cygwin, refuse usernames that have differences in
784 case from that matched in the system password database. On this
785 platform, passwords are stored case-insensitively, but sshd requires
786 exact case matching for Match blocks in sshd_config(5). Based on
787 a patch from vinschen AT redhat.com.
788 - (tim) [ssh-pkcs11-helper.c] Move declarations before calling functions
789 to make older compilers (gcc 2.95) happy.
790
79120100227
792 - (djm) [ssh-pkcs11-helper.c ] Ensure RNG is initialised and seeded
793 - (djm) [openbsd-compat/bsd-cygwin_util.c] Reduce the set of environment
794 variables copied into sshd child processes. From vinschen AT redhat.com
795
79620100226
797 - OpenBSD CVS Sync
798 - djm@cvs.openbsd.org 2010/02/26 20:29:54
799 [PROTOCOL PROTOCOL.agent PROTOCOL.certkeys addrmatch.c auth-options.c]
800 [auth-options.h auth.h auth2-pubkey.c authfd.c dns.c dns.h hostfile.c]
801 [hostfile.h kex.h kexdhs.c kexgexs.c key.c key.h match.h monitor.c]
802 [myproposal.h servconf.c servconf.h ssh-add.c ssh-agent.c ssh-dss.c]
803 [ssh-keygen.1 ssh-keygen.c ssh-rsa.c ssh.1 ssh.c ssh2.h sshconnect.c]
804 [sshconnect2.c sshd.8 sshd.c sshd_config.5]
805 Add support for certificate key types for users and hosts.
806
807 OpenSSH certificate key types are not X.509 certificates, but a much
808 simpler format that encodes a public key, identity information and
809 some validity constraints and signs it with a CA key. CA keys are
810 regular SSH keys. This certificate style avoids the attack surface
811 of X.509 certificates and is very easy to deploy.
812
813 Certified host keys allow automatic acceptance of new host keys
814 when a CA certificate is marked as trusted in ~/.ssh/known_hosts.
815 see VERIFYING HOST KEYS in ssh(1) for details.
816
817 Certified user keys allow authentication of users when the signing
818 CA key is marked as trusted in authorized_keys. See "AUTHORIZED_KEYS
819 FILE FORMAT" in sshd(8) for details.
820
821 Certificates are minted using ssh-keygen(1), documentation is in
822 the "CERTIFICATES" section of that manpage.
823
824 Documentation on the format of certificates is in the file
825 PROTOCOL.certkeys
826
827 feedback and ok markus@
828 - djm@cvs.openbsd.org 2010/02/26 20:33:21
829 [Makefile regress/cert-hostkey.sh regress/cert-userkey.sh]
830 regression tests for certified keys
831
83220100224
833 - (djm) [pkcs11.h ssh-pkcs11-client.c ssh-pkcs11-helper.c ssh-pkcs11.c]
834 [ssh-pkcs11.h] Add $OpenBSD$ RCS idents so we can sync portable
835 - (djm) OpenBSD CVS Sync
836 - djm@cvs.openbsd.org 2010/02/11 20:37:47
837 [pathnames.h]
838 correct comment
839 - dtucker@cvs.openbsd.org 2009/11/09 04:20:04
840 [regress/Makefile]
841 add regression test for ssh-keygen pubkey conversions
842 - dtucker@cvs.openbsd.org 2010/01/11 02:53:44
843 [regress/forwarding.sh]
844 regress test for stdio forwarding
845 - djm@cvs.openbsd.org 2010/02/09 04:57:36
846 [regress/addrmatch.sh]
847 clean up droppings
848 - djm@cvs.openbsd.org 2010/02/09 06:29:02
849 [regress/Makefile]
850 turn on all the malloc(3) checking options when running regression
851 tests. this has caught a few bugs for me in the past; ok dtucker@
852 - djm@cvs.openbsd.org 2010/02/24 06:21:56
853 [regress/test-exec.sh]
854 wait for sshd to fully stop in cleanup() function; avoids races in tests
855 that do multiple start_sshd/cleanup cycles; "I hate pidfiles" deraadt@
856 - markus@cvs.openbsd.org 2010/02/08 10:52:47
857 [regress/agent-pkcs11.sh]
858 test for PKCS#11 support (currently disabled)
859 - (djm) [Makefile.in ssh-pkcs11-helper.8] Add manpage for PKCS#11 helper
860 - (djm) [contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
861 [contrib/suse/openssh.spec] Add PKCS#11 helper binary and manpage
862
86320100212
864 - (djm) OpenBSD CVS Sync
865 - djm@cvs.openbsd.org 2010/02/02 22:49:34
866 [bufaux.c]
867 make buffer_get_string_ret() really non-fatal in all cases (it was
868 using buffer_get_int(), which could fatal() on buffer empty);
869 ok markus dtucker
870 - markus@cvs.openbsd.org 2010/02/08 10:50:20
871 [pathnames.h readconf.c readconf.h scp.1 sftp.1 ssh-add.1 ssh-add.c]
872 [ssh-agent.c ssh-keygen.1 ssh-keygen.c ssh.1 ssh.c ssh_config.5]
873 replace our obsolete smartcard code with PKCS#11.
874 ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-11/v2-20/pkcs-11v2-20.pdf
875 ssh(1) and ssh-keygen(1) use dlopen(3) directly to talk to a PKCS#11
876 provider (shared library) while ssh-agent(1) delegates PKCS#11 to
877 a forked a ssh-pkcs11-helper process.
878 PKCS#11 is currently a compile time option.
879 feedback and ok djm@; inspired by patches from Alon Bar-Lev
880 - jmc@cvs.openbsd.org 2010/02/08 22:03:05
881 [ssh-add.1 ssh-keygen.1 ssh.1 ssh.c]
882 tweak previous; ok markus
883 - djm@cvs.openbsd.org 2010/02/09 00:50:36
884 [ssh-agent.c]
885 fallout from PKCS#11: unbreak -D
886 - djm@cvs.openbsd.org 2010/02/09 00:50:59
887 [ssh-keygen.c]
888 fix -Wall
889 - djm@cvs.openbsd.org 2010/02/09 03:56:28
890 [buffer.c buffer.h]
891 constify the arguments to buffer_len, buffer_ptr and buffer_dump
892 - djm@cvs.openbsd.org 2010/02/09 06:18:46
893 [auth.c]
894 unbreak ChrootDirectory+internal-sftp by skipping check for executable
895 shell when chrooting; reported by danh AT wzrd.com; ok dtucker@
896 - markus@cvs.openbsd.org 2010/02/10 23:20:38
897 [ssh-add.1 ssh-keygen.1 ssh.1 ssh_config.5]
898 pkcs#11 is no longer optional; improve wording; ok jmc@
899 - jmc@cvs.openbsd.org 2010/02/11 13:23:29
900 [ssh.1]
901 libarary -> library;
902 - (djm) [INSTALL Makefile.in README.smartcard configure.ac scard-opensc.c]
903 [scard.c scard.h pkcs11.h scard/Makefile.in scard/Ssh.bin.uu scard/Ssh.java]
904 Remove obsolete smartcard support
905 - (djm) [ssh-pkcs11-client.c ssh-pkcs11-helper.c ssh-pkcs11.c]
906 Make it compile on OSX
907 - (djm) [ssh-pkcs11-client.c ssh-pkcs11-helper.c ssh-pkcs11.c]
908 Use ssh_get_progname to fill __progname
909 - (djm) [configure.ac] Enable PKCS#11 support only when we find a working
910 dlopen()
911
91220100210
913 - (djm) add -lselinux to LIBS before calling AC_CHECK_FUNCS for
914 getseuserbyname; patch from calebcase AT gmail.com via
915 cjwatson AT debian.org
916
91720100202
918 - (djm) OpenBSD CVS Sync
919 - djm@cvs.openbsd.org 2010/01/30 21:08:33
920 [sshd.8]
921 debug output goes to stderr, not "the system log"; ok markus dtucker
922 - djm@cvs.openbsd.org 2010/01/30 21:12:08
923 [channels.c]
924 fake local addr:port when stdio fowarding as some servers (Tectia at
925 least) validate that they are well-formed;
926 reported by imorgan AT nas.nasa.gov
927 ok dtucker
928
92920100130
930 - (djm) OpenBSD CVS Sync
931 - djm@cvs.openbsd.org 2010/01/28 00:21:18
932 [clientloop.c]
933 downgrade an error() to a debug() - this particular case can be hit in
934 normal operation for certain sequences of mux slave vs session closure
935 and is harmless
936 - djm@cvs.openbsd.org 2010/01/29 00:20:41
937 [sshd.c]
938 set FD_CLOEXEC on sock_in/sock_out; bz#1706 from jchadima AT redhat.com
939 ok dtucker@
940 - djm@cvs.openbsd.org 2010/01/29 20:16:17
941 [mux.c]
942 kill correct channel (was killing already-dead mux channel, not
943 its session channel)
944 - djm@cvs.openbsd.org 2010/01/30 02:54:53
945 [mux.c]
946 don't mark channel as read failed if it is already closing; suppresses
947 harmless error messages when connecting to SSH.COM Tectia server
948 report by imorgan AT nas.nasa.gov
949
95020100129
951 - (dtucker) [openbsd-compat/openssl-compat.c] Bug #1707: Call OPENSSL_config()
952 after registering the hardware engines, which causes the openssl.cnf file to
953 be processed. See OpenSSL's man page for OPENSSL_config(3) for details.
954 Patch from Solomon Peachy, ok djm@.
955
95620100128
957 - (djm) OpenBSD CVS Sync
958 - djm@cvs.openbsd.org 2010/01/26 02:15:20
959 [mux.c]
960 -Wuninitialized and remove a // comment; from portable
961 (Id sync only)
962 - djm@cvs.openbsd.org 2010/01/27 13:26:17
963 [mux.c]
964 fix bug introduced in mux rewrite:
965
966 In a mux master, when a socket to a mux slave closes before its server
967 session (as may occur when the slave has been signalled), gracefully
968 close the server session rather than deleting its channel immediately.
969 A server may have more messages on that channel to send (e.g. an exit
970 message) that will fatal() the client if they are sent to a channel that
971 has been prematurely deleted.
972
973 spotted by imorgan AT nas.nasa.gov
974 - djm@cvs.openbsd.org 2010/01/27 19:21:39
975 [sftp.c]
976 add missing "p" flag to getopt optstring;
977 bz#1704 from imorgan AT nas.nasa.gov
978
97920100126
980 - (djm) OpenBSD CVS Sync
981 - tedu@cvs.openbsd.org 2010/01/17 21:49:09
982 [ssh-agent.1]
983 Correct and clarify ssh-add's password asking behavior.
984 Improved text dtucker and ok jmc
985 - dtucker@cvs.openbsd.org 2010/01/18 01:50:27
986 [roaming_client.c]
987 s/long long unsigned/unsigned long long/, from tim via portable
988 (Id sync only, change already in portable)
989 - djm@cvs.openbsd.org 2010/01/26 01:28:35
990 [channels.c channels.h clientloop.c clientloop.h mux.c nchan.c ssh.c]
991 rewrite ssh(1) multiplexing code to a more sensible protocol.
992
993 The new multiplexing code uses channels for the listener and
994 accepted control sockets to make the mux master non-blocking, so
995 no stalls when processing messages from a slave.
996
997 avoid use of fatal() in mux master protocol parsing so an errant slave
998 process cannot take down a running master.
999
1000 implement requesting of port-forwards over multiplexed sessions. Any
1001 port forwards requested by the slave are added to those the master has
1002 established.
1003
1004 add support for stdio forwarding ("ssh -W host:port ...") in mux slaves.
1005
1006 document master/slave mux protocol so that other tools can use it to
1007 control a running ssh(1). Note: there are no guarantees that this
1008 protocol won't be incompatibly changed (though it is versioned).
1009
1010 feedback Salvador Fandino, dtucker@
1011 channel changes ok markus@
1012
101320100122
1014 - (tim) [configure.ac] Due to constraints in Windows Sockets in terms of
1015 socket inheritance, reduce the default SO_RCVBUF/SO_SNDBUF buffer size
1016 in Cygwin to 65535. Patch from Corinna Vinschen.
1017
101820100117
1019 - (tim) [configure.ac] OpenServer 5 needs BROKEN_GETADDRINFO too.
1020 - (tim) [configure.ac] On SVR5 systems, use the C99-conforming functions
1021 snprintf() and vsnprintf() named _xsnprintf() and _xvsnprintf().
1022
102320100116
1024 - (dtucker) [openbsd-compat/pwcache.c] Pull in includes.h and thus defines.h
1025 so we correctly detect whether or not we have a native user_from_uid.
1026 - (dtucker) [openbsd-compat/openbsd-compat.h] Prototypes for user_from_uid
1027 and group_from_gid.
1028 - (dtucker) [openbsd-compat/openbsd-compat.h] Fix prototypes, spotted by
1029 Tim.
1030 - (dtucker) OpenBSD CVS Sync
1031 - markus@cvs.openbsd.org 2010/01/15 09:24:23
1032 [sftp-common.c]
1033 unused
1034 - (dtucker) [openbsd-compat/pwcache.c] Shrink ifdef area to prevent unused
1035 variable warnings.
1036 - (dtucker) [openbsd-compat/openbsd-compat.h] Typo.
1037 - (tim) [regress/portnum.sh] Shell portability fix.
1038 - (tim) [configure.ac] Define BROKEN_GETADDRINFO on SVR5 systems. The native
1039 getaddrinfo() is too old and limited for addr_pton() in addrmatch.c.
1040 - (tim) [roaming_client.c] Use of <sys/queue.h> is not really portable so we
1041 use "openbsd-compat/sys-queue.h". s/long long unsigned/unsigned long long/
1042 to keep USL compilers happy.
1043
104420100115
1045 - (dtucker) OpenBSD CVS Sync
1046 - jmc@cvs.openbsd.org 2010/01/13 12:48:34
1047 [sftp.1 sftp.c]
1048 sftp.1: put ls -h in the right place
1049 sftp.c: as above, plus add -p to get/put, and shorten their arg names
1050 to keep the help usage nicely aligned
1051 ok djm
1052 - djm@cvs.openbsd.org 2010/01/13 23:47:26
1053 [auth.c]
1054 when using ChrootDirectory, make sure we test for the existence of the
1055 user's shell inside the chroot; bz #1679, patch from alex AT rtfs.hu;
1056 ok dtucker
1057 - dtucker@cvs.openbsd.org 2010/01/14 23:41:49
1058 [sftp-common.c]
1059 use user_from{uid,gid} to lookup up ids since it keeps a small cache.
1060 ok djm
1061 - guenther@cvs.openbsd.org 2010/01/15 00:05:22
1062 [sftp.c]
1063 Reset SIGTERM to SIG_DFL before executing ssh, so that even if sftp
1064 inherited SIGTERM as ignored it will still be able to kill the ssh it
1065 starts.
1066 ok dtucker@
1067 - (dtucker) [openbsd-compat/pwcache.c] Pull in pwcache.c from OpenBSD (no
1068 changes yet but there will be some to come).
1069 - (dtucker) [configure.ac openbsd-compat/{Makefile.in,pwcache.c} Portability
1070 for pwcache. Also, added caching of negative hits.
1071
107220100114
1073 - (djm) [platform.h] Add missing prototype for
1074 platform_krb5_get_principal_name
1075
107620100113
1077 - (dtucker) [monitor_fdpass.c] Wrap poll.h include in ifdefs.
1078 - (dtucker) [openbsd-compat/readpassphrase.c] Resync against OpenBSD's r1.18:
1079 missing restore of SIGTTOU and some whitespace.
1080 - (dtucker) [openbsd-compat/readpassphrase.c] Update to OpenBSD's r1.21.
1081 - (dtucker) [openbsd-compat/readpassphrase.c] Update to OpenBSD's r1.22.
1082 Fixes bz #1590, where sometimes you could not interrupt a connection while
1083 ssh was prompting for a passphrase or password.
1084 - (dtucker) OpenBSD CVS Sync
1085 - dtucker@cvs.openbsd.org 2010/01/13 00:19:04
1086 [sshconnect.c auth.c]
1087 Fix a couple of typos/mispellings in comments
1088 - dtucker@cvs.openbsd.org 2010/01/13 01:10:56
1089 [key.c]
1090 Ignore and log any Protocol 1 keys where the claimed size is not equal to
1091 the actual size. Noted by Derek Martin, ok djm@
1092 - dtucker@cvs.openbsd.org 2010/01/13 01:20:20
1093 [canohost.c ssh-keysign.c sshconnect2.c]
1094 Make HostBased authentication work with a ProxyCommand. bz #1569, patch
1095 from imorgan at nas nasa gov, ok djm@
1096 - djm@cvs.openbsd.org 2010/01/13 01:40:16
1097 [sftp.c sftp-server.c sftp.1 sftp-common.c sftp-common.h]
1098 support '-h' (human-readable units) for sftp's ls command, just like
1099 ls(1); ok dtucker@
1100 - djm@cvs.openbsd.org 2010/01/13 03:48:13
1101 [servconf.c servconf.h sshd.c]
1102 avoid run-time failures when specifying hostkeys via a relative
1103 path by prepending the cwd in these cases; bz#1290; ok dtucker@
1104 - djm@cvs.openbsd.org 2010/01/13 04:10:50
1105 [sftp.c]
1106 don't append a space after inserting a completion of a directory (i.e.
1107 a path ending in '/') for a slightly better user experience; ok dtucker@
1108 - (dtucker) [sftp-common.c] Wrap include of util.h in an ifdef.
1109 - (tim) [defines.h] openbsd-compat/readpassphrase.c now needs _NSIG.
1110 feedback and ok dtucker@
1111
111220100112
1113 - (dtucker) OpenBSD CVS Sync
1114 - dtucker@cvs.openbsd.org 2010/01/11 01:39:46
1115 [ssh_config channels.c ssh.1 channels.h ssh.c]
1116 Add a 'netcat mode' (ssh -W). This connects stdio on the client to a
1117 single port forward on the server. This allows, for example, using ssh as
1118 a ProxyCommand to route connections via intermediate servers.
1119 bz #1618, man page help from jmc@, ok markus@
1120 - dtucker@cvs.openbsd.org 2010/01/11 04:46:45
1121 [authfile.c sshconnect2.c]
1122 Do not prompt for a passphrase if we fail to open a keyfile, and log the
1123 reason the open failed to debug.
1124 bz #1693, found by tj AT castaglia org, ok djm@
1125 - djm@cvs.openbsd.org 2010/01/11 10:51:07
1126 [ssh-keygen.c]
1127 when converting keys, truncate key comments at 72 chars as per RFC4716;
1128 bz#1630 reported by tj AT castaglia.org; ok markus@
1129 - dtucker@cvs.openbsd.org 2010/01/12 00:16:47
1130 [authfile.c]
1131 Fix bug introduced in r1.78 (incorrect brace location) that broke key auth.
1132 Patch from joachim joachimschipper nl.
1133 - djm@cvs.openbsd.org 2010/01/12 00:58:25
1134 [monitor_fdpass.c]
1135 avoid spinning when fd passing on nonblocking sockets by calling poll()
1136 in the EINTR/EAGAIN path, much like we do in atomicio; ok dtucker@
1137 - djm@cvs.openbsd.org 2010/01/12 00:59:29
1138 [roaming_common.c]
1139 delete with extreme prejudice a debug() that fired with every keypress;
1140 ok dtucker deraadt
1141 - dtucker@cvs.openbsd.org 2010/01/12 01:31:05
1142 [session.c]
1143 Do not allow logins if /etc/nologin exists but is not readable by the user
1144 logging in. Noted by Jan.Pechanec at Sun, ok djm@ deraadt@
1145 - djm@cvs.openbsd.org 2010/01/12 01:36:08
1146 [buffer.h bufaux.c]
1147 add a buffer_get_string_ptr_ret() that does the same as
1148 buffer_get_string_ptr() but does not fatal() on error; ok dtucker@
1149 - dtucker@cvs.openbsd.org 2010/01/12 08:33:17
1150 [session.c]
1151 Add explicit stat so we reliably detect nologin with bad perms.
1152 ok djm markus
1153
115420100110
1155 - (dtucker) [configure.ac misc.c readconf.c servconf.c ssh-keyscan.c]
1156 Remove hacks add for RoutingDomain in preparation for its removal.
1157 - (dtucker) OpenBSD CVS Sync
1158 - dtucker@cvs.openbsd.org 2010/01/09 23:04:13
1159 [channels.c ssh.1 servconf.c sshd_config.5 sshd.c channels.h servconf.h
1160 ssh-keyscan.1 ssh-keyscan.c readconf.c sshconnect.c misc.c ssh.c
1161 readconf.h scp.1 sftp.1 ssh_config.5 misc.h]
1162 Remove RoutingDomain from ssh since it's now not needed. It can be
1163 replaced with "route exec" or "nc -V" as a proxycommand. "route exec"
1164 also ensures that trafic such as DNS lookups stays withing the specified
1165 routingdomain. For example (from reyk):
1166 # route -T 2 exec /usr/sbin/sshd
1167 or inherited from the parent process
1168 $ route -T 2 exec sh
1169 $ ssh 10.1.2.3
1170 ok deraadt@ markus@ stevesk@ reyk@
1171 - dtucker@cvs.openbsd.org 2010/01/10 03:51:17
1172 [servconf.c]
1173 Add ChrootDirectory to sshd.c test-mode output
1174 - dtucker@cvs.openbsd.org 2010/01/10 07:15:56
1175 [auth.c]
1176 Output a debug if we can't open an existing keyfile. bz#1694, ok djm@
1177
117820100109
1179 - (dtucker) Wrap use of IPPROTO_IPV6 in an ifdef for platforms that don't
1180 have it.
1181 - (dtucker) [defines.h] define PRIu64 for platforms that don't have it.
1182 - (dtucker) [roaming_client.c] Wrap inttypes.h in an ifdef.
1183 - (dtucker) [loginrec.c] Use the SUSv3 specified name for the user name
1184 when using utmpx. Patch from Ed Schouten.
1185 - (dtucker) OpenBSD CVS Sync
1186 - djm@cvs.openbsd.org 2010/01/09 00:20:26
1187 [sftp-server.c sftp-server.8]
1188 add a 'read-only' mode to sftp-server(8) that disables open in write mode
1189 and all other fs-modifying protocol methods. bz#430 ok dtucker@
1190 - djm@cvs.openbsd.org 2010/01/09 00:57:10
1191 [PROTOCOL]
1192 tweak language
1193 - jmc@cvs.openbsd.org 2010/01/09 03:36:00
1194 [sftp-server.8]
1195 bad place to forget a comma...
1196 - djm@cvs.openbsd.org 2010/01/09 05:04:24
1197 [mux.c sshpty.h clientloop.c sshtty.c]
1198 quell tc[gs]etattr warnings when forcing a tty (ssh -tt), since we
1199 usually don't actually have a tty to read/set; bz#1686 ok dtucker@
1200 - dtucker@cvs.openbsd.org 2010/01/09 05:17:00
1201 [roaming_client.c]
1202 Remove a PRIu64 format string that snuck in with roaming. ok djm@
1203 - dtucker@cvs.openbsd.org 2010/01/09 11:13:02
1204 [sftp.c]
1205 Prevent sftp from derefing a null pointer when given a "-" without a
1206 command. Also, allow whitespace to follow a "-". bz#1691, path from
1207 Colin Watson via Debian. ok djm@ deraadt@
1208 - dtucker@cvs.openbsd.org 2010/01/09 11:17:56
1209 [sshd.c]
1210 Afer sshd receives a SIGHUP, ignore subsequent HUPs while sshd re-execs
1211 itself. Prevents two HUPs in quick succession from resulting in sshd
1212 dying. bz#1692, patch from Colin Watson via Ubuntu.
1213 - (dtucker) [defines.h] Remove now-undeeded PRIu64 define.
1214
121520100108
1216 - (dtucker) OpenBSD CVS Sync
1217 - andreas@cvs.openbsd.org 2009/10/24 11:11:58
1218 [roaming.h]
1219 Declarations needed for upcoming changes.
1220 ok markus@
1221 - andreas@cvs.openbsd.org 2009/10/24 11:13:54
1222 [sshconnect2.c kex.h kex.c]
1223 Let the client detect if the server supports roaming by looking
1224 for the resume@appgate.com kex algorithm.
1225 ok markus@
1226 - andreas@cvs.openbsd.org 2009/10/24 11:15:29
1227 [clientloop.c]
1228 client_loop() must detect if the session has been suspended and resumed,
1229 and take appropriate action in that case.
1230 From Martin Forssen, maf at appgate dot com
1231 - andreas@cvs.openbsd.org 2009/10/24 11:19:17
1232 [ssh2.h]
1233 Define the KEX messages used when resuming a suspended connection.
1234 ok markus@
1235 - andreas@cvs.openbsd.org 2009/10/24 11:22:37
1236 [roaming_common.c]
1237 Do the actual suspend/resume in the client. This won't be useful until
1238 the server side supports roaming.
1239 Most code from Martin Forssen, maf at appgate dot com. Some changes by
1240 me and markus@
1241 ok markus@
1242 - andreas@cvs.openbsd.org 2009/10/24 11:23:42
1243 [ssh.c]
1244 Request roaming to be enabled if UseRoaming is true and the server
1245 supports it.
1246 ok markus@
1247 - reyk@cvs.openbsd.org 2009/10/28 16:38:18
1248 [ssh_config.5 sshd.c misc.h ssh-keyscan.1 readconf.h sshconnect.c
1249 channels.c channels.h servconf.h servconf.c ssh.1 ssh-keyscan.c scp.1
1250 sftp.1 sshd_config.5 readconf.c ssh.c misc.c]
1251 Allow to set the rdomain in ssh/sftp/scp/sshd and ssh-keyscan.
1252 ok markus@
1253 - jmc@cvs.openbsd.org 2009/10/28 21:45:08
1254 [sshd_config.5 sftp.1]
1255 tweak previous;
1256 - djm@cvs.openbsd.org 2009/11/10 02:56:22
1257 [ssh_config.5]
1258 explain the constraints on LocalCommand some more so people don't
1259 try to abuse it.
1260 - djm@cvs.openbsd.org 2009/11/10 02:58:56
1261 [sshd_config.5]
1262 clarify that StrictModes does not apply to ChrootDirectory. Permissions
1263 and ownership are always checked when chrooting. bz#1532
1264 - dtucker@cvs.openbsd.org 2009/11/10 04:30:45
1265 [sshconnect2.c channels.c sshconnect.c]
1266 Set close-on-exec on various descriptors so they don't get leaked to
1267 child processes. bz #1643, patch from jchadima at redhat, ok deraadt.
1268 - markus@cvs.openbsd.org 2009/11/11 21:37:03
1269 [channels.c channels.h]
1270 fix race condition in x11/agent channel allocation: don't read after
1271 the end of the select read/write fdset and make sure a reused FD
1272 is not touched before the pre-handlers are called.
1273 with and ok djm@
1274 - djm@cvs.openbsd.org 2009/11/17 05:31:44
1275 [clientloop.c]
1276 fix incorrect exit status when multiplexing and channel ID 0 is recycled
1277 bz#1570 reported by peter.oliver AT eon-is.co.uk; ok dtucker
1278 - djm@cvs.openbsd.org 2009/11/19 23:39:50
1279 [session.c]
1280 bz#1606: error when an attempt is made to connect to a server
1281 with ForceCommand=internal-sftp with a shell session (i.e. not a
1282 subsystem session). Avoids stuck client when attempting to ssh to such a
1283 service. ok dtucker@
1284 - dtucker@cvs.openbsd.org 2009/11/20 00:15:41
1285 [session.c]
1286 Warn but do not fail if stat()ing the subsystem binary fails. This helps
1287 with chrootdirectory+forcecommand=sftp-server and restricted shells.
1288 bz #1599, ok djm.
1289 - djm@cvs.openbsd.org 2009/11/20 00:54:01
1290 [sftp.c]
1291 bz#1588 change "Connecting to host..." message to "Connected to host."
1292 and delay it until after the sftp protocol connection has been established.
1293 Avoids confusing sequence of messages when the underlying ssh connection
1294 experiences problems. ok dtucker@
1295 - dtucker@cvs.openbsd.org 2009/11/20 00:59:36
1296 [sshconnect2.c]
1297 Use the HostKeyAlias when prompting for passwords. bz#1039, ok djm@
1298 - djm@cvs.openbsd.org 2009/11/20 03:24:07
1299 [misc.c]
1300 correct off-by-one in percent_expand(): we would fatal() when trying
1301 to expand EXPAND_MAX_KEYS, allowing only EXPAND_MAX_KEYS-1 to actually
1302 work. Note that nothing in OpenSSH actually uses close to this limit at
1303 present. bz#1607 from Jan.Pechanec AT Sun.COM
1304 - halex@cvs.openbsd.org 2009/11/22 13:18:00
1305 [sftp.c]
1306 make passing of zero-length arguments to ssh safe by
1307 passing "-<switch>" "<value>" rather than "-<switch><value>"
1308 ok dtucker@, guenther@, djm@
1309 - dtucker@cvs.openbsd.org 2009/12/06 23:41:15
1310 [sshconnect2.c]
1311 zap unused variable and strlen; from Steve McClellan, ok djm
1312 - djm@cvs.openbsd.org 2009/12/06 23:53:45
1313 [roaming_common.c]
1314 use socklen_t for getsockopt optlen parameter; reported by
1315 Steve.McClellan AT radisys.com, ok dtucker@
1316 - dtucker@cvs.openbsd.org 2009/12/06 23:53:54
1317 [sftp.c]
1318 fix potential divide-by-zero in sftp's "df" output when talking to a server
1319 that reports zero files on the filesystem (Unix filesystems always have at
1320 least the root inode). From Steve McClellan at radisys, ok djm@
1321 - markus@cvs.openbsd.org 2009/12/11 18:16:33
1322 [key.c]
1323 switch from 35 to the more common value of RSA_F4 == (2**16)+1 == 65537
1324 for the RSA public exponent; discussed with provos; ok djm@
1325 - guenther@cvs.openbsd.org 2009/12/20 07:28:36
1326 [ssh.c sftp.c scp.c]
1327 When passing user-controlled options with arguments to other programs,
1328 pass the option and option argument as separate argv entries and
1329 not smashed into one (e.g., as -l foo and not -lfoo). Also, always
1330 pass a "--" argument to stop option parsing, so that a positional
1331 argument that starts with a '-' isn't treated as an option. This
1332 fixes some error cases as well as the handling of hostnames and
1333 filenames that start with a '-'.
1334 Based on a diff by halex@
1335 ok halex@ djm@ deraadt@
1336 - djm@cvs.openbsd.org 2009/12/20 23:20:40
1337 [PROTOCOL]
1338 fix an incorrect magic number and typo in PROTOCOL; bz#1688
1339 report and fix from ueno AT unixuser.org
1340 - stevesk@cvs.openbsd.org 2009/12/25 19:40:21
1341 [readconf.c servconf.c misc.h ssh-keyscan.c misc.c]
1342 validate routing domain is in range 0-RT_TABLEID_MAX.
1343 'Looks right' deraadt@
1344 - stevesk@cvs.openbsd.org 2009/12/29 16:38:41
1345 [sshd_config.5 readconf.c ssh_config.5 scp.1 servconf.c sftp.1 ssh.1]
1346 Rename RDomain config option to RoutingDomain to be more clear and
1347 consistent with other options.
1348 NOTE: if you currently use RDomain in the ssh client or server config,
1349 or ssh/sshd -o, you must update to use RoutingDomain.
1350 ok markus@ djm@
1351 - jmc@cvs.openbsd.org 2009/12/29 18:03:32
1352 [sshd_config.5 ssh_config.5]
1353 sort previous;
1354 - dtucker@cvs.openbsd.org 2010/01/04 01:45:30
1355 [sshconnect2.c]
1356 Don't escape backslashes in the SSH2 banner. bz#1533, patch from
1357 Michal Gorny via Gentoo.
1358 - djm@cvs.openbsd.org 2010/01/04 02:03:57
1359 [sftp.c]
1360 Implement tab-completion of commands, local and remote filenames for sftp.
1361 Hacked on and off for some time by myself, mouring, Carlos Silva (via 2009
1362 Google Summer of Code) and polished to a fine sheen by myself again.
1363 It should deal more-or-less correctly with the ikky corner-cases presented
1364 by quoted filenames, but the UI could still be slightly improved.
1365 In particular, it is quite slow for remote completion on large directories.
1366 bz#200; ok markus@
1367 - djm@cvs.openbsd.org 2010/01/04 02:25:15
1368 [sftp-server.c]
1369 bz#1566 don't unnecessarily dup() in and out fds for sftp-server;
1370 ok markus@
1371 - dtucker@cvs.openbsd.org 2010/01/08 21:50:49
1372 [sftp.c]
1373 Fix two warnings: possibly used unitialized and use a nul byte instead of
1374 NULL pointer. ok djm@
1375 - (dtucker) [Makefile.in added roaming_client.c roaming_serv.c] Import new
1376 files for roaming and add to Makefile.
1377 - (dtucker) [Makefile.in] .c files do not belong in the OBJ lines.
1378 - (dtucker) [sftp.c] ifdef out the sftp completion bits for platforms that
1379 don't have libedit.
1380 - (dtucker) [configure.ac misc.c readconf.c servconf.c ssh-keyscan.c] Make
1381 RoutingDomain an unsupported option on platforms that don't have it.
1382 - (dtucker) [sftp.c] Expand ifdef for libedit to cover complete_is_remote
1383 too.
1384 - (dtucker) [misc.c] Move the routingdomain ifdef to allow the socket to
1385 be created.
1386 - (dtucker] [misc.c] Shrink the area covered by USE_ROUTINGDOMAIN more
1387 to eliminate an unused variable warning.
1388 - (dtucker) [roaming_serv.c] Include includes.h for u_intXX_t types.
1389
139020091226
1391 - (tim) [contrib/cygwin/Makefile] Install ssh-copy-id and ssh-copy-id.1
1392 Gzip all man pages. Patch from Corinna Vinschen.
1393
139420091221
1395 - (dtucker) [auth-krb5.c platform.{c,h} openbsd-compat/port-aix.{c,h}]
1396 Bug #1583: Use system's kerberos principal name on AIX if it's available.
1397 Based on a patch from and tested by Miguel Sanders
1398
139920091208
1400 - (dtucker) Bug #1470: Disable OOM-killing of the listening sshd on Linux,
1401 based on a patch from Vaclav Ovsik and Colin Watson. ok djm.
1402
140320091207
1404 - (dtucker) Bug #1160: use pkg-config for opensc config if it's available.
1405 Tested by Martin Paljak.
1406 - (dtucker) Bug #1677: add conditionals around the source for ssh-askpass.
1407
140820091121
1409 - (tim) [opensshd.init.in] If PidFile is set in sshd_config, use it.
1410 Bug 1628. OK dtucker@
1411
141220091120
1413 - (djm) [ssh-rand-helper.c] Print error and usage() when passed command-
1414 line arguments as none are supported. Exit when passed unrecognised
1415 commandline flags. bz#1568 from gson AT araneus.fi
1416
141720091118
1418 - (djm) [channels.c misc.c misc.h sshd.c] add missing setsockopt() to
1419 set IPV6_V6ONLY for local forwarding with GatwayPorts=yes. Unify
1420 setting IPV6_V6ONLY behind a new function misc.c:sock_set_v6only()
1421 bz#1648, report and fix from jan.kratochvil AT redhat.com
1422 - (djm) [contrib/gnome-ssh-askpass2.c] Make askpass dialog desktop-modal.
1423 bz#1645, patch from jchadima AT redhat.com
1424
142520091107
1426 - (dtucker) [authfile.c] Fall back to 3DES for the encryption of private
1427 keys when built with OpenSSL versions that don't do AES.
1428
142920091105
1430 - (dtucker) [authfile.c] Add OpenSSL compat header so this still builds with
1431 older versions of OpenSSL.
1432
143320091024
1434 - (dtucker) OpenBSD CVS Sync
1435 - djm@cvs.openbsd.org 2009/10/11 23:03:15
1436 [hostfile.c]
1437 mention the host name that we are looking for in check_host_in_hostfile()
1438 - sobrado@cvs.openbsd.org 2009/10/17 12:10:39
1439 [sftp-server.c]
1440 sort flags.
1441 - sobrado@cvs.openbsd.org 2009/10/22 12:35:53
1442 [ssh.1 ssh-agent.1 ssh-add.1]
1443 use the UNIX-related macros (.At and .Ux) where appropriate.
1444 ok jmc@
1445 - sobrado@cvs.openbsd.org 2009/10/22 15:02:12
1446 [ssh-agent.1 ssh-add.1 ssh.1]
1447 write UNIX-domain in a more consistent way; while here, replace a
1448 few remaining ".Tn UNIX" macros with ".Ux" ones.
1449 pointed out by ratchov@, thanks!
1450 ok jmc@
1451 - djm@cvs.openbsd.org 2009/10/22 22:26:13
1452 [authfile.c]
1453 switch from 3DES to AES-128 for encryption of passphrase-protected
1454 SSH protocol 2 private keys; ok several
1455 - djm@cvs.openbsd.org 2009/10/23 01:57:11
1456 [sshconnect2.c]
1457 disallow a hostile server from checking jpake auth by sending an
1458 out-of-sequence success message. (doesn't affect code enabled by default)
1459 - dtucker@cvs.openbsd.org 2009/10/24 00:48:34
1460 [ssh-keygen.1]
1461 ssh-keygen now uses AES-128 for private keys
1462 - (dtucker) [mdoc2man.awk] Teach it to understand the .Ux macro.
1463 - (dtucker) [session.c openbsd-compat/port-linux.{c,h}] Bug #1637: if selinux
1464 is enabled set the security context to "sftpd_t" before running the
1465 internal sftp server Based on a patch from jchadima at redhat.
1466
146720091011
1468 - (dtucker) [configure.ac sftp-client.c] Remove the gyrations required for
1469 dirent d_type and DTTOIF as we've switched OpenBSD to the more portable
1470 lstat.
1471 - (dtucker) OpenBSD CVS Sync
1472 - markus@cvs.openbsd.org 2009/10/08 14:03:41
1473 [sshd_config readconf.c ssh_config.5 servconf.c sshd_config.5]
1474 disable protocol 1 by default (after a transition period of about 10 years)
1475 ok deraadt
1476 - jmc@cvs.openbsd.org 2009/10/08 20:42:12
1477 [sshd_config.5 ssh_config.5 sshd.8 ssh.1]
1478 some tweaks now that protocol 1 is not offered by default; ok markus
1479 - dtucker@cvs.openbsd.org 2009/10/11 10:41:26
1480 [sftp-client.c]
1481 d_type isn't portable so use lstat to get dirent modes. Suggested by and
1482 "looks sane" deraadt@
1483 - markus@cvs.openbsd.org 2009/10/08 18:04:27
1484 [regress/test-exec.sh]
1485 re-enable protocol v1 for the tests.
1486
148720091007
1488 - (dtucker) OpenBSD CVS Sync
1489 - djm@cvs.openbsd.org 2009/08/12 00:13:00
1490 [sftp.c sftp.1]
1491 support most of scp(1)'s commandline arguments in sftp(1), as a first
1492 step towards making sftp(1) a drop-in replacement for scp(1).
1493 One conflicting option (-P) has not been changed, pending further
1494 discussion.
1495 Patch from carlosvsilvapt@gmail.com as part of his work in the
1496 Google Summer of Code
1497 - jmc@cvs.openbsd.org 2009/08/12 06:31:42
1498 [sftp.1]
1499 sort options;
1500 - djm@cvs.openbsd.org 2009/08/13 01:11:19
1501 [sftp.1 sftp.c]
1502 Swizzle options: "-P sftp_server_path" moves to "-D sftp_server_path",
1503 add "-P port" to match scp(1). Fortunately, the -P option is only really
1504 used by our regression scripts.
1505 part of larger patch from carlosvsilvapt@gmail.com for his Google Summer
1506 of Code work; ok deraadt markus
1507 - jmc@cvs.openbsd.org 2009/08/13 13:39:54
1508 [sftp.1 sftp.c]
1509 sync synopsis and usage();
1510 - djm@cvs.openbsd.org 2009/08/14 18:17:49
1511 [sftp-client.c]
1512 make the "get_handle: ..." error messages vaguely useful by allowing
1513 callers to specify their own error message strings.
1514 - fgsch@cvs.openbsd.org 2009/08/15 18:56:34
1515 [auth.h]
1516 remove unused define. markus@ ok.
1517 (Id sync only, Portable still uses this.)
1518 - dtucker@cvs.openbsd.org 2009/08/16 23:29:26
1519 [sshd_config.5]
1520 Add PubkeyAuthentication to the list allowed in a Match block (bz #1577)
1521 - djm@cvs.openbsd.org 2009/08/18 18:36:21
1522 [sftp-client.h sftp.1 sftp-client.c sftp.c]
1523 recursive transfer support for get/put and on the commandline
1524 work mostly by carlosvsilvapt@gmail.com for the Google Summer of Code
1525 with some tweaks by me; "go for it" deraadt@
1526 - djm@cvs.openbsd.org 2009/08/18 21:15:59
1527 [sftp.1]
1528 fix "get" command usage, spotted by jmc@
1529 - jmc@cvs.openbsd.org 2009/08/19 04:56:03
1530 [sftp.1]
1531 ether -> either;
1532 - dtucker@cvs.openbsd.org 2009/08/20 23:54:28
1533 [mux.c]
1534 subsystem_flag is defined in ssh.c so it's extern; ok djm
1535 - djm@cvs.openbsd.org 2009/08/27 17:28:52
1536 [sftp-server.c]
1537 allow setting an explicit umask on the commandline to override whatever
1538 default the user has. bz#1229; ok dtucker@ deraadt@ markus@
1539 - djm@cvs.openbsd.org 2009/08/27 17:33:49
1540 [ssh-keygen.c]
1541 force use of correct hash function for random-art signature display
1542 as it was inheriting the wrong one when bubblebabble signatures were
1543 activated; bz#1611 report and patch from fwojcik+openssh AT besh.com;
1544 ok markus@
1545 - djm@cvs.openbsd.org 2009/08/27 17:43:00
1546 [sftp-server.8]
1547 allow setting an explicit umask on the commandline to override whatever
1548 default the user has. bz#1229; ok dtucker@ deraadt@ markus@
1549 - djm@cvs.openbsd.org 2009/08/27 17:44:52
1550 [authfd.c ssh-add.c authfd.h]
1551 Do not fall back to adding keys without contraints (ssh-add -c / -t ...)
1552 when the agent refuses the constrained add request. This was a useful
1553 migration measure back in 2002 when constraints were new, but just
1554 adds risk now.
1555 bz #1612, report and patch from dkg AT fifthhorseman.net; ok markus@
1556 - djm@cvs.openbsd.org 2009/08/31 20:56:02
1557 [sftp-server.c]
1558 check correct variable for error message, spotted by martynas@
1559 - djm@cvs.openbsd.org 2009/08/31 21:01:29
1560 [sftp-server.8]
1561 document -e and -h; prodded by jmc@
1562 - djm@cvs.openbsd.org 2009/09/01 14:43:17
1563 [ssh-agent.c]
1564 fix a race condition in ssh-agent that could result in a wedged or
1565 spinning agent: don't read off the end of the allocated fd_sets, and
1566 don't issue blocking read/write on agent sockets - just fall back to
1567 select() on retriable read/write errors. bz#1633 reported and tested
1568 by "noodle10000 AT googlemail.com"; ok dtucker@ markus@
1569 - grunk@cvs.openbsd.org 2009/10/01 11:37:33
1570 [dh.c]
1571 fix a cast
1572 ok djm@ markus@
1573 - djm@cvs.openbsd.org 2009/10/06 04:46:40
1574 [session.c]
1575 bz#1596: fflush(NULL) before exec() to ensure that everying (motd
1576 in particular) has made it out before the streams go away.
1577 - djm@cvs.openbsd.org 2008/12/07 22:17:48
1578 [regress/addrmatch.sh]
1579 match string "passwordauthentication" only at start of line, not anywhere
1580 in sshd -T output
1581 - dtucker@cvs.openbsd.org 2009/05/05 07:51:36
1582 [regress/multiplex.sh]
1583 Always specify ssh_config for multiplex tests: prevents breakage caused
1584 by options in ~/.ssh/config. From Dan Peterson.
1585 - djm@cvs.openbsd.org 2009/08/13 00:57:17
1586 [regress/Makefile]
1587 regression test for port number parsing. written as part of the a2port
1588 change that went into 5.2 but I forgot to commit it at the time...
1589 - djm@cvs.openbsd.org 2009/08/13 01:11:55
1590 [regress/sftp-batch.sh regress/sftp-badcmds.sh regress/sftp.sh
1591 regress/sftp-cmds.sh regres/sftp-glob.sh]
1592 date: 2009/08/13 01:11:19; author: djm; state: Exp; lines: +10 -7
1593 Swizzle options: "-P sftp_server_path" moves to "-D sftp_server_path",
1594 add "-P port" to match scp(1). Fortunately, the -P option is only really
1595 used by our regression scripts.
1596 part of larger patch from carlosvsilvapt@gmail.com for his Google Summer
1597 of Code work; ok deraadt markus
1598 - djm@cvs.openbsd.org 2009/08/20 18:43:07
1599 [regress/ssh-com-sftp.sh]
1600 fix one sftp -D ... => sftp -P ... conversion that I missed; from Carlos
1601 Silva for Google Summer of Code
1602 - dtucker@cvs.openbsd.org 2009/10/06 23:51:49
1603 [regress/ssh2putty.sh]
1604 Add OpenBSD tag to make syncs easier
1605 - (dtucker) [regress/portnum.sh] Import new test.
1606 - (dtucker) [configure.ac sftp-client.c] DTOTIF is in fs/ffs/dir.h on at
1607 least dragonflybsd.
1608 - (dtucker) d_type is not mandated by POSIX, so add fallback code using
1609 stat(), needed on at least cygwin.
1610
161120091002
1612 - (djm) [Makefile.in] Mention readconf.o in ssh-keysign's make deps.
1613 spotted by des AT des.no
1614
161520090926
1616 - (djm) [contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
1617 [contrib/suse/openssh.spec] Update for release
1618 - (djm) [README] update relnotes URL
1619 - (djm) [packet.c] Restore EWOULDBLOCK handling that got lost somewhere
1620 - (djm) Release 5.3p1
1621
162220090911
1623 - (dtucker) [configure.ac] Change the -lresolv check so it works on Mac OS X
1624 10.6 (which doesn't have BIND8_COMPAT and thus uses res_9_query). Patch
1625 from jbasney at ncsa uiuc edu.
1626
162720090908
1628 - (djm) [serverloop.c] Fix test for server-assigned remote forwarding port
1629 (-R 0:...); bz#1578, spotted and fix by gavin AT emf.net; ok dtucker@
1630
163120090901
1632 - (dtucker) [configure.ac] Bug #1639: use AC_PATH_PROG to search the path for
1633 krb5-config if it's not in the location specified by --with-kerberos5.
1634 Patch from jchadima at redhat.
1635
163620090829
1637 - (dtucker) [README.platform] Add text about development packages, based on
1638 text from Chris Pepper in bug #1631.
1639
164020090828
1641 - dtucker [auth-sia.c] Roll back the change for bug #1241 as it apparently
1642 causes problems in some Tru64 configurations.
1643 - (djm) [sshd_config.5] downgrade mention of login.conf to be an example
1644 and mention PAM as another provider for ChallengeResponseAuthentication;
1645 bz#1408; ok dtucker@
1646 - (djm) [sftp-server.c] bz#1535: accept ENOSYS as a fallback error when
1647 attempting atomic rename(); ok dtucker@
1648 - (djm) [Makefile.in] bz#1505: Solaris make(1) doesn't accept make variables
1649 in argv, so pass them in the environment; ok dtucker@
1650 - (dtucker) [channels.c configure.ac] Bug #1528: skip the tcgetattr call on
1651 the pty master on Solaris, since it never succeeds and can hang if large
1652 amounts of data is sent to the slave (eg a copy-paste). Based on a patch
1653 originally from Doke Scott, ok djm@
1654 - (dtucker) [clientloop.c configure.ac defines.h] Make the client's IO buffer
1655 size a compile-time option and set it to 64k on Cygwin, since Corinna
1656 reports that it makes a significant difference to performance. ok djm@
1657 - (dtucker) [configure.ac] Fix the syntax of the Solaris tcgetattr entry.
1658
165920090820
1660 - (dtucker) [includes.h] Bug #1634: do not include system glob.h if we're not
1661 using it since the type conflicts can cause problems on FreeBSD. Patch
1662 from Jonathan Chen.
1663 - (dtucker) [session.c openbsd-compat/port-aix.h] Bugs #1249 and #1567: move
1664 the setpcred call on AIX to immediately before the permanently_set_uid().
1665 Ensures that we still have privileges when we call chroot and
1666 pam_open_sesson. Based on a patch from David Leonard.
1667
166820090817
1669 - (dtucker) [configure.ac] Check for headers before libraries for openssl an
1670 zlib, which should make the errors slightly more meaningful on platforms
1671 where there's separate "-devel" packages for those.
1672 - (dtucker) [sshlogin.c openbsd-compat/port-aix.{c,h}] Bug #1595: make
1673 PrintLastLog work on AIX. Based in part on a patch from Miguel Sanders.
1674
167520090729
1676 - (tim) [contrib/cygwin/ssh-user-config] Change script to call correct error
1677 function. Patch from Corinna Vinschen.
1678
167920090713
1680 - (dtucker) [openbsd-compat/getrrsetbyname.c] Reduce answer buffer size so it
1681 fits into 16 bits to work around a bug in glibc's resolver where it masks
1682 off the buffer size at 16 bits. Patch from Hauke Lampe, ok djm jakob.
1683
168420090712
1685 - (dtucker) [configure.ac] Include sys/param.h for the sys/mount.h test,
1686 prevents configure complaining on older BSDs.
1687 - (dtucker [contrib/cygwin/ssh-{host,user}-config] Add license text. Patch
1688 from Corinna Vinschen.
1689 - (dtucker) [auth-pam.c] Bug #1534: move the deletion of PAM credentials on
1690 logout to after the session close. Patch from Anicka Bernathova,
1691 originally from Andreas Schwab via Novelll ok djm.
1692
169320090707
1694 - (dtucker) [contrib/cygwin/ssh-host-config] better support for automated
1695 scripts and fix usage of eval. Patch from Corinna Vinschen.
1696
169720090705
1698 - (dtucker) OpenBSD CVS Sync
1699 - andreas@cvs.openbsd.org 2009/06/27 09:29:06
1700 [packet.h packet.c]
1701 packet_bacup_state() and packet_restore_state() will be used to
1702 temporarily save the current state ren resuming a suspended connection.
1703 ok markus@
1704 - andreas@cvs.openbsd.org 2009/06/27 09:32:43
1705 [roaming_common.c roaming.h]
1706 It may be necessary to retransmit some data when resuming, so add it
1707 to a buffer when roaming is enabled.
1708 Most of this code was written by Martin Forssen, maf at appgate dot com.
1709 ok markus@
1710 - andreas@cvs.openbsd.org 2009/06/27 09:35:06
1711 [readconf.h readconf.c]
1712 Add client option UseRoaming. It doesn't do anything yet but will
1713 control whether the client tries to use roaming if enabled on the
1714 server. From Martin Forssen.
1715 ok markus@
1716 - markus@cvs.openbsd.org 2009/06/30 14:54:40
1717 [version.h]
1718 crank version; ok deraadt
1719 - dtucker@cvs.openbsd.org 2009/07/02 02:11:47
1720 [ssh.c]
1721 allow for long home dir paths (bz #1615). ok deraadt
1722 (based in part on a patch from jchadima at redhat)
1723 - stevesk@cvs.openbsd.org 2009/07/05 19:28:33
1724 [clientloop.c]
1725 only send SSH2_MSG_DISCONNECT if we're in compat20; from dtucker@
1726 ok deraadt@ markus@
1727
172820090622
1729 - (dtucker) OpenBSD CVS Sync
1730 - dtucker@cvs.openbsd.org 2009/06/22 05:39:28
1731 [monitor_wrap.c monitor_mm.c ssh-keygen.c auth2.c gss-genr.c sftp-client.c]
1732 alphabetize includes; reduces diff vs portable and style(9).
1733 ok stevesk djm
1734 (Id sync only; these were already in order in -portable)
1735
173620090621
1737 - (dtucker) OpenBSD CVS Sync
1738 - markus@cvs.openbsd.org 2009/03/17 21:37:00
1739 [ssh.c]
1740 pass correct argv[0] to openlog(); ok djm@
1741 - jmc@cvs.openbsd.org 2009/03/19 15:15:09
1742 [ssh.1]
1743 for "Ciphers", just point the reader to the keyword in ssh_config(5), just
1744 as we do for "MACs": this stops us getting out of sync when the lists
1745 change;
1746 fixes documentation/6102, submitted by Peter J. Philipp
1747 alternative fix proposed by djm
1748 ok markus
1749 - tobias@cvs.openbsd.org 2009/03/23 08:31:19
1750 [ssh-agent.c]
1751 Fixed a possible out-of-bounds memory access if the environment variable
1752 SHELL is shorter than 3 characters.
1753 with input by and ok dtucker
1754 - tobias@cvs.openbsd.org 2009/03/23 19:38:04
1755 [ssh-agent.c]
1756 My previous commit didn't fix the problem at all, so stick at my first
1757 version of the fix presented to dtucker.
1758 Issue notified by Matthias Barkhoff (matthias dot barkhoff at gmx dot de).
1759 ok dtucker
1760 - sobrado@cvs.openbsd.org 2009/03/26 08:38:39
1761 [sftp-server.8 sshd.8 ssh-agent.1]
1762 fix a few typographical errors found by spell(1).
1763 ok dtucker@, jmc@
1764 - stevesk@cvs.openbsd.org 2009/04/13 19:07:44
1765 [sshd_config.5]
1766 fix possessive; ok djm@
1767 - stevesk@cvs.openbsd.org 2009/04/14 16:33:42
1768 [sftp-server.c]
1769 remove unused option character from getopt() optstring; ok markus@
1770 - jj@cvs.openbsd.org 2009/04/14 21:10:54
1771 [servconf.c]
1772 Fixed a few the-the misspellings in comments. Skipped a bunch in
1773 binutils,gcc and so on. ok jmc@
1774 - stevesk@cvs.openbsd.org 2009/04/17 19:23:06
1775 [session.c]
1776 use INTERNAL_SFTP_NAME for setproctitle() of in-process sftp-server;
1777 ok djm@ markus@
1778 - stevesk@cvs.openbsd.org 2009/04/17 19:40:17
1779 [sshd_config.5]
1780 clarify that even internal-sftp needs /dev/log for logging to work; ok
1781 markus@
1782 - jmc@cvs.openbsd.org 2009/04/18 18:39:10
1783 [sshd_config.5]
1784 tweak previous; ok stevesk
1785 - stevesk@cvs.openbsd.org 2009/04/21 15:13:17
1786 [sshd_config.5]
1787 clarify we cd to user's home after chroot; ok markus@ on
1788 earlier version; tweaks and ok jmc@
1789 - andreas@cvs.openbsd.org 2009/05/25 06:48:01
1790 [channels.c packet.c clientloop.c packet.h serverloop.c monitor_wrap.c
1791 monitor.c]
1792 Put the globals in packet.c into a struct and don't access it directly
1793 from other files. No functional changes.
1794 ok markus@ djm@
1795 - andreas@cvs.openbsd.org 2009/05/27 06:31:25
1796 [canohost.h canohost.c]
1797 Add clear_cached_addr(), needed for upcoming changes allowing the peer
1798 address to change.
1799 ok markus@
1800 - andreas@cvs.openbsd.org 2009/05/27 06:33:39
1801 [clientloop.c]
1802 Send SSH2_MSG_DISCONNECT when the client disconnects. From a larger
1803 change from Martin Forssen, maf at appgate dot com.
1804 ok markus@
1805 - andreas@cvs.openbsd.org 2009/05/27 06:34:36
1806 [kex.c kex.h]
1807 Move the KEX_COOKIE_LEN define to kex.h
1808 ok markus@
1809 - andreas@cvs.openbsd.org 2009/05/27 06:36:07
1810 [packet.h packet.c]
1811 Add packet_put_int64() and packet_get_int64(), part of a larger change
1812 from Martin Forssen.
1813 ok markus@
1814 - andreas@cvs.openbsd.org 2009/05/27 06:38:16
1815 [sshconnect.h sshconnect.c]
1816 Un-static ssh_exchange_identification(), part of a larger change from
1817 Martin Forssen and needed for upcoming changes.
1818 ok markus@
1819 - andreas@cvs.openbsd.org 2009/05/28 16:50:16
1820 [sshd.c packet.c serverloop.c monitor_wrap.c clientloop.c sshconnect.c
1821 monitor.c Added roaming.h roaming_common.c roaming_dummy.c]
1822 Keep track of number of bytes read and written. Needed for upcoming
1823 changes. Most code from Martin Forssen, maf at appgate dot com.
1824 ok markus@
1825 Also, applied appropriate changes to Makefile.in
1826 - andreas@cvs.openbsd.org 2009/06/12 20:43:22
1827 [monitor.c packet.c]
1828 Fix warnings found by chl@ and djm@ and change roaming_atomicio's
1829 return type to match atomicio's
1830 Diff from djm@, ok markus@
1831 - andreas@cvs.openbsd.org 2009/06/12 20:58:32
1832 [packet.c]
1833 Move some more statics into session_state
1834 ok markus@ djm@
1835 - dtucker@cvs.openbsd.org 2009/06/21 07:37:15
1836 [kexdhs.c kexgexs.c]
1837 abort if key_sign fails, preventing possible null deref. Based on report
1838 from Paolo Ganci, ok markus@ djm@
1839 - dtucker@cvs.openbsd.org 2009/06/21 09:04:03
1840 [roaming.h roaming_common.c roaming_dummy.c]
1841 Add tags for the benefit of the sync scripts
1842 Also: pull in the changes for 1.1->1.2 missed in the previous sync.
1843 - (dtucker) [auth2-jpake.c auth2.c canohost.h session.c] Whitespace and
1844 header-order changes to reduce diff vs OpenBSD.
1845 - (dtucker) [servconf.c sshd.c] More whitespace sync.
1846 - (dtucker) [roaming_common.c roaming_dummy.c] Wrap #include <inttypes.h> in
1847 ifdef.
1848
184920090616
1850 - (dtucker) [configure.ac defines.h] Bug #1607: handle the case where fsid_t
1851 is a struct with a __val member. Fixes build on, eg, Redhat 6.2.
1852
185320090504
1854 - (dtucker) [sshlogin.c] Move the NO_SSH_LASTLOG #ifndef line to include
1855 variable declarations. Should prevent unused warnings anywhere it's set
1856 (only Crays as far as I can tell) and be a no-op everywhere else.
1857
185820090318
1859 - (tim) [configure.ac] Remove setting IP_TOS_IS_BROKEN for Cygwin. The problem
1860 that setsockopt(IP_TOS) doesn't work on Cygwin has been fixed since 2005.
1861 Based on patch from vinschen at redhat com.
1862
186320090308
1864 - (dtucker) [auth-passwd.c auth1.c auth2-kbdint.c auth2-none.c auth2-passwd.c
1865 auth2-pubkey.c session.c openbsd-compat/bsd-cygwin_util.{c,h}
1866 openbsd-compat/daemon.c] Remove support for Windows 95/98/ME and very old
1867 version of Cygwin. Patch from vinschen at redhat com.
1868
186920090307
1870 - (dtucker) [contrib/aix/buildbff.sh] Only try to rename ssh_prng_cmds if it
1871 exists (it's not created if OpenSSL's PRNG is self-seeded, eg if the OS
1872 has a /dev/random).
1873 - (dtucker) [schnorr.c openbsd-compat/openssl-compat.{c,h}] Add
1874 EVP_DigestUpdate to the OLD_EVP compatibility functions and tell schnorr.c
1875 to use them. Allows building with older OpenSSL versions.
1876 - (dtucker) [configure.ac defines.h] Check for in_port_t and typedef if needed.
1877 - (dtucker) [configure.ac] Missing comma in type list.
1878 - (dtucker) [configure.ac openbsd-compat/openssl-compat.{c,h}]
1879 EVP_DigestUpdate does not exactly match the other OLD_EVP functions (eg
1880 in openssl 0.9.6) so add an explicit test for it.
1881
188220090306
1883 - (djm) OpenBSD CVS Sync
1884 - djm@cvs.openbsd.org 2009/03/05 07:18:19
1885 [auth2-jpake.c jpake.c jpake.h monitor_wrap.c monitor_wrap.h schnorr.c]
1886 [sshconnect2.c]
1887 refactor the (disabled) Schnorr proof code to make it a little more
1888 generally useful
1889 - djm@cvs.openbsd.org 2009/03/05 11:30:50
1890 [uuencode.c]
1891 document what these functions do so I don't ever have to recuse into
1892 b64_pton/ntop to remember their return values
1893
189420090223
1895 - (djm) OpenBSD CVS Sync
1896 - djm@cvs.openbsd.org 2009/02/22 23:50:57
1897 [ssh_config.5 sshd_config.5]
1898 don't advertise experimental options
1899 - djm@cvs.openbsd.org 2009/02/22 23:59:25
1900 [sshd_config.5]
1901 missing period
1902 - djm@cvs.openbsd.org 2009/02/23 00:06:15
1903 [version.h]
1904 openssh-5.2
1905 - (djm) [README] update for 5.2
1906 - (djm) Release openssh-5.2p1
1907
190820090222
1909 - (djm) OpenBSD CVS Sync
1910 - tobias@cvs.openbsd.org 2009/02/21 19:32:04
1911 [misc.c sftp-server-main.c ssh-keygen.c]
1912 Added missing newlines in error messages.
1913 ok dtucker
1914
191520090221
1916 - (djm) OpenBSD CVS Sync
1917 - djm@cvs.openbsd.org 2009/02/17 01:28:32
1918 [ssh_config]
1919 sync with revised default ciphers; pointed out by dkrause@
1920 - djm@cvs.openbsd.org 2009/02/18 04:31:21
1921 [schnorr.c]
1922 signature should hash over the entire group, not just the generator
1923 (this is still disabled code)
1924 - (djm) [contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
1925 [contrib/suse/openssh.spec] Prepare for 5.2p1
1926
192720090216
1928 - (djm) [regress/conch-ciphers.sh regress/putty-ciphers.sh]
1929 [regress/putty-kex.sh regress/putty-transfer.sh] Downgrade disabled
1930 interop tests from FATAL error to a warning. Allows some interop
1931 tests to proceed if others are missing necessary prerequisites.
1932 - (djm) [configure.ac] support GNU/kFreeBSD and GNU/kOpensolaris
1933 systems; patch from Aurelien Jarno via rmh AT aybabtu.com
1934
193520090214
1936 - (djm) OpenBSD CVS Sync
1937 - dtucker@cvs.openbsd.org 2009/02/02 11:15:14
1938 [sftp.c]
1939 Initialize a few variables to prevent spurious "may be used
1940 uninitialized" warnings from newer gcc's. ok djm@
1941 - djm@cvs.openbsd.org 2009/02/12 03:00:56
1942 [canohost.c canohost.h channels.c channels.h clientloop.c readconf.c]
1943 [readconf.h serverloop.c ssh.c]
1944 support remote port forwarding with a zero listen port (-R0:...) to
1945 dyamically allocate a listen port at runtime (this is actually
1946 specified in rfc4254); bz#1003 ok markus@
1947 - djm@cvs.openbsd.org 2009/02/12 03:16:01
1948 [serverloop.c]
1949 tighten check for -R0:... forwarding: only allow dynamic allocation
1950 if want_reply is set in the packet
1951 - djm@cvs.openbsd.org 2009/02/12 03:26:22
1952 [monitor.c]
1953 some paranoia: check that the serialised key is really KEY_RSA before
1954 diddling its internals
1955 - djm@cvs.openbsd.org 2009/02/12 03:42:09
1956 [ssh.1]
1957 document -R0:... usage
1958 - djm@cvs.openbsd.org 2009/02/12 03:44:25
1959 [ssh.1]
1960 consistency: Dq => Ql
1961 - djm@cvs.openbsd.org 2009/02/12 03:46:17
1962 [ssh_config.5]
1963 document RemoteForward usage with 0 listen port
1964 - jmc@cvs.openbsd.org 2009/02/12 07:34:20
1965 [ssh_config.5]
1966 kill trailing whitespace;
1967 - markus@cvs.openbsd.org 2009/02/13 11:50:21
1968 [packet.c]
1969 check for enc !=NULL in packet_start_discard
1970 - djm@cvs.openbsd.org 2009/02/14 06:35:49
1971 [PROTOCOL]
1972 mention that eow and no-more-sessions extensions are sent only to
1973 OpenSSH peers
1974
197520090212
1976 - (djm) [sshpty.c] bz#1419: OSX uses cloning ptys that automagically
1977 set ownership and modes, so avoid explicitly setting them
1978 - (djm) [configure.ac loginrec.c] bz#1421: fix lastlog support for OSX.
1979 OSX provides a getlastlogxbyname function that automates the reading of
1980 a lastlog file. Also, the pututxline function will update lastlog so
1981 there is no need for loginrec.c to do it explicitly. Collapse some
1982 overly verbose code while I'm in there.
1983
198420090201
1985 - (dtucker) [defines.h sshconnect.c] INET6_ADDRSTRLEN is now needed in
1986 channels.c too, so move the definition for non-IP6 platforms to defines.h
1987 where it can be shared.
1988
198920090129
1990 - (tim) [contrib/cygwin/ssh-host-config] Patch from Corinna Vinschen.
1991 If the CYGWIN environment variable is empty, the installer script
1992 should not install the service with an empty CYGWIN variable, but
1993 rather without setting CYGWNI entirely.
1994 - (tim) [contrib/cygwin/ssh-host-config] Whitespace cleanup. No code changes.
1995
199620090128
1997 - (tim) [contrib/cygwin/ssh-host-config] Patch from Corinna Vinschen.
1998 Changes to work on Cygwin 1.5.x as well as on the new Cygwin 1.7.x.
1999 The information given for the setting of the CYGWIN environment variable
2000 is wrong for both releases so I just removed it, together with the
2001 unnecessary (Cygwin 1.5.x) or wrong (Cygwin 1.7.x) default setting.
2002
200320081228
2004 - (djm) OpenBSD CVS Sync
2005 - stevesk@cvs.openbsd.org 2008/12/09 03:20:42
2006 [channels.c servconf.c]
2007 channel_print_adm_permitted_opens() should deal with all the printing
2008 for that config option. suggested by markus@; ok markus@ djm@
2009 dtucker@
2010 - djm@cvs.openbsd.org 2008/12/09 04:32:22
2011 [auth2-chall.c]
2012 replace by-hand string building with xasprinf(); ok deraadt@
2013 - sobrado@cvs.openbsd.org 2008/12/09 15:35:00
2014 [sftp.1 sftp.c]
2015 update for the synopses displayed by the 'help' command, there are a
2016 few missing flags; add 'bye' to the output of 'help'; sorting and spacing.
2017 jmc@ suggested replacing .Oo/.Oc with a single .Op macro.
2018 ok jmc@
2019 - stevesk@cvs.openbsd.org 2008/12/09 22:37:33
2020 [clientloop.c]
2021 fix typo in error message
2022 - stevesk@cvs.openbsd.org 2008/12/10 03:55:20
2023 [addrmatch.c]
2024 o cannot be NULL here but use xfree() to be consistent; ok djm@
2025 - stevesk@cvs.openbsd.org 2008/12/29 01:12:36
2026 [ssh-keyscan.1]
2027 fix example, default key type is rsa for 3+ years; from
2028 frederic.perrin@resel.fr
2029 - stevesk@cvs.openbsd.org 2008/12/29 02:23:26
2030 [pathnames.h]
2031 no need to escape single quotes in comments
2032 - okan@cvs.openbsd.org 2008/12/30 00:46:56
2033 [sshd_config.5]
2034 add AllowAgentForwarding to available Match keywords list
2035 ok djm
2036 - djm@cvs.openbsd.org 2009/01/01 21:14:35
2037 [channels.c]
2038 call channel destroy callbacks on receipt of open failure messages.
2039 fixes client hangs when connecting to a server that has MaxSessions=0
2040 set spotted by imorgan AT nas.nasa.gov; ok markus@
2041 - djm@cvs.openbsd.org 2009/01/01 21:17:36
2042 [kexgexs.c]
2043 fix hash calculation for KEXGEX: hash over the original client-supplied
2044 values and not the sanity checked versions that we acutally use;
2045 bz#1540 reported by john.smith AT arrows.demon.co.uk
2046 ok markus@
2047 - djm@cvs.openbsd.org 2009/01/14 01:38:06
2048 [channels.c]
2049 support SOCKS4A protocol, from dwmw2 AT infradead.org via bz#1482;
2050 "looks ok" markus@
2051 - stevesk@cvs.openbsd.org 2009/01/15 17:38:43
2052 [readconf.c]
2053 1) use obsolete instead of alias for consistency
2054 2) oUserKnownHostsFile not obsolete but oGlobalKnownHostsFile2 is
2055 so move the comment.
2056 3) reorder so like options are together
2057 ok djm@
2058 - djm@cvs.openbsd.org 2009/01/22 09:46:01
2059 [channels.c channels.h session.c]
2060 make Channel->path an allocated string, saving a few bytes here and
2061 there and fixing bz#1380 in the process; ok markus@
2062 - djm@cvs.openbsd.org 2009/01/22 09:49:57
2063 [channels.c]
2064 oops! I committed the wrong version of the Channel->path diff,
2065 it was missing some tweaks suggested by stevesk@
2066 - djm@cvs.openbsd.org 2009/01/22 10:02:34
2067 [clientloop.c misc.c readconf.c readconf.h servconf.c servconf.h]
2068 [serverloop.c ssh-keyscan.c ssh.c sshd.c]
2069 make a2port() return -1 when it encounters an invalid port number
2070 rather than 0, which it will now treat as valid (needed for future work)
2071 adjust current consumers of a2port() to check its return value is <= 0,
2072 which in turn required some things to be converted from u_short => int
2073 make use of int vs. u_short consistent in some other places too
2074 feedback & ok markus@
2075 - djm@cvs.openbsd.org 2009/01/22 10:09:16
2076 [auth-options.c]
2077 another chunk of a2port() diff that got away. wtfdjm??
2078 - djm@cvs.openbsd.org 2009/01/23 07:58:11
2079 [myproposal.h]
2080 prefer CTR modes and revised arcfour (i.e w/ discard) modes to CBC
2081 modes; ok markus@
2082 - naddy@cvs.openbsd.org 2009/01/24 17:10:22
2083 [ssh_config.5 sshd_config.5]
2084 sync list of preferred ciphers; ok djm@
2085 - markus@cvs.openbsd.org 2009/01/26 09:58:15
2086 [cipher.c cipher.h packet.c]
2087 Work around the CPNI-957037 Plaintext Recovery Attack by always
2088 reading 256K of data on packet size or HMAC errors (in CBC mode only).
2089 Help, feedback and ok djm@
2090 Feedback from Martin Albrecht and Paterson Kenny
2091
209220090107
2093 - (djm) [uidswap.c] bz#1412: Support >16 supplemental groups in OS X.
2094 Patch based on one from vgiffin AT apple.com; ok dtucker@
2095 - (djm) [channels.c] bz#1419: support "on demand" X11 forwarding via
2096 launchd on OS X; patch from vgiffin AT apple.com, slightly tweaked;
2097 ok dtucker@
2098 - (djm) [contrib/ssh-copy-id.1 contrib/ssh-copy-id] bz#1492: Make
2099 ssh-copy-id copy id_rsa.pub by default (instead of the legacy "identity"
2100 key). Patch from cjwatson AT debian.org
2101
210220090107
2103 - (tim) [configure.ac defines.h openbsd-compat/port-uw.c
2104 openbsd-compat/xcrypt.c] Add SECUREWARE support to OpenServer 6 SVR5 ABI.
2105 OK djm@ dtucker@
2106 - (tim) [configure.ac] Move check_for_libcrypt_later=1 in *-*-sysv5*) section.
2107 OpenServer 6 doesn't need libcrypt.
2108
210920081209
2110 - (djm) OpenBSD CVS Sync
2111 - djm@cvs.openbsd.org 2008/12/09 02:38:18
2112 [clientloop.c]
2113 The ~C escape handler does not work correctly for multiplexed sessions -
2114 it opens a commandline on the master session, instead of on the slave
2115 that requested it. Disable it on slave sessions until such time as it
2116 is fixed; bz#1543 report from Adrian Bridgett via Colin Watson
2117 ok markus@
2118 - djm@cvs.openbsd.org 2008/12/09 02:39:59
2119 [sftp.c]
2120 Deal correctly with failures in remote stat() operation in sftp,
2121 correcting fail-on-error behaviour in batchmode. bz#1541 report and
2122 fix from anedvedicky AT gmail.com; ok markus@
2123 - djm@cvs.openbsd.org 2008/12/09 02:58:16
2124 [readconf.c]
2125 don't leave junk (free'd) pointers around in Forward *fwd argument on
2126 failure; avoids double-free in ~C -L handler when given an invalid
2127 forwarding specification; bz#1539 report from adejong AT debian.org
2128 via Colin Watson; ok markus@ dtucker@
2129 - djm@cvs.openbsd.org 2008/12/09 03:02:37
2130 [sftp.1 sftp.c]
2131 correct sftp(1) and corresponding usage syntax;
2132 bz#1518 patch from imorgan AT nas.nasa.gov; ok deraadt@ improved diff jmc@
2133
213420081208
2135 - (djm) [configure.ac] bz#1538: better test for ProPolice/SSP: actually
2136 use some stack in main().
2137 Report and suggested fix from vapier AT gentoo.org
2138 - (djm) OpenBSD CVS Sync
2139 - markus@cvs.openbsd.org 2008/12/02 19:01:07
2140 [clientloop.c]
2141 we have to use the recipient's channel number (RFC 4254) for
2142 SSH2_MSG_CHANNEL_SUCCESS/SSH2_MSG_CHANNEL_FAILURE messages,
2143 otherwise we trigger 'Non-public channel' error messages on sshd
2144 systems with clientkeepalive enabled; noticed by sturm; ok djm;
2145 - markus@cvs.openbsd.org 2008/12/02 19:08:59
2146 [serverloop.c]
2147 backout 1.149, since it's not necessary and openssh clients send
2148 broken CHANNEL_FAILURE/SUCCESS messages since about 2004; ok djm@
2149 - markus@cvs.openbsd.org 2008/12/02 19:09:38
2150 [channels.c]
2151 s/remote_id/id/ to be more consistent with other code; ok djm@
2152
215320081201
2154 - (dtucker) [contrib/cygwin/{Makefile,ssh-host-config}] Add new doc files
2155 and tweak the is-sshd-running check in ssh-host-config. Patch from
2156 vinschen at redhat com.
2157 - (dtucker) OpenBSD CVS Sync
2158 - markus@cvs.openbsd.org 2008/11/21 15:47:38
2159 [packet.c]
2160 packet_disconnect() on padding error, too. should reduce the success
2161 probability for the CPNI-957037 Plaintext Recovery Attack to 2^-18
2162 ok djm@
2163 - dtucker@cvs.openbsd.org 2008/11/30 11:59:26
2164 [monitor_fdpass.c]
2165 Retry sendmsg/recvmsg on EAGAIN and EINTR; ok djm@
2166
216720081123
2168 - (dtucker) [monitor_fdpass.c] Reduce diff vs OpenBSD by moving some
2169 declarations, removing an unnecessary union member and adding whitespace.
2170 cmsgbuf.tmp thing spotted by des at des no, ok djm some time ago.
2171
217220081118
2173 - (tim) [addrmatch.c configure.ac] Some platforms do not have sin6_scope_id
2174 member of sockaddr_in6. Also reported in Bug 1491 by David Leonard. OK and
2175 feedback by djm@
2176
217720081111
2178 - (dtucker) OpenBSD CVS Sync
2179 - jmc@cvs.openbsd.org 2008/11/05 11:22:54
2180 [servconf.c]
2181 passord -> password;
2182 fixes user/5975 from Rene Maroufi
2183 - stevesk@cvs.openbsd.org 2008/11/07 00:42:12
2184 [ssh-keygen.c]
2185 spelling/typo in comment
2186 - stevesk@cvs.openbsd.org 2008/11/07 18:50:18
2187 [nchan.c]
2188 add space to some log/debug messages for readability; ok djm@ markus@
2189 - dtucker@cvs.openbsd.org 2008/11/07 23:34:48
2190 [auth2-jpake.c]
2191 Move JPAKE define to make life easier for portable. ok djm@
2192 - tobias@cvs.openbsd.org 2008/11/09 12:34:47
2193 [session.c ssh.1]
2194 typo fixed (overriden -> overridden)
2195 ok espie, jmc
2196 - stevesk@cvs.openbsd.org 2008/11/11 02:58:09
2197 [servconf.c]
2198 USE_AFS not referenced so remove #ifdef. fixes sshd -T not printing
2199 kerberosgetafstoken. ok dtucker@
2200 (Id sync only, we still want the ifdef in portable)
2201 - stevesk@cvs.openbsd.org 2008/11/11 03:55:11
2202 [channels.c]
2203 for sshd -T print 'permitopen any' vs. 'permitopen' for case of no
2204 permitopen's; ok and input dtucker@
2205 - djm@cvs.openbsd.org 2008/11/10 02:06:35
2206 [regress/putty-ciphers.sh]
2207 PuTTY supports AES CTR modes, so interop test against them too
2208
220920081105
2210 - OpenBSD CVS Sync
2211 - djm@cvs.openbsd.org 2008/11/03 08:59:41
2212 [servconf.c]
2213 include MaxSessions in sshd -T output; patch from imorgan AT nas.nasa.gov
2214 - djm@cvs.openbsd.org 2008/11/04 07:58:09
2215 [auth.c]
2216 need unistd.h for close() prototype
2217 (ID sync only)
2218 - djm@cvs.openbsd.org 2008/11/04 08:22:13
2219 [auth.h auth2.c monitor.c monitor.h monitor_wrap.c monitor_wrap.h]
2220 [readconf.c readconf.h servconf.c servconf.h ssh2.h ssh_config.5]
2221 [sshconnect2.c sshd_config.5 jpake.c jpake.h schnorr.c auth2-jpake.c]
2222 [Makefile.in]
2223 Add support for an experimental zero-knowledge password authentication
2224 method using the J-PAKE protocol described in F. Hao, P. Ryan,
2225 "Password Authenticated Key Exchange by Juggling", 16th Workshop on
2226 Security Protocols, Cambridge, April 2008.
2227
2228 This method allows password-based authentication without exposing
2229 the password to the server. Instead, the client and server exchange
2230 cryptographic proofs to demonstrate of knowledge of the password while
2231 revealing nothing useful to an attacker or compromised endpoint.
2232
2233 This is experimental, work-in-progress code and is presently
2234 compiled-time disabled (turn on -DJPAKE in Makefile.inc).
2235
2236 "just commit it. It isn't too intrusive." deraadt@
2237 - stevesk@cvs.openbsd.org 2008/11/04 19:18:00
2238 [readconf.c]
2239 because parse_forward() is now used to parse all forward types (DLR),
2240 and it malloc's space for host variables, we don't need to malloc
2241 here. fixes small memory leaks.
2242
2243 previously dynamic forwards were not parsed in parse_forward() and
2244 space was not malloc'd in that case.
2245
2246 ok djm@
2247 - stevesk@cvs.openbsd.org 2008/11/05 03:23:09
2248 [clientloop.c ssh.1]
2249 add dynamic forward escape command line; ok djm@
2250
225120081103
2252 - OpenBSD CVS Sync
2253 - sthen@cvs.openbsd.org 2008/07/24 23:55:30
2254 [ssh-keygen.1]
2255 Add "ssh-keygen -F -l" to synopsis (displays fingerprint from
2256 known_hosts). ok djm@
2257 - grunk@cvs.openbsd.org 2008/07/25 06:56:35
2258 [ssh_config]
2259 Add VisualHostKey to example file, ok djm@
2260 - grunk@cvs.openbsd.org 2008/07/25 07:05:16
2261 [key.c]
2262 In random art visualization, make sure to use the end marker only at the
2263 end. Initial diff by Dirk Loss, tweaks and ok djm@
2264 - markus@cvs.openbsd.org 2008/07/31 14:48:28
2265 [sshconnect2.c]
2266 don't allocate space for empty banners; report t8m at centrum.cz;
2267 ok deraadt
2268 - krw@cvs.openbsd.org 2008/08/02 04:29:51
2269 [ssh_config.5]
2270 whitepsace -> whitespace. From Matthew Clarke via bugs@.
2271 - djm@cvs.openbsd.org 2008/08/21 04:09:57
2272 [session.c]
2273 allow ForceCommand internal-sftp with arguments. based on patch from
2274 michael.barabanov AT gmail.com; ok markus@
2275 - djm@cvs.openbsd.org 2008/09/06 12:24:13
2276 [kex.c]
2277 OpenSSL 0.9.8h supplies a real EVP_sha256 so we do not need our
2278 replacement anymore
2279 (ID sync only for portable - we still need this)
2280 - markus@cvs.openbsd.org 2008/09/11 14:22:37
2281 [compat.c compat.h nchan.c ssh.c]
2282 only send eow and no-more-sessions requests to openssh 5 and newer;
2283 fixes interop problems with broken ssh v2 implementations; ok djm@
2284 - millert@cvs.openbsd.org 2008/10/02 14:39:35
2285 [session.c]
2286 Convert an unchecked strdup to xstrdup. OK deraadt@
2287 - jmc@cvs.openbsd.org 2008/10/03 13:08:12
2288 [sshd.8]
2289 do not give an example of how to chmod files: we can presume the user
2290 knows that. removes an ambiguity in the permission of authorized_keys;
2291 ok deraadt
2292 - deraadt@cvs.openbsd.org 2008/10/03 23:56:28
2293 [sshconnect2.c]
2294 Repair strnvis() buffersize of 4*n+1, with termination gauranteed by the
2295 function.
2296 spotted by des@freebsd, who commited an incorrect fix to the freebsd tree
2297 and (as is fairly typical) did not report the problem to us. But this fix
2298 is correct.
2299 ok djm
2300 - djm@cvs.openbsd.org 2008/10/08 23:34:03
2301 [ssh.1 ssh.c]
2302 Add -y option to force logging via syslog rather than stderr.
2303 Useful for daemonised ssh connection (ssh -f). Patch originally from
2304 and ok'd by markus@
2305 - djm@cvs.openbsd.org 2008/10/09 03:50:54
2306 [servconf.c sshd_config.5]
2307 support setting PermitEmptyPasswords in a Match block
2308 requested in PR3891; ok dtucker@
2309 - jmc@cvs.openbsd.org 2008/10/09 06:54:22
2310 [ssh.c]
2311 add -y to usage();
2312 - stevesk@cvs.openbsd.org 2008/10/10 04:55:16
2313 [scp.c]
2314 spelling in comment; ok djm@
2315 - stevesk@cvs.openbsd.org 2008/10/10 05:00:12
2316 [key.c]
2317 typo in error message; ok djm@
2318 - stevesk@cvs.openbsd.org 2008/10/10 16:43:27
2319 [ssh_config.5]
2320 use 'Privileged ports can be forwarded only when logging in as root on
2321 the remote machine.' for RemoteForward just like ssh.1 -R.
2322 ok djm@ jmc@
2323 - stevesk@cvs.openbsd.org 2008/10/14 18:11:33
2324 [sshconnect.c]
2325 use #define ROQUIET here; no binary change. ok dtucker@
2326 - stevesk@cvs.openbsd.org 2008/10/17 18:36:24
2327 [ssh_config.5]
2328 correct and clarify VisualHostKey; ok jmc@
2329 - stevesk@cvs.openbsd.org 2008/10/30 19:31:16
2330 [clientloop.c sshd.c]
2331 don't need to #include "monitor_fdpass.h"
2332 - stevesk@cvs.openbsd.org 2008/10/31 15:05:34
2333 [dispatch.c]
2334 remove unused #define DISPATCH_MIN; ok markus@
2335 - djm@cvs.openbsd.org 2008/11/01 04:50:08
2336 [sshconnect2.c]
2337 sprinkle ARGSUSED on dispatch handlers
2338 nuke stale unusued prototype
2339 - stevesk@cvs.openbsd.org 2008/11/01 06:43:33
2340 [channels.c]
2341 fix some typos in log messages; ok djm@
2342 - sobrado@cvs.openbsd.org 2008/11/01 11:14:36
2343 [ssh-keyscan.1 ssh-keyscan.c]
2344 the ellipsis is not an optional argument; while here, improve spacing.
2345 - stevesk@cvs.openbsd.org 2008/11/01 17:40:33
2346 [clientloop.c readconf.c readconf.h ssh.c]
2347 merge dynamic forward parsing into parse_forward();
2348 'i think this is OK' djm@
2349 - stevesk@cvs.openbsd.org 2008/11/02 00:16:16
2350 [ttymodes.c]
2351 protocol 2 tty modes support is now 7.5 years old so remove these
2352 debug3()s; ok deraadt@
2353 - stevesk@cvs.openbsd.org 2008/11/03 01:07:02
2354 [readconf.c]
2355 remove valueless comment
2356 - stevesk@cvs.openbsd.org 2008/11/03 02:44:41
2357 [readconf.c]
2358 fix comment
2359 - (djm) [contrib/caldera/ssh-host-keygen contrib/suse/rc.sshd]
2360 Make example scripts generate keys with default sizes rather than fixed,
2361 non-default 1024 bits; patch from imorgan AT nas.nasa.gov
2362 - (djm) [contrib/sshd.pam.generic contrib/caldera/sshd.pam]
2363 [contrib/redhat/sshd.pam] Move pam_nologin to account group from
2364 incorrect auth group in example files;
2365 patch from imorgan AT nas.nasa.gov
2366
236720080906
2368 - (dtucker) [config.guess config.sub] Update to latest versions from
2369 http://git.savannah.gnu.org/gitweb/ (2008-04-14 and 2008-06-16
2370 respectively).
2371
237220080830
2373 - (dtucker) [openbsd-compat/bsd-poll.c] correctly check for number of FDs
2374 larger than FD_SETSIZE (OpenSSH only ever uses poll with one fd). Patch
2375 from Nicholas Marriott.
2376
237720080721
2378 - (djm) OpenBSD CVS Sync
2379 - djm@cvs.openbsd.org 2008/07/23 07:36:55
2380 [servconf.c]
2381 do not try to print options that have been compile-time disabled
2382 in config test mode (sshd -T); report from nix-corp AT esperi.org.uk
2383 ok dtucker@
2384 - (djm) [servconf.c] Print UsePAM option in config test mode (when it
2385 has been compiled in); report from nix-corp AT esperi.org.uk
2386 ok dtucker@
2387
238820080721
2389 - (djm) OpenBSD CVS Sync
2390 - jmc@cvs.openbsd.org 2008/07/18 22:51:01
2391 [sftp-server.8]
2392 no need for .Pp before or after .Sh;
2393 - djm@cvs.openbsd.org 2008/07/21 08:19:07
2394 [version.h]
2395 openssh-5.1
2396 - (djm) [README contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
2397 [contrib/suse/openssh.spec] Update version number in README and RPM specs
2398 - (djm) Release OpenSSH-5.1
2399
240020080717
2401 - (djm) OpenBSD CVS Sync
2402 - djm@cvs.openbsd.org 2008/07/17 08:48:00
2403 [sshconnect2.c]
2404 strnvis preauth banner; pointed out by mpf@ ok markus@
2405 - djm@cvs.openbsd.org 2008/07/17 08:51:07
2406 [auth2-hostbased.c]
2407 strip trailing '.' from hostname when HostbasedUsesNameFromPacketOnly=yes
2408 report and patch from res AT qoxp.net (bz#1200); ok markus@
2409 - (dtucker) [openbsd-compat/bsd-cygwin_util.c] Remove long-unneeded compat
2410 code, replace with equivalent cygwin library call. Patch from vinschen
2411 at redhat.com, ok djm@.
2412 - (djm) [sshconnect2.c] vis.h isn't available everywhere
2413
241420080716
2415 - OpenBSD CVS Sync
2416 - djm@cvs.openbsd.org 2008/07/15 02:23:14
2417 [sftp.1]
2418 number of pipelined requests is now 64;
2419 prodded by Iain.Morgan AT nasa.gov
2420 - djm@cvs.openbsd.org 2008/07/16 11:51:14
2421 [clientloop.c]
2422 rename variable first_gc -> last_gc (since it is actually the last
2423 in the list).
2424 - djm@cvs.openbsd.org 2008/07/16 11:52:19
2425 [channels.c]
2426 this loop index should be automatic, not static
2427
242820080714
2429 - (djm) OpenBSD CVS Sync
2430 - sthen@cvs.openbsd.org 2008/07/13 21:22:52
2431 [ssh-keygen.c]
2432 Change "ssh-keygen -F [host] -l" to not display random art unless
2433 -v is also specified, making it consistent with the manual and other
2434 uses of -l.
2435 ok grunk@
2436 - djm@cvs.openbsd.org 2008/07/13 22:13:07
2437 [channels.c]
2438 use struct sockaddr_storage instead of struct sockaddr for accept(2)
2439 address argument. from visibilis AT yahoo.com in bz#1485; ok markus@
2440 - djm@cvs.openbsd.org 2008/07/13 22:16:03
2441 [sftp.c]
2442 increase number of piplelined requests so they properly fill the
2443 (recently increased) channel window. prompted by rapier AT psc.edu;
2444 ok markus@
2445 - djm@cvs.openbsd.org 2008/07/14 01:55:56
2446 [sftp-server.8]
2447 mention requirement for /dev/log inside chroot when using sftp-server
2448 with ChrootDirectory
2449 - (djm) [openbsd-compat/bindresvport.c] Rename variables s/sin/in/ to
2450 avoid clash with sin(3) function; reported by
2451 cristian.ionescu-idbohrn AT axis.com
2452 - (djm) [openbsd-compat/rresvport.c] Add unistd.h for missing close()
2453 prototype; reported by cristian.ionescu-idbohrn AT axis.com
2454 - (djm) [umac.c] Rename variable s/buffer_ptr/bufp/ to avoid clash;
2455 reported by cristian.ionescu-idbohrn AT axis.com
2456 - (djm) [contrib/cygwin/Makefile contrib/cygwin/ssh-host-config]
2457 [contrib/cygwin/ssh-user-config contrib/cygwin/sshd-inetd]
2458 Revamped and simplified Cygwin ssh-host-config script that uses
2459 unified csih configuration tool. Requires recent Cygwin.
2460 Patch from vinschen AT redhat.com
2461
246220080712
2463 - (djm) OpenBSD CVS Sync
2464 - djm@cvs.openbsd.org 2008/07/12 04:52:50
2465 [channels.c]
2466 unbreak; move clearing of cctx struct to before first use
2467 reported by dkrause@
2468 - djm@cvs.openbsd.org 2008/07/12 05:33:41
2469 [scp.1]
2470 better description for -i flag:
2471 s/RSA authentication/public key authentication/
2472 - (djm) [openbsd-compat/fake-rfc2553.c openbsd-compat/fake-rfc2553.h]
2473 return EAI_FAMILY when trying to lookup unsupported address family;
2474 from vinschen AT redhat.com
2475
247620080711
2477 - (djm) OpenBSD CVS Sync
2478 - stevesk@cvs.openbsd.org 2008/07/07 00:31:41
2479 [ttymodes.c]
2480 we don't need arg after the debug3() was removed. from lint.
2481 ok djm@
2482 - stevesk@cvs.openbsd.org 2008/07/07 23:32:51
2483 [key.c]
2484 /*NOTREACHED*/ for lint warning:
2485 warning: function key_equal falls off bottom without returning value
2486 ok djm@
2487 - markus@cvs.openbsd.org 2008/07/10 18:05:58
2488 [channels.c]
2489 missing bzero; from mickey; ok djm@
2490 - markus@cvs.openbsd.org 2008/07/10 18:08:11
2491 [clientloop.c monitor.c monitor_wrap.c packet.c packet.h sshd.c]
2492 sync v1 and v2 traffic accounting; add it to sshd, too;
2493 ok djm@, dtucker@
2494
249520080709
2496 - (djm) [Makefile.in] Print "all tests passed" when all regress tests pass
2497 - (djm) [auth1.c] Fix format string vulnerability in protocol 1 PAM
2498 account check failure path. The vulnerable format buffer is supplied
2499 from PAM and should not contain attacker-supplied data.
2500 - (djm) [auth.c] Missing unistd.h for close()
2501 - (djm) [configure.ac] Add -Wformat-security to CFLAGS for gcc 3.x and 4.x
2502
250320080705
2504 - (djm) [auth.c] Fixed test for locked account on HP/UX with shadowed
2505 passwords disabled. bz#1083 report & patch from senthilkumar_sen AT
2506 hotpop.com, w/ dtucker@
2507 - (djm) [atomicio.c configure.ac] Disable poll() fallback in atomiciov for
2508 Tru64. readv doesn't seem to be a comparable object there.
2509 bz#1386, patch from dtucker@ ok me
2510 - (djm) [Makefile.in] Pass though pass to conch for interop tests
2511 - (djm) [configure.ac] unbreak: remove extra closing brace
2512 - (djm) OpenBSD CVS Sync
2513 - djm@cvs.openbsd.org 2008/07/04 23:08:25
2514 [packet.c]
2515 handle EINTR in packet_write_poll()l ok dtucker@
2516 - djm@cvs.openbsd.org 2008/07/04 23:30:16
2517 [auth1.c auth2.c]
2518 Make protocol 1 MaxAuthTries logic match protocol 2's.
2519 Do not treat the first protocol 2 authentication attempt as
2520 a failure IFF it is for method "none".
2521 Makes MaxAuthTries' user-visible behaviour identical for
2522 protocol 1 vs 2.
2523 ok dtucker@
2524 - djm@cvs.openbsd.org 2008/07/05 05:16:01
2525 [PROTOCOL]
2526 grammar
2527
252820080704
2529 - (dtucker) OpenBSD CVS Sync
2530 - djm@cvs.openbsd.org 2008/07/02 13:30:34
2531 [auth2.c]
2532 really really remove the freebie "none" auth try for protocol 2
2533 - djm@cvs.openbsd.org 2008/07/02 13:47:39
2534 [ssh.1 ssh.c]
2535 When forking after authentication ("ssh -f") with ExitOnForwardFailure
2536 enabled, delay the fork until after replies for any -R forwards have
2537 been seen. Allows for robust detection of -R forward failure when
2538 using -f (similar to bz#92); ok dtucker@
2539 - otto@cvs.openbsd.org 2008/07/03 21:46:58
2540 [auth2-pubkey.c]
2541 avoid nasty double free; ok dtucker@ djm@
2542 - djm@cvs.openbsd.org 2008/07/04 03:44:59
2543 [servconf.c groupaccess.h groupaccess.c]
2544 support negation of groups in "Match group" block (bz#1315); ok dtucker@
2545 - dtucker@cvs.openbsd.org 2008/07/04 03:47:02
2546 [monitor.c]
2547 Make debug a little clearer. ok djm@
2548 - djm@cvs.openbsd.org 2008/06/30 08:07:34
2549 [regress/key-options.sh]
2550 shell portability: use "=" instead of "==" in test(1) expressions,
2551 double-quote string with backslash escaped /
2552 - djm@cvs.openbsd.org 2008/06/30 10:31:11
2553 [regress/{putty-transfer,putty-kex,putty-ciphers}.sh]
2554 remove "set -e" left over from debugging
2555 - djm@cvs.openbsd.org 2008/06/30 10:43:03
2556 [regress/conch-ciphers.sh]
2557 explicitly disable conch options that could interfere with the test
2558 - (dtucker) [sftp-server.c] Bug #1447: fall back to racy rename if link
2559 returns EXDEV. Patch from Mike Garrison, ok djm@
2560 - (djm) [atomicio.c channels.c clientloop.c defines.h includes.h]
2561 [packet.c scp.c serverloop.c sftp-client.c ssh-agent.c ssh-keyscan.c]
2562 [sshd.c] Explicitly handle EWOULDBLOCK wherever we handle EAGAIN, on
2563 some platforms (HP nonstop) it is a distinct errno;
2564 bz#1467 reported by sconeu AT yahoo.com; ok dtucker@
2565
256620080702
2567 - (dtucker) OpenBSD CVS Sync
2568 - djm@cvs.openbsd.org 2008/06/30 08:05:59
2569 [PROTOCOL.agent]
2570 typo: s/constraint_date/constraint_data/
2571 - djm@cvs.openbsd.org 2008/06/30 12:15:39
2572 [serverloop.c]
2573 only pass channel requests on session channels through to the session
2574 channel handler, avoiding spurious log messages; ok! markus@
2575 - djm@cvs.openbsd.org 2008/06/30 12:16:02
2576 [nchan.c]
2577 only send eow@openssh.com notifications for session channels; ok! markus@
2578 - djm@cvs.openbsd.org 2008/06/30 12:18:34
2579 [PROTOCOL]
2580 clarify that eow@openssh.com is only sent on session channels
2581 - dtucker@cvs.openbsd.org 2008/07/01 07:20:52
2582 [sshconnect.c]
2583 Check ExitOnForwardFailure if forwardings are disabled due to a failed
2584 host key check. ok djm@
2585 - dtucker@cvs.openbsd.org 2008/07/01 07:24:22
2586 [sshconnect.c sshd.c]
2587 Send CR LF during protocol banner exchanges, but only for Protocol 2 only,
2588 in order to comply with RFC 4253. bz #1443, ok djm@
2589 - stevesk@cvs.openbsd.org 2008/07/01 23:12:47
2590 [PROTOCOL.agent]
2591 fix some typos; ok djm@
2592 - djm@cvs.openbsd.org 2008/07/02 02:24:18
2593 [sshd_config sshd_config.5 sshd.8 servconf.c]
2594 increase default size of ssh protocol 1 ephemeral key from 768 to 1024
2595 bits; prodded by & ok dtucker@ ok deraadt@
2596 - dtucker@cvs.openbsd.org 2008/07/02 12:03:51
2597 [auth-rsa.c auth.c auth2-pubkey.c auth.h]
2598 Merge duplicate host key file checks, based in part on a patch from Rob
2599 Holland via bz #1348 . Also checks for non-regular files during protocol
2600 1 RSA auth. ok djm@
2601 - djm@cvs.openbsd.org 2008/07/02 12:36:39
2602 [auth2-none.c auth2.c]
2603 Make protocol 2 MaxAuthTries behaviour a little more sensible:
2604 Check whether client has exceeded MaxAuthTries before running
2605 an authentication method and skip it if they have, previously it
2606 would always allow one try (for "none" auth).
2607 Preincrement failure count before post-auth test - previously this
2608 checked and postincremented, also to allow one "none" try.
2609 Together, these two changes always count the "none" auth method
2610 which could be skipped by a malicious client (e.g. an SSH worm)
2611 to get an extra attempt at a real auth method. They also make
2612 MaxAuthTries=0 a useful way to block users entirely (esp. in a
2613 sshd_config Match block).
2614 Also, move sending of any preauth banner from "none" auth method
2615 to the first call to input_userauth_request(), so worms that skip
2616 the "none" method get to see it too.
2617
261820080630
2619 - (djm) OpenBSD CVS Sync
2620 - dtucker@cvs.openbsd.org 2008/06/10 23:13:43
2621 [regress/Makefile regress/key-options.sh]
2622 Add regress test for key options. ok djm@
2623 - dtucker@cvs.openbsd.org 2008/06/11 23:11:40
2624 [regress/Makefile]
2625 Don't run cipher-speed test by default; mistakenly enabled by me
2626 - djm@cvs.openbsd.org 2008/06/28 13:57:25
2627 [regress/Makefile regress/test-exec.sh regress/conch-ciphers.sh]
2628 very basic regress test against Twisted Conch in "make interop"
2629 target (conch is available in ports/devel/py-twisted/conch);
2630 ok markus@
2631 - (djm) [regress/Makefile] search for conch by path, like we do putty
2632
263320080629
2634 - (djm) OpenBSD CVS Sync
2635 - martynas@cvs.openbsd.org 2008/06/21 07:46:46
2636 [sftp.c]
2637 use optopt to get invalid flag, instead of return value of getopt,
2638 which is always '?'; ok djm@
2639 - otto@cvs.openbsd.org 2008/06/25 11:13:43
2640 [key.c]
2641 add key length to visual fingerprint; zap magical constants;
2642 ok grunk@ djm@
2643 - djm@cvs.openbsd.org 2008/06/26 06:10:09
2644 [sftp-client.c sftp-server.c]
2645 allow the sftp chmod(2)-equivalent operation to set set[ug]id/sticky
2646 bits. Note that this only affects explicit setting of modes (e.g. via
2647 sftp(1)'s chmod command) and not file transfers. (bz#1310)
2648 ok deraadt@ at c2k8
2649 - djm@cvs.openbsd.org 2008/06/26 09:19:40
2650 [dh.c dh.h moduli.c]
2651 when loading moduli from /etc/moduli in sshd(8), check that they
2652 are of the expected "safe prime" structure and have had
2653 appropriate primality tests performed;
2654 feedback and ok dtucker@
2655 - grunk@cvs.openbsd.org 2008/06/26 11:46:31
2656 [readconf.c readconf.h ssh.1 ssh_config.5 sshconnect.c]
2657 Move SSH Fingerprint Visualization away from sharing the config option
2658 CheckHostIP to an own config option named VisualHostKey.
2659 While there, fix the behaviour that ssh would draw a random art picture
2660 on every newly seen host even when the option was not enabled.
2661 prodded by deraadt@, discussions,
2662 help and ok markus@ djm@ dtucker@
2663 - jmc@cvs.openbsd.org 2008/06/26 21:11:46
2664 [ssh.1]
2665 add VisualHostKey to the list of options listed in -o;
2666 - djm@cvs.openbsd.org 2008/06/28 07:25:07
2667 [PROTOCOL]
2668 spelling fixes
2669 - djm@cvs.openbsd.org 2008/06/28 13:58:23
2670 [ssh-agent.c]
2671 refuse to add a key that has unknown constraints specified;
2672 ok markus
2673 - djm@cvs.openbsd.org 2008/06/28 14:05:15
2674 [ssh-agent.c]
2675 reset global compat flag after processing a protocol 2 signature
2676 request with the legacy DSA encoding flag set; ok markus
2677 - djm@cvs.openbsd.org 2008/06/28 14:08:30
2678 [PROTOCOL PROTOCOL.agent]
2679 document the protocol used by ssh-agent; "looks ok" markus@
2680
268120080628
2682 - (djm) [RFC.nroff contrib/cygwin/Makefile contrib/suse/openssh.spec]
2683 RFC.nroff lacks a license, remove it (it is long gone in OpenBSD).
2684
268520080626
2686 - (djm) [Makefile.in moduli.5] Include moduli(5) manpage from OpenBSD.
2687 (bz#1372)
2688 - (djm) [ contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
2689 [contrib/suse/openssh.spec] Include moduli.5 in RPM spec files.
2690
269120080616
2692 - (dtucker) OpenBSD CVS Sync
2693 - dtucker@cvs.openbsd.org 2008/06/16 13:22:53
2694 [session.c channels.c]
2695 Rename the isatty argument to is_tty so we don't shadow
2696 isatty(3). ok markus@
2697 - (dtucker) [channels.c] isatty -> is_tty here too.
2698
269920080615
2700 - (dtucker) [configure.ac] Enable -fno-builtin-memset when using gcc.
2701 - OpenBSD CVS Sync
2702 - dtucker@cvs.openbsd.org 2008/06/14 15:49:48
2703 [sshd.c]
2704 wrap long line at 80 chars
2705 - dtucker@cvs.openbsd.org 2008/06/14 17:07:11
2706 [sshd.c]
2707 ensure default umask disallows at least group and world write; ok djm@
2708 - djm@cvs.openbsd.org 2008/06/14 18:33:43
2709 [session.c]
2710 suppress the warning message from chdir(homedir) failures
2711 when chrooted (bz#1461); ok dtucker
2712 - dtucker@cvs.openbsd.org 2008/06/14 19:42:10
2713 [scp.1]
2714 Mention that scp follows symlinks during -r. bz #1466,
2715 from nectar at apple
2716 - dtucker@cvs.openbsd.org 2008/06/15 16:55:38
2717 [sshd_config.5]
2718 MaxSessions is allowed in a Match block too
2719 - dtucker@cvs.openbsd.org 2008/06/15 16:58:40
2720 [servconf.c sshd_config.5]
2721 Allow MaxAuthTries within a Match block. ok djm@
2722 - djm@cvs.openbsd.org 2008/06/15 20:06:26
2723 [channels.c channels.h session.c]
2724 don't call isatty() on a pty master, instead pass a flag down to
2725 channel_set_fds() indicating that te fds refer to a tty. Fixes a
2726 hang on exit on Solaris (bz#1463) in portable but is actually
2727 a generic bug; ok dtucker deraadt markus
2728
272920080614
2730 - (djm) [openbsd-compat/sigact.c] Avoid NULL derefs in ancient sigaction
2731 replacement code; patch from ighighi AT gmail.com in bz#1240;
2732 ok dtucker
2733
273420080613
2735 - (dtucker) OpenBSD CVS Sync
2736 - deraadt@cvs.openbsd.org 2008/06/13 09:44:36
2737 [packet.c]
2738 compile on older gcc; no decl after code
2739 - dtucker@cvs.openbsd.org 2008/06/13 13:56:59
2740 [monitor.c]
2741 Clear key options in the monitor on failed authentication, prevents
2742 applying additional restrictions to non-pubkey authentications in
2743 the case where pubkey fails but another method subsequently succeeds.
2744 bz #1472, found by Colin Watson, ok markus@ djm@
2745 - dtucker@cvs.openbsd.org 2008/06/13 14:18:51
2746 [auth2-pubkey.c auth-rhosts.c]
2747 Include unistd.h for close(), prevents warnings in -portable
2748 - dtucker@cvs.openbsd.org 2008/06/13 17:21:20
2749 [mux.c]
2750 Friendlier error messages for mux fallback. ok djm@
2751 - dtucker@cvs.openbsd.org 2008/06/13 18:55:22
2752 [scp.c]
2753 Prevent -Wsign-compare warnings on LP64 systems. bz #1192, ok deraadt@
2754 - grunk@cvs.openbsd.org 2008/06/13 20:13:26
2755 [ssh.1]
2756 Explain the use of SSH fpr visualization using random art, and cite the
2757 original scientific paper inspiring that technique.
2758 Much help with English and nroff by jmc@, thanks.
2759 - (dtucker) [configure.ac] Bug #1276: avoid linking against libgssapi, which
2760 despite its name doesn't seem to implement all of GSSAPI. Patch from
2761 Jan Engelhardt, sanity checked by Simon Wilkinson.
2762
276320080612
2764 - (dtucker) OpenBSD CVS Sync
2765 - jmc@cvs.openbsd.org 2008/06/11 07:30:37
2766 [sshd.8]
2767 kill trailing whitespace;
2768 - grunk@cvs.openbsd.org 2008/06/11 21:01:35
2769 [ssh_config.5 key.h readconf.c readconf.h ssh-keygen.1 ssh-keygen.c key.c
2770 sshconnect.c]
2771 Introduce SSH Fingerprint ASCII Visualization, a technique inspired by the
2772 graphical hash visualization schemes known as "random art", and by
2773 Dan Kaminsky's musings on the subject during a BlackOp talk at the
2774 23C3 in Berlin.
2775 Scientific publication (original paper):
2776 "Hash Visualization: a New Technique to improve Real-World Security",
2777 Perrig A. and Song D., 1999, International Workshop on Cryptographic
2778 Techniques and E-Commerce (CrypTEC '99)
2779 http://sparrow.ece.cmu.edu/~adrian/projects/validation/validation.pdf
2780 The algorithm used here is a worm crawling over a discrete plane,
2781 leaving a trace (augmenting the field) everywhere it goes.
2782 Movement is taken from dgst_raw 2bit-wise. Bumping into walls
2783 makes the respective movement vector be ignored for this turn,
2784 thus switching to the other color of the chessboard.
2785 Graphs are not unambiguous for now, because circles in graphs can be
2786 walked in either direction.
2787 discussions with several people,
2788 help, corrections and ok markus@ djm@
2789 - grunk@cvs.openbsd.org 2008/06/11 21:38:25
2790 [ssh-keygen.c]
2791 ssh-keygen -lv -f /etc/ssh/ssh_host_rsa_key.pub
2792 would not display you the random art as intended, spotted by canacar@
2793 - grunk@cvs.openbsd.org 2008/06/11 22:20:46
2794 [ssh-keygen.c ssh-keygen.1]
2795 ssh-keygen would write fingerprints to STDOUT, and random art to STDERR,
2796 that is not how it was envisioned.
2797 Also correct manpage saying that -v is needed along with -l for it to work.
2798 spotted by naddy@
2799 - otto@cvs.openbsd.org 2008/06/11 23:02:22
2800 [key.c]
2801 simpler way of computing the augmentations; ok grunk@
2802 - grunk@cvs.openbsd.org 2008/06/11 23:03:56
2803 [ssh_config.5]
2804 CheckHostIP set to ``fingerprint'' will display both hex and random art
2805 spotted by naddy@
2806 - grunk@cvs.openbsd.org 2008/06/11 23:51:57
2807 [key.c]
2808 #define statements that are not atoms need braces around them, else they
2809 will cause trouble in some cases.
2810 Also do a computation of -1 once, and not in a loop several times.
2811 spotted by otto@
2812 - dtucker@cvs.openbsd.org 2008/06/12 00:03:49
2813 [dns.c canohost.c sshconnect.c]
2814 Do not pass "0" strings as ports to getaddrinfo because the lookups
2815 can slow things down and we never use the service info anyway. bz
2816 #859, patch from YOSHIFUJI Hideaki and John Devitofranceschi. ok
2817 deraadt@ djm@
2818 djm belives that the reason for the "0" strings is to ensure that
2819 it's not possible to call getaddrinfo with both host and port being
2820 NULL. In the case of canohost.c host is a local array. In the
2821 case of sshconnect.c, it's checked for null immediately before use.
2822 In dns.c it ultimately comes from ssh.c:main() and is guaranteed to
2823 be non-null but it's not obvious, so I added a warning message in
2824 case it is ever passed a null.
2825 - grunk@cvs.openbsd.org 2008/06/12 00:13:55
2826 [sshconnect.c]
2827 Make ssh print the random art also when ssh'ing to a host using IP only.
2828 spotted by naddy@, ok and help djm@ dtucker@
2829 - otto@cvs.openbsd.org 2008/06/12 00:13:13
2830 [key.c]
2831 use an odd number of rows and columns and a separate start marker, looks
2832 better; ok grunk@
2833 - djm@cvs.openbsd.org 2008/06/12 03:40:52
2834 [clientloop.h mux.c channels.c clientloop.c channels.h]
2835 Enable ~ escapes for multiplex slave sessions; give each channel
2836 its own escape state and hook the escape filters up to muxed
2837 channels. bz #1331
2838 Mux slaves do not currently support the ~^Z and ~& escapes.
2839 NB. this change cranks the mux protocol version, so a new ssh
2840 mux client will not be able to connect to a running old ssh
2841 mux master.
2842 ok dtucker@
2843 - djm@cvs.openbsd.org 2008/06/12 04:06:00
2844 [clientloop.h ssh.c clientloop.c]
2845 maintain an ordered queue of outstanding global requests that we
2846 expect replies to, similar to the per-channel confirmation queue.
2847 Use this queue to verify success or failure for remote forward
2848 establishment in a race free way.
2849 ok dtucker@
2850 - djm@cvs.openbsd.org 2008/06/12 04:17:47
2851 [clientloop.c]
2852 thall shalt not code past the eightieth column
2853 - djm@cvs.openbsd.org 2008/06/12 04:24:06
2854 [ssh.c]
2855 thal shalt not code past the eightieth column
2856 - djm@cvs.openbsd.org 2008/06/12 05:15:41
2857 [PROTOCOL]
2858 document tun@openssh.com forwarding method
2859 - djm@cvs.openbsd.org 2008/06/12 05:32:30
2860 [mux.c]
2861 some more TODO for me
2862 - grunk@cvs.openbsd.org 2008/06/12 05:42:46
2863 [key.c]
2864 supply the key type (rsa1, rsa, dsa) as a caption in the frame of the
2865 random art. while there, stress the fact that the field base should at
2866 least be 8 characters for the pictures to make sense.
2867 comment and ok djm@
2868 - grunk@cvs.openbsd.org 2008/06/12 06:32:59
2869 [key.c]
2870 We already mark the start of the worm, now also mark the end of the worm
2871 in our random art drawings.
2872 ok djm@
2873 - djm@cvs.openbsd.org 2008/06/12 15:19:17
2874 [clientloop.h channels.h clientloop.c channels.c mux.c]
2875 The multiplexing escape char handler commit last night introduced a
2876 small memory leak per session; plug it.
2877 - dtucker@cvs.openbsd.org 2008/06/12 16:35:31
2878 [ssh_config.5 ssh.c]
2879 keyword expansion for localcommand. ok djm@
2880 - jmc@cvs.openbsd.org 2008/06/12 19:10:09
2881 [ssh_config.5 ssh-keygen.1]
2882 tweak the ascii art text; ok grunk
2883 - dtucker@cvs.openbsd.org 2008/06/12 20:38:28
2884 [sshd.c sshconnect.c packet.h misc.c misc.h packet.c]
2885 Make keepalive timeouts apply while waiting for a packet, particularly
2886 during key renegotiation (bz #1363). With djm and Matt Day, ok djm@
2887 - djm@cvs.openbsd.org 2008/06/12 20:47:04
2888 [sftp-client.c]
2889 print extension revisions for extensions that we understand
2890 - djm@cvs.openbsd.org 2008/06/12 21:06:25
2891 [clientloop.c]
2892 I was coalescing expected global request confirmation replies at
2893 the wrong end of the queue - fix; prompted by markus@
2894 - grunk@cvs.openbsd.org 2008/06/12 21:14:46
2895 [ssh-keygen.c]
2896 make ssh-keygen -lf show the key type just as ssh-add -l would do it
2897 ok djm@ markus@
2898 - grunk@cvs.openbsd.org 2008/06/12 22:03:36
2899 [key.c]
2900 add my copyright, ok djm@
2901 - ian@cvs.openbsd.org 2008/06/12 23:24:58
2902 [sshconnect.c]
2903 tweak wording in message, ok deraadt@ jmc@
2904 - dtucker@cvs.openbsd.org 2008/06/13 00:12:02
2905 [sftp.h log.h]
2906 replace __dead with __attribute__((noreturn)), makes things
2907 a little easier to port. Also, add it to sigdie(). ok djm@
2908 - djm@cvs.openbsd.org 2008/06/13 00:16:49
2909 [mux.c]
2910 fall back to creating a new TCP connection on most multiplexing errors
2911 (socket connect fail, invalid version, refused permittion, corrupted
2912 messages, etc.); bz #1329 ok dtucker@
2913 - dtucker@cvs.openbsd.org 2008/06/13 00:47:53
2914 [mux.c]
2915 upcast size_t to u_long to match format arg; ok djm@
2916 - dtucker@cvs.openbsd.org 2008/06/13 00:51:47
2917 [mac.c]
2918 upcast another size_t to u_long to match format
2919 - dtucker@cvs.openbsd.org 2008/06/13 01:38:23
2920 [misc.c]
2921 upcast uid to long with matching %ld, prevents warnings in portable
2922 - djm@cvs.openbsd.org 2008/06/13 04:40:22
2923 [auth2-pubkey.c auth-rhosts.c]
2924 refuse to read ~/.shosts or ~/.ssh/authorized_keys that are not
2925 regular files; report from Solar Designer via Colin Watson in bz#1471
2926 ok dtucker@ deraadt
2927 - (dtucker) [clientloop.c serverloop.c] channel_register_filter now
2928 takes 2 more args. with djm@
2929 - (dtucker) [defines.h] Bug #1112: __dead is, well dead. Based on a patch
2930 from Todd Vierling.
2931 - (dtucker) [auth-sia.c] Bug #1241: support password expiry on Tru64 SIA
2932 systems. Patch from R. Scott Bailey.
2933 - (dtucker) [umac.c] STORE_UINT32_REVERSED and endian_convert are never used
2934 on big endian machines, so ifdef them for little-endian only to prevent
2935 unused function warnings on big-endians.
2936 - (dtucker) [openbsd-compat/setenv.c] Make offsets size_t to prevent
2937 compiler warnings on some platforms. Based on a discussion with otto@
2938
293920080611
2940 - (djm) [channels.c configure.ac]
2941 Do not set SO_REUSEADDR on wildcard X11 listeners (X11UseLocalhost=no)
2942 bz#1464; ok dtucker
2943
294420080610
2945 - (dtucker) OpenBSD CVS Sync
2946 - djm@cvs.openbsd.org 2008/06/10 03:57:27
2947 [servconf.c match.h sshd_config.5]
2948 support CIDR address matching in sshd_config "Match address" blocks, with
2949 full support for negation and fall-back to classic wildcard matching.
2950 For example:
2951 Match address 192.0.2.0/24,3ffe:ffff::/32,!10.*
2952 PasswordAuthentication yes
2953 addrmatch.c code mostly lifted from flowd's addr.c
2954 feedback and ok dtucker@
2955 - djm@cvs.openbsd.org 2008/06/10 04:17:46
2956 [sshd_config.5]
2957 better reference for pattern-list
2958 - dtucker@cvs.openbsd.org 2008/06/10 04:50:25
2959 [sshd.c channels.h channels.c log.c servconf.c log.h servconf.h sshd.8]
2960 Add extended test mode (-T) and connection parameters for test mode (-C).
2961 -T causes sshd to write its effective configuration to stdout and exit.
2962 -C causes any relevant Match rules to be applied before output. The
2963 combination allows tesing of the parser and config files. ok deraadt djm
2964 - jmc@cvs.openbsd.org 2008/06/10 07:12:00
2965 [sshd_config.5]
2966 tweak previous;
2967 - jmc@cvs.openbsd.org 2008/06/10 08:17:40
2968 [sshd.8 sshd.c]
2969 - update usage()
2970 - fix SYNOPSIS, and sort options
2971 - some minor additional fixes
2972 - dtucker@cvs.openbsd.org 2008/06/09 18:06:32
2973 [regress/test-exec.sh]
2974 Don't generate putty keys if we're not going to use them. ok djm
2975 - dtucker@cvs.openbsd.org 2008/06/10 05:23:32
2976 [regress/addrmatch.sh regress/Makefile]
2977 Regress test for Match CIDR rules. ok djm@
2978 - dtucker@cvs.openbsd.org 2008/06/10 15:21:41
2979 [test-exec.sh]
2980 Use a more portable construct for checking if we're running a putty test
2981 - dtucker@cvs.openbsd.org 2008/06/10 15:28:49
2982 [test-exec.sh]
2983 Add quotes
2984 - dtucker@cvs.openbsd.org 2008/06/10 18:21:24
2985 [ssh_config.5]
2986 clarify that Host patterns are space-separated. ok deraadt
2987 - djm@cvs.openbsd.org 2008/06/10 22:15:23
2988 [PROTOCOL ssh.c serverloop.c]
2989 Add a no-more-sessions@openssh.com global request extension that the
2990 client sends when it knows that it will never request another session
2991 (i.e. when session multiplexing is disabled). This allows a server to
2992 disallow further session requests and terminate the session.
2993 Why would a non-multiplexing client ever issue additional session
2994 requests? It could have been attacked with something like SSH'jack:
2995 http://www.storm.net.nz/projects/7
2996 feedback & ok markus
2997 - djm@cvs.openbsd.org 2008/06/10 23:06:19
2998 [auth-options.c match.c servconf.c addrmatch.c sshd.8]
2999 support CIDR address matching in .ssh/authorized_keys from="..." stanzas
3000 ok and extensive testing dtucker@
3001 - dtucker@cvs.openbsd.org 2008/06/10 23:21:34
3002 [bufaux.c]
3003 Use '\0' for a nul byte rather than unadorned 0. ok djm@
3004 - dtucker@cvs.openbsd.org 2008/06/10 23:13:43
3005 [Makefile regress/key-options.sh]
3006 Add regress test for key options. ok djm@
3007 - (dtucker) [openbsd-compat/fake-rfc2553.h] Add sin6_scope_id to sockaddr_in6
3008 since the new CIDR code in addmatch.c references it.
3009 - (dtucker) [Makefile.in configure.ac regress/addrmatch.sh] Skip IPv6
3010 specific tests on platforms that don't do IPv6.
3011 - (dtucker) [Makefile.in] Define TEST_SSH_IPV6 in make's arguments as well
3012 as environment.
3013 - (dtucker) [Makefile.in] Move addrmatch.o to libssh.a where it's needed now.
3014
301520080609
3016 - (dtucker) OpenBSD CVS Sync
3017 - dtucker@cvs.openbsd.org 2008/06/08 17:04:41
3018 [sftp-server.c]
3019 Add case for ENOSYS in errno_to_portable; ok deraadt
3020 - dtucker@cvs.openbsd.org 2008/06/08 20:15:29
3021 [sftp.c sftp-client.c sftp-client.h]
3022 Have the sftp client store the statvfs replies in wire format,
3023 which prevents problems when the server's native sizes exceed the
3024 client's.
3025 Also extends the sizes of the remaining 32bit wire format to 64bit,
3026 they're specified as unsigned long in the standard.
3027 - dtucker@cvs.openbsd.org 2008/06/09 13:02:39
3028 [sftp-server.c]
3029 Extend 32bit -> 64bit values for statvfs extension missed in previous
3030 commit.
3031 - dtucker@cvs.openbsd.org 2008/06/09 13:38:46
3032 [PROTOCOL]
3033 Use a $OpenBSD tag so our scripts will sync changes.
3034
303520080608
3036 - (dtucker) [configure.ac defines.h sftp-client.c sftp-server.c sftp.c
3037 openbsd-compat/Makefile.in openbsd-compat/openbsd-compat.h
3038 openbsd-compat/bsd-statvfs.{c,h}] Add a null implementation of statvfs and
3039 fstatvfs and remove #defines around statvfs code. ok djm@
3040 - (dtucker) [configure.ac defines.h sftp-client.c M sftp-server.c] Add a
3041 macro to convert fsid to unsigned long for platforms where fsid is a
3042 2-member array.
3043
304420080607
3045 - (dtucker) [mux.c] Include paths.h inside ifdef HAVE_PATHS_H.
3046 - (dtucker) [configure.ac defines.h sftp-client.c sftp-server.c sftp.c]
3047 Do not enable statvfs extensions on platforms that do not have statvfs.
3048 - (dtucker) OpenBSD CVS Sync
3049 - djm@cvs.openbsd.org 2008/05/19 06:14:02
3050 [packet.c] unbreak protocol keepalive timeouts bz#1465; ok dtucker@
3051 - djm@cvs.openbsd.org 2008/05/19 15:45:07
3052 [sshtty.c ttymodes.c sshpty.h]
3053 Fix sending tty modes when stdin is not a tty (bz#1199). Previously
3054 we would send the modes corresponding to a zeroed struct termios,
3055 whereas we should have been sending an empty list of modes.
3056 Based on patch from daniel.ritz AT alcatel.ch; ok dtucker@ markus@
3057 - djm@cvs.openbsd.org 2008/05/19 15:46:31
3058 [ssh-keygen.c]
3059 support -l (print fingerprint) in combination with -F (find host) to
3060 search for a host in ~/.ssh/known_hosts and display its fingerprint;
3061 ok markus@
3062 - djm@cvs.openbsd.org 2008/05/19 20:53:52
3063 [clientloop.c]
3064 unbreak tree by committing this bit that I missed from:
3065 Fix sending tty modes when stdin is not a tty (bz#1199). Previously
3066 we would send the modes corresponding to a zeroed struct termios,
3067 whereas we should have been sending an empty list of modes.
3068 Based on patch from daniel.ritz AT alcatel.ch; ok dtucker@ markus@
3069
307020080604
3071 - (djm) [openbsd-compat/bsd-arc4random.c] Fix math bug that caused bias
3072 in arc4random_uniform with upper_bound in (2^30,2*31). Note that
3073 OpenSSH did not make requests with upper bounds in this range.
3074
307520080519
3076 - (djm) [configure.ac mux.c sftp.c openbsd-compat/Makefile.in]
3077 [openbsd-compat/fmt_scaled.c openbsd-compat/openbsd-compat.h]
3078 Fix compilation on Linux, including pulling in fmt_scaled(3)
3079 implementation from OpenBSD's libutil.
3080
308120080518
3082 - (djm) OpenBSD CVS Sync
3083 - djm@cvs.openbsd.org 2008/04/04 05:14:38
3084 [sshd_config.5]
3085 ChrootDirectory is supported in Match blocks (in fact, it is most useful
3086 there). Spotted by Minstrel AT minstrel.org.uk
3087 - djm@cvs.openbsd.org 2008/04/04 06:44:26
3088 [sshd_config.5]
3089 oops, some unrelated stuff crept into that commit - backout.
3090 spotted by jmc@
3091 - djm@cvs.openbsd.org 2008/04/05 02:46:02
3092 [sshd_config.5]
3093 HostbasedAuthentication is supported under Match too
3094 - (djm) [openbsd-compat/bsd-arc4random.c openbsd-compat/openbsd-compat.c]
3095 [configure.ac] Implement arc4random_buf(), import implementation of
3096 arc4random_uniform() from OpenBSD
3097 - (djm) [openbsd-compat/bsd-arc4random.c] Warning fixes
3098 - (djm) [openbsd-compat/port-tun.c] needs sys/queue.h
3099 - (djm) OpenBSD CVS Sync
3100 - djm@cvs.openbsd.org 2008/04/13 00:22:17
3101 [dh.c sshd.c]
3102 Use arc4random_buf() when requesting more than a single word of output
3103 Use arc4random_uniform() when the desired random number upper bound
3104 is not a power of two
3105 ok deraadt@ millert@
3106 - djm@cvs.openbsd.org 2008/04/18 12:32:11
3107 [sftp-client.c sftp-client.h sftp-server.c sftp.1 sftp.c sftp.h]
3108 introduce sftp extension methods statvfs@openssh.com and
3109 fstatvfs@openssh.com that implement statvfs(2)-like operations,
3110 based on a patch from miklos AT szeredi.hu (bz#1399)
3111 also add a "df" command to the sftp client that uses the
3112 statvfs@openssh.com to produce a df(1)-like display of filesystem
3113 space and inode utilisation
3114 ok markus@
3115 - jmc@cvs.openbsd.org 2008/04/18 17:15:47
3116 [sftp.1]
3117 macro fixage;
3118 - djm@cvs.openbsd.org 2008/04/18 22:01:33
3119 [session.c]
3120 remove unneccessary parentheses
3121 - otto@cvs.openbsd.org 2008/04/29 11:20:31
3122 [monitor_mm.h]
3123 garbage collect two unused fields in struct mm_master; ok markus@
3124 - djm@cvs.openbsd.org 2008/04/30 10:14:03
3125 [ssh-keyscan.1 ssh-keyscan.c]
3126 default to rsa (protocol 2) keys, instead of rsa1 keys; spotted by
3127 larsnooden AT openoffice.org
3128 - pyr@cvs.openbsd.org 2008/05/07 05:49:37
3129 [servconf.c servconf.h session.c sshd_config.5]
3130 Enable the AllowAgentForwarding option in sshd_config (global and match
3131 context), to specify if agents should be permitted on the server.
3132 As the man page states:
3133 ``Note that disabling Agent forwarding does not improve security
3134 unless users are also denied shell access, as they can always install
3135 their own forwarders.''
3136 ok djm@, ok and a mild frown markus@
3137 - pyr@cvs.openbsd.org 2008/05/07 06:43:35
3138 [sshd_config]
3139 push the sshd_config bits in, spotted by ajacoutot@
3140 - jmc@cvs.openbsd.org 2008/05/07 08:00:14
3141 [sshd_config.5]
3142 sort;
3143 - markus@cvs.openbsd.org 2008/05/08 06:59:01
3144 [bufaux.c buffer.h channels.c packet.c packet.h]
3145 avoid extra malloc/copy/free when receiving data over the net;
3146 ~10% speedup for localhost-scp; ok djm@
3147 - djm@cvs.openbsd.org 2008/05/08 12:02:23
3148 [auth-options.c auth1.c channels.c channels.h clientloop.c gss-serv.c]
3149 [monitor.c monitor_wrap.c nchan.c servconf.c serverloop.c session.c]
3150 [ssh.c sshd.c]
3151 Implement a channel success/failure status confirmation callback
3152 mechanism. Each channel maintains a queue of callbacks, which will
3153 be drained in order (RFC4253 guarantees confirm messages are not
3154 reordered within an channel).
3155 Also includes a abandonment callback to clean up if a channel is
3156 closed without sending confirmation messages. This probably
3157 shouldn't happen in compliant implementations, but it could be
3158 abused to leak memory.
3159 ok markus@ (as part of a larger diff)
3160 - djm@cvs.openbsd.org 2008/05/08 12:21:16
3161 [monitor.c monitor_wrap.c session.h servconf.c servconf.h session.c]
3162 [sshd_config sshd_config.5]
3163 Make the maximum number of sessions run-time controllable via
3164 a sshd_config MaxSessions knob. This is useful for disabling
3165 login/shell/subsystem access while leaving port-forwarding working
3166 (MaxSessions 0), disabling connection multiplexing (MaxSessions 1) or
3167 simply increasing the number of allows multiplexed sessions.
3168 Because some bozos are sure to configure MaxSessions in excess of the
3169 number of available file descriptors in sshd (which, at peak, might be
3170 as many as 9*MaxSessions), audit sshd to ensure that it doesn't leak fds
3171 on error paths, and make it fail gracefully on out-of-fd conditions -
3172 sending channel errors instead of than exiting with fatal().
3173 bz#1090; MaxSessions config bits and manpage from junyer AT gmail.com
3174 ok markus@
3175 - djm@cvs.openbsd.org 2008/05/08 13:06:11
3176 [clientloop.c clientloop.h ssh.c]
3177 Use new channel status confirmation callback system to properly deal
3178 with "important" channel requests that fail, in particular command exec,
3179 shell and subsystem requests. Previously we would optimistically assume
3180 that the requests would always succeed, which could cause hangs if they
3181 did not (e.g. when the server runs out of fds) or were unimplemented by
3182 the server (bz #1384)
3183 Also, properly report failing multiplex channel requests via the mux
3184 client stderr (subject to LogLevel in the mux master) - better than
3185 silently failing.
3186 most bits ok markus@ (as part of a larger diff)
3187 - djm@cvs.openbsd.org 2008/05/09 04:55:56
3188 [channels.c channels.h clientloop.c serverloop.c]
3189 Try additional addresses when connecting to a port forward destination
3190 whose DNS name resolves to more than one address. The previous behaviour
3191 was to try the first address and give up.
3192 Reported by stig AT venaas.com in bz#343
3193 great feedback and ok markus@
3194 - djm@cvs.openbsd.org 2008/05/09 14:18:44
3195 [clientloop.c clientloop.h ssh.c mux.c]
3196 tidy up session multiplexing code, moving it into its own file and
3197 making the function names more consistent - making ssh.c and
3198 clientloop.c a fair bit more readable.
3199 ok markus@
3200 - djm@cvs.openbsd.org 2008/05/09 14:26:08
3201 [ssh.c]
3202 dingo stole my diff hunk
3203 - markus@cvs.openbsd.org 2008/05/09 16:16:06
3204 [session.c]
3205 re-add the USE_PIPES code and enable it.
3206 without pipes shutdown-read from the sshd does not trigger
3207 a SIGPIPE when the forked program does a write.
3208 ok djm@
3209 (Id sync only, USE_PIPES never left portable OpenSSH)
3210 - markus@cvs.openbsd.org 2008/05/09 16:17:51
3211 [channels.c]
3212 error-fd race: don't enable the error fd in the select bitmask
3213 for channels with both in- and output closed, since the channel
3214 will go away before we call select();
3215 report, lots of debugging help and ok djm@
3216 - markus@cvs.openbsd.org 2008/05/09 16:21:13
3217 [channels.h clientloop.c nchan.c serverloop.c]
3218 unbreak
3219 ssh -2 localhost od /bin/ls | true
3220 ignoring SIGPIPE by adding a new channel message (EOW) that signals
3221 the peer that we're not interested in any data it might send.
3222 fixes bz #85; discussion, debugging and ok djm@
3223 - pvalchev@cvs.openbsd.org 2008/05/12 20:52:20
3224 [umac.c]
3225 Ensure nh_result lies on a 64-bit boundary (fixes warnings observed
3226 on Itanium on Linux); from Dale Talcott (bug #1462); ok djm@
3227 - djm@cvs.openbsd.org 2008/05/15 23:52:24
3228 [nchan2.ms]
3229 document eow message in ssh protocol 2 channel state machine;
3230 feedback and ok markus@
3231 - djm@cvs.openbsd.org 2008/05/18 21:29:05
3232 [sftp-server.c]
3233 comment extension announcement
3234 - djm@cvs.openbsd.org 2008/05/16 08:30:42
3235 [PROTOCOL]
3236 document our protocol extensions and deviations; ok markus@
3237 - djm@cvs.openbsd.org 2008/05/17 01:31:56
3238 [PROTOCOL]
3239 grammar and correctness fixes from stevesk@
3240
324120080403
3242 - (djm) [openbsd-compat/bsd-poll.c] Include stdlib.h to avoid compile-
3243 time warnings on LynxOS. Patch from ops AT iki.fi
3244 - (djm) Force string arguments to replacement setproctitle() though
3245 strnvis first. Ok dtucker@
3246
324720080403
3248 - (djm) OpenBSD CVS sync:
3249 - markus@cvs.openbsd.org 2008/04/02 15:36:51
3250 [channels.c]
3251 avoid possible hijacking of x11-forwarded connections (back out 1.183)
3252 CVE-2008-1483; ok djm@
3253 - jmc@cvs.openbsd.org 2008/03/27 22:37:57
3254 [sshd.8]
3255 remove trailing whitespace;
3256 - djm@cvs.openbsd.org 2008/04/03 09:50:14
3257 [version.h]
3258 openssh-5.0
3259 - (djm) [contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
3260 [contrib/suse/openssh.spec] Crank version numbers in RPM spec files
3261 - (djm) [README] Update link to release notes
3262 - (djm) Release 5.0p1
diff --git a/LICENCE b/LICENCE
index 3964b1d77..120d6fd54 100644
--- a/LICENCE
+++ b/LICENCE
@@ -206,6 +206,7 @@ OpenSSH contains no GPL code.
206 Sun Microsystems 206 Sun Microsystems
207 The SCO Group 207 The SCO Group
208 Daniel Walsh 208 Daniel Walsh
209 Red Hat, Inc
209 210
210 * Redistribution and use in source and binary forms, with or without 211 * Redistribution and use in source and binary forms, with or without
211 * modification, are permitted provided that the following conditions 212 * modification, are permitted provided that the following conditions
diff --git a/Makefile.in b/Makefile.in
index eaf362652..d594ff0e1 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
1# $Id: Makefile.in,v 1.310 2010/05/12 06:51:39 dtucker Exp $ 1# $Id: Makefile.in,v 1.320 2011/01/17 10:15:29 dtucker Exp $
2 2
3# uncomment if you run a non bourne compatable shell. Ie. csh 3# uncomment if you run a non bourne compatable shell. Ie. csh
4#SHELL = @SH@ 4#SHELL = @SH@
@@ -58,6 +58,7 @@ ENT=@ENT@
58XAUTH_PATH=@XAUTH_PATH@ 58XAUTH_PATH=@XAUTH_PATH@
59LDFLAGS=-L. -Lopenbsd-compat/ @LDFLAGS@ 59LDFLAGS=-L. -Lopenbsd-compat/ @LDFLAGS@
60EXEEXT=@EXEEXT@ 60EXEEXT=@EXEEXT@
61MANFMT=@MANFMT@
61 62
62INSTALL_SSH_PRNG_CMDS=@INSTALL_SSH_PRNG_CMDS@ 63INSTALL_SSH_PRNG_CMDS=@INSTALL_SSH_PRNG_CMDS@
63INSTALL_SSH_RAND_HELPER=@INSTALL_SSH_RAND_HELPER@ 64INSTALL_SSH_RAND_HELPER=@INSTALL_SSH_RAND_HELPER@
@@ -71,26 +72,27 @@ LIBSSH_OBJS=acss.o authfd.o authfile.o bufaux.o bufbn.o buffer.o \
71 log.o match.o md-sha256.o moduli.o nchan.o packet.o \ 72 log.o match.o md-sha256.o moduli.o nchan.o packet.o \
72 readpass.o rsa.o ttymodes.o xmalloc.o addrmatch.o \ 73 readpass.o rsa.o ttymodes.o xmalloc.o addrmatch.o \
73 atomicio.o key.o dispatch.o kex.o mac.o uidswap.o uuencode.o misc.o \ 74 atomicio.o key.o dispatch.o kex.o mac.o uidswap.o uuencode.o misc.o \
74 monitor_fdpass.o rijndael.o ssh-dss.o ssh-rsa.o dh.o kexdh.o \ 75 monitor_fdpass.o rijndael.o ssh-dss.o ssh-ecdsa.o ssh-rsa.o dh.o \
75 kexgex.o kexdhc.o kexgexc.o msg.o progressmeter.o dns.o \ 76 kexdh.o kexgex.o kexdhc.o kexgexc.o bufec.o kexecdh.o kexecdhc.o \
76 entropy.o gss-genr.o umac.o jpake.o schnorr.o kexgssc.o \ 77 msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o jpake.o \
77 ssh-pkcs11.o 78 schnorr.o kexgssc.o ssh-pkcs11.o
78 79
79SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \ 80SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \
80 sshconnect.o sshconnect1.o sshconnect2.o mux.o \ 81 sshconnect.o sshconnect1.o sshconnect2.o mux.o \
81 roaming_common.o roaming_client.o 82 roaming_common.o roaming_client.o
82 83
83SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \ 84SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
85 audit.o audit-bsm.o audit-linux.o platform.o \
84 sshpty.o sshlogin.o servconf.o serverloop.o \ 86 sshpty.o sshlogin.o servconf.o serverloop.o \
85 auth.o auth1.o auth2.o auth-options.o session.o \ 87 auth.o auth1.o auth2.o auth-options.o session.o \
86 auth-chall.o auth2-chall.o groupaccess.o \ 88 auth-chall.o auth2-chall.o groupaccess.o \
87 auth-skey.o auth-bsdauth.o auth2-hostbased.o auth2-kbdint.o \ 89 auth-skey.o auth-bsdauth.o auth2-hostbased.o auth2-kbdint.o \
88 auth2-none.o auth2-passwd.o auth2-pubkey.o auth2-jpake.o \ 90 auth2-none.o auth2-passwd.o auth2-pubkey.o auth2-jpake.o \
89 monitor_mm.o monitor.o monitor_wrap.o kexdhs.o kexgexs.o \ 91 monitor_mm.o monitor.o monitor_wrap.o kexdhs.o kexgexs.o kexecdhs.o \
90 auth-krb5.o \ 92 auth-krb5.o \
91 auth2-gss.o gss-serv.o gss-serv-krb5.o kexgsss.o\ 93 auth2-gss.o gss-serv.o gss-serv-krb5.o kexgsss.o\
92 loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \ 94 loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \
93 audit.o audit-bsm.o platform.o sftp-server.o sftp-common.o \ 95 sftp-server.o sftp-common.o \
94 roaming_common.o roaming_serv.o 96 roaming_common.o roaming_serv.o
95 97
96MANPAGES = moduli.5.out scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.8.out sftp-server.8.out sftp.1.out ssh-rand-helper.8.out ssh-keysign.8.out ssh-pkcs11-helper.8.out sshd_config.5.out ssh_config.5.out 98MANPAGES = moduli.5.out scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.8.out sftp-server.8.out sftp.1.out ssh-rand-helper.8.out ssh-keysign.8.out ssh-pkcs11-helper.8.out sshd_config.5.out ssh_config.5.out
@@ -108,6 +110,7 @@ PATHSUBS = \
108 -e 's|/usr/libexec|$(libexecdir)|g' \ 110 -e 's|/usr/libexec|$(libexecdir)|g' \
109 -e 's|/etc/shosts.equiv|$(sysconfdir)/shosts.equiv|g' \ 111 -e 's|/etc/shosts.equiv|$(sysconfdir)/shosts.equiv|g' \
110 -e 's|/etc/ssh/ssh_host_key|$(sysconfdir)/ssh_host_key|g' \ 112 -e 's|/etc/ssh/ssh_host_key|$(sysconfdir)/ssh_host_key|g' \
113 -e 's|/etc/ssh/ssh_host_ecdsa_key|$(sysconfdir)/ssh_host_ecdsa_key|g' \
111 -e 's|/etc/ssh/ssh_host_dsa_key|$(sysconfdir)/ssh_host_dsa_key|g' \ 114 -e 's|/etc/ssh/ssh_host_dsa_key|$(sysconfdir)/ssh_host_dsa_key|g' \
112 -e 's|/etc/ssh/ssh_host_rsa_key|$(sysconfdir)/ssh_host_rsa_key|g' \ 115 -e 's|/etc/ssh/ssh_host_rsa_key|$(sysconfdir)/ssh_host_rsa_key|g' \
113 -e 's|/var/run/sshd.pid|$(piddir)/sshd.pid|g' \ 116 -e 's|/var/run/sshd.pid|$(piddir)/sshd.pid|g' \
@@ -230,7 +233,7 @@ catman-do:
230 @for f in $(MANPAGES_IN) ; do \ 233 @for f in $(MANPAGES_IN) ; do \
231 base=`echo $$f | sed 's/\..*$$//'` ; \ 234 base=`echo $$f | sed 's/\..*$$//'` ; \
232 echo "$$f -> $$base.0" ; \ 235 echo "$$f -> $$base.0" ; \
233 nroff -mandoc $$f | cat -v | sed -e 's/.\^H//g' \ 236 $(MANFMT) $$f | cat -v | sed -e 's/.\^H//g' \
234 >$$base.0 ; \ 237 >$$base.0 ; \
235 done 238 done
236 239
@@ -324,20 +327,27 @@ install-sysconf:
324 327
325host-key: ssh-keygen$(EXEEXT) 328host-key: ssh-keygen$(EXEEXT)
326 @if [ -z "$(DESTDIR)" ] ; then \ 329 @if [ -z "$(DESTDIR)" ] ; then \
327 if [ -f "$(DESTDIR)$(sysconfdir)/ssh_host_key" ] ; then \ 330 if [ -f "$(sysconfdir)/ssh_host_key" ] ; then \
328 echo "$(DESTDIR)$(sysconfdir)/ssh_host_key already exists, skipping." ; \ 331 echo "$(sysconfdir)/ssh_host_key already exists, skipping." ; \
329 else \ 332 else \
330 ./ssh-keygen -t rsa1 -f $(DESTDIR)$(sysconfdir)/ssh_host_key -N "" ; \ 333 ./ssh-keygen -t rsa1 -f $(sysconfdir)/ssh_host_key -N "" ; \
331 fi ; \ 334 fi ; \
332 if [ -f $(DESTDIR)$(sysconfdir)/ssh_host_dsa_key ] ; then \ 335 if [ -f $(sysconfdir)/ssh_host_dsa_key ] ; then \
333 echo "$(DESTDIR)$(sysconfdir)/ssh_host_dsa_key already exists, skipping." ; \ 336 echo "$(sysconfdir)/ssh_host_dsa_key already exists, skipping." ; \
334 else \ 337 else \
335 ./ssh-keygen -t dsa -f $(DESTDIR)$(sysconfdir)/ssh_host_dsa_key -N "" ; \ 338 ./ssh-keygen -t dsa -f $(sysconfdir)/ssh_host_dsa_key -N "" ; \
336 fi ; \ 339 fi ; \
337 if [ -f $(DESTDIR)$(sysconfdir)/ssh_host_rsa_key ] ; then \ 340 if [ -f $(sysconfdir)/ssh_host_rsa_key ] ; then \
338 echo "$(DESTDIR)$(sysconfdir)/ssh_host_rsa_key already exists, skipping." ; \ 341 echo "$(sysconfdir)/ssh_host_rsa_key already exists, skipping." ; \
339 else \ 342 else \
340 ./ssh-keygen -t rsa -f $(DESTDIR)$(sysconfdir)/ssh_host_rsa_key -N "" ; \ 343 ./ssh-keygen -t rsa -f $(sysconfdir)/ssh_host_rsa_key -N "" ; \
344 fi ; \
345 if [ -z "@COMMENT_OUT_ECC@" ] ; then \
346 if [ -f $(sysconfdir)/ssh_host_ecdsa_key ] ; then \
347 echo "$(sysconfdir)/ssh_host_ecdsa_key already exists, skipping." ; \
348 else \
349 ./ssh-keygen -t ecdsa -f $(sysconfdir)/ssh_host_ecdsa_key -N "" ; \
350 fi ; \
341 fi ; \ 351 fi ; \
342 fi ; 352 fi ;
343 353
@@ -345,6 +355,7 @@ host-key-force: ssh-keygen$(EXEEXT)
345 ./ssh-keygen -t rsa1 -f $(DESTDIR)$(sysconfdir)/ssh_host_key -N "" 355 ./ssh-keygen -t rsa1 -f $(DESTDIR)$(sysconfdir)/ssh_host_key -N ""
346 ./ssh-keygen -t dsa -f $(DESTDIR)$(sysconfdir)/ssh_host_dsa_key -N "" 356 ./ssh-keygen -t dsa -f $(DESTDIR)$(sysconfdir)/ssh_host_dsa_key -N ""
347 ./ssh-keygen -t rsa -f $(DESTDIR)$(sysconfdir)/ssh_host_rsa_key -N "" 357 ./ssh-keygen -t rsa -f $(DESTDIR)$(sysconfdir)/ssh_host_rsa_key -N ""
358 test -z "@COMMENT_OUT_ECC@" && ./ssh-keygen -t ecdsa -f $(DESTDIR)$(sysconfdir)/ssh_host_ecdsa_key -N ""
348 359
349uninstallall: uninstall 360uninstallall: uninstall
350 -rm -f $(DESTDIR)$(sysconfdir)/ssh_config 361 -rm -f $(DESTDIR)$(sysconfdir)/ssh_config
@@ -405,6 +416,8 @@ tests interop-tests: $(TARGETS)
405 TEST_SSH_PUTTYGEN="puttygen"; \ 416 TEST_SSH_PUTTYGEN="puttygen"; \
406 TEST_SSH_CONCH="conch"; \ 417 TEST_SSH_CONCH="conch"; \
407 TEST_SSH_IPV6="@TEST_SSH_IPV6@" ; \ 418 TEST_SSH_IPV6="@TEST_SSH_IPV6@" ; \
419 TEST_SSH_ECC="@TEST_SSH_ECC@" ; \
420 TEST_SSH_SHA256="@TEST_SSH_SHA256@" ; \
408 cd $(srcdir)/regress || exit $$?; \ 421 cd $(srcdir)/regress || exit $$?; \
409 $(MAKE) \ 422 $(MAKE) \
410 .OBJDIR="$${BUILDDIR}/regress" \ 423 .OBJDIR="$${BUILDDIR}/regress" \
@@ -425,7 +438,9 @@ tests interop-tests: $(TARGETS)
425 TEST_SSH_PLINK="$${TEST_SSH_PLINK}" \ 438 TEST_SSH_PLINK="$${TEST_SSH_PLINK}" \
426 TEST_SSH_PUTTYGEN="$${TEST_SSH_PUTTYGEN}" \ 439 TEST_SSH_PUTTYGEN="$${TEST_SSH_PUTTYGEN}" \
427 TEST_SSH_CONCH="$${TEST_SSH_CONCH}" \ 440 TEST_SSH_CONCH="$${TEST_SSH_CONCH}" \
428 TEST_SSH_IPV6="@TEST_SSH_IPV6@" \ 441 TEST_SSH_IPV6="$${TEST_SSH_IPV6}" \
442 TEST_SSH_ECC="$${TEST_SSH_ECC}" \
443 TEST_SSH_SHA256="$${TEST_SSH_SHA256}" \
429 EXEEXT="$(EXEEXT)" \ 444 EXEEXT="$(EXEEXT)" \
430 $@ && echo all tests passed 445 $@ && echo all tests passed
431 446
diff --git a/PROTOCOL b/PROTOCOL
index 5fc31eade..c28196011 100644
--- a/PROTOCOL
+++ b/PROTOCOL
@@ -12,7 +12,9 @@ are individually implemented as extensions described below.
12The protocol used by OpenSSH's ssh-agent is described in the file 12The protocol used by OpenSSH's ssh-agent is described in the file
13PROTOCOL.agent 13PROTOCOL.agent
14 14
151. transport: Protocol 2 MAC algorithm "umac-64@openssh.com" 151. Transport protocol changes
16
171.1. transport: Protocol 2 MAC algorithm "umac-64@openssh.com"
16 18
17This is a new transport-layer MAC method using the UMAC algorithm 19This is a new transport-layer MAC method using the UMAC algorithm
18(rfc4418). This method is identical to the "umac-64" method documented 20(rfc4418). This method is identical to the "umac-64" method documented
@@ -20,7 +22,7 @@ in:
20 22
21http://www.openssh.com/txt/draft-miller-secsh-umac-01.txt 23http://www.openssh.com/txt/draft-miller-secsh-umac-01.txt
22 24
232. transport: Protocol 2 compression algorithm "zlib@openssh.com" 251.2. transport: Protocol 2 compression algorithm "zlib@openssh.com"
24 26
25This transport-layer compression method uses the zlib compression 27This transport-layer compression method uses the zlib compression
26algorithm (identical to the "zlib" method in rfc4253), but delays the 28algorithm (identical to the "zlib" method in rfc4253), but delays the
@@ -31,14 +33,27 @@ The method is documented in:
31 33
32http://www.openssh.com/txt/draft-miller-secsh-compression-delayed-00.txt 34http://www.openssh.com/txt/draft-miller-secsh-compression-delayed-00.txt
33 35
343. transport: New public key algorithms "ssh-rsa-cert-v00@openssh.com" and 361.3. transport: New public key algorithms "ssh-rsa-cert-v00@openssh.com",
35 "ssh-dsa-cert-v00@openssh.com" 37 "ssh-dsa-cert-v00@openssh.com",
38 "ecdsa-sha2-nistp256-cert-v01@openssh.com",
39 "ecdsa-sha2-nistp384-cert-v01@openssh.com" and
40 "ecdsa-sha2-nistp521-cert-v01@openssh.com"
36 41
37OpenSSH introduces two new public key algorithms to support certificate 42OpenSSH introduces new public key algorithms to support certificate
38authentication for users and hostkeys. These methods are documented in 43authentication for users and hostkeys. These methods are documented in
39the file PROTOCOL.certkeys 44the file PROTOCOL.certkeys
40 45
414. connection: Channel write close extension "eow@openssh.com" 461.4. transport: Elliptic Curve cryptography
47
48OpenSSH supports ECC key exchange and public key authentication as
49specified in RFC5656. Only the ecdsa-sha2-nistp256, ecdsa-sha2-nistp384
50and ecdsa-sha2-nistp521 curves over GF(p) are supported. Elliptic
51curve points encoded using point compression are NOT accepted or
52generated.
53
542. Connection protocol changes
55
562.1. connection: Channel write close extension "eow@openssh.com"
42 57
43The SSH connection protocol (rfc4254) provides the SSH_MSG_CHANNEL_EOF 58The SSH connection protocol (rfc4254) provides the SSH_MSG_CHANNEL_EOF
44message to allow an endpoint to signal its peer that it will send no 59message to allow an endpoint to signal its peer that it will send no
@@ -77,8 +92,8 @@ message is only sent to OpenSSH peers (identified by banner).
77Other SSH implementations may be whitelisted to receive this message 92Other SSH implementations may be whitelisted to receive this message
78upon request. 93upon request.
79 94
805. connection: disallow additional sessions extension 952.2. connection: disallow additional sessions extension
81 "no-more-sessions@openssh.com" 96 "no-more-sessions@openssh.com"
82 97
83Most SSH connections will only ever request a single session, but a 98Most SSH connections will only ever request a single session, but a
84attacker may abuse a running ssh client to surreptitiously open 99attacker may abuse a running ssh client to surreptitiously open
@@ -105,7 +120,7 @@ of this message, the no-more-sessions request is only sent to OpenSSH
105servers (identified by banner). Other SSH implementations may be 120servers (identified by banner). Other SSH implementations may be
106whitelisted to receive this message upon request. 121whitelisted to receive this message upon request.
107 122
1086. connection: Tunnel forward extension "tun@openssh.com" 1232.3. connection: Tunnel forward extension "tun@openssh.com"
109 124
110OpenSSH supports layer 2 and layer 3 tunnelling via the "tun@openssh.com" 125OpenSSH supports layer 2 and layer 3 tunnelling via the "tun@openssh.com"
111channel type. This channel type supports forwarding of network packets 126channel type. This channel type supports forwarding of network packets
@@ -166,7 +181,9 @@ The contents of the "data" field for layer 2 packets is:
166The "frame" field contains an IEEE 802.3 Ethernet frame, including 181The "frame" field contains an IEEE 802.3 Ethernet frame, including
167header. 182header.
168 183
1697. sftp: Reversal of arguments to SSH_FXP_SYMLINK 1843. SFTP protocol changes
185
1863.1. sftp: Reversal of arguments to SSH_FXP_SYMLINK
170 187
171When OpenSSH's sftp-server was implemented, the order of the arguments 188When OpenSSH's sftp-server was implemented, the order of the arguments
172to the SSH_FXP_SYMLINK method was inadvertently reversed. Unfortunately, 189to the SSH_FXP_SYMLINK method was inadvertently reversed. Unfortunately,
@@ -179,7 +196,7 @@ SSH_FXP_SYMLINK as follows:
179 string targetpath 196 string targetpath
180 string linkpath 197 string linkpath
181 198
1828. sftp: Server extension announcement in SSH_FXP_VERSION 1993.2. sftp: Server extension announcement in SSH_FXP_VERSION
183 200
184OpenSSH's sftp-server lists the extensions it supports using the 201OpenSSH's sftp-server lists the extensions it supports using the
185standard extension announcement mechanism in the SSH_FXP_VERSION server 202standard extension announcement mechanism in the SSH_FXP_VERSION server
@@ -200,7 +217,7 @@ ever changed in an incompatible way. The server MAY advertise the same
200extension with multiple versions (though this is unlikely). Clients MUST 217extension with multiple versions (though this is unlikely). Clients MUST
201check the version number before attempting to use the extension. 218check the version number before attempting to use the extension.
202 219
2039. sftp: Extension request "posix-rename@openssh.com" 2203.3. sftp: Extension request "posix-rename@openssh.com"
204 221
205This operation provides a rename operation with POSIX semantics, which 222This operation provides a rename operation with POSIX semantics, which
206are different to those provided by the standard SSH_FXP_RENAME in 223are different to those provided by the standard SSH_FXP_RENAME in
@@ -217,7 +234,7 @@ rename(oldpath, newpath) and will respond with a SSH_FXP_STATUS message.
217This extension is advertised in the SSH_FXP_VERSION hello with version 234This extension is advertised in the SSH_FXP_VERSION hello with version
218"1". 235"1".
219 236
22010. sftp: Extension requests "statvfs@openssh.com" and 2373.4. sftp: Extension requests "statvfs@openssh.com" and
221 "fstatvfs@openssh.com" 238 "fstatvfs@openssh.com"
222 239
223These requests correspond to the statvfs and fstatvfs POSIX system 240These requests correspond to the statvfs and fstatvfs POSIX system
@@ -258,4 +275,20 @@ The values of the f_flag bitmask are as follows:
258Both the "statvfs@openssh.com" and "fstatvfs@openssh.com" extensions are 275Both the "statvfs@openssh.com" and "fstatvfs@openssh.com" extensions are
259advertised in the SSH_FXP_VERSION hello with version "2". 276advertised in the SSH_FXP_VERSION hello with version "2".
260 277
261$OpenBSD: PROTOCOL,v 1.15 2010/02/26 20:29:54 djm Exp $ 27810. sftp: Extension request "hardlink@openssh.com"
279
280This request is for creating a hard link to a regular file. This
281request is implemented as a SSH_FXP_EXTENDED request with the
282following format:
283
284 uint32 id
285 string "hardlink@openssh.com"
286 string oldpath
287 string newpath
288
289On receiving this request the server will perform the operation
290link(oldpath, newpath) and will respond with a SSH_FXP_STATUS message.
291This extension is advertised in the SSH_FXP_VERSION hello with version
292"1".
293
294$OpenBSD: PROTOCOL,v 1.17 2010/12/04 00:18:01 djm Exp $
diff --git a/PROTOCOL.agent b/PROTOCOL.agent
index b34fcd318..de94d037d 100644
--- a/PROTOCOL.agent
+++ b/PROTOCOL.agent
@@ -159,8 +159,8 @@ successfully added or a SSH_AGENT_FAILURE if an error occurred.
159 159
1602.2.3 Add protocol 2 key 1602.2.3 Add protocol 2 key
161 161
162The OpenSSH agent supports DSA and RSA keys for protocol 2. DSA keys may 162The OpenSSH agent supports DSA, ECDSA and RSA keys for protocol 2. DSA
163be added using the following request 163keys may be added using the following request
164 164
165 byte SSH2_AGENTC_ADD_IDENTITY or 165 byte SSH2_AGENTC_ADD_IDENTITY or
166 SSH2_AGENTC_ADD_ID_CONSTRAINED 166 SSH2_AGENTC_ADD_ID_CONSTRAINED
@@ -182,6 +182,30 @@ DSA certificates may be added with:
182 string key_comment 182 string key_comment
183 constraint[] key_constraints 183 constraint[] key_constraints
184 184
185ECDSA keys may be added using the following request
186
187 byte SSH2_AGENTC_ADD_IDENTITY or
188 SSH2_AGENTC_ADD_ID_CONSTRAINED
189 string "ecdsa-sha2-nistp256" |
190 "ecdsa-sha2-nistp384" |
191 "ecdsa-sha2-nistp521"
192 string ecdsa_curve_name
193 string ecdsa_public_key
194 mpint ecdsa_private
195 string key_comment
196 constraint[] key_constraints
197
198ECDSA certificates may be added with:
199 byte SSH2_AGENTC_ADD_IDENTITY or
200 SSH2_AGENTC_ADD_ID_CONSTRAINED
201 string "ecdsa-sha2-nistp256-cert-v01@openssh.com" |
202 "ecdsa-sha2-nistp384-cert-v01@openssh.com" |
203 "ecdsa-sha2-nistp521-cert-v01@openssh.com"
204 string certificate
205 mpint ecdsa_private_key
206 string key_comment
207 constraint[] key_constraints
208
185RSA keys may be added with this request: 209RSA keys may be added with this request:
186 210
187 byte SSH2_AGENTC_ADD_IDENTITY or 211 byte SSH2_AGENTC_ADD_IDENTITY or
@@ -214,7 +238,7 @@ order to the protocol 1 add keys message. As with the corresponding
214protocol 1 "add key" request, the private key is overspecified to avoid 238protocol 1 "add key" request, the private key is overspecified to avoid
215redundant processing. 239redundant processing.
216 240
217For both DSA and RSA key add requests, "key_constraints" may only be 241For DSA, ECDSA and RSA key add requests, "key_constraints" may only be
218present if the request type is SSH2_AGENTC_ADD_ID_CONSTRAINED. 242present if the request type is SSH2_AGENTC_ADD_ID_CONSTRAINED.
219 243
220The agent will reply with a SSH_AGENT_SUCCESS if the key has been 244The agent will reply with a SSH_AGENT_SUCCESS if the key has been
@@ -294,8 +318,7 @@ Protocol 2 keys may be removed with the following request:
294 string key_blob 318 string key_blob
295 319
296Where "key_blob" is encoded as per RFC 4253 section 6.6 "Public Key 320Where "key_blob" is encoded as per RFC 4253 section 6.6 "Public Key
297Algorithms" for either of the supported key types: "ssh-dss" or 321Algorithms" for any of the supported protocol 2 key types.
298"ssh-rsa".
299 322
300The agent will delete any private key matching the specified public key 323The agent will delete any private key matching the specified public key
301and return SSH_AGENT_SUCCESS. If no such key was found, the agent will 324and return SSH_AGENT_SUCCESS. If no such key was found, the agent will
@@ -364,8 +387,7 @@ Followed by zero or more consecutive keys, encoded as:
364 string key_comment 387 string key_comment
365 388
366Where "key_blob" is encoded as per RFC 4253 section 6.6 "Public Key 389Where "key_blob" is encoded as per RFC 4253 section 6.6 "Public Key
367Algorithms" for either of the supported key types: "ssh-dss" or 390Algorithms" for any of the supported protocol 2 key types.
368"ssh-rsa".
369 391
3702.6 Private key operations 3922.6 Private key operations
371 393
@@ -429,9 +451,9 @@ a protocol 2 key:
429 uint32 flags 451 uint32 flags
430 452
431Where "key_blob" is encoded as per RFC 4253 section 6.6 "Public Key 453Where "key_blob" is encoded as per RFC 4253 section 6.6 "Public Key
432Algorithms" for either of the supported key types: "ssh-dss" or 454Algorithms" for any of the supported protocol 2 key types. "flags" is
433"ssh-rsa". "flags" is a bit-mask, but at present only one possible value 455a bit-mask, but at present only one possible value is defined (see below
434is defined (see below for its meaning): 456for its meaning):
435 457
436 SSH_AGENT_OLD_SIGNATURE 1 458 SSH_AGENT_OLD_SIGNATURE 1
437 459
@@ -535,4 +557,4 @@ Locking and unlocking affects both protocol 1 and protocol 2 keys.
535 SSH_AGENT_CONSTRAIN_LIFETIME 1 557 SSH_AGENT_CONSTRAIN_LIFETIME 1
536 SSH_AGENT_CONSTRAIN_CONFIRM 2 558 SSH_AGENT_CONSTRAIN_CONFIRM 2
537 559
538$OpenBSD: PROTOCOL.agent,v 1.5 2010/02/26 20:29:54 djm Exp $ 560$OpenBSD: PROTOCOL.agent,v 1.6 2010/08/31 11:54:45 djm Exp $
diff --git a/PROTOCOL.certkeys b/PROTOCOL.certkeys
index 1d1be13da..2f9764981 100644
--- a/PROTOCOL.certkeys
+++ b/PROTOCOL.certkeys
@@ -5,31 +5,37 @@ Background
5---------- 5----------
6 6
7The SSH protocol currently supports a simple public key authentication 7The SSH protocol currently supports a simple public key authentication
8mechanism. Unlike other public key implementations, SSH eschews the 8mechanism. Unlike other public key implementations, SSH eschews the use
9use of X.509 certificates and uses raw keys. This approach has some 9of X.509 certificates and uses raw keys. This approach has some benefits
10benefits relating to simplicity of configuration and minimisation 10relating to simplicity of configuration and minimisation of attack
11of attack surface, but it does not support the important use-cases 11surface, but it does not support the important use-cases of centrally
12of centrally managed, passwordless authentication and centrally 12managed, passwordless authentication and centrally certified host keys.
13certified host keys.
14 13
15These protocol extensions build on the simple public key authentication 14These protocol extensions build on the simple public key authentication
16system already in SSH to allow certificate-based authentication. 15system already in SSH to allow certificate-based authentication. The
17The certificates used are not traditional X.509 certificates, with 16certificates used are not traditional X.509 certificates, with numerous
18numerous options and complex encoding rules, but something rather 17options and complex encoding rules, but something rather more minimal: a
19more minimal: a key, some identity information and usage options 18key, some identity information and usage options that have been signed
20that have been signed with some other trusted key. 19with some other trusted key.
21 20
22A sshd server may be configured to allow authentication via certified 21A sshd server may be configured to allow authentication via certified
23keys, by extending the existing ~/.ssh/authorized_keys mechanism 22keys, by extending the existing ~/.ssh/authorized_keys mechanism to
24to allow specification of certification authority keys in addition 23allow specification of certification authority keys in addition to
25to raw user keys. The ssh client will support automatic verification 24raw user keys. The ssh client will support automatic verification of
26of acceptance of certified host keys, by adding a similar ability 25acceptance of certified host keys, by adding a similar ability to
27to specify CA keys in ~/.ssh/known_hosts. 26specify CA keys in ~/.ssh/known_hosts.
28 27
29Certified keys are represented using two new key types: 28Certified keys are represented using new key types:
30ssh-rsa-cert-v01@openssh.com and ssh-dss-cert-v01@openssh.com that 29
31include certification information along with the public key that is used 30 ssh-rsa-cert-v01@openssh.com
32to sign challenges. ssh-keygen performs the CA signing operation. 31 ssh-dss-cert-v01@openssh.com
32 ecdsa-sha2-nistp256-cert-v01@openssh.com
33 ecdsa-sha2-nistp384-cert-v01@openssh.com
34 ecdsa-sha2-nistp521-cert-v01@openssh.com
35
36These include certification information along with the public key
37that is used to sign challenges. ssh-keygen performs the CA signing
38operation.
33 39
34Protocol extensions 40Protocol extensions
35------------------- 41-------------------
@@ -47,10 +53,9 @@ in RFC4252 section 7.
47New public key formats 53New public key formats
48---------------------- 54----------------------
49 55
50The ssh-rsa-cert-v01@openssh.com and ssh-dss-cert-v01@openssh.com key 56The certificate key types take a similar high-level format (note: data
51types take a similar high-level format (note: data types and 57types and encoding are as per RFC4251 section 5). The serialised wire
52encoding are as per RFC4251 section 5). The serialised wire encoding of 58encoding of these certificates is also used for storing them on disk.
53these certificates is also used for storing them on disk.
54 59
55#define SSH_CERT_TYPE_USER 1 60#define SSH_CERT_TYPE_USER 1
56#define SSH_CERT_TYPE_HOST 2 61#define SSH_CERT_TYPE_HOST 2
@@ -93,6 +98,26 @@ DSA certificate
93 string signature key 98 string signature key
94 string signature 99 string signature
95 100
101ECDSA certificate
102
103 string "ecdsa-sha2-nistp256@openssh.com" |
104 "ecdsa-sha2-nistp384@openssh.com" |
105 "ecdsa-sha2-nistp521@openssh.com"
106 string nonce
107 string curve
108 string public_key
109 uint64 serial
110 uint32 type
111 string key id
112 string valid principals
113 uint64 valid after
114 uint64 valid before
115 string critical options
116 string extensions
117 string reserved
118 string signature key
119 string signature
120
96The nonce field is a CA-provided random bitstring of arbitrary length 121The nonce field is a CA-provided random bitstring of arbitrary length
97(but typically 16 or 32 bytes) included to make attacks that depend on 122(but typically 16 or 32 bytes) included to make attacks that depend on
98inducing collisions in the signature hash infeasible. 123inducing collisions in the signature hash infeasible.
@@ -101,6 +126,9 @@ e and n are the RSA exponent and public modulus respectively.
101 126
102p, q, g, y are the DSA parameters as described in FIPS-186-2. 127p, q, g, y are the DSA parameters as described in FIPS-186-2.
103 128
129curve and public key are respectively the ECDSA "[identifier]" and "Q"
130defined in section 3.1 of RFC5656.
131
104serial is an optional certificate serial number set by the CA to 132serial is an optional certificate serial number set by the CA to
105provide an abbreviated way to refer to certificates from that CA. 133provide an abbreviated way to refer to certificates from that CA.
106If a CA does not wish to number its certificates it must set this 134If a CA does not wish to number its certificates it must set this
@@ -123,7 +151,8 @@ any principal of the specified type. XXX DNS wildcards?
123"valid after" and "valid before" specify a validity period for the 151"valid after" and "valid before" specify a validity period for the
124certificate. Each represents a time in seconds since 1970-01-01 152certificate. Each represents a time in seconds since 1970-01-01
12500:00:00. A certificate is considered valid if: 15300:00:00. A certificate is considered valid if:
126 valid after <= current time < valid before 154
155 valid after <= current time < valid before
127 156
128criticial options is a set of zero or more key options encoded as 157criticial options is a set of zero or more key options encoded as
129below. All such options are "critical" in the sense that an implementation 158below. All such options are "critical" in the sense that an implementation
@@ -137,15 +166,17 @@ The reserved field is currently unused and is ignored in this version of
137the protocol. 166the protocol.
138 167
139signature key contains the CA key used to sign the certificate. 168signature key contains the CA key used to sign the certificate.
140The valid key types for CA keys are ssh-rsa and ssh-dss. "Chained" 169The valid key types for CA keys are ssh-rsa, ssh-dss and the ECDSA types
170ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521. "Chained"
141certificates, where the signature key type is a certificate type itself 171certificates, where the signature key type is a certificate type itself
142are NOT supported. Note that it is possible for a RSA certificate key to 172are NOT supported. Note that it is possible for a RSA certificate key to
143be signed by a DSS CA key and vice-versa. 173be signed by a DSS or ECDSA CA key and vice-versa.
144 174
145signature is computed over all preceding fields from the initial string 175signature is computed over all preceding fields from the initial string
146up to, and including the signature key. Signatures are computed and 176up to, and including the signature key. Signatures are computed and
147encoded according to the rules defined for the CA's public key algorithm 177encoded according to the rules defined for the CA's public key algorithm
148(RFC4253 section 6.6 for ssh-rsa and ssh-dss). 178(RFC4253 section 6.6 for ssh-rsa and ssh-dss, RFC5656 for the ECDSA
179types).
149 180
150Critical options 181Critical options
151---------------- 182----------------
@@ -222,4 +253,4 @@ permit-user-rc empty Flag indicating that execution of
222 of this script will not be permitted if 253 of this script will not be permitted if
223 this option is not present. 254 this option is not present.
224 255
225$OpenBSD: PROTOCOL.certkeys,v 1.7 2010/08/04 05:40:39 djm Exp $ 256$OpenBSD: PROTOCOL.certkeys,v 1.8 2010/08/31 11:54:45 djm Exp $
diff --git a/PROTOCOL.mux b/PROTOCOL.mux
index 1d8c463a7..3d6f81878 100644
--- a/PROTOCOL.mux
+++ b/PROTOCOL.mux
@@ -28,7 +28,7 @@ defined.
28To open a new multiplexed session, a client may send the following 28To open a new multiplexed session, a client may send the following
29request: 29request:
30 30
31 uint32 MUX_C_MSG_NEW_SESSION 31 uint32 MUX_C_NEW_SESSION
32 uint32 request id 32 uint32 request id
33 string reserved 33 string reserved
34 bool want tty flag 34 bool want tty flag
@@ -99,7 +99,7 @@ The server will reply with one of MUX_S_OK or MUX_S_PERMISSION_DENIED.
99 99
100A client may request the master to establish a port forward: 100A client may request the master to establish a port forward:
101 101
102 uint32 MUX_C_OPEN_FORWARD 102 uint32 MUX_C_OPEN_FWD
103 uint32 request id 103 uint32 request id
104 uint32 forwarding type 104 uint32 forwarding type
105 string listen host 105 string listen host
@@ -118,24 +118,23 @@ For dynamically allocated listen port the server replies with
118 uint32 client request id 118 uint32 client request id
119 uint32 allocated remote listen port 119 uint32 allocated remote listen port
120 120
1215. Requesting closure of port forwards 1216. Requesting closure of port forwards
122
123Note: currently unimplemented (server will always reply with MUX_S_FAILURE).
122 124
123A client may request the master to establish a port forward: 125A client may request the master to establish a port forward:
124 126
125 uint32 MUX_C_OPEN_FORWARD 127 uint32 MUX_C_CLOSE_FWD
126 uint32 request id 128 uint32 request id
127 uint32 forwarding type
128 string listen host 129 string listen host
129 string listen port 130 string listen port
130 string connect host 131 string connect host
131 string connect port 132 string connect port
132 133
133forwarding type may be MUX_FWD_LOCAL, MUX_FWD_REMOTE, MUX_FWD_DYNAMIC.
134
135A server may reply with a MUX_S_OK, a MUX_S_PERMISSION_DENIED or a 134A server may reply with a MUX_S_OK, a MUX_S_PERMISSION_DENIED or a
136MUX_S_FAILURE. 135MUX_S_FAILURE.
137 136
1386. Requesting stdio forwarding 1377. Requesting stdio forwarding
139 138
140A client may request the master to establish a stdio forwarding: 139A client may request the master to establish a stdio forwarding:
141 140
@@ -153,7 +152,7 @@ The contents of "reserved" are currently ignored.
153A server may reply with a MUX_S_SESSION_OPEED, a MUX_S_PERMISSION_DENIED 152A server may reply with a MUX_S_SESSION_OPEED, a MUX_S_PERMISSION_DENIED
154or a MUX_S_FAILURE. 153or a MUX_S_FAILURE.
155 154
1567. Status messages 1558. Status messages
157 156
158The MUX_S_OK message is empty: 157The MUX_S_OK message is empty:
159 158
@@ -170,14 +169,15 @@ The MUX_S_PERMISSION_DENIED and MUX_S_FAILURE include a reason:
170 uint32 client request id 169 uint32 client request id
171 string reason 170 string reason
172 171
1737. Protocol numbers 1729. Protocol numbers
174 173
175#define MUX_MSG_HELLO 0x00000001 174#define MUX_MSG_HELLO 0x00000001
176#define MUX_C_NEW_SESSION 0x10000002 175#define MUX_C_NEW_SESSION 0x10000002
177#define MUX_C_ALIVE_CHECK 0x10000004 176#define MUX_C_ALIVE_CHECK 0x10000004
178#define MUX_C_TERMINATE 0x10000005 177#define MUX_C_TERMINATE 0x10000005
179#define MUX_C_OPEN_FORWARD 0x10000006 178#define MUX_C_OPEN_FWD 0x10000006
180#define MUX_C_CLOSE_FORWARD 0x10000007 179#define MUX_C_CLOSE_FWD 0x10000007
180#define MUX_C_NEW_STDIO_FWD 0x10000008
181#define MUX_S_OK 0x80000001 181#define MUX_S_OK 0x80000001
182#define MUX_S_PERMISSION_DENIED 0x80000002 182#define MUX_S_PERMISSION_DENIED 0x80000002
183#define MUX_S_FAILURE 0x80000003 183#define MUX_S_FAILURE 0x80000003
@@ -200,4 +200,4 @@ XXX server->client error/warning notifications
200XXX port0 rfwd (need custom response message) 200XXX port0 rfwd (need custom response message)
201XXX send signals via mux 201XXX send signals via mux
202 202
203$OpenBSD: PROTOCOL.mux,v 1.2 2010/05/16 12:55:51 markus Exp $ 203$OpenBSD: PROTOCOL.mux,v 1.3 2011/01/13 21:55:25 djm Exp $
diff --git a/README b/README
index 4eaa54588..4e7e9a9f2 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
1See http://www.openssh.com/txt/release-5.6 for the release notes. 1See http://www.openssh.com/txt/release-5.7 for the release notes.
2 2
3- A Japanese translation of this document and of the OpenSSH FAQ is 3- A Japanese translation of this document and of the OpenSSH FAQ is
4- available at http://www.unixuser.org/~haruyama/security/openssh/index.html 4- available at http://www.unixuser.org/~haruyama/security/openssh/index.html
@@ -62,4 +62,4 @@ References -
62[6] http://www.openbsd.org/cgi-bin/man.cgi?query=style&sektion=9 62[6] http://www.openbsd.org/cgi-bin/man.cgi?query=style&sektion=9
63[7] http://www.openssh.com/faq.html 63[7] http://www.openssh.com/faq.html
64 64
65$Id: README,v 1.74 2010/08/08 16:32:06 djm Exp $ 65$Id: README,v 1.75 2011/01/22 09:23:12 djm Exp $
diff --git a/atomicio.c b/atomicio.c
index a6b2d127a..601b3c371 100644
--- a/atomicio.c
+++ b/atomicio.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: atomicio.c,v 1.25 2007/06/25 12:02:27 dtucker Exp $ */ 1/* $OpenBSD: atomicio.c,v 1.26 2010/09/22 22:58:51 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2006 Damien Miller. All rights reserved. 3 * Copyright (c) 2006 Damien Miller. All rights reserved.
4 * Copyright (c) 2005 Anil Madhavapeddy. All rights reserved. 4 * Copyright (c) 2005 Anil Madhavapeddy. All rights reserved.
@@ -48,7 +48,8 @@
48 * ensure all of data on socket comes through. f==read || f==vwrite 48 * ensure all of data on socket comes through. f==read || f==vwrite
49 */ 49 */
50size_t 50size_t
51atomicio(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n) 51atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n,
52 int (*cb)(void *, size_t), void *cb_arg)
52{ 53{
53 char *s = _s; 54 char *s = _s;
54 size_t pos = 0; 55 size_t pos = 0;
@@ -73,17 +74,28 @@ atomicio(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n)
73 return pos; 74 return pos;
74 default: 75 default:
75 pos += (size_t)res; 76 pos += (size_t)res;
77 if (cb != NULL && cb(cb_arg, (size_t)res) == -1) {
78 errno = EINTR;
79 return pos;
80 }
76 } 81 }
77 } 82 }
78 return (pos); 83 return pos;
84}
85
86size_t
87atomicio(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n)
88{
89 return atomicio6(f, fd, _s, n, NULL, NULL);
79} 90}
80 91
81/* 92/*
82 * ensure all of data on socket comes through. f==readv || f==writev 93 * ensure all of data on socket comes through. f==readv || f==writev
83 */ 94 */
84size_t 95size_t
85atomiciov(ssize_t (*f) (int, const struct iovec *, int), int fd, 96atomiciov6(ssize_t (*f) (int, const struct iovec *, int), int fd,
86 const struct iovec *_iov, int iovcnt) 97 const struct iovec *_iov, int iovcnt,
98 int (*cb)(void *, size_t), void *cb_arg)
87{ 99{
88 size_t pos = 0, rem; 100 size_t pos = 0, rem;
89 ssize_t res; 101 ssize_t res;
@@ -137,6 +149,17 @@ atomiciov(ssize_t (*f) (int, const struct iovec *, int), int fd,
137 iov[0].iov_base = ((char *)iov[0].iov_base) + rem; 149 iov[0].iov_base = ((char *)iov[0].iov_base) + rem;
138 iov[0].iov_len -= rem; 150 iov[0].iov_len -= rem;
139 } 151 }
152 if (cb != NULL && cb(cb_arg, (size_t)res) == -1) {
153 errno = EINTR;
154 return pos;
155 }
140 } 156 }
141 return pos; 157 return pos;
142} 158}
159
160size_t
161atomiciov(ssize_t (*f) (int, const struct iovec *, int), int fd,
162 const struct iovec *_iov, int iovcnt)
163{
164 return atomiciov6(f, fd, _iov, iovcnt, NULL, NULL);
165}
diff --git a/atomicio.h b/atomicio.h
index 2fcd25d43..0d728ac86 100644
--- a/atomicio.h
+++ b/atomicio.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: atomicio.h,v 1.10 2006/08/03 03:34:41 deraadt Exp $ */ 1/* $OpenBSD: atomicio.h,v 1.11 2010/09/22 22:58:51 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006 Damien Miller. All rights reserved. 4 * Copyright (c) 2006 Damien Miller. All rights reserved.
@@ -32,6 +32,9 @@
32/* 32/*
33 * Ensure all of data on socket comes through. f==read || f==vwrite 33 * Ensure all of data on socket comes through. f==read || f==vwrite
34 */ 34 */
35size_t
36atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n,
37 int (*cb)(void *, size_t), void *);
35size_t atomicio(ssize_t (*)(int, void *, size_t), int, void *, size_t); 38size_t atomicio(ssize_t (*)(int, void *, size_t), int, void *, size_t);
36 39
37#define vwrite (ssize_t (*)(int, void *, size_t))write 40#define vwrite (ssize_t (*)(int, void *, size_t))write
@@ -39,6 +42,9 @@ size_t atomicio(ssize_t (*)(int, void *, size_t), int, void *, size_t);
39/* 42/*
40 * ensure all of data on socket comes through. f==readv || f==writev 43 * ensure all of data on socket comes through. f==readv || f==writev
41 */ 44 */
45size_t
46atomiciov6(ssize_t (*f) (int, const struct iovec *, int), int fd,
47 const struct iovec *_iov, int iovcnt, int (*cb)(void *, size_t), void *);
42size_t atomiciov(ssize_t (*)(int, const struct iovec *, int), 48size_t atomiciov(ssize_t (*)(int, const struct iovec *, int),
43 int, const struct iovec *, int); 49 int, const struct iovec *, int);
44 50
diff --git a/audit-bsm.c b/audit-bsm.c
index 2c417bc27..f196d4f1e 100644
--- a/audit-bsm.c
+++ b/audit-bsm.c
@@ -1,4 +1,4 @@
1/* $Id: audit-bsm.c,v 1.6 2008/02/25 10:05:04 dtucker Exp $ */ 1/* $Id: audit-bsm.c,v 1.7 2011/01/17 10:15:29 dtucker Exp $ */
2 2
3/* 3/*
4 * TODO 4 * TODO
@@ -305,13 +305,13 @@ audit_run_command(const char *command)
305} 305}
306 306
307void 307void
308audit_session_open(const char *ttyn) 308audit_session_open(struct logininfo *li)
309{ 309{
310 /* not implemented */ 310 /* not implemented */
311} 311}
312 312
313void 313void
314audit_session_close(const char *ttyn) 314audit_session_close(struct logininfo *li)
315{ 315{
316 /* not implemented */ 316 /* not implemented */
317} 317}
diff --git a/audit-linux.c b/audit-linux.c
new file mode 100644
index 000000000..b3ee2f4da
--- /dev/null
+++ b/audit-linux.c
@@ -0,0 +1,126 @@
1/* $Id: audit-linux.c,v 1.1 2011/01/17 10:15:30 dtucker Exp $ */
2
3/*
4 * Copyright 2010 Red Hat, Inc. All rights reserved.
5 * Use is subject to license terms.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Red Hat author: Jan F. Chadima <jchadima@redhat.com>
28 */
29
30#include "includes.h"
31#if defined(USE_LINUX_AUDIT)
32#include <libaudit.h>
33#include <unistd.h>
34#include <string.h>
35
36#include "log.h"
37#include "audit.h"
38#include "canohost.h"
39
40const char* audit_username(void);
41
42int
43linux_audit_record_event(int uid, const char *username,
44 const char *hostname, const char *ip, const char *ttyn, int success)
45{
46 int audit_fd, rc, saved_errno;
47
48 audit_fd = audit_open();
49 if (audit_fd < 0) {
50 if (errno == EINVAL || errno == EPROTONOSUPPORT ||
51 errno == EAFNOSUPPORT)
52 return 1; /* No audit support in kernel */
53 else
54 return 0; /* Must prevent login */
55 }
56 rc = audit_log_acct_message(audit_fd, AUDIT_USER_LOGIN,
57 NULL, "login", username ? username : "(unknown)",
58 username == NULL ? uid : -1, hostname, ip, ttyn, success);
59 saved_errno = errno;
60 close(audit_fd);
61 /*
62 * Do not report error if the error is EPERM and sshd is run as non
63 * root user.
64 */
65 if ((rc == -EPERM) && (geteuid() != 0))
66 rc = 0;
67 errno = saved_errno;
68 return (rc >= 0);
69}
70
71/* Below is the sshd audit API code */
72
73void
74audit_connection_from(const char *host, int port)
75{
76}
77 /* not implemented */
78
79void
80audit_run_command(const char *command)
81{
82 /* not implemented */
83}
84
85void
86audit_session_open(struct logininfo *li)
87{
88 if (linux_audit_record_event(li->uid, NULL, li->hostname,
89 NULL, li->line, 1) == 0)
90 fatal("linux_audit_write_entry failed: %s", strerror(errno));
91}
92
93void
94audit_session_close(struct logininfo *li)
95{
96 /* not implemented */
97}
98
99void
100audit_event(ssh_audit_event_t event)
101{
102 switch(event) {
103 case SSH_AUTH_SUCCESS:
104 case SSH_CONNECTION_CLOSE:
105 case SSH_NOLOGIN:
106 case SSH_LOGIN_EXCEED_MAXTRIES:
107 case SSH_LOGIN_ROOT_DENIED:
108 break;
109
110 case SSH_AUTH_FAIL_NONE:
111 case SSH_AUTH_FAIL_PASSWD:
112 case SSH_AUTH_FAIL_KBDINT:
113 case SSH_AUTH_FAIL_PUBKEY:
114 case SSH_AUTH_FAIL_HOSTBASED:
115 case SSH_AUTH_FAIL_GSSAPI:
116 case SSH_INVALID_USER:
117 linux_audit_record_event(-1, audit_username(), NULL,
118 get_remote_ipaddr(), "sshd", 0);
119 break;
120
121 default:
122 debug("%s: unhandled event %d", __func__, event);
123 }
124}
125
126#endif /* USE_LINUX_AUDIT */
diff --git a/audit.c b/audit.c
index dbea34cb2..ced57fa64 100644
--- a/audit.c
+++ b/audit.c
@@ -1,4 +1,4 @@
1/* $Id: audit.c,v 1.5 2006/09/01 05:38:36 djm Exp $ */ 1/* $Id: audit.c,v 1.6 2011/01/17 10:15:30 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2004, 2005 Darren Tucker. All rights reserved. 4 * Copyright (c) 2004, 2005 Darren Tucker. All rights reserved.
@@ -147,9 +147,9 @@ audit_event(ssh_audit_event_t event)
147 * within a single connection. 147 * within a single connection.
148 */ 148 */
149void 149void
150audit_session_open(const char *ttyn) 150audit_session_open(struct logininfo *li)
151{ 151{
152 const char *t = ttyn ? ttyn : "(no tty)"; 152 const char *t = li->line ? li->line : "(no tty)";
153 153
154 debug("audit session open euid %d user %s tty name %s", geteuid(), 154 debug("audit session open euid %d user %s tty name %s", geteuid(),
155 audit_username(), t); 155 audit_username(), t);
@@ -163,9 +163,9 @@ audit_session_open(const char *ttyn)
163 * within a single connection. 163 * within a single connection.
164 */ 164 */
165void 165void
166audit_session_close(const char *ttyn) 166audit_session_close(struct logininfo *li)
167{ 167{
168 const char *t = ttyn ? ttyn : "(no tty)"; 168 const char *t = li->line ? li->line : "(no tty)";
169 169
170 debug("audit session close euid %d user %s tty name %s", geteuid(), 170 debug("audit session close euid %d user %s tty name %s", geteuid(),
171 audit_username(), t); 171 audit_username(), t);
diff --git a/audit.h b/audit.h
index 695f72354..92ede5bc4 100644
--- a/audit.h
+++ b/audit.h
@@ -1,4 +1,4 @@
1/* $Id: audit.h,v 1.3 2006/08/05 14:05:10 dtucker Exp $ */ 1/* $Id: audit.h,v 1.4 2011/01/17 10:15:30 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2004, 2005 Darren Tucker. All rights reserved. 4 * Copyright (c) 2004, 2005 Darren Tucker. All rights reserved.
@@ -26,6 +26,9 @@
26 26
27#ifndef _SSH_AUDIT_H 27#ifndef _SSH_AUDIT_H
28# define _SSH_AUDIT_H 28# define _SSH_AUDIT_H
29
30#include "loginrec.h"
31
29enum ssh_audit_event_type { 32enum ssh_audit_event_type {
30 SSH_LOGIN_EXCEED_MAXTRIES, 33 SSH_LOGIN_EXCEED_MAXTRIES,
31 SSH_LOGIN_ROOT_DENIED, 34 SSH_LOGIN_ROOT_DENIED,
@@ -46,8 +49,8 @@ typedef enum ssh_audit_event_type ssh_audit_event_t;
46 49
47void audit_connection_from(const char *, int); 50void audit_connection_from(const char *, int);
48void audit_event(ssh_audit_event_t); 51void audit_event(ssh_audit_event_t);
49void audit_session_open(const char *); 52void audit_session_open(struct logininfo *);
50void audit_session_close(const char *); 53void audit_session_close(struct logininfo *);
51void audit_run_command(const char *); 54void audit_run_command(const char *);
52ssh_audit_event_t audit_classify_auth(const char *); 55ssh_audit_event_t audit_classify_auth(const char *);
53 56
diff --git a/auth-options.c b/auth-options.c
index a7040247f..eae45cf2b 100644
--- a/auth-options.c
+++ b/auth-options.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth-options.c,v 1.52 2010/05/20 23:46:02 djm Exp $ */ 1/* $OpenBSD: auth-options.c,v 1.54 2010/12/24 21:41:48 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -172,7 +172,7 @@ auth_parse_options(struct passwd *pw, char *opts, char *file, u_long linenum)
172 goto bad_option; 172 goto bad_option;
173 } 173 }
174 forced_command[i] = '\0'; 174 forced_command[i] = '\0';
175 auth_debug_add("Forced command: %.900s", forced_command); 175 auth_debug_add("Forced command.");
176 opts++; 176 opts++;
177 goto next_option; 177 goto next_option;
178 } 178 }
@@ -444,7 +444,7 @@ parse_option_list(u_char *optblob, size_t optblob_len, struct passwd *pw,
444 buffer_append(&c, optblob, optblob_len); 444 buffer_append(&c, optblob, optblob_len);
445 445
446 while (buffer_len(&c) > 0) { 446 while (buffer_len(&c) > 0) {
447 if ((name = buffer_get_string_ret(&c, &nlen)) == NULL || 447 if ((name = buffer_get_cstring_ret(&c, &nlen)) == NULL ||
448 (data_blob = buffer_get_string_ret(&c, &dlen)) == NULL) { 448 (data_blob = buffer_get_string_ret(&c, &dlen)) == NULL) {
449 error("Certificate options corrupt"); 449 error("Certificate options corrupt");
450 goto out; 450 goto out;
@@ -479,7 +479,7 @@ parse_option_list(u_char *optblob, size_t optblob_len, struct passwd *pw,
479 } 479 }
480 if (!found && (which & OPTIONS_CRITICAL) != 0) { 480 if (!found && (which & OPTIONS_CRITICAL) != 0) {
481 if (strcmp(name, "force-command") == 0) { 481 if (strcmp(name, "force-command") == 0) {
482 if ((command = buffer_get_string_ret(&data, 482 if ((command = buffer_get_cstring_ret(&data,
483 &clen)) == NULL) { 483 &clen)) == NULL) {
484 error("Certificate constraint \"%s\" " 484 error("Certificate constraint \"%s\" "
485 "corrupt", name); 485 "corrupt", name);
@@ -500,7 +500,7 @@ parse_option_list(u_char *optblob, size_t optblob_len, struct passwd *pw,
500 found = 1; 500 found = 1;
501 } 501 }
502 if (strcmp(name, "source-address") == 0) { 502 if (strcmp(name, "source-address") == 0) {
503 if ((allowed = buffer_get_string_ret(&data, 503 if ((allowed = buffer_get_cstring_ret(&data,
504 &clen)) == NULL) { 504 &clen)) == NULL) {
505 error("Certificate constraint " 505 error("Certificate constraint "
506 "\"%s\" corrupt", name); 506 "\"%s\" corrupt", name);
diff --git a/auth-rsa.c b/auth-rsa.c
index 56702d130..4edaab056 100644
--- a/auth-rsa.c
+++ b/auth-rsa.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth-rsa.c,v 1.78 2010/07/13 23:13:16 djm Exp $ */ 1/* $OpenBSD: auth-rsa.c,v 1.79 2010/12/03 23:55:27 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -94,9 +94,6 @@ auth_rsa_verify_response(Key *key, BIGNUM *challenge, u_char response[16])
94 MD5_CTX md; 94 MD5_CTX md;
95 int len; 95 int len;
96 96
97 if (auth_key_is_revoked(key))
98 return 0;
99
100 /* don't allow short keys */ 97 /* don't allow short keys */
101 if (BN_num_bits(key->rsa->n) < SSH_RSA_MINIMUM_MODULUS_SIZE) { 98 if (BN_num_bits(key->rsa->n) < SSH_RSA_MINIMUM_MODULUS_SIZE) {
102 error("auth_rsa_verify_response: RSA modulus too small: %d < minimum %d bits", 99 error("auth_rsa_verify_response: RSA modulus too small: %d < minimum %d bits",
@@ -249,6 +246,10 @@ auth_rsa_key_allowed(struct passwd *pw, BIGNUM *client_n, Key **rkey)
249 "actual %d vs. announced %d.", 246 "actual %d vs. announced %d.",
250 file, linenum, BN_num_bits(key->rsa->n), bits); 247 file, linenum, BN_num_bits(key->rsa->n), bits);
251 248
249 /* Never accept a revoked key */
250 if (auth_key_is_revoked(key))
251 break;
252
252 /* We have found the desired key. */ 253 /* We have found the desired key. */
253 /* 254 /*
254 * If our options do not allow this key to be used, 255 * If our options do not allow this key to be used,
diff --git a/auth.c b/auth.c
index dba1e6555..33680b91b 100644
--- a/auth.c
+++ b/auth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth.c,v 1.89 2010/08/04 05:42:47 djm Exp $ */ 1/* $OpenBSD: auth.c,v 1.91 2010/11/29 23:45:51 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -379,16 +379,15 @@ HostStatus
379check_key_in_hostfiles(struct passwd *pw, Key *key, const char *host, 379check_key_in_hostfiles(struct passwd *pw, Key *key, const char *host,
380 const char *sysfile, const char *userfile) 380 const char *sysfile, const char *userfile)
381{ 381{
382 Key *found;
383 char *user_hostfile; 382 char *user_hostfile;
384 struct stat st; 383 struct stat st;
385 HostStatus host_status; 384 HostStatus host_status;
385 struct hostkeys *hostkeys;
386 const struct hostkey_entry *found;
386 387
387 /* Check if we know the host and its host key. */ 388 hostkeys = init_hostkeys();
388 found = key_new(key_is_cert(key) ? KEY_UNSPEC : key->type); 389 load_hostkeys(hostkeys, host, sysfile);
389 host_status = check_host_in_hostfile(sysfile, host, key, found, NULL); 390 if (userfile != NULL) {
390
391 if (host_status != HOST_OK && userfile != NULL) {
392 user_hostfile = tilde_expand_filename(userfile, pw->pw_uid); 391 user_hostfile = tilde_expand_filename(userfile, pw->pw_uid);
393 if (options.strict_modes && 392 if (options.strict_modes &&
394 (stat(user_hostfile, &st) == 0) && 393 (stat(user_hostfile, &st) == 0) &&
@@ -401,16 +400,23 @@ check_key_in_hostfiles(struct passwd *pw, Key *key, const char *host,
401 user_hostfile); 400 user_hostfile);
402 } else { 401 } else {
403 temporarily_use_uid(pw); 402 temporarily_use_uid(pw);
404 host_status = check_host_in_hostfile(user_hostfile, 403 load_hostkeys(hostkeys, host, user_hostfile);
405 host, key, found, NULL);
406 restore_uid(); 404 restore_uid();
407 } 405 }
408 xfree(user_hostfile); 406 xfree(user_hostfile);
409 } 407 }
410 key_free(found); 408 host_status = check_key_in_hostkeys(hostkeys, key, &found);
409 if (host_status == HOST_REVOKED)
410 error("WARNING: revoked key for %s attempted authentication",
411 found->host);
412 else if (host_status == HOST_OK)
413 debug("%s: key for %s found at %s:%ld", __func__,
414 found->host, found->file, found->line);
415 else
416 debug("%s: key for host %s not found", __func__, host);
417
418 free_hostkeys(hostkeys);
411 419
412 debug2("check_key_in_hostfiles: key %s for %s", host_status == HOST_OK ?
413 "ok" : "not found", host);
414 return host_status; 420 return host_status;
415} 421}
416 422
@@ -518,7 +524,7 @@ auth_openfile(const char *file, struct passwd *pw, int strict_modes,
518 close(fd); 524 close(fd);
519 return NULL; 525 return NULL;
520 } 526 }
521 if (options.strict_modes && 527 if (strict_modes &&
522 secure_filename(f, file, pw, line, sizeof(line)) != 0) { 528 secure_filename(f, file, pw, line, sizeof(line)) != 0) {
523 fclose(f); 529 fclose(f);
524 logit("Authentication refused: %s", line); 530 logit("Authentication refused: %s", line);
diff --git a/auth1.c b/auth1.c
index bf442dbf6..cc85aec74 100644
--- a/auth1.c
+++ b/auth1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth1.c,v 1.74 2010/06/25 08:46:17 djm Exp $ */ 1/* $OpenBSD: auth1.c,v 1.75 2010/08/31 09:58:37 djm Exp $ */
2/* 2/*
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4 * All rights reserved 4 * All rights reserved
@@ -167,7 +167,7 @@ auth1_process_rhosts_rsa(Authctxt *authctxt, char *info, size_t infolen)
167 * trust the client; root on the client machine can 167 * trust the client; root on the client machine can
168 * claim to be any user. 168 * claim to be any user.
169 */ 169 */
170 client_user = packet_get_string(&ulen); 170 client_user = packet_get_cstring(&ulen);
171 171
172 /* Get the client host key. */ 172 /* Get the client host key. */
173 client_host_key = key_new(KEY_RSA1); 173 client_host_key = key_new(KEY_RSA1);
@@ -389,7 +389,7 @@ do_authentication(Authctxt *authctxt)
389 packet_read_expect(SSH_CMSG_USER); 389 packet_read_expect(SSH_CMSG_USER);
390 390
391 /* Get the user name. */ 391 /* Get the user name. */
392 user = packet_get_string(&ulen); 392 user = packet_get_cstring(&ulen);
393 packet_check_eom(); 393 packet_check_eom();
394 394
395 if ((style = strchr(user, ':')) != NULL) 395 if ((style = strchr(user, ':')) != NULL)
diff --git a/auth2-jpake.c b/auth2-jpake.c
index 5de5506a6..a460e8216 100644
--- a/auth2-jpake.c
+++ b/auth2-jpake.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2-jpake.c,v 1.3 2009/03/05 07:18:19 djm Exp $ */ 1/* $OpenBSD: auth2-jpake.c,v 1.4 2010/08/31 11:54:45 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2008 Damien Miller. All rights reserved. 3 * Copyright (c) 2008 Damien Miller. All rights reserved.
4 * 4 *
@@ -162,6 +162,11 @@ derive_rawsalt(const char *username, u_char *rawsalt, u_int len)
162 fatal("%s: DSA key missing priv_key", __func__); 162 fatal("%s: DSA key missing priv_key", __func__);
163 buffer_put_bignum2(&b, k->dsa->priv_key); 163 buffer_put_bignum2(&b, k->dsa->priv_key);
164 break; 164 break;
165 case KEY_ECDSA:
166 if (EC_KEY_get0_private_key(k->ecdsa) == NULL)
167 fatal("%s: ECDSA key missing priv_key", __func__);
168 buffer_put_bignum2(&b, EC_KEY_get0_private_key(k->ecdsa));
169 break;
165 default: 170 default:
166 fatal("%s: unknown key type %d", __func__, k->type); 171 fatal("%s: unknown key type %d", __func__, k->type);
167 } 172 }
diff --git a/auth2-pubkey.c b/auth2-pubkey.c
index 35cf79c9f..7d2141355 100644
--- a/auth2-pubkey.c
+++ b/auth2-pubkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2-pubkey.c,v 1.26 2010/06/29 23:16:46 djm Exp $ */ 1/* $OpenBSD: auth2-pubkey.c,v 1.27 2010/11/20 05:12:38 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -232,7 +232,7 @@ match_principals_file(char *file, struct passwd *pw, struct KeyCert *cert)
232 if ((ep = strrchr(cp, ' ')) != NULL || 232 if ((ep = strrchr(cp, ' ')) != NULL ||
233 (ep = strrchr(cp, '\t')) != NULL) { 233 (ep = strrchr(cp, '\t')) != NULL) {
234 for (; *ep == ' ' || *ep == '\t'; ep++) 234 for (; *ep == ' ' || *ep == '\t'; ep++)
235 ;; 235 ;
236 line_opts = cp; 236 line_opts = cp;
237 cp = ep; 237 cp = ep;
238 } 238 }
diff --git a/auth2.c b/auth2.c
index 61b5c0148..3c38cdddc 100644
--- a/auth2.c
+++ b/auth2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2.c,v 1.121 2009/06/22 05:39:28 dtucker Exp $ */ 1/* $OpenBSD: auth2.c,v 1.122 2010/08/31 09:58:37 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -184,7 +184,7 @@ input_service_request(int type, u_int32_t seq, void *ctxt)
184 Authctxt *authctxt = ctxt; 184 Authctxt *authctxt = ctxt;
185 u_int len; 185 u_int len;
186 int acceptit = 0; 186 int acceptit = 0;
187 char *service = packet_get_string(&len); 187 char *service = packet_get_cstring(&len);
188 packet_check_eom(); 188 packet_check_eom();
189 189
190 if (authctxt == NULL) 190 if (authctxt == NULL)
@@ -223,9 +223,9 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
223 if (authctxt == NULL) 223 if (authctxt == NULL)
224 fatal("input_userauth_request: no authctxt"); 224 fatal("input_userauth_request: no authctxt");
225 225
226 user = packet_get_string(NULL); 226 user = packet_get_cstring(NULL);
227 service = packet_get_string(NULL); 227 service = packet_get_cstring(NULL);
228 method = packet_get_string(NULL); 228 method = packet_get_cstring(NULL);
229 debug("userauth-request for user %s service %s method %s", user, service, method); 229 debug("userauth-request for user %s service %s method %s", user, service, method);
230 debug("attempt %d failures %d", authctxt->attempt, authctxt->failures); 230 debug("attempt %d failures %d", authctxt->attempt, authctxt->failures);
231 231
diff --git a/authfd.c b/authfd.c
index 739722fbf..c11c3f5a8 100644
--- a/authfd.c
+++ b/authfd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: authfd.c,v 1.83 2010/04/16 01:47:26 djm Exp $ */ 1/* $OpenBSD: authfd.c,v 1.84 2010/08/31 11:54:45 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -509,6 +509,21 @@ ssh_encode_identity_ssh2(Buffer *b, Key *key, const char *comment)
509 buffer_len(&key->cert->certblob)); 509 buffer_len(&key->cert->certblob));
510 buffer_put_bignum2(b, key->dsa->priv_key); 510 buffer_put_bignum2(b, key->dsa->priv_key);
511 break; 511 break;
512#ifdef OPENSSL_HAS_ECC
513 case KEY_ECDSA:
514 buffer_put_cstring(b, key_curve_nid_to_name(key->ecdsa_nid));
515 buffer_put_ecpoint(b, EC_KEY_get0_group(key->ecdsa),
516 EC_KEY_get0_public_key(key->ecdsa));
517 buffer_put_bignum2(b, EC_KEY_get0_private_key(key->ecdsa));
518 break;
519 case KEY_ECDSA_CERT:
520 if (key->cert == NULL || buffer_len(&key->cert->certblob) == 0)
521 fatal("%s: no cert/certblob", __func__);
522 buffer_put_string(b, buffer_ptr(&key->cert->certblob),
523 buffer_len(&key->cert->certblob));
524 buffer_put_bignum2(b, EC_KEY_get0_private_key(key->ecdsa));
525 break;
526#endif
512 } 527 }
513 buffer_put_cstring(b, comment); 528 buffer_put_cstring(b, comment);
514} 529}
@@ -541,6 +556,8 @@ ssh_add_identity_constrained(AuthenticationConnection *auth, Key *key,
541 case KEY_DSA: 556 case KEY_DSA:
542 case KEY_DSA_CERT: 557 case KEY_DSA_CERT:
543 case KEY_DSA_CERT_V00: 558 case KEY_DSA_CERT_V00:
559 case KEY_ECDSA:
560 case KEY_ECDSA_CERT:
544 type = constrained ? 561 type = constrained ?
545 SSH2_AGENTC_ADD_ID_CONSTRAINED : 562 SSH2_AGENTC_ADD_ID_CONSTRAINED :
546 SSH2_AGENTC_ADD_IDENTITY; 563 SSH2_AGENTC_ADD_IDENTITY;
@@ -589,7 +606,8 @@ ssh_remove_identity(AuthenticationConnection *auth, Key *key)
589 buffer_put_bignum(&msg, key->rsa->e); 606 buffer_put_bignum(&msg, key->rsa->e);
590 buffer_put_bignum(&msg, key->rsa->n); 607 buffer_put_bignum(&msg, key->rsa->n);
591 } else if (key_type_plain(key->type) == KEY_DSA || 608 } else if (key_type_plain(key->type) == KEY_DSA ||
592 key_type_plain(key->type) == KEY_RSA) { 609 key_type_plain(key->type) == KEY_RSA ||
610 key_type_plain(key->type) == KEY_ECDSA) {
593 key_to_blob(key, &blob, &blen); 611 key_to_blob(key, &blob, &blen);
594 buffer_put_char(&msg, SSH2_AGENTC_REMOVE_IDENTITY); 612 buffer_put_char(&msg, SSH2_AGENTC_REMOVE_IDENTITY);
595 buffer_put_string(&msg, blob, blen); 613 buffer_put_string(&msg, blob, blen);
diff --git a/authfile.c b/authfile.c
index 2bd887845..f2aec267a 100644
--- a/authfile.c
+++ b/authfile.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: authfile.c,v 1.82 2010/08/04 05:49:22 djm Exp $ */ 1/* $OpenBSD: authfile.c,v 1.87 2010/11/29 18:57:04 markus Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -74,19 +74,18 @@ static const char authfile_id_string[] =
74 "SSH PRIVATE KEY FILE FORMAT 1.1\n"; 74 "SSH PRIVATE KEY FILE FORMAT 1.1\n";
75 75
76/* 76/*
77 * Saves the authentication (private) key in a file, encrypting it with 77 * Serialises the authentication (private) key to a blob, encrypting it with
78 * passphrase. The identification of the file (lowest 64 bits of n) will 78 * passphrase. The identification of the blob (lowest 64 bits of n) will
79 * precede the key to provide identification of the key without needing a 79 * precede the key to provide identification of the key without needing a
80 * passphrase. 80 * passphrase.
81 */ 81 */
82
83static int 82static int
84key_save_private_rsa1(Key *key, const char *filename, const char *passphrase, 83key_private_rsa1_to_blob(Key *key, Buffer *blob, const char *passphrase,
85 const char *comment) 84 const char *comment)
86{ 85{
87 Buffer buffer, encrypted; 86 Buffer buffer, encrypted;
88 u_char buf[100], *cp; 87 u_char buf[100], *cp;
89 int fd, i, cipher_num; 88 int i, cipher_num;
90 CipherContext ciphercontext; 89 CipherContext ciphercontext;
91 Cipher *cipher; 90 Cipher *cipher;
92 u_int32_t rnd; 91 u_int32_t rnd;
@@ -157,156 +156,222 @@ key_save_private_rsa1(Key *key, const char *filename, const char *passphrase,
157 memset(buf, 0, sizeof(buf)); 156 memset(buf, 0, sizeof(buf));
158 buffer_free(&buffer); 157 buffer_free(&buffer);
159 158
160 fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0600); 159 buffer_append(blob, buffer_ptr(&encrypted), buffer_len(&encrypted));
161 if (fd < 0) {
162 error("open %s failed: %s.", filename, strerror(errno));
163 buffer_free(&encrypted);
164 return 0;
165 }
166 if (atomicio(vwrite, fd, buffer_ptr(&encrypted),
167 buffer_len(&encrypted)) != buffer_len(&encrypted)) {
168 error("write to key file %s failed: %s", filename,
169 strerror(errno));
170 buffer_free(&encrypted);
171 close(fd);
172 unlink(filename);
173 return 0;
174 }
175 close(fd);
176 buffer_free(&encrypted); 160 buffer_free(&encrypted);
161
177 return 1; 162 return 1;
178} 163}
179 164
180/* save SSH v2 key in OpenSSL PEM format */ 165/* convert SSH v2 key in OpenSSL PEM format */
181static int 166static int
182key_save_private_pem(Key *key, const char *filename, const char *_passphrase, 167key_private_pem_to_blob(Key *key, Buffer *blob, const char *_passphrase,
183 const char *comment) 168 const char *comment)
184{ 169{
185 FILE *fp;
186 int fd;
187 int success = 0; 170 int success = 0;
188 int len = strlen(_passphrase); 171 int blen, len = strlen(_passphrase);
189 u_char *passphrase = (len > 0) ? (u_char *)_passphrase : NULL; 172 u_char *passphrase = (len > 0) ? (u_char *)_passphrase : NULL;
190#if (OPENSSL_VERSION_NUMBER < 0x00907000L) 173#if (OPENSSL_VERSION_NUMBER < 0x00907000L)
191 const EVP_CIPHER *cipher = (len > 0) ? EVP_des_ede3_cbc() : NULL; 174 const EVP_CIPHER *cipher = (len > 0) ? EVP_des_ede3_cbc() : NULL;
192#else 175#else
193 const EVP_CIPHER *cipher = (len > 0) ? EVP_aes_128_cbc() : NULL; 176 const EVP_CIPHER *cipher = (len > 0) ? EVP_aes_128_cbc() : NULL;
194#endif 177#endif
178 const u_char *bptr;
179 BIO *bio;
195 180
196 if (len > 0 && len <= 4) { 181 if (len > 0 && len <= 4) {
197 error("passphrase too short: have %d bytes, need > 4", len); 182 error("passphrase too short: have %d bytes, need > 4", len);
198 return 0; 183 return 0;
199 } 184 }
200 fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0600); 185 if ((bio = BIO_new(BIO_s_mem())) == NULL) {
201 if (fd < 0) { 186 error("%s: BIO_new failed", __func__);
202 error("open %s failed: %s.", filename, strerror(errno));
203 return 0;
204 }
205 fp = fdopen(fd, "w");
206 if (fp == NULL) {
207 error("fdopen %s failed: %s.", filename, strerror(errno));
208 close(fd);
209 return 0; 187 return 0;
210 } 188 }
211 switch (key->type) { 189 switch (key->type) {
212 case KEY_DSA: 190 case KEY_DSA:
213 success = PEM_write_DSAPrivateKey(fp, key->dsa, 191 success = PEM_write_bio_DSAPrivateKey(bio, key->dsa,
214 cipher, passphrase, len, NULL, NULL); 192 cipher, passphrase, len, NULL, NULL);
215 break; 193 break;
194#ifdef OPENSSL_HAS_ECC
195 case KEY_ECDSA:
196 success = PEM_write_bio_ECPrivateKey(bio, key->ecdsa,
197 cipher, passphrase, len, NULL, NULL);
198 break;
199#endif
216 case KEY_RSA: 200 case KEY_RSA:
217 success = PEM_write_RSAPrivateKey(fp, key->rsa, 201 success = PEM_write_bio_RSAPrivateKey(bio, key->rsa,
218 cipher, passphrase, len, NULL, NULL); 202 cipher, passphrase, len, NULL, NULL);
219 break; 203 break;
220 } 204 }
221 fclose(fp); 205 if (success) {
206 if ((blen = BIO_get_mem_data(bio, &bptr)) <= 0)
207 success = 0;
208 else
209 buffer_append(blob, bptr, blen);
210 }
211 BIO_free(bio);
222 return success; 212 return success;
223} 213}
224 214
225int 215/* Save a key blob to a file */
226key_save_private(Key *key, const char *filename, const char *passphrase, 216static int
217key_save_private_blob(Buffer *keybuf, const char *filename)
218{
219 int fd;
220
221 if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0) {
222 error("open %s failed: %s.", filename, strerror(errno));
223 return 0;
224 }
225 if (atomicio(vwrite, fd, buffer_ptr(keybuf),
226 buffer_len(keybuf)) != buffer_len(keybuf)) {
227 error("write to key file %s failed: %s", filename,
228 strerror(errno));
229 close(fd);
230 unlink(filename);
231 return 0;
232 }
233 close(fd);
234 return 1;
235}
236
237/* Serialise "key" to buffer "blob" */
238static int
239key_private_to_blob(Key *key, Buffer *blob, const char *passphrase,
227 const char *comment) 240 const char *comment)
228{ 241{
229 switch (key->type) { 242 switch (key->type) {
230 case KEY_RSA1: 243 case KEY_RSA1:
231 return key_save_private_rsa1(key, filename, passphrase, 244 return key_private_rsa1_to_blob(key, blob, passphrase, comment);
232 comment);
233 case KEY_DSA: 245 case KEY_DSA:
246 case KEY_ECDSA:
234 case KEY_RSA: 247 case KEY_RSA:
235 return key_save_private_pem(key, filename, passphrase, 248 return key_private_pem_to_blob(key, blob, passphrase, comment);
236 comment);
237 default: 249 default:
238 break; 250 error("%s: cannot save key type %d", __func__, key->type);
251 return 0;
239 } 252 }
240 error("key_save_private: cannot save key type %d", key->type); 253}
241 return 0; 254
255int
256key_save_private(Key *key, const char *filename, const char *passphrase,
257 const char *comment)
258{
259 Buffer keyblob;
260 int success = 0;
261
262 buffer_init(&keyblob);
263 if (!key_private_to_blob(key, &keyblob, passphrase, comment))
264 goto out;
265 if (!key_save_private_blob(&keyblob, filename))
266 goto out;
267 success = 1;
268 out:
269 buffer_free(&keyblob);
270 return success;
242} 271}
243 272
244/* 273/*
245 * Loads the public part of the ssh v1 key file. Returns NULL if an error was 274 * Parse the public, unencrypted portion of a RSA1 key.
246 * encountered (the file does not exist or is not readable), and the key
247 * otherwise.
248 */ 275 */
249
250static Key * 276static Key *
251key_load_public_rsa1(int fd, const char *filename, char **commentp) 277key_parse_public_rsa1(Buffer *blob, char **commentp)
252{ 278{
253 Buffer buffer;
254 Key *pub; 279 Key *pub;
255 struct stat st; 280
256 char *cp; 281 /* Check that it is at least big enough to contain the ID string. */
257 u_int i; 282 if (buffer_len(blob) < sizeof(authfile_id_string)) {
283 debug3("Truncated RSA1 identifier");
284 return NULL;
285 }
286
287 /*
288 * Make sure it begins with the id string. Consume the id string
289 * from the buffer.
290 */
291 if (memcmp(buffer_ptr(blob), authfile_id_string,
292 sizeof(authfile_id_string)) != 0) {
293 debug3("Incorrect RSA1 identifier");
294 return NULL;
295 }
296 buffer_consume(blob, sizeof(authfile_id_string));
297
298 /* Skip cipher type and reserved data. */
299 (void) buffer_get_char(blob); /* cipher type */
300 (void) buffer_get_int(blob); /* reserved */
301
302 /* Read the public key from the buffer. */
303 (void) buffer_get_int(blob);
304 pub = key_new(KEY_RSA1);
305 buffer_get_bignum(blob, pub->rsa->n);
306 buffer_get_bignum(blob, pub->rsa->e);
307 if (commentp)
308 *commentp = buffer_get_string(blob, NULL);
309 /* The encrypted private part is not parsed by this function. */
310 buffer_clear(blob);
311
312 return pub;
313}
314
315/* Load the contents of a key file into a buffer */
316static int
317key_load_file(int fd, const char *filename, Buffer *blob)
318{
258 size_t len; 319 size_t len;
320 u_char *cp;
321 struct stat st;
259 322
260 if (fstat(fd, &st) < 0) { 323 if (fstat(fd, &st) < 0) {
261 error("fstat for key file %.200s failed: %.100s", 324 error("%s: fstat of key file %.200s%sfailed: %.100s", __func__,
262 filename, strerror(errno)); 325 filename == NULL ? "" : filename,
263 return NULL; 326 filename == NULL ? "" : " ",
327 strerror(errno));
328 close(fd);
329 return 0;
264 } 330 }
265 if (st.st_size > 1*1024*1024) { 331 if (st.st_size > 1*1024*1024) {
266 error("key file %.200s too large", filename); 332 error("%s: key file %.200s%stoo large", __func__,
267 return NULL; 333 filename == NULL ? "" : filename,
334 filename == NULL ? "" : " ");
335 close(fd);
336 return 0;
268 } 337 }
269 len = (size_t)st.st_size; /* truncated */ 338 len = (size_t)st.st_size; /* truncated */
270 339
271 buffer_init(&buffer); 340 buffer_init(blob);
272 cp = buffer_append_space(&buffer, len); 341 cp = buffer_append_space(blob, len);
273 342
274 if (atomicio(read, fd, cp, len) != len) { 343 if (atomicio(read, fd, cp, len) != len) {
275 debug("Read from key file %.200s failed: %.100s", filename, 344 debug("%s: read from key file %.200s%sfailed: %.100s", __func__,
345 filename == NULL ? "" : filename,
346 filename == NULL ? "" : " ",
276 strerror(errno)); 347 strerror(errno));
277 buffer_free(&buffer); 348 buffer_clear(blob);
278 return NULL; 349 close(fd);
350 return 0;
279 } 351 }
352 return 1;
353}
280 354
281 /* Check that it is at least big enough to contain the ID string. */ 355/*
282 if (len < sizeof(authfile_id_string)) { 356 * Loads the public part of the ssh v1 key file. Returns NULL if an error was
283 debug3("Not a RSA1 key file %.200s.", filename); 357 * encountered (the file does not exist or is not readable), and the key
358 * otherwise.
359 */
360static Key *
361key_load_public_rsa1(int fd, const char *filename, char **commentp)
362{
363 Buffer buffer;
364 Key *pub;
365
366 buffer_init(&buffer);
367 if (!key_load_file(fd, filename, &buffer)) {
284 buffer_free(&buffer); 368 buffer_free(&buffer);
285 return NULL; 369 return NULL;
286 } 370 }
287 /*
288 * Make sure it begins with the id string. Consume the id string
289 * from the buffer.
290 */
291 for (i = 0; i < sizeof(authfile_id_string); i++)
292 if (buffer_get_char(&buffer) != authfile_id_string[i]) {
293 debug3("Not a RSA1 key file %.200s.", filename);
294 buffer_free(&buffer);
295 return NULL;
296 }
297 /* Skip cipher type and reserved data. */
298 (void) buffer_get_char(&buffer); /* cipher type */
299 (void) buffer_get_int(&buffer); /* reserved */
300
301 /* Read the public key from the buffer. */
302 (void) buffer_get_int(&buffer);
303 pub = key_new(KEY_RSA1);
304 buffer_get_bignum(&buffer, pub->rsa->n);
305 buffer_get_bignum(&buffer, pub->rsa->e);
306 if (commentp)
307 *commentp = buffer_get_string(&buffer, NULL);
308 /* The encrypted private part is not parsed by this function. */
309 371
372 pub = key_parse_public_rsa1(&buffer, commentp);
373 if (pub == NULL)
374 debug3("Could not load \"%s\" as a RSA1 public key", filename);
310 buffer_free(&buffer); 375 buffer_free(&buffer);
311 return pub; 376 return pub;
312} 377}
@@ -329,113 +394,73 @@ key_load_public_type(int type, const char *filename, char **commentp)
329 return NULL; 394 return NULL;
330} 395}
331 396
332/*
333 * Loads the private key from the file. Returns 0 if an error is encountered
334 * (file does not exist or is not readable, or passphrase is bad). This
335 * initializes the private key.
336 * Assumes we are called under uid of the owner of the file.
337 */
338
339static Key * 397static Key *
340key_load_private_rsa1(int fd, const char *filename, const char *passphrase, 398key_parse_private_rsa1(Buffer *blob, const char *passphrase, char **commentp)
341 char **commentp)
342{ 399{
343 u_int i;
344 int check1, check2, cipher_type; 400 int check1, check2, cipher_type;
345 size_t len; 401 Buffer decrypted;
346 Buffer buffer, decrypted;
347 u_char *cp; 402 u_char *cp;
348 CipherContext ciphercontext; 403 CipherContext ciphercontext;
349 Cipher *cipher; 404 Cipher *cipher;
350 Key *prv = NULL; 405 Key *prv = NULL;
351 struct stat st;
352
353 if (fstat(fd, &st) < 0) {
354 error("fstat for key file %.200s failed: %.100s",
355 filename, strerror(errno));
356 close(fd);
357 return NULL;
358 }
359 if (st.st_size > 1*1024*1024) {
360 error("key file %.200s too large", filename);
361 close(fd);
362 return (NULL);
363 }
364 len = (size_t)st.st_size; /* truncated */
365
366 buffer_init(&buffer);
367 cp = buffer_append_space(&buffer, len);
368
369 if (atomicio(read, fd, cp, len) != len) {
370 debug("Read from key file %.200s failed: %.100s", filename,
371 strerror(errno));
372 buffer_free(&buffer);
373 close(fd);
374 return NULL;
375 }
376 406
377 /* Check that it is at least big enough to contain the ID string. */ 407 /* Check that it is at least big enough to contain the ID string. */
378 if (len < sizeof(authfile_id_string)) { 408 if (buffer_len(blob) < sizeof(authfile_id_string)) {
379 debug3("Not a RSA1 key file %.200s.", filename); 409 debug3("Truncated RSA1 identifier");
380 buffer_free(&buffer);
381 close(fd);
382 return NULL; 410 return NULL;
383 } 411 }
412
384 /* 413 /*
385 * Make sure it begins with the id string. Consume the id string 414 * Make sure it begins with the id string. Consume the id string
386 * from the buffer. 415 * from the buffer.
387 */ 416 */
388 for (i = 0; i < sizeof(authfile_id_string); i++) 417 if (memcmp(buffer_ptr(blob), authfile_id_string,
389 if (buffer_get_char(&buffer) != authfile_id_string[i]) { 418 sizeof(authfile_id_string)) != 0) {
390 debug3("Not a RSA1 key file %.200s.", filename); 419 debug3("Incorrect RSA1 identifier");
391 buffer_free(&buffer); 420 return NULL;
392 close(fd); 421 }
393 return NULL; 422 buffer_consume(blob, sizeof(authfile_id_string));
394 }
395 423
396 /* Read cipher type. */ 424 /* Read cipher type. */
397 cipher_type = buffer_get_char(&buffer); 425 cipher_type = buffer_get_char(blob);
398 (void) buffer_get_int(&buffer); /* Reserved data. */ 426 (void) buffer_get_int(blob); /* Reserved data. */
399 427
400 /* Read the public key from the buffer. */ 428 /* Read the public key from the buffer. */
401 (void) buffer_get_int(&buffer); 429 (void) buffer_get_int(blob);
402 prv = key_new_private(KEY_RSA1); 430 prv = key_new_private(KEY_RSA1);
403 431
404 buffer_get_bignum(&buffer, prv->rsa->n); 432 buffer_get_bignum(blob, prv->rsa->n);
405 buffer_get_bignum(&buffer, prv->rsa->e); 433 buffer_get_bignum(blob, prv->rsa->e);
406 if (commentp) 434 if (commentp)
407 *commentp = buffer_get_string(&buffer, NULL); 435 *commentp = buffer_get_string(blob, NULL);
408 else 436 else
409 xfree(buffer_get_string(&buffer, NULL)); 437 (void)buffer_get_string_ptr(blob, NULL);
410 438
411 /* Check that it is a supported cipher. */ 439 /* Check that it is a supported cipher. */
412 cipher = cipher_by_number(cipher_type); 440 cipher = cipher_by_number(cipher_type);
413 if (cipher == NULL) { 441 if (cipher == NULL) {
414 debug("Unsupported cipher %d used in key file %.200s.", 442 debug("Unsupported RSA1 cipher %d", cipher_type);
415 cipher_type, filename);
416 buffer_free(&buffer);
417 goto fail; 443 goto fail;
418 } 444 }
419 /* Initialize space for decrypted data. */ 445 /* Initialize space for decrypted data. */
420 buffer_init(&decrypted); 446 buffer_init(&decrypted);
421 cp = buffer_append_space(&decrypted, buffer_len(&buffer)); 447 cp = buffer_append_space(&decrypted, buffer_len(blob));
422 448
423 /* Rest of the buffer is encrypted. Decrypt it using the passphrase. */ 449 /* Rest of the buffer is encrypted. Decrypt it using the passphrase. */
424 cipher_set_key_string(&ciphercontext, cipher, passphrase, 450 cipher_set_key_string(&ciphercontext, cipher, passphrase,
425 CIPHER_DECRYPT); 451 CIPHER_DECRYPT);
426 cipher_crypt(&ciphercontext, cp, 452 cipher_crypt(&ciphercontext, cp,
427 buffer_ptr(&buffer), buffer_len(&buffer)); 453 buffer_ptr(blob), buffer_len(blob));
428 cipher_cleanup(&ciphercontext); 454 cipher_cleanup(&ciphercontext);
429 memset(&ciphercontext, 0, sizeof(ciphercontext)); 455 memset(&ciphercontext, 0, sizeof(ciphercontext));
430 buffer_free(&buffer); 456 buffer_clear(blob);
431 457
432 check1 = buffer_get_char(&decrypted); 458 check1 = buffer_get_char(&decrypted);
433 check2 = buffer_get_char(&decrypted); 459 check2 = buffer_get_char(&decrypted);
434 if (check1 != buffer_get_char(&decrypted) || 460 if (check1 != buffer_get_char(&decrypted) ||
435 check2 != buffer_get_char(&decrypted)) { 461 check2 != buffer_get_char(&decrypted)) {
436 if (strcmp(passphrase, "") != 0) 462 if (strcmp(passphrase, "") != 0)
437 debug("Bad passphrase supplied for key file %.200s.", 463 debug("Bad passphrase supplied for RSA1 key");
438 filename);
439 /* Bad passphrase. */ 464 /* Bad passphrase. */
440 buffer_free(&decrypted); 465 buffer_free(&decrypted);
441 goto fail; 466 goto fail;
@@ -454,38 +479,37 @@ key_load_private_rsa1(int fd, const char *filename, const char *passphrase,
454 479
455 /* enable blinding */ 480 /* enable blinding */
456 if (RSA_blinding_on(prv->rsa, NULL) != 1) { 481 if (RSA_blinding_on(prv->rsa, NULL) != 1) {
457 error("key_load_private_rsa1: RSA_blinding_on failed"); 482 error("%s: RSA_blinding_on failed", __func__);
458 goto fail; 483 goto fail;
459 } 484 }
460 close(fd);
461 return prv; 485 return prv;
462 486
463fail: 487fail:
464 if (commentp) 488 if (commentp)
465 xfree(*commentp); 489 xfree(*commentp);
466 close(fd);
467 key_free(prv); 490 key_free(prv);
468 return NULL; 491 return NULL;
469} 492}
470 493
471Key * 494static Key *
472key_load_private_pem(int fd, int type, const char *passphrase, 495key_parse_private_pem(Buffer *blob, int type, const char *passphrase,
473 char **commentp) 496 char **commentp)
474{ 497{
475 FILE *fp;
476 EVP_PKEY *pk = NULL; 498 EVP_PKEY *pk = NULL;
477 Key *prv = NULL; 499 Key *prv = NULL;
478 char *name = "<no key>"; 500 char *name = "<no key>";
501 BIO *bio;
479 502
480 fp = fdopen(fd, "r"); 503 if ((bio = BIO_new_mem_buf(buffer_ptr(blob),
481 if (fp == NULL) { 504 buffer_len(blob))) == NULL) {
482 error("fdopen failed: %s", strerror(errno)); 505 error("%s: BIO_new_mem_buf failed", __func__);
483 close(fd);
484 return NULL; 506 return NULL;
485 } 507 }
486 pk = PEM_read_PrivateKey(fp, NULL, NULL, (char *)passphrase); 508
509 pk = PEM_read_bio_PrivateKey(bio, NULL, NULL, (char *)passphrase);
510 BIO_free(bio);
487 if (pk == NULL) { 511 if (pk == NULL) {
488 debug("PEM_read_PrivateKey failed"); 512 debug("%s: PEM_read_PrivateKey failed", __func__);
489 (void)ERR_get_error(); 513 (void)ERR_get_error();
490 } else if (pk->type == EVP_PKEY_RSA && 514 } else if (pk->type == EVP_PKEY_RSA &&
491 (type == KEY_UNSPEC||type==KEY_RSA)) { 515 (type == KEY_UNSPEC||type==KEY_RSA)) {
@@ -497,7 +521,7 @@ key_load_private_pem(int fd, int type, const char *passphrase,
497 RSA_print_fp(stderr, prv->rsa, 8); 521 RSA_print_fp(stderr, prv->rsa, 8);
498#endif 522#endif
499 if (RSA_blinding_on(prv->rsa, NULL) != 1) { 523 if (RSA_blinding_on(prv->rsa, NULL) != 1) {
500 error("key_load_private_pem: RSA_blinding_on failed"); 524 error("%s: RSA_blinding_on failed", __func__);
501 key_free(prv); 525 key_free(prv);
502 prv = NULL; 526 prv = NULL;
503 } 527 }
@@ -510,11 +534,31 @@ key_load_private_pem(int fd, int type, const char *passphrase,
510#ifdef DEBUG_PK 534#ifdef DEBUG_PK
511 DSA_print_fp(stderr, prv->dsa, 8); 535 DSA_print_fp(stderr, prv->dsa, 8);
512#endif 536#endif
537#ifdef OPENSSL_HAS_ECC
538 } else if (pk->type == EVP_PKEY_EC &&
539 (type == KEY_UNSPEC||type==KEY_ECDSA)) {
540 prv = key_new(KEY_UNSPEC);
541 prv->ecdsa = EVP_PKEY_get1_EC_KEY(pk);
542 prv->type = KEY_ECDSA;
543 if ((prv->ecdsa_nid = key_ecdsa_key_to_nid(prv->ecdsa)) == -1 ||
544 key_curve_nid_to_name(prv->ecdsa_nid) == NULL ||
545 key_ec_validate_public(EC_KEY_get0_group(prv->ecdsa),
546 EC_KEY_get0_public_key(prv->ecdsa)) != 0 ||
547 key_ec_validate_private(prv->ecdsa) != 0) {
548 error("%s: bad ECDSA key", __func__);
549 key_free(prv);
550 prv = NULL;
551 }
552 name = "ecdsa w/o comment";
553#ifdef DEBUG_PK
554 if (prv != NULL && prv->ecdsa != NULL)
555 key_dump_ec_key(prv->ecdsa);
556#endif
557#endif /* OPENSSL_HAS_ECC */
513 } else { 558 } else {
514 error("PEM_read_PrivateKey: mismatch or " 559 error("%s: PEM_read_PrivateKey: mismatch or "
515 "unknown EVP_PKEY save_type %d", pk->save_type); 560 "unknown EVP_PKEY save_type %d", __func__, pk->save_type);
516 } 561 }
517 fclose(fp);
518 if (pk != NULL) 562 if (pk != NULL)
519 EVP_PKEY_free(pk); 563 EVP_PKEY_free(pk);
520 if (prv != NULL && commentp) 564 if (prv != NULL && commentp)
@@ -524,6 +568,23 @@ key_load_private_pem(int fd, int type, const char *passphrase,
524 return prv; 568 return prv;
525} 569}
526 570
571Key *
572key_load_private_pem(int fd, int type, const char *passphrase,
573 char **commentp)
574{
575 Buffer buffer;
576 Key *prv;
577
578 buffer_init(&buffer);
579 if (!key_load_file(fd, NULL, &buffer)) {
580 buffer_free(&buffer);
581 return NULL;
582 }
583 prv = key_parse_private_pem(&buffer, type, passphrase, commentp);
584 buffer_free(&buffer);
585 return prv;
586}
587
527int 588int
528key_perm_ok(int fd, const char *filename) 589key_perm_ok(int fd, const char *filename)
529{ 590{
@@ -552,11 +613,31 @@ key_perm_ok(int fd, const char *filename)
552 return 1; 613 return 1;
553} 614}
554 615
616static Key *
617key_parse_private_type(Buffer *blob, int type, const char *passphrase,
618 char **commentp)
619{
620 switch (type) {
621 case KEY_RSA1:
622 return key_parse_private_rsa1(blob, passphrase, commentp);
623 case KEY_DSA:
624 case KEY_ECDSA:
625 case KEY_RSA:
626 case KEY_UNSPEC:
627 return key_parse_private_pem(blob, type, passphrase, commentp);
628 default:
629 break;
630 }
631 return NULL;
632}
633
555Key * 634Key *
556key_load_private_type(int type, const char *filename, const char *passphrase, 635key_load_private_type(int type, const char *filename, const char *passphrase,
557 char **commentp, int *perm_ok) 636 char **commentp, int *perm_ok)
558{ 637{
559 int fd; 638 int fd;
639 Key *ret;
640 Buffer buffer;
560 641
561 fd = open(filename, O_RDONLY); 642 fd = open(filename, O_RDONLY);
562 if (fd < 0) { 643 if (fd < 0) {
@@ -575,21 +656,17 @@ key_load_private_type(int type, const char *filename, const char *passphrase,
575 } 656 }
576 if (perm_ok != NULL) 657 if (perm_ok != NULL)
577 *perm_ok = 1; 658 *perm_ok = 1;
578 switch (type) { 659
579 case KEY_RSA1: 660 buffer_init(&buffer);
580 return key_load_private_rsa1(fd, filename, passphrase, 661 if (!key_load_file(fd, filename, &buffer)) {
581 commentp); 662 buffer_free(&buffer);
582 /* closes fd */
583 case KEY_DSA:
584 case KEY_RSA:
585 case KEY_UNSPEC:
586 return key_load_private_pem(fd, type, passphrase, commentp);
587 /* closes fd */
588 default:
589 close(fd); 663 close(fd);
590 break; 664 return NULL;
591 } 665 }
592 return NULL; 666 close(fd);
667 ret = key_parse_private_type(&buffer, type, passphrase, commentp);
668 buffer_free(&buffer);
669 return ret;
593} 670}
594 671
595Key * 672Key *
@@ -597,6 +674,7 @@ key_load_private(const char *filename, const char *passphrase,
597 char **commentp) 674 char **commentp)
598{ 675{
599 Key *pub, *prv; 676 Key *pub, *prv;
677 Buffer buffer, pubcopy;
600 int fd; 678 int fd;
601 679
602 fd = open(filename, O_RDONLY); 680 fd = open(filename, O_RDONLY);
@@ -610,20 +688,33 @@ key_load_private(const char *filename, const char *passphrase,
610 close(fd); 688 close(fd);
611 return NULL; 689 return NULL;
612 } 690 }
613 pub = key_load_public_rsa1(fd, filename, commentp); 691
614 lseek(fd, (off_t) 0, SEEK_SET); /* rewind */ 692 buffer_init(&buffer);
693 if (!key_load_file(fd, filename, &buffer)) {
694 buffer_free(&buffer);
695 close(fd);
696 return NULL;
697 }
698 close(fd);
699
700 buffer_init(&pubcopy);
701 buffer_append(&pubcopy, buffer_ptr(&buffer), buffer_len(&buffer));
702 /* it's a SSH v1 key if the public key part is readable */
703 pub = key_parse_public_rsa1(&pubcopy, commentp);
704 buffer_free(&pubcopy);
615 if (pub == NULL) { 705 if (pub == NULL) {
616 /* closes fd */ 706 prv = key_parse_private_type(&buffer, KEY_UNSPEC,
617 prv = key_load_private_pem(fd, KEY_UNSPEC, passphrase, NULL); 707 passphrase, NULL);
618 /* use the filename as a comment for PEM */ 708 /* use the filename as a comment for PEM */
619 if (commentp && prv) 709 if (commentp && prv)
620 *commentp = xstrdup(filename); 710 *commentp = xstrdup(filename);
621 } else { 711 } else {
622 /* it's a SSH v1 key if the public key part is readable */
623 key_free(pub); 712 key_free(pub);
624 /* closes fd */ 713 /* key_parse_public_rsa1() has already loaded the comment */
625 prv = key_load_private_rsa1(fd, filename, passphrase, NULL); 714 prv = key_parse_private_type(&buffer, KEY_RSA1, passphrase,
715 NULL);
626 } 716 }
717 buffer_free(&buffer);
627 return prv; 718 return prv;
628} 719}
629 720
@@ -721,6 +812,7 @@ key_load_private_cert(int type, const char *filename, const char *passphrase,
721 switch (type) { 812 switch (type) {
722 case KEY_RSA: 813 case KEY_RSA:
723 case KEY_DSA: 814 case KEY_DSA:
815 case KEY_ECDSA:
724 break; 816 break;
725 default: 817 default:
726 error("%s: unsupported key type", __func__); 818 error("%s: unsupported key type", __func__);
diff --git a/bufaux.c b/bufaux.c
index 854fd510a..00208ca27 100644
--- a/bufaux.c
+++ b/bufaux.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bufaux.c,v 1.49 2010/03/26 03:13:17 djm Exp $ */ 1/* $OpenBSD: bufaux.c,v 1.50 2010/08/31 09:58:37 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -202,6 +202,39 @@ buffer_get_string(Buffer *buffer, u_int *length_ptr)
202 return (ret); 202 return (ret);
203} 203}
204 204
205char *
206buffer_get_cstring_ret(Buffer *buffer, u_int *length_ptr)
207{
208 u_int length;
209 char *cp, *ret = buffer_get_string_ret(buffer, &length);
210
211 if (ret == NULL)
212 return NULL;
213 if ((cp = memchr(ret, '\0', length)) != NULL) {
214 /* XXX allow \0 at end-of-string for a while, remove later */
215 if (cp == ret + length - 1)
216 error("buffer_get_cstring_ret: string contains \\0");
217 else {
218 bzero(ret, length);
219 xfree(ret);
220 return NULL;
221 }
222 }
223 if (length_ptr != NULL)
224 *length_ptr = length;
225 return ret;
226}
227
228char *
229buffer_get_cstring(Buffer *buffer, u_int *length_ptr)
230{
231 char *ret;
232
233 if ((ret = buffer_get_cstring_ret(buffer, length_ptr)) == NULL)
234 fatal("buffer_get_cstring: buffer error");
235 return ret;
236}
237
205void * 238void *
206buffer_get_string_ptr_ret(Buffer *buffer, u_int *length_ptr) 239buffer_get_string_ptr_ret(Buffer *buffer, u_int *length_ptr)
207{ 240{
diff --git a/bufec.c b/bufec.c
new file mode 100644
index 000000000..3dcb49477
--- /dev/null
+++ b/bufec.c
@@ -0,0 +1,146 @@
1/* $OpenBSD: bufec.c,v 1.1 2010/08/31 11:54:45 djm Exp $ */
2/*
3 * Copyright (c) 2010 Damien Miller <djm@mindrot.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include "includes.h"
19
20#ifdef OPENSSL_HAS_ECC
21
22#include <sys/types.h>
23
24#include <openssl/bn.h>
25#include <openssl/ec.h>
26
27#include <string.h>
28#include <stdarg.h>
29
30#include "xmalloc.h"
31#include "buffer.h"
32#include "log.h"
33#include "misc.h"
34
35/*
36 * Maximum supported EC GFp field length is 528 bits. SEC1 uncompressed
37 * encoding represents this as two bitstring points that should each
38 * be no longer than the field length, SEC1 specifies a 1 byte
39 * point type header.
40 * Being paranoid here may insulate us to parsing problems in
41 * EC_POINT_oct2point.
42 */
43#define BUFFER_MAX_ECPOINT_LEN ((528*2 / 8) + 1)
44
45/*
46 * Append an EC_POINT to the buffer as a string containing a SEC1 encoded
47 * uncompressed point. Fortunately OpenSSL handles the gory details for us.
48 */
49int
50buffer_put_ecpoint_ret(Buffer *buffer, const EC_GROUP *curve,
51 const EC_POINT *point)
52{
53 u_char *buf = NULL;
54 size_t len;
55 BN_CTX *bnctx;
56 int ret = -1;
57
58 /* Determine length */
59 if ((bnctx = BN_CTX_new()) == NULL)
60 fatal("%s: BN_CTX_new failed", __func__);
61 len = EC_POINT_point2oct(curve, point, POINT_CONVERSION_UNCOMPRESSED,
62 NULL, 0, bnctx);
63 if (len > BUFFER_MAX_ECPOINT_LEN) {
64 error("%s: giant EC point: len = %lu (max %u)",
65 __func__, (u_long)len, BUFFER_MAX_ECPOINT_LEN);
66 goto out;
67 }
68 /* Convert */
69 buf = xmalloc(len);
70 if (EC_POINT_point2oct(curve, point, POINT_CONVERSION_UNCOMPRESSED,
71 buf, len, bnctx) != len) {
72 error("%s: EC_POINT_point2oct length mismatch", __func__);
73 goto out;
74 }
75 /* Append */
76 buffer_put_string(buffer, buf, len);
77 ret = 0;
78 out:
79 if (buf != NULL) {
80 bzero(buf, len);
81 xfree(buf);
82 }
83 BN_CTX_free(bnctx);
84 return ret;
85}
86
87void
88buffer_put_ecpoint(Buffer *buffer, const EC_GROUP *curve,
89 const EC_POINT *point)
90{
91 if (buffer_put_ecpoint_ret(buffer, curve, point) == -1)
92 fatal("%s: buffer error", __func__);
93}
94
95int
96buffer_get_ecpoint_ret(Buffer *buffer, const EC_GROUP *curve,
97 EC_POINT *point)
98{
99 u_char *buf;
100 u_int len;
101 BN_CTX *bnctx;
102 int ret = -1;
103
104 if ((buf = buffer_get_string_ret(buffer, &len)) == NULL) {
105 error("%s: invalid point", __func__);
106 return -1;
107 }
108 if ((bnctx = BN_CTX_new()) == NULL)
109 fatal("%s: BN_CTX_new failed", __func__);
110 if (len > BUFFER_MAX_ECPOINT_LEN) {
111 error("%s: EC_POINT too long: %u > max %u", __func__,
112 len, BUFFER_MAX_ECPOINT_LEN);
113 goto out;
114 }
115 if (len == 0) {
116 error("%s: EC_POINT buffer is empty", __func__);
117 goto out;
118 }
119 if (buf[0] != POINT_CONVERSION_UNCOMPRESSED) {
120 error("%s: EC_POINT is in an incorrect form: "
121 "0x%02x (want 0x%02x)", __func__, buf[0],
122 POINT_CONVERSION_UNCOMPRESSED);
123 goto out;
124 }
125 if (EC_POINT_oct2point(curve, point, buf, len, bnctx) != 1) {
126 error("buffer_get_bignum2_ret: BN_bin2bn failed");
127 goto out;
128 }
129 /* EC_POINT_oct2point verifies that the point is on the curve for us */
130 ret = 0;
131 out:
132 BN_CTX_free(bnctx);
133 bzero(buf, len);
134 xfree(buf);
135 return ret;
136}
137
138void
139buffer_get_ecpoint(Buffer *buffer, const EC_GROUP *curve,
140 EC_POINT *point)
141{
142 if (buffer_get_ecpoint_ret(buffer, curve, point) == -1)
143 fatal("%s: buffer error", __func__);
144}
145
146#endif /* OPENSSL_HAS_ECC */
diff --git a/buffer.h b/buffer.h
index 4ef4f80b3..e2a9dd100 100644
--- a/buffer.h
+++ b/buffer.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: buffer.h,v 1.19 2010/02/09 03:56:28 djm Exp $ */ 1/* $OpenBSD: buffer.h,v 1.21 2010/08/31 11:54:45 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -68,6 +68,7 @@ void buffer_put_char(Buffer *, int);
68void *buffer_get_string(Buffer *, u_int *); 68void *buffer_get_string(Buffer *, u_int *);
69void *buffer_get_string_ptr(Buffer *, u_int *); 69void *buffer_get_string_ptr(Buffer *, u_int *);
70void buffer_put_string(Buffer *, const void *, u_int); 70void buffer_put_string(Buffer *, const void *, u_int);
71char *buffer_get_cstring(Buffer *, u_int *);
71void buffer_put_cstring(Buffer *, const char *); 72void buffer_put_cstring(Buffer *, const char *);
72 73
73#define buffer_skip_string(b) \ 74#define buffer_skip_string(b) \
@@ -81,7 +82,17 @@ int buffer_get_short_ret(u_short *, Buffer *);
81int buffer_get_int_ret(u_int *, Buffer *); 82int buffer_get_int_ret(u_int *, Buffer *);
82int buffer_get_int64_ret(u_int64_t *, Buffer *); 83int buffer_get_int64_ret(u_int64_t *, Buffer *);
83void *buffer_get_string_ret(Buffer *, u_int *); 84void *buffer_get_string_ret(Buffer *, u_int *);
85char *buffer_get_cstring_ret(Buffer *, u_int *);
84void *buffer_get_string_ptr_ret(Buffer *, u_int *); 86void *buffer_get_string_ptr_ret(Buffer *, u_int *);
85int buffer_get_char_ret(char *, Buffer *); 87int buffer_get_char_ret(char *, Buffer *);
86 88
89#ifdef OPENSSL_HAS_ECC
90#include <openssl/ec.h>
91
92int buffer_put_ecpoint_ret(Buffer *, const EC_GROUP *, const EC_POINT *);
93void buffer_put_ecpoint(Buffer *, const EC_GROUP *, const EC_POINT *);
94int buffer_get_ecpoint_ret(Buffer *, const EC_GROUP *, EC_POINT *);
95void buffer_get_ecpoint(Buffer *, const EC_GROUP *, EC_POINT *);
96#endif
97
87#endif /* BUFFER_H */ 98#endif /* BUFFER_H */
diff --git a/canohost.c b/canohost.c
index ef94d9155..dabd8a31a 100644
--- a/canohost.c
+++ b/canohost.c
@@ -199,7 +199,7 @@ ipv64_normalise_mapped(struct sockaddr_storage *addr, socklen_t *len)
199 memcpy(&inaddr, ((char *)&a6->sin6_addr) + 12, sizeof(inaddr)); 199 memcpy(&inaddr, ((char *)&a6->sin6_addr) + 12, sizeof(inaddr));
200 port = a6->sin6_port; 200 port = a6->sin6_port;
201 201
202 memset(addr, 0, sizeof(*a4)); 202 bzero(a4, sizeof(*a4));
203 203
204 a4->sin_family = AF_INET; 204 a4->sin_family = AF_INET;
205 *len = sizeof(*a4); 205 *len = sizeof(*a4);
diff --git a/channels.c b/channels.c
index 1cd5004c4..6abe2d012 100644
--- a/channels.c
+++ b/channels.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: channels.c,v 1.309 2010/08/05 13:08:42 djm Exp $ */ 1/* $OpenBSD: channels.c,v 1.310 2010/11/24 01:24:14 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -373,9 +373,6 @@ channel_close_fd(int *fdp)
373static void 373static void
374channel_close_fds(Channel *c) 374channel_close_fds(Channel *c)
375{ 375{
376 debug3("channel %d: close_fds r %d w %d e %d",
377 c->self, c->rfd, c->wfd, c->efd);
378
379 channel_close_fd(&c->sock); 376 channel_close_fd(&c->sock);
380 channel_close_fd(&c->rfd); 377 channel_close_fd(&c->rfd);
381 channel_close_fd(&c->wfd); 378 channel_close_fd(&c->wfd);
diff --git a/cipher-3des1.c b/cipher-3des1.c
index 17a13a133..b7aa588cd 100644
--- a/cipher-3des1.c
+++ b/cipher-3des1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cipher-3des1.c,v 1.6 2006/08/03 03:34:42 deraadt Exp $ */ 1/* $OpenBSD: cipher-3des1.c,v 1.7 2010/10/01 23:05:32 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2003 Markus Friedl. All rights reserved. 3 * Copyright (c) 2003 Markus Friedl. All rights reserved.
4 * 4 *
@@ -103,7 +103,8 @@ ssh1_3des_init(EVP_CIPHER_CTX *ctx, const u_char *key, const u_char *iv,
103} 103}
104 104
105static int 105static int
106ssh1_3des_cbc(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src, u_int len) 106ssh1_3des_cbc(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src,
107 LIBCRYPTO_EVP_INL_TYPE len)
107{ 108{
108 struct ssh1_3des_ctx *c; 109 struct ssh1_3des_ctx *c;
109 110
diff --git a/cipher-acss.c b/cipher-acss.c
index cb0bf736c..e755f92b9 100644
--- a/cipher-acss.c
+++ b/cipher-acss.c
@@ -23,6 +23,7 @@
23#if !defined(EVP_CTRL_SET_ACSS_MODE) && (OPENSSL_VERSION_NUMBER >= 0x00907000L) 23#if !defined(EVP_CTRL_SET_ACSS_MODE) && (OPENSSL_VERSION_NUMBER >= 0x00907000L)
24 24
25#include "acss.h" 25#include "acss.h"
26#include "openbsd-compat/openssl-compat.h"
26 27
27#define data(ctx) ((EVP_ACSS_KEY *)(ctx)->cipher_data) 28#define data(ctx) ((EVP_ACSS_KEY *)(ctx)->cipher_data)
28 29
@@ -43,7 +44,7 @@ acss_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
43 44
44static int 45static int
45acss_ciph(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, 46acss_ciph(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in,
46 unsigned int inl) 47 LIBCRYPTO_EVP_INL_TYPE inl)
47{ 48{
48 acss(&data(ctx)->ks,inl,in,out); 49 acss(&data(ctx)->ks,inl,in,out);
49 return 1; 50 return 1;
diff --git a/cipher-aes.c b/cipher-aes.c
index 3ea594969..bfda6d2f2 100644
--- a/cipher-aes.c
+++ b/cipher-aes.c
@@ -72,7 +72,7 @@ ssh_rijndael_init(EVP_CIPHER_CTX *ctx, const u_char *key, const u_char *iv,
72 72
73static int 73static int
74ssh_rijndael_cbc(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src, 74ssh_rijndael_cbc(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src,
75 u_int len) 75 LIBCRYPTO_EVP_INL_TYPE len)
76{ 76{
77 struct ssh_rijndael_ctx *c; 77 struct ssh_rijndael_ctx *c;
78 u_char buf[RIJNDAEL_BLOCKSIZE]; 78 u_char buf[RIJNDAEL_BLOCKSIZE];
diff --git a/cipher-bf1.c b/cipher-bf1.c
index e0e33b4c0..309509dd7 100644
--- a/cipher-bf1.c
+++ b/cipher-bf1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cipher-bf1.c,v 1.5 2006/08/03 03:34:42 deraadt Exp $ */ 1/* $OpenBSD: cipher-bf1.c,v 1.6 2010/10/01 23:05:32 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2003 Markus Friedl. All rights reserved. 3 * Copyright (c) 2003 Markus Friedl. All rights reserved.
4 * 4 *
@@ -76,10 +76,12 @@ static void bf_ssh1_init (EVP_CIPHER_CTX * ctx, const unsigned char *key,
76} 76}
77#endif 77#endif
78 78
79static int (*orig_bf)(EVP_CIPHER_CTX *, u_char *, const u_char *, u_int) = NULL; 79static int (*orig_bf)(EVP_CIPHER_CTX *, u_char *,
80 const u_char *, LIBCRYPTO_EVP_INL_TYPE) = NULL;
80 81
81static int 82static int
82bf_ssh1_cipher(EVP_CIPHER_CTX *ctx, u_char *out, const u_char *in, u_int len) 83bf_ssh1_cipher(EVP_CIPHER_CTX *ctx, u_char *out, const u_char *in,
84 LIBCRYPTO_EVP_INL_TYPE len)
83{ 85{
84 int ret; 86 int ret;
85 87
diff --git a/cipher-ctr.c b/cipher-ctr.c
index 3b86cc10b..04975b4b6 100644
--- a/cipher-ctr.c
+++ b/cipher-ctr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cipher-ctr.c,v 1.10 2006/08/03 03:34:42 deraadt Exp $ */ 1/* $OpenBSD: cipher-ctr.c,v 1.11 2010/10/01 23:05:32 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2003 Markus Friedl <markus@openbsd.org> 3 * Copyright (c) 2003 Markus Friedl <markus@openbsd.org>
4 * 4 *
@@ -34,7 +34,7 @@
34#endif 34#endif
35 35
36const EVP_CIPHER *evp_aes_128_ctr(void); 36const EVP_CIPHER *evp_aes_128_ctr(void);
37void ssh_aes_ctr_iv(EVP_CIPHER_CTX *, int, u_char *, u_int); 37void ssh_aes_ctr_iv(EVP_CIPHER_CTX *, int, u_char *, size_t);
38 38
39struct ssh_aes_ctr_ctx 39struct ssh_aes_ctr_ctx
40{ 40{
@@ -48,7 +48,7 @@ struct ssh_aes_ctr_ctx
48 * (LSB at ctr[len-1], MSB at ctr[0]) 48 * (LSB at ctr[len-1], MSB at ctr[0])
49 */ 49 */
50static void 50static void
51ssh_ctr_inc(u_char *ctr, u_int len) 51ssh_ctr_inc(u_char *ctr, size_t len)
52{ 52{
53 int i; 53 int i;
54 54
@@ -59,10 +59,10 @@ ssh_ctr_inc(u_char *ctr, u_int len)
59 59
60static int 60static int
61ssh_aes_ctr(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src, 61ssh_aes_ctr(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src,
62 u_int len) 62 LIBCRYPTO_EVP_INL_TYPE len)
63{ 63{
64 struct ssh_aes_ctr_ctx *c; 64 struct ssh_aes_ctr_ctx *c;
65 u_int n = 0; 65 size_t n = 0;
66 u_char buf[AES_BLOCK_SIZE]; 66 u_char buf[AES_BLOCK_SIZE];
67 67
68 if (len == 0) 68 if (len == 0)
@@ -113,7 +113,7 @@ ssh_aes_ctr_cleanup(EVP_CIPHER_CTX *ctx)
113} 113}
114 114
115void 115void
116ssh_aes_ctr_iv(EVP_CIPHER_CTX *evp, int doset, u_char * iv, u_int len) 116ssh_aes_ctr_iv(EVP_CIPHER_CTX *evp, int doset, u_char * iv, size_t len)
117{ 117{
118 struct ssh_aes_ctr_ctx *c; 118 struct ssh_aes_ctr_ctx *c;
119 119
diff --git a/clientloop.c b/clientloop.c
index ef97859f1..ed1902363 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: clientloop.c,v 1.222 2010/07/19 09:15:12 djm Exp $ */ 1/* $OpenBSD: clientloop.c,v 1.231 2011/01/16 12:05:59 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -329,7 +329,7 @@ client_x11_get_proto(const char *display, const char *xauth_path,
329 if (trusted == 0) { 329 if (trusted == 0) {
330 xauthdir = xmalloc(MAXPATHLEN); 330 xauthdir = xmalloc(MAXPATHLEN);
331 xauthfile = xmalloc(MAXPATHLEN); 331 xauthfile = xmalloc(MAXPATHLEN);
332 strlcpy(xauthdir, "/tmp/ssh-XXXXXXXXXX", MAXPATHLEN); 332 mktemp_proto(xauthdir, MAXPATHLEN);
333 if (mkdtemp(xauthdir) != NULL) { 333 if (mkdtemp(xauthdir) != NULL) {
334 do_unlink = 1; 334 do_unlink = 1;
335 snprintf(xauthfile, MAXPATHLEN, "%s/xauthfile", 335 snprintf(xauthfile, MAXPATHLEN, "%s/xauthfile",
@@ -548,7 +548,7 @@ static void
548server_alive_check(void) 548server_alive_check(void)
549{ 549{
550 if (packet_inc_alive_timeouts() > options.server_alive_count_max) { 550 if (packet_inc_alive_timeouts() > options.server_alive_count_max) {
551 logit("Timeout, server not responding."); 551 logit("Timeout, server %s not responding.", host);
552 cleanup_exit(255); 552 cleanup_exit(255);
553 } 553 }
554 packet_start(SSH2_MSG_GLOBAL_REQUEST); 554 packet_start(SSH2_MSG_GLOBAL_REQUEST);
@@ -1603,25 +1603,23 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
1603 } 1603 }
1604 1604
1605 /* Output any buffered data for stdout. */ 1605 /* Output any buffered data for stdout. */
1606 while (buffer_len(&stdout_buffer) > 0) { 1606 if (buffer_len(&stdout_buffer) > 0) {
1607 len = write(fileno(stdout), buffer_ptr(&stdout_buffer), 1607 len = atomicio(vwrite, fileno(stdout),
1608 buffer_len(&stdout_buffer)); 1608 buffer_ptr(&stdout_buffer), buffer_len(&stdout_buffer));
1609 if (len <= 0) { 1609 if (len < 0 || (u_int)len != buffer_len(&stdout_buffer))
1610 error("Write failed flushing stdout buffer."); 1610 error("Write failed flushing stdout buffer.");
1611 break; 1611 else
1612 } 1612 buffer_consume(&stdout_buffer, len);
1613 buffer_consume(&stdout_buffer, len);
1614 } 1613 }
1615 1614
1616 /* Output any buffered data for stderr. */ 1615 /* Output any buffered data for stderr. */
1617 while (buffer_len(&stderr_buffer) > 0) { 1616 if (buffer_len(&stderr_buffer) > 0) {
1618 len = write(fileno(stderr), buffer_ptr(&stderr_buffer), 1617 len = atomicio(vwrite, fileno(stderr),
1619 buffer_len(&stderr_buffer)); 1618 buffer_ptr(&stderr_buffer), buffer_len(&stderr_buffer));
1620 if (len <= 0) { 1619 if (len < 0 || (u_int)len != buffer_len(&stderr_buffer))
1621 error("Write failed flushing stderr buffer."); 1620 error("Write failed flushing stderr buffer.");
1622 break; 1621 else
1623 } 1622 buffer_consume(&stderr_buffer, len);
1624 buffer_consume(&stderr_buffer, len);
1625 } 1623 }
1626 1624
1627 /* Clear and free any buffers. */ 1625 /* Clear and free any buffers. */
@@ -1635,7 +1633,7 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
1635 packet_get_state(MODE_IN, NULL, NULL, NULL, &ibytes); 1633 packet_get_state(MODE_IN, NULL, NULL, NULL, &ibytes);
1636 packet_get_state(MODE_OUT, NULL, NULL, NULL, &obytes); 1634 packet_get_state(MODE_OUT, NULL, NULL, NULL, &obytes);
1637 verbose("Transferred: sent %llu, received %llu bytes, in %.1f seconds", 1635 verbose("Transferred: sent %llu, received %llu bytes, in %.1f seconds",
1638 obytes, ibytes, total_time); 1636 (unsigned long long)obytes, (unsigned long long)ibytes, total_time);
1639 if (total_time > 0) 1637 if (total_time > 0)
1640 verbose("Bytes per second: sent %.1f, received %.1f", 1638 verbose("Bytes per second: sent %.1f, received %.1f",
1641 obytes / total_time, ibytes / total_time); 1639 obytes / total_time, ibytes / total_time);
@@ -1946,7 +1944,7 @@ client_input_channel_req(int type, u_int32_t seq, void *ctxt)
1946 } 1944 }
1947 packet_check_eom(); 1945 packet_check_eom();
1948 } 1946 }
1949 if (reply) { 1947 if (reply && c != NULL) {
1950 packet_start(success ? 1948 packet_start(success ?
1951 SSH2_MSG_CHANNEL_SUCCESS : SSH2_MSG_CHANNEL_FAILURE); 1949 SSH2_MSG_CHANNEL_SUCCESS : SSH2_MSG_CHANNEL_FAILURE);
1952 packet_put_int(c->remote_id); 1950 packet_put_int(c->remote_id);
@@ -1986,6 +1984,9 @@ client_session2_setup(int id, int want_tty, int want_subsystem,
1986 if ((c = channel_lookup(id)) == NULL) 1984 if ((c = channel_lookup(id)) == NULL)
1987 fatal("client_session2_setup: channel %d: unknown channel", id); 1985 fatal("client_session2_setup: channel %d: unknown channel", id);
1988 1986
1987 packet_set_interactive(want_tty,
1988 options.ip_qos_interactive, options.ip_qos_bulk);
1989
1989 if (want_tty) { 1990 if (want_tty) {
1990 struct winsize ws; 1991 struct winsize ws;
1991 1992
@@ -2142,5 +2143,6 @@ cleanup_exit(int i)
2142 leave_non_blocking(); 2143 leave_non_blocking();
2143 if (options.control_path != NULL && muxserver_sock != -1) 2144 if (options.control_path != NULL && muxserver_sock != -1)
2144 unlink(options.control_path); 2145 unlink(options.control_path);
2146 ssh_kill_proxy_command();
2145 _exit(i); 2147 _exit(i);
2146} 2148}
diff --git a/compress.c b/compress.c
index c058d2224..24778e524 100644
--- a/compress.c
+++ b/compress.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: compress.c,v 1.25 2006/08/06 01:13:32 stevesk Exp $ */ 1/* $OpenBSD: compress.c,v 1.26 2010/09/08 04:13:31 deraadt Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -17,12 +17,13 @@
17#include <sys/types.h> 17#include <sys/types.h>
18 18
19#include <stdarg.h> 19#include <stdarg.h>
20#include <zlib.h>
21 20
22#include "log.h" 21#include "log.h"
23#include "buffer.h" 22#include "buffer.h"
24#include "compress.h" 23#include "compress.h"
25 24
25#include <zlib.h>
26
26z_stream incoming_stream; 27z_stream incoming_stream;
27z_stream outgoing_stream; 28z_stream outgoing_stream;
28static int compress_init_send_called = 0; 29static int compress_init_send_called = 0;
diff --git a/config.h.in b/config.h.in
index 4ff407fcc..e5c9379c8 100644
--- a/config.h.in
+++ b/config.h.in
@@ -125,6 +125,9 @@
125/* Builtin PRNG command timeout */ 125/* Builtin PRNG command timeout */
126#undef ENTROPY_TIMEOUT_MSEC 126#undef ENTROPY_TIMEOUT_MSEC
127 127
128/* File names may not contain backslash characters */
129#undef FILESYSTEM_NO_BACKSLASH
130
128/* fsid_t has member val */ 131/* fsid_t has member val */
129#undef FSID_HAS_VAL 132#undef FSID_HAS_VAL
130 133
@@ -143,6 +146,9 @@
143/* Define if your system glob() function has gl_matchc options in glob_t */ 146/* Define if your system glob() function has gl_matchc options in glob_t */
144#undef GLOB_HAS_GL_MATCHC 147#undef GLOB_HAS_GL_MATCHC
145 148
149/* Define if your system glob() function has gl_statv options in glob_t */
150#undef GLOB_HAS_GL_STATV
151
146/* Define this if you want GSSAPI support in the version 2 protocol */ 152/* Define this if you want GSSAPI support in the version 2 protocol */
147#undef GSSAPI 153#undef GSSAPI
148 154
@@ -203,6 +209,9 @@
203/* Define to 1 if you have the `bindresvport_sa' function. */ 209/* Define to 1 if you have the `bindresvport_sa' function. */
204#undef HAVE_BINDRESVPORT_SA 210#undef HAVE_BINDRESVPORT_SA
205 211
212/* Define to 1 if you have the `BN_is_prime_ex' function. */
213#undef HAVE_BN_IS_PRIME_EX
214
206/* Define to 1 if you have the <bsm/audit.h> header file. */ 215/* Define to 1 if you have the <bsm/audit.h> header file. */
207#undef HAVE_BSM_AUDIT_H 216#undef HAVE_BSM_AUDIT_H
208 217
@@ -311,6 +320,9 @@
311/* Define to 1 if you have the `dirname' function. */ 320/* Define to 1 if you have the `dirname' function. */
312#undef HAVE_DIRNAME 321#undef HAVE_DIRNAME
313 322
323/* Define to 1 if you have the `DSA_generate_parameters_ex' function. */
324#undef HAVE_DSA_GENERATE_PARAMETERS_EX
325
314/* Define to 1 if you have the <endian.h> header file. */ 326/* Define to 1 if you have the <endian.h> header file. */
315#undef HAVE_ENDIAN_H 327#undef HAVE_ENDIAN_H
316 328
@@ -533,9 +545,15 @@
533/* Define to 1 if the system has the type `in_port_t'. */ 545/* Define to 1 if the system has the type `in_port_t'. */
534#undef HAVE_IN_PORT_T 546#undef HAVE_IN_PORT_T
535 547
548/* Define if you have isblank(3C). */
549#undef HAVE_ISBLANK
550
536/* Define to 1 if you have the <lastlog.h> header file. */ 551/* Define to 1 if you have the <lastlog.h> header file. */
537#undef HAVE_LASTLOG_H 552#undef HAVE_LASTLOG_H
538 553
554/* Define to 1 if you have the <libaudit.h> header file. */
555#undef HAVE_LIBAUDIT_H
556
539/* Define to 1 if you have the `bsm' library (-lbsm). */ 557/* Define to 1 if you have the `bsm' library (-lbsm). */
540#undef HAVE_LIBBSM 558#undef HAVE_LIBBSM
541 559
@@ -738,6 +756,12 @@
738/* Define to 1 if you have the `rresvport_af' function. */ 756/* Define to 1 if you have the `rresvport_af' function. */
739#undef HAVE_RRESVPORT_AF 757#undef HAVE_RRESVPORT_AF
740 758
759/* Define to 1 if you have the `RSA_generate_key_ex' function. */
760#undef HAVE_RSA_GENERATE_KEY_EX
761
762/* Define to 1 if you have the `RSA_get_default_method' function. */
763#undef HAVE_RSA_GET_DEFAULT_METHOD
764
741/* define if you have sa_family_t data type */ 765/* define if you have sa_family_t data type */
742#undef HAVE_SA_FAMILY_T 766#undef HAVE_SA_FAMILY_T
743 767
@@ -1044,6 +1068,9 @@
1044/* Define if you have ut_time in utmpx.h */ 1068/* Define if you have ut_time in utmpx.h */
1045#undef HAVE_TIME_IN_UTMPX 1069#undef HAVE_TIME_IN_UTMPX
1046 1070
1071/* Define to 1 if you have the `timingsafe_bcmp' function. */
1072#undef HAVE_TIMINGSAFE_BCMP
1073
1047/* Define to 1 if you have the <tmpdir.h> header file. */ 1074/* Define to 1 if you have the <tmpdir.h> header file. */
1048#undef HAVE_TMPDIR_H 1075#undef HAVE_TMPDIR_H
1049 1076
@@ -1259,6 +1286,9 @@
1259/* Define if EVP_DigestUpdate returns void */ 1286/* Define if EVP_DigestUpdate returns void */
1260#undef OPENSSL_EVP_DIGESTUPDATE_VOID 1287#undef OPENSSL_EVP_DIGESTUPDATE_VOID
1261 1288
1289/* libcrypto includes complete ECC support */
1290#undef OPENSSL_HAS_ECC
1291
1262/* libcrypto is missing AES 192 and 256 bit functions */ 1292/* libcrypto is missing AES 192 and 256 bit functions */
1263#undef OPENSSL_LOBOTOMISED_AES 1293#undef OPENSSL_LOBOTOMISED_AES
1264 1294
@@ -1390,6 +1420,9 @@
1390/* Use libedit for sftp */ 1420/* Use libedit for sftp */
1391#undef USE_LIBEDIT 1421#undef USE_LIBEDIT
1392 1422
1423/* Use Linux audit module */
1424#undef USE_LINUX_AUDIT
1425
1393/* Enable OpenSSL engine support */ 1426/* Enable OpenSSL engine support */
1394#undef USE_OPENSSL_ENGINE 1427#undef USE_OPENSSL_ENGINE
1395 1428
@@ -1402,6 +1435,9 @@
1402/* Define if you have Solaris process contracts */ 1435/* Define if you have Solaris process contracts */
1403#undef USE_SOLARIS_PROCESS_CONTRACTS 1436#undef USE_SOLARIS_PROCESS_CONTRACTS
1404 1437
1438/* Define if you have Solaris projects */
1439#undef USE_SOLARIS_PROJECTS
1440
1405/* Define if you shouldn't strip 'tty' from your ttyname in [uw]tmp */ 1441/* Define if you shouldn't strip 'tty' from your ttyname in [uw]tmp */
1406#undef WITH_ABBREV_NO_TTY 1442#undef WITH_ABBREV_NO_TTY
1407 1443
diff --git a/configure b/configure
index ef3bb0f0f..6e05311aa 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
1#! /bin/sh 1#! /bin/sh
2# From configure.ac Revision: 1.451 . 2# From configure.ac Revision: 1.469 .
3# Guess values for system-dependent variables and create Makefiles. 3# Guess values for system-dependent variables and create Makefiles.
4# Generated by GNU Autoconf 2.61 for OpenSSH Portable. 4# Generated by GNU Autoconf 2.61 for OpenSSH Portable.
5# 5#
@@ -684,7 +684,11 @@ SED
684ENT 684ENT
685TEST_MINUS_S_SH 685TEST_MINUS_S_SH
686SH 686SH
687GROFF
688NROFF
689MANDOC
687TEST_SHELL 690TEST_SHELL
691MANFMT
688PATH_GROUPADD_PROG 692PATH_GROUPADD_PROG
689PATH_USERADD_PROG 693PATH_USERADD_PROG
690MAKE_PACKAGE_SUPPORTED 694MAKE_PACKAGE_SUPPORTED
@@ -695,6 +699,9 @@ LD
695SSHDLIBS 699SSHDLIBS
696PKGCONFIG 700PKGCONFIG
697LIBEDIT 701LIBEDIT
702TEST_SSH_SHA256
703TEST_SSH_ECC
704COMMENT_OUT_ECC
698INSTALL_SSH_RAND_HELPER 705INSTALL_SSH_RAND_HELPER
699SSH_PRIVSEP_USER 706SSH_PRIVSEP_USER
700PROG_LS 707PROG_LS
@@ -719,7 +726,6 @@ PRIVSEP_PATH
719xauth_path 726xauth_path
720STRIP_OPT 727STRIP_OPT
721XAUTH_PATH 728XAUTH_PATH
722NROFF
723MANTYPE 729MANTYPE
724mansubdir 730mansubdir
725user_path 731user_path
@@ -1334,13 +1340,14 @@ Optional Packages:
1334 --with-libs Specify additional libraries to link with 1340 --with-libs Specify additional libraries to link with
1335 --with-Werror Build main code with -Werror 1341 --with-Werror Build main code with -Werror
1336 --with-solaris-contracts Enable Solaris process contracts (experimental) 1342 --with-solaris-contracts Enable Solaris process contracts (experimental)
1343 --with-solaris-projects Enable Solaris projects (experimental)
1337 --with-osfsia Enable Digital Unix SIA 1344 --with-osfsia Enable Digital Unix SIA
1338 --with-zlib=PATH Use zlib in PATH 1345 --with-zlib=PATH Use zlib in PATH
1339 --without-zlib-version-check Disable zlib version check 1346 --without-zlib-version-check Disable zlib version check
1340 --with-skey[=PATH] Enable S/Key support (optionally in PATH) 1347 --with-skey[=PATH] Enable S/Key support (optionally in PATH)
1341 --with-tcp-wrappers[=PATH] Enable tcpwrappers support (optionally in PATH) 1348 --with-tcp-wrappers[=PATH] Enable tcpwrappers support (optionally in PATH)
1342 --with-libedit[=PATH] Enable libedit support for sftp 1349 --with-libedit[=PATH] Enable libedit support for sftp
1343 --with-audit=module Enable EXPERIMENTAL audit support (modules=debug,bsm) 1350 --with-audit=module Enable audit support (modules=debug,bsm,linux)
1344 --with-ssl-dir=PATH Specify path to OpenSSL installation 1351 --with-ssl-dir=PATH Specify path to OpenSSL installation
1345 --without-openssl-header-check Disable OpenSSL version consistency check 1352 --without-openssl-header-check Disable OpenSSL version consistency check
1346 --with-ssl-engine Enable OpenSSL (hardware) ENGINE support 1353 --with-ssl-engine Enable OpenSSL (hardware) ENGINE support
@@ -1809,6 +1816,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
1809 1816
1810 1817
1811 1818
1819# local macros
1820
1821
1812ac_config_headers="$ac_config_headers config.h" 1822ac_config_headers="$ac_config_headers config.h"
1813 1823
1814ac_ext=c 1824ac_ext=c
@@ -4657,9 +4667,142 @@ echo "${ECHO_T}no" >&6; }
4657fi 4667fi
4658 4668
4659 4669
4670# Extract the first word of "groff", so it can be a program name with args.
4671set dummy groff; ac_word=$2
4672{ echo "$as_me:$LINENO: checking for $ac_word" >&5
4673echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
4674if test "${ac_cv_path_GROFF+set}" = set; then
4675 echo $ECHO_N "(cached) $ECHO_C" >&6
4676else
4677 case $GROFF in
4678 [\\/]* | ?:[\\/]*)
4679 ac_cv_path_GROFF="$GROFF" # Let the user override the test with a path.
4680 ;;
4681 *)
4682 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4683for as_dir in $PATH
4684do
4685 IFS=$as_save_IFS
4686 test -z "$as_dir" && as_dir=.
4687 for ac_exec_ext in '' $ac_executable_extensions; do
4688 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
4689 ac_cv_path_GROFF="$as_dir/$ac_word$ac_exec_ext"
4690 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
4691 break 2
4692 fi
4693done
4694done
4695IFS=$as_save_IFS
4696
4697 ;;
4698esac
4699fi
4700GROFF=$ac_cv_path_GROFF
4701if test -n "$GROFF"; then
4702 { echo "$as_me:$LINENO: result: $GROFF" >&5
4703echo "${ECHO_T}$GROFF" >&6; }
4704else
4705 { echo "$as_me:$LINENO: result: no" >&5
4706echo "${ECHO_T}no" >&6; }
4707fi
4708
4709
4710# Extract the first word of "nroff", so it can be a program name with args.
4711set dummy nroff; ac_word=$2
4712{ echo "$as_me:$LINENO: checking for $ac_word" >&5
4713echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
4714if test "${ac_cv_path_NROFF+set}" = set; then
4715 echo $ECHO_N "(cached) $ECHO_C" >&6
4716else
4717 case $NROFF in
4718 [\\/]* | ?:[\\/]*)
4719 ac_cv_path_NROFF="$NROFF" # Let the user override the test with a path.
4720 ;;
4721 *)
4722 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4723for as_dir in $PATH
4724do
4725 IFS=$as_save_IFS
4726 test -z "$as_dir" && as_dir=.
4727 for ac_exec_ext in '' $ac_executable_extensions; do
4728 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
4729 ac_cv_path_NROFF="$as_dir/$ac_word$ac_exec_ext"
4730 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
4731 break 2
4732 fi
4733done
4734done
4735IFS=$as_save_IFS
4736
4737 ;;
4738esac
4739fi
4740NROFF=$ac_cv_path_NROFF
4741if test -n "$NROFF"; then
4742 { echo "$as_me:$LINENO: result: $NROFF" >&5
4743echo "${ECHO_T}$NROFF" >&6; }
4744else
4745 { echo "$as_me:$LINENO: result: no" >&5
4746echo "${ECHO_T}no" >&6; }
4747fi
4748
4749
4750# Extract the first word of "mandoc", so it can be a program name with args.
4751set dummy mandoc; ac_word=$2
4752{ echo "$as_me:$LINENO: checking for $ac_word" >&5
4753echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
4754if test "${ac_cv_path_MANDOC+set}" = set; then
4755 echo $ECHO_N "(cached) $ECHO_C" >&6
4756else
4757 case $MANDOC in
4758 [\\/]* | ?:[\\/]*)
4759 ac_cv_path_MANDOC="$MANDOC" # Let the user override the test with a path.
4760 ;;
4761 *)
4762 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4763for as_dir in $PATH
4764do
4765 IFS=$as_save_IFS
4766 test -z "$as_dir" && as_dir=.
4767 for ac_exec_ext in '' $ac_executable_extensions; do
4768 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
4769 ac_cv_path_MANDOC="$as_dir/$ac_word$ac_exec_ext"
4770 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
4771 break 2
4772 fi
4773done
4774done
4775IFS=$as_save_IFS
4776
4777 ;;
4778esac
4779fi
4780MANDOC=$ac_cv_path_MANDOC
4781if test -n "$MANDOC"; then
4782 { echo "$as_me:$LINENO: result: $MANDOC" >&5
4783echo "${ECHO_T}$MANDOC" >&6; }
4784else
4785 { echo "$as_me:$LINENO: result: no" >&5
4786echo "${ECHO_T}no" >&6; }
4787fi
4788
4789
4660TEST_SHELL=sh 4790TEST_SHELL=sh
4661 4791
4662 4792
4793if test "x$MANDOC" != "x" ; then
4794 MANFMT="$MANDOC"
4795elif test "x$NROFF" != "x" ; then
4796 MANFMT="$NROFF -mandoc"
4797elif test "x$GROFF" != "x" ; then
4798 MANFMT="$GROFF -mandoc -Tascii"
4799else
4800 { echo "$as_me:$LINENO: WARNING: no manpage formatted found" >&5
4801echo "$as_me: WARNING: no manpage formatted found" >&2;}
4802 MANFMT="false"
4803fi
4804
4805
4663# Extract the first word of "groupadd", so it can be a program name with args. 4806# Extract the first word of "groupadd", so it can be a program name with args.
4664set dummy groupadd; ac_word=$2 4807set dummy groupadd; ac_word=$2
4665{ echo "$as_me:$LINENO: checking for $ac_word" >&5 4808{ echo "$as_me:$LINENO: checking for $ac_word" >&5
@@ -5395,20 +5538,333 @@ if test "${with_stackprotect+set}" = set; then
5395fi 5538fi
5396 5539
5397 5540
5541
5398if test "$GCC" = "yes" || test "$GCC" = "egcs"; then 5542if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
5399 CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wuninitialized" 5543 {
5544 { echo "$as_me:$LINENO: checking if $CC supports -Wall" >&5
5545echo $ECHO_N "checking if $CC supports -Wall... $ECHO_C" >&6; }
5546 saved_CFLAGS="$CFLAGS"
5547 CFLAGS="$CFLAGS -Wall"
5548 cat >conftest.$ac_ext <<_ACEOF
5549void main(void) { return 0; }
5550_ACEOF
5551rm -f conftest.$ac_objext
5552if { (ac_try="$ac_compile"
5553case "(($ac_try" in
5554 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
5555 *) ac_try_echo=$ac_try;;
5556esac
5557eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
5558 (eval "$ac_compile") 2>conftest.er1
5559 ac_status=$?
5560 grep -v '^ *+' conftest.er1 >conftest.err
5561 rm -f conftest.er1
5562 cat conftest.err >&5
5563 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5564 (exit $ac_status); } && {
5565 test -z "$ac_c_werror_flag" ||
5566 test ! -s conftest.err
5567 } && test -s conftest.$ac_objext; then
5568 { echo "$as_me:$LINENO: result: yes" >&5
5569echo "${ECHO_T}yes" >&6; }
5570else
5571 echo "$as_me: failed program was:" >&5
5572sed 's/^/| /' conftest.$ac_ext >&5
5573
5574 { echo "$as_me:$LINENO: result: no" >&5
5575echo "${ECHO_T}no" >&6; }
5576 CFLAGS="$saved_CFLAGS"
5577
5578fi
5579
5580rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5581}
5582 {
5583 { echo "$as_me:$LINENO: checking if $CC supports -Wpointer-arith" >&5
5584echo $ECHO_N "checking if $CC supports -Wpointer-arith... $ECHO_C" >&6; }
5585 saved_CFLAGS="$CFLAGS"
5586 CFLAGS="$CFLAGS -Wpointer-arith"
5587 cat >conftest.$ac_ext <<_ACEOF
5588void main(void) { return 0; }
5589_ACEOF
5590rm -f conftest.$ac_objext
5591if { (ac_try="$ac_compile"
5592case "(($ac_try" in
5593 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
5594 *) ac_try_echo=$ac_try;;
5595esac
5596eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
5597 (eval "$ac_compile") 2>conftest.er1
5598 ac_status=$?
5599 grep -v '^ *+' conftest.er1 >conftest.err
5600 rm -f conftest.er1
5601 cat conftest.err >&5
5602 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5603 (exit $ac_status); } && {
5604 test -z "$ac_c_werror_flag" ||
5605 test ! -s conftest.err
5606 } && test -s conftest.$ac_objext; then
5607 { echo "$as_me:$LINENO: result: yes" >&5
5608echo "${ECHO_T}yes" >&6; }
5609else
5610 echo "$as_me: failed program was:" >&5
5611sed 's/^/| /' conftest.$ac_ext >&5
5612
5613 { echo "$as_me:$LINENO: result: no" >&5
5614echo "${ECHO_T}no" >&6; }
5615 CFLAGS="$saved_CFLAGS"
5616
5617fi
5618
5619rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5620}
5621 {
5622 { echo "$as_me:$LINENO: checking if $CC supports -Wuninitialized" >&5
5623echo $ECHO_N "checking if $CC supports -Wuninitialized... $ECHO_C" >&6; }
5624 saved_CFLAGS="$CFLAGS"
5625 CFLAGS="$CFLAGS -Wuninitialized"
5626 cat >conftest.$ac_ext <<_ACEOF
5627void main(void) { return 0; }
5628_ACEOF
5629rm -f conftest.$ac_objext
5630if { (ac_try="$ac_compile"
5631case "(($ac_try" in
5632 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
5633 *) ac_try_echo=$ac_try;;
5634esac
5635eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
5636 (eval "$ac_compile") 2>conftest.er1
5637 ac_status=$?
5638 grep -v '^ *+' conftest.er1 >conftest.err
5639 rm -f conftest.er1
5640 cat conftest.err >&5
5641 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5642 (exit $ac_status); } && {
5643 test -z "$ac_c_werror_flag" ||
5644 test ! -s conftest.err
5645 } && test -s conftest.$ac_objext; then
5646 { echo "$as_me:$LINENO: result: yes" >&5
5647echo "${ECHO_T}yes" >&6; }
5648else
5649 echo "$as_me: failed program was:" >&5
5650sed 's/^/| /' conftest.$ac_ext >&5
5651
5652 { echo "$as_me:$LINENO: result: no" >&5
5653echo "${ECHO_T}no" >&6; }
5654 CFLAGS="$saved_CFLAGS"
5655
5656fi
5657
5658rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5659}
5660 {
5661 { echo "$as_me:$LINENO: checking if $CC supports -Wsign-compare" >&5
5662echo $ECHO_N "checking if $CC supports -Wsign-compare... $ECHO_C" >&6; }
5663 saved_CFLAGS="$CFLAGS"
5664 CFLAGS="$CFLAGS -Wsign-compare"
5665 cat >conftest.$ac_ext <<_ACEOF
5666void main(void) { return 0; }
5667_ACEOF
5668rm -f conftest.$ac_objext
5669if { (ac_try="$ac_compile"
5670case "(($ac_try" in
5671 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
5672 *) ac_try_echo=$ac_try;;
5673esac
5674eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
5675 (eval "$ac_compile") 2>conftest.er1
5676 ac_status=$?
5677 grep -v '^ *+' conftest.er1 >conftest.err
5678 rm -f conftest.er1
5679 cat conftest.err >&5
5680 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5681 (exit $ac_status); } && {
5682 test -z "$ac_c_werror_flag" ||
5683 test ! -s conftest.err
5684 } && test -s conftest.$ac_objext; then
5685 { echo "$as_me:$LINENO: result: yes" >&5
5686echo "${ECHO_T}yes" >&6; }
5687else
5688 echo "$as_me: failed program was:" >&5
5689sed 's/^/| /' conftest.$ac_ext >&5
5690
5691 { echo "$as_me:$LINENO: result: no" >&5
5692echo "${ECHO_T}no" >&6; }
5693 CFLAGS="$saved_CFLAGS"
5694
5695fi
5696
5697rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5698}
5699 {
5700 { echo "$as_me:$LINENO: checking if $CC supports -Wformat-security" >&5
5701echo $ECHO_N "checking if $CC supports -Wformat-security... $ECHO_C" >&6; }
5702 saved_CFLAGS="$CFLAGS"
5703 CFLAGS="$CFLAGS -Wformat-security"
5704 cat >conftest.$ac_ext <<_ACEOF
5705void main(void) { return 0; }
5706_ACEOF
5707rm -f conftest.$ac_objext
5708if { (ac_try="$ac_compile"
5709case "(($ac_try" in
5710 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
5711 *) ac_try_echo=$ac_try;;
5712esac
5713eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
5714 (eval "$ac_compile") 2>conftest.er1
5715 ac_status=$?
5716 grep -v '^ *+' conftest.er1 >conftest.err
5717 rm -f conftest.er1
5718 cat conftest.err >&5
5719 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5720 (exit $ac_status); } && {
5721 test -z "$ac_c_werror_flag" ||
5722 test ! -s conftest.err
5723 } && test -s conftest.$ac_objext; then
5724 { echo "$as_me:$LINENO: result: yes" >&5
5725echo "${ECHO_T}yes" >&6; }
5726else
5727 echo "$as_me: failed program was:" >&5
5728sed 's/^/| /' conftest.$ac_ext >&5
5729
5730 { echo "$as_me:$LINENO: result: no" >&5
5731echo "${ECHO_T}no" >&6; }
5732 CFLAGS="$saved_CFLAGS"
5733
5734fi
5735
5736rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5737}
5738 {
5739 { echo "$as_me:$LINENO: checking if $CC supports -Wno-pointer-sign" >&5
5740echo $ECHO_N "checking if $CC supports -Wno-pointer-sign... $ECHO_C" >&6; }
5741 saved_CFLAGS="$CFLAGS"
5742 CFLAGS="$CFLAGS -Wno-pointer-sign"
5743 cat >conftest.$ac_ext <<_ACEOF
5744void main(void) { return 0; }
5745_ACEOF
5746rm -f conftest.$ac_objext
5747if { (ac_try="$ac_compile"
5748case "(($ac_try" in
5749 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
5750 *) ac_try_echo=$ac_try;;
5751esac
5752eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
5753 (eval "$ac_compile") 2>conftest.er1
5754 ac_status=$?
5755 grep -v '^ *+' conftest.er1 >conftest.err
5756 rm -f conftest.er1
5757 cat conftest.err >&5
5758 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5759 (exit $ac_status); } && {
5760 test -z "$ac_c_werror_flag" ||
5761 test ! -s conftest.err
5762 } && test -s conftest.$ac_objext; then
5763 { echo "$as_me:$LINENO: result: yes" >&5
5764echo "${ECHO_T}yes" >&6; }
5765else
5766 echo "$as_me: failed program was:" >&5
5767sed 's/^/| /' conftest.$ac_ext >&5
5768
5769 { echo "$as_me:$LINENO: result: no" >&5
5770echo "${ECHO_T}no" >&6; }
5771 CFLAGS="$saved_CFLAGS"
5772
5773fi
5774
5775rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5776}
5777 {
5778 { echo "$as_me:$LINENO: checking if $CC supports -Wno-unused-result" >&5
5779echo $ECHO_N "checking if $CC supports -Wno-unused-result... $ECHO_C" >&6; }
5780 saved_CFLAGS="$CFLAGS"
5781 CFLAGS="$CFLAGS -Wno-unused-result"
5782 cat >conftest.$ac_ext <<_ACEOF
5783void main(void) { return 0; }
5784_ACEOF
5785rm -f conftest.$ac_objext
5786if { (ac_try="$ac_compile"
5787case "(($ac_try" in
5788 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
5789 *) ac_try_echo=$ac_try;;
5790esac
5791eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
5792 (eval "$ac_compile") 2>conftest.er1
5793 ac_status=$?
5794 grep -v '^ *+' conftest.er1 >conftest.err
5795 rm -f conftest.er1
5796 cat conftest.err >&5
5797 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5798 (exit $ac_status); } && {
5799 test -z "$ac_c_werror_flag" ||
5800 test ! -s conftest.err
5801 } && test -s conftest.$ac_objext; then
5802 { echo "$as_me:$LINENO: result: yes" >&5
5803echo "${ECHO_T}yes" >&6; }
5804else
5805 echo "$as_me: failed program was:" >&5
5806sed 's/^/| /' conftest.$ac_ext >&5
5807
5808 { echo "$as_me:$LINENO: result: no" >&5
5809echo "${ECHO_T}no" >&6; }
5810 CFLAGS="$saved_CFLAGS"
5811
5812fi
5813
5814rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5815}
5816 {
5817 { echo "$as_me:$LINENO: checking if $CC supports -fno-strict-aliasing" >&5
5818echo $ECHO_N "checking if $CC supports -fno-strict-aliasing... $ECHO_C" >&6; }
5819 saved_CFLAGS="$CFLAGS"
5820 CFLAGS="$CFLAGS -fno-strict-aliasing"
5821 cat >conftest.$ac_ext <<_ACEOF
5822void main(void) { return 0; }
5823_ACEOF
5824rm -f conftest.$ac_objext
5825if { (ac_try="$ac_compile"
5826case "(($ac_try" in
5827 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
5828 *) ac_try_echo=$ac_try;;
5829esac
5830eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
5831 (eval "$ac_compile") 2>conftest.er1
5832 ac_status=$?
5833 grep -v '^ *+' conftest.er1 >conftest.err
5834 rm -f conftest.er1
5835 cat conftest.err >&5
5836 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5837 (exit $ac_status); } && {
5838 test -z "$ac_c_werror_flag" ||
5839 test ! -s conftest.err
5840 } && test -s conftest.$ac_objext; then
5841 { echo "$as_me:$LINENO: result: yes" >&5
5842echo "${ECHO_T}yes" >&6; }
5843else
5844 echo "$as_me: failed program was:" >&5
5845sed 's/^/| /' conftest.$ac_ext >&5
5846
5847 { echo "$as_me:$LINENO: result: no" >&5
5848echo "${ECHO_T}no" >&6; }
5849 CFLAGS="$saved_CFLAGS"
5850
5851fi
5852
5853rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5854}
5855 { echo "$as_me:$LINENO: checking gcc version" >&5
5856echo $ECHO_N "checking gcc version... $ECHO_C" >&6; }
5400 GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'` 5857 GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
5401 case $GCC_VER in 5858 case $GCC_VER in
5402 1.*) no_attrib_nonnull=1 ;; 5859 1.*) no_attrib_nonnull=1 ;;
5403 2.8* | 2.9*) 5860 2.8* | 2.9*)
5404 CFLAGS="$CFLAGS -Wsign-compare"
5405 no_attrib_nonnull=1 5861 no_attrib_nonnull=1
5406 ;; 5862 ;;
5407 2.*) no_attrib_nonnull=1 ;; 5863 2.*) no_attrib_nonnull=1 ;;
5408 3.*) CFLAGS="$CFLAGS -Wsign-compare -Wformat-security" ;;
5409 4.*) CFLAGS="$CFLAGS -Wsign-compare -Wno-pointer-sign -Wformat-security -fno-strict-aliasing" ;;
5410 *) ;; 5864 *) ;;
5411 esac 5865 esac
5866 { echo "$as_me:$LINENO: result: $GCC_VER" >&5
5867echo "${ECHO_T}$GCC_VER" >&6; }
5412 5868
5413 { echo "$as_me:$LINENO: checking if $CC accepts -fno-builtin-memset" >&5 5869 { echo "$as_me:$LINENO: checking if $CC accepts -fno-builtin-memset" >&5
5414echo $ECHO_N "checking if $CC accepts -fno-builtin-memset... $ECHO_C" >&6; } 5870echo $ECHO_N "checking if $CC accepts -fno-builtin-memset... $ECHO_C" >&6; }
@@ -6256,6 +6712,7 @@ done
6256# Messages for features tested for in target-specific section 6712# Messages for features tested for in target-specific section
6257SIA_MSG="no" 6713SIA_MSG="no"
6258SPC_MSG="no" 6714SPC_MSG="no"
6715SP_MSG="no"
6259 6716
6260# Check for some target-specific stuff 6717# Check for some target-specific stuff
6261case "$host" in 6718case "$host" in
@@ -7245,6 +7702,11 @@ cat >>confdefs.h <<\_ACEOF
7245#define SSH_IOBUFSZ 65535 7702#define SSH_IOBUFSZ 65535
7246_ACEOF 7703_ACEOF
7247 7704
7705
7706cat >>confdefs.h <<\_ACEOF
7707#define FILESYSTEM_NO_BACKSLASH 1
7708_ACEOF
7709
7248 ;; 7710 ;;
7249*-*-dgux*) 7711*-*-dgux*)
7250 7712
@@ -8592,6 +9054,85 @@ fi
8592 9054
8593fi 9055fi
8594 9056
9057
9058# Check whether --with-solaris-projects was given.
9059if test "${with_solaris_projects+set}" = set; then
9060 withval=$with_solaris_projects;
9061 { echo "$as_me:$LINENO: checking for setproject in -lproject" >&5
9062echo $ECHO_N "checking for setproject in -lproject... $ECHO_C" >&6; }
9063if test "${ac_cv_lib_project_setproject+set}" = set; then
9064 echo $ECHO_N "(cached) $ECHO_C" >&6
9065else
9066 ac_check_lib_save_LIBS=$LIBS
9067LIBS="-lproject $LIBS"
9068cat >conftest.$ac_ext <<_ACEOF
9069/* confdefs.h. */
9070_ACEOF
9071cat confdefs.h >>conftest.$ac_ext
9072cat >>conftest.$ac_ext <<_ACEOF
9073/* end confdefs.h. */
9074
9075/* Override any GCC internal prototype to avoid an error.
9076 Use char because int might match the return type of a GCC
9077 builtin and then its argument prototype would still apply. */
9078#ifdef __cplusplus
9079extern "C"
9080#endif
9081char setproject ();
9082int
9083main ()
9084{
9085return setproject ();
9086 ;
9087 return 0;
9088}
9089_ACEOF
9090rm -f conftest.$ac_objext conftest$ac_exeext
9091if { (ac_try="$ac_link"
9092case "(($ac_try" in
9093 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
9094 *) ac_try_echo=$ac_try;;
9095esac
9096eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
9097 (eval "$ac_link") 2>conftest.er1
9098 ac_status=$?
9099 grep -v '^ *+' conftest.er1 >conftest.err
9100 rm -f conftest.er1
9101 cat conftest.err >&5
9102 echo "$as_me:$LINENO: \$? = $ac_status" >&5
9103 (exit $ac_status); } && {
9104 test -z "$ac_c_werror_flag" ||
9105 test ! -s conftest.err
9106 } && test -s conftest$ac_exeext &&
9107 $as_test_x conftest$ac_exeext; then
9108 ac_cv_lib_project_setproject=yes
9109else
9110 echo "$as_me: failed program was:" >&5
9111sed 's/^/| /' conftest.$ac_ext >&5
9112
9113 ac_cv_lib_project_setproject=no
9114fi
9115
9116rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
9117 conftest$ac_exeext conftest.$ac_ext
9118LIBS=$ac_check_lib_save_LIBS
9119fi
9120{ echo "$as_me:$LINENO: result: $ac_cv_lib_project_setproject" >&5
9121echo "${ECHO_T}$ac_cv_lib_project_setproject" >&6; }
9122if test $ac_cv_lib_project_setproject = yes; then
9123
9124cat >>confdefs.h <<\_ACEOF
9125#define USE_SOLARIS_PROJECTS 1
9126_ACEOF
9127
9128 SSHDLIBS="$SSHDLIBS -lproject"
9129
9130 SP_MSG="yes"
9131fi
9132
9133
9134fi
9135
8595 ;; 9136 ;;
8596*-*-sunos4*) 9137*-*-sunos4*)
8597 CPPFLAGS="$CPPFLAGS -DSUNOS4" 9138 CPPFLAGS="$CPPFLAGS -DSUNOS4"
@@ -12014,6 +12555,69 @@ fi
12014 12555
12015rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 12556rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
12016 12557
12558# Check for g.gl_statv glob() extension
12559{ echo "$as_me:$LINENO: checking for gl_statv and GLOB_KEEPSTAT extensions for glob" >&5
12560echo $ECHO_N "checking for gl_statv and GLOB_KEEPSTAT extensions for glob... $ECHO_C" >&6; }
12561cat >conftest.$ac_ext <<_ACEOF
12562/* confdefs.h. */
12563_ACEOF
12564cat confdefs.h >>conftest.$ac_ext
12565cat >>conftest.$ac_ext <<_ACEOF
12566/* end confdefs.h. */
12567 #include <glob.h>
12568int
12569main ()
12570{
12571
12572#ifndef GLOB_KEEPSTAT
12573#error "glob does not support GLOB_KEEPSTAT extension"
12574#endif
12575glob_t g;
12576g.gl_statv = NULL;
12577
12578 ;
12579 return 0;
12580}
12581_ACEOF
12582rm -f conftest.$ac_objext
12583if { (ac_try="$ac_compile"
12584case "(($ac_try" in
12585 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12586 *) ac_try_echo=$ac_try;;
12587esac
12588eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12589 (eval "$ac_compile") 2>conftest.er1
12590 ac_status=$?
12591 grep -v '^ *+' conftest.er1 >conftest.err
12592 rm -f conftest.er1
12593 cat conftest.err >&5
12594 echo "$as_me:$LINENO: \$? = $ac_status" >&5
12595 (exit $ac_status); } && {
12596 test -z "$ac_c_werror_flag" ||
12597 test ! -s conftest.err
12598 } && test -s conftest.$ac_objext; then
12599
12600
12601cat >>confdefs.h <<\_ACEOF
12602#define GLOB_HAS_GL_STATV 1
12603_ACEOF
12604
12605 { echo "$as_me:$LINENO: result: yes" >&5
12606echo "${ECHO_T}yes" >&6; }
12607
12608else
12609 echo "$as_me: failed program was:" >&5
12610sed 's/^/| /' conftest.$ac_ext >&5
12611
12612
12613 { echo "$as_me:$LINENO: result: no" >&5
12614echo "${ECHO_T}no" >&6; }
12615
12616
12617fi
12618
12619rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
12620
12017{ echo "$as_me:$LINENO: checking whether GLOB_NOMATCH is declared" >&5 12621{ echo "$as_me:$LINENO: checking whether GLOB_NOMATCH is declared" >&5
12018echo $ECHO_N "checking whether GLOB_NOMATCH is declared... $ECHO_C" >&6; } 12622echo $ECHO_N "checking whether GLOB_NOMATCH is declared... $ECHO_C" >&6; }
12019if test "${ac_cv_have_decl_GLOB_NOMATCH+set}" = set; then 12623if test "${ac_cv_have_decl_GLOB_NOMATCH+set}" = set; then
@@ -12468,7 +13072,7 @@ echo "${ECHO_T}no" >&6; }
12468 LDFLAGS="-L${withval}/lib ${LDFLAGS}" 13072 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
12469 fi 13073 fi
12470 fi 13074 fi
12471 if test "x$use_pkgconfig_for_libedit" == "xyes"; then 13075 if test "x$use_pkgconfig_for_libedit" = "xyes"; then
12472 LIBEDIT=`$PKGCONFIG --libs-only-l libedit` 13076 LIBEDIT=`$PKGCONFIG --libs-only-l libedit`
12473 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`" 13077 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`"
12474 else 13078 else
@@ -12961,6 +13565,162 @@ cat >>confdefs.h <<\_ACEOF
12961_ACEOF 13565_ACEOF
12962 13566
12963 ;; 13567 ;;
13568 linux)
13569 { echo "$as_me:$LINENO: result: linux" >&5
13570echo "${ECHO_T}linux" >&6; }
13571 AUDIT_MODULE=linux
13572
13573for ac_header in libaudit.h
13574do
13575as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
13576if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
13577 { echo "$as_me:$LINENO: checking for $ac_header" >&5
13578echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
13579if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
13580 echo $ECHO_N "(cached) $ECHO_C" >&6
13581fi
13582ac_res=`eval echo '${'$as_ac_Header'}'`
13583 { echo "$as_me:$LINENO: result: $ac_res" >&5
13584echo "${ECHO_T}$ac_res" >&6; }
13585else
13586 # Is the header compilable?
13587{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
13588echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
13589cat >conftest.$ac_ext <<_ACEOF
13590/* confdefs.h. */
13591_ACEOF
13592cat confdefs.h >>conftest.$ac_ext
13593cat >>conftest.$ac_ext <<_ACEOF
13594/* end confdefs.h. */
13595$ac_includes_default
13596#include <$ac_header>
13597_ACEOF
13598rm -f conftest.$ac_objext
13599if { (ac_try="$ac_compile"
13600case "(($ac_try" in
13601 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13602 *) ac_try_echo=$ac_try;;
13603esac
13604eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13605 (eval "$ac_compile") 2>conftest.er1
13606 ac_status=$?
13607 grep -v '^ *+' conftest.er1 >conftest.err
13608 rm -f conftest.er1
13609 cat conftest.err >&5
13610 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13611 (exit $ac_status); } && {
13612 test -z "$ac_c_werror_flag" ||
13613 test ! -s conftest.err
13614 } && test -s conftest.$ac_objext; then
13615 ac_header_compiler=yes
13616else
13617 echo "$as_me: failed program was:" >&5
13618sed 's/^/| /' conftest.$ac_ext >&5
13619
13620 ac_header_compiler=no
13621fi
13622
13623rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13624{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
13625echo "${ECHO_T}$ac_header_compiler" >&6; }
13626
13627# Is the header present?
13628{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
13629echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
13630cat >conftest.$ac_ext <<_ACEOF
13631/* confdefs.h. */
13632_ACEOF
13633cat confdefs.h >>conftest.$ac_ext
13634cat >>conftest.$ac_ext <<_ACEOF
13635/* end confdefs.h. */
13636#include <$ac_header>
13637_ACEOF
13638if { (ac_try="$ac_cpp conftest.$ac_ext"
13639case "(($ac_try" in
13640 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13641 *) ac_try_echo=$ac_try;;
13642esac
13643eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13644 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
13645 ac_status=$?
13646 grep -v '^ *+' conftest.er1 >conftest.err
13647 rm -f conftest.er1
13648 cat conftest.err >&5
13649 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13650 (exit $ac_status); } >/dev/null && {
13651 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
13652 test ! -s conftest.err
13653 }; then
13654 ac_header_preproc=yes
13655else
13656 echo "$as_me: failed program was:" >&5
13657sed 's/^/| /' conftest.$ac_ext >&5
13658
13659 ac_header_preproc=no
13660fi
13661
13662rm -f conftest.err conftest.$ac_ext
13663{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
13664echo "${ECHO_T}$ac_header_preproc" >&6; }
13665
13666# So? What about this header?
13667case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
13668 yes:no: )
13669 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
13670echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
13671 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
13672echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
13673 ac_header_preproc=yes
13674 ;;
13675 no:yes:* )
13676 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
13677echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
13678 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
13679echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
13680 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
13681echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
13682 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
13683echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
13684 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
13685echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
13686 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
13687echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
13688 ( cat <<\_ASBOX
13689## ------------------------------------------- ##
13690## Report this to openssh-unix-dev@mindrot.org ##
13691## ------------------------------------------- ##
13692_ASBOX
13693 ) | sed "s/^/$as_me: WARNING: /" >&2
13694 ;;
13695esac
13696{ echo "$as_me:$LINENO: checking for $ac_header" >&5
13697echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
13698if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
13699 echo $ECHO_N "(cached) $ECHO_C" >&6
13700else
13701 eval "$as_ac_Header=\$ac_header_preproc"
13702fi
13703ac_res=`eval echo '${'$as_ac_Header'}'`
13704 { echo "$as_me:$LINENO: result: $ac_res" >&5
13705echo "${ECHO_T}$ac_res" >&6; }
13706
13707fi
13708if test `eval echo '${'$as_ac_Header'}'` = yes; then
13709 cat >>confdefs.h <<_ACEOF
13710#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
13711_ACEOF
13712
13713fi
13714
13715done
13716
13717 SSHDLIBS="$SSHDLIBS -laudit"
13718
13719cat >>confdefs.h <<\_ACEOF
13720#define USE_LINUX_AUDIT 1
13721_ACEOF
13722
13723 ;;
12964 debug) 13724 debug)
12965 AUDIT_MODULE=debug 13725 AUDIT_MODULE=debug
12966 { echo "$as_me:$LINENO: result: debug" >&5 13726 { echo "$as_me:$LINENO: result: debug" >&5
@@ -13079,6 +13839,7 @@ fi
13079 13839
13080 13840
13081 13841
13842
13082for ac_func in \ 13843for ac_func in \
13083 arc4random \ 13844 arc4random \
13084 arc4random_buf \ 13845 arc4random_buf \
@@ -13166,6 +13927,7 @@ for ac_func in \
13166 swap32 \ 13927 swap32 \
13167 sysconf \ 13928 sysconf \
13168 tcgetpgrp \ 13929 tcgetpgrp \
13930 timingsafe_bcmp \
13169 truncate \ 13931 truncate \
13170 unsetenv \ 13932 unsetenv \
13171 updwtmpx \ 13933 updwtmpx \
@@ -13268,6 +14030,49 @@ fi
13268done 14030done
13269 14031
13270 14032
14033cat >conftest.$ac_ext <<_ACEOF
14034
14035#include <ctype.h>
14036int main(void)
14037{
14038 return (isblank('a'));
14039}
14040
14041_ACEOF
14042rm -f conftest.$ac_objext conftest$ac_exeext
14043if { (ac_try="$ac_link"
14044case "(($ac_try" in
14045 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14046 *) ac_try_echo=$ac_try;;
14047esac
14048eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
14049 (eval "$ac_link") 2>conftest.er1
14050 ac_status=$?
14051 grep -v '^ *+' conftest.er1 >conftest.err
14052 rm -f conftest.er1
14053 cat conftest.err >&5
14054 echo "$as_me:$LINENO: \$? = $ac_status" >&5
14055 (exit $ac_status); } && {
14056 test -z "$ac_c_werror_flag" ||
14057 test ! -s conftest.err
14058 } && test -s conftest$ac_exeext &&
14059 $as_test_x conftest$ac_exeext; then
14060
14061cat >>confdefs.h <<\_ACEOF
14062#define HAVE_ISBLANK 1
14063_ACEOF
14064
14065
14066else
14067 echo "$as_me: failed program was:" >&5
14068sed 's/^/| /' conftest.$ac_ext >&5
14069
14070
14071fi
14072
14073rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
14074 conftest$ac_exeext conftest.$ac_ext
14075
13271# PKCS#11 support requires dlopen() and co 14076# PKCS#11 support requires dlopen() and co
13272{ echo "$as_me:$LINENO: checking for library containing dlopen" >&5 14077{ echo "$as_me:$LINENO: checking for library containing dlopen" >&5
13273echo $ECHO_N "checking for library containing dlopen... $ECHO_C" >&6; } 14078echo $ECHO_N "checking for library containing dlopen... $ECHO_C" >&6; }
@@ -17135,6 +17940,104 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
17135 conftest$ac_exeext conftest.$ac_ext 17940 conftest$ac_exeext conftest.$ac_ext
17136 17941
17137 17942
17943
17944
17945
17946for ac_func in RSA_generate_key_ex DSA_generate_parameters_ex BN_is_prime_ex RSA_get_default_method
17947do
17948as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
17949{ echo "$as_me:$LINENO: checking for $ac_func" >&5
17950echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
17951if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
17952 echo $ECHO_N "(cached) $ECHO_C" >&6
17953else
17954 cat >conftest.$ac_ext <<_ACEOF
17955/* confdefs.h. */
17956_ACEOF
17957cat confdefs.h >>conftest.$ac_ext
17958cat >>conftest.$ac_ext <<_ACEOF
17959/* end confdefs.h. */
17960/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
17961 For example, HP-UX 11i <limits.h> declares gettimeofday. */
17962#define $ac_func innocuous_$ac_func
17963
17964/* System header to define __stub macros and hopefully few prototypes,
17965 which can conflict with char $ac_func (); below.
17966 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
17967 <limits.h> exists even on freestanding compilers. */
17968
17969#ifdef __STDC__
17970# include <limits.h>
17971#else
17972# include <assert.h>
17973#endif
17974
17975#undef $ac_func
17976
17977/* Override any GCC internal prototype to avoid an error.
17978 Use char because int might match the return type of a GCC
17979 builtin and then its argument prototype would still apply. */
17980#ifdef __cplusplus
17981extern "C"
17982#endif
17983char $ac_func ();
17984/* The GNU C library defines this for functions which it implements
17985 to always fail with ENOSYS. Some functions are actually named
17986 something starting with __ and the normal name is an alias. */
17987#if defined __stub_$ac_func || defined __stub___$ac_func
17988choke me
17989#endif
17990
17991int
17992main ()
17993{
17994return $ac_func ();
17995 ;
17996 return 0;
17997}
17998_ACEOF
17999rm -f conftest.$ac_objext conftest$ac_exeext
18000if { (ac_try="$ac_link"
18001case "(($ac_try" in
18002 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
18003 *) ac_try_echo=$ac_try;;
18004esac
18005eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
18006 (eval "$ac_link") 2>conftest.er1
18007 ac_status=$?
18008 grep -v '^ *+' conftest.er1 >conftest.err
18009 rm -f conftest.er1
18010 cat conftest.err >&5
18011 echo "$as_me:$LINENO: \$? = $ac_status" >&5
18012 (exit $ac_status); } && {
18013 test -z "$ac_c_werror_flag" ||
18014 test ! -s conftest.err
18015 } && test -s conftest$ac_exeext &&
18016 $as_test_x conftest$ac_exeext; then
18017 eval "$as_ac_var=yes"
18018else
18019 echo "$as_me: failed program was:" >&5
18020sed 's/^/| /' conftest.$ac_ext >&5
18021
18022 eval "$as_ac_var=no"
18023fi
18024
18025rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
18026 conftest$ac_exeext conftest.$ac_ext
18027fi
18028ac_res=`eval echo '${'$as_ac_var'}'`
18029 { echo "$as_me:$LINENO: result: $ac_res" >&5
18030echo "${ECHO_T}$ac_res" >&6; }
18031if test `eval echo '${'$as_ac_var'}'` = yes; then
18032 cat >>confdefs.h <<_ACEOF
18033#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
18034_ACEOF
18035
18036fi
18037done
18038
18039
18040
17138# Check whether --with-ssl-engine was given. 18041# Check whether --with-ssl-engine was given.
17139if test "${with_ssl_engine+set}" = set; then 18042if test "${with_ssl_engine+set}" = set; then
17140 withval=$with_ssl_engine; if test "x$withval" != "xno" ; then 18043 withval=$with_ssl_engine; if test "x$withval" != "xno" ; then
@@ -17547,11 +18450,86 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
17547 cat >>confdefs.h <<_ACEOF 18450 cat >>confdefs.h <<_ACEOF
17548#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 18451#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
17549_ACEOF 18452_ACEOF
17550 18453 TEST_SSH_SHA256=yes
18454else
18455 TEST_SSH_SHA256=no
17551fi 18456fi
17552done 18457done
17553 18458
17554 18459
18460
18461# Check complete ECC support in OpenSSL
18462{ echo "$as_me:$LINENO: checking whether OpenSSL has complete ECC support" >&5
18463echo $ECHO_N "checking whether OpenSSL has complete ECC support... $ECHO_C" >&6; }
18464cat >conftest.$ac_ext <<_ACEOF
18465/* confdefs.h. */
18466_ACEOF
18467cat confdefs.h >>conftest.$ac_ext
18468cat >>conftest.$ac_ext <<_ACEOF
18469/* end confdefs.h. */
18470
18471#include <openssl/ec.h>
18472#include <openssl/ecdh.h>
18473#include <openssl/ecdsa.h>
18474#include <openssl/evp.h>
18475#include <openssl/objects.h>
18476#include <openssl/opensslv.h>
18477#if OPENSSL_VERSION_NUMBER < 0x0090807f /* 0.9.8g */
18478# error "OpenSSL < 0.9.8g has unreliable ECC code"
18479#endif
18480int main(void) {
18481 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
18482 const EVP_MD *m = EVP_sha512(); /* We need this too */
18483}
18484
18485_ACEOF
18486rm -f conftest.$ac_objext conftest$ac_exeext
18487if { (ac_try="$ac_link"
18488case "(($ac_try" in
18489 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
18490 *) ac_try_echo=$ac_try;;
18491esac
18492eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
18493 (eval "$ac_link") 2>conftest.er1
18494 ac_status=$?
18495 grep -v '^ *+' conftest.er1 >conftest.err
18496 rm -f conftest.er1
18497 cat conftest.err >&5
18498 echo "$as_me:$LINENO: \$? = $ac_status" >&5
18499 (exit $ac_status); } && {
18500 test -z "$ac_c_werror_flag" ||
18501 test ! -s conftest.err
18502 } && test -s conftest$ac_exeext &&
18503 $as_test_x conftest$ac_exeext; then
18504
18505 { echo "$as_me:$LINENO: result: yes" >&5
18506echo "${ECHO_T}yes" >&6; }
18507
18508cat >>confdefs.h <<\_ACEOF
18509#define OPENSSL_HAS_ECC 1
18510_ACEOF
18511
18512 TEST_SSH_ECC=yes
18513 COMMENT_OUT_ECC=""
18514
18515else
18516 echo "$as_me: failed program was:" >&5
18517sed 's/^/| /' conftest.$ac_ext >&5
18518
18519
18520 { echo "$as_me:$LINENO: result: no" >&5
18521echo "${ECHO_T}no" >&6; }
18522 TEST_SSH_ECC=no
18523 COMMENT_OUT_ECC="#no ecc#"
18524
18525
18526fi
18527
18528rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
18529 conftest$ac_exeext conftest.$ac_ext
18530
18531
18532
17555saved_LIBS="$LIBS" 18533saved_LIBS="$LIBS"
17556{ echo "$as_me:$LINENO: checking for ia_openinfo in -liaf" >&5 18534{ echo "$as_me:$LINENO: checking for ia_openinfo in -liaf" >&5
17557echo $ECHO_N "checking for ia_openinfo in -liaf... $ECHO_C" >&6; } 18535echo $ECHO_N "checking for ia_openinfo in -liaf... $ECHO_C" >&6; }
@@ -27106,7 +28084,7 @@ echo "${ECHO_T}yes" >&6; }
27106#define HEIMDAL 1 28084#define HEIMDAL 1
27107_ACEOF 28085_ACEOF
27108 28086
27109 K5LIBS="-lkrb5 -ldes" 28087 K5LIBS="-lkrb5"
27110 K5LIBS="$K5LIBS -lcom_err -lasn1" 28088 K5LIBS="$K5LIBS -lcom_err -lasn1"
27111 { echo "$as_me:$LINENO: checking for net_write in -lroken" >&5 28089 { echo "$as_me:$LINENO: checking for net_write in -lroken" >&5
27112echo $ECHO_N "checking for net_write in -lroken... $ECHO_C" >&6; } 28090echo $ECHO_N "checking for net_write in -lroken... $ECHO_C" >&6; }
@@ -27173,6 +28151,71 @@ if test $ac_cv_lib_roken_net_write = yes; then
27173 K5LIBS="$K5LIBS -lroken" 28151 K5LIBS="$K5LIBS -lroken"
27174fi 28152fi
27175 28153
28154 { echo "$as_me:$LINENO: checking for des_cbc_encrypt in -ldes" >&5
28155echo $ECHO_N "checking for des_cbc_encrypt in -ldes... $ECHO_C" >&6; }
28156if test "${ac_cv_lib_des_des_cbc_encrypt+set}" = set; then
28157 echo $ECHO_N "(cached) $ECHO_C" >&6
28158else
28159 ac_check_lib_save_LIBS=$LIBS
28160LIBS="-ldes $LIBS"
28161cat >conftest.$ac_ext <<_ACEOF
28162/* confdefs.h. */
28163_ACEOF
28164cat confdefs.h >>conftest.$ac_ext
28165cat >>conftest.$ac_ext <<_ACEOF
28166/* end confdefs.h. */
28167
28168/* Override any GCC internal prototype to avoid an error.
28169 Use char because int might match the return type of a GCC
28170 builtin and then its argument prototype would still apply. */
28171#ifdef __cplusplus
28172extern "C"
28173#endif
28174char des_cbc_encrypt ();
28175int
28176main ()
28177{
28178return des_cbc_encrypt ();
28179 ;
28180 return 0;
28181}
28182_ACEOF
28183rm -f conftest.$ac_objext conftest$ac_exeext
28184if { (ac_try="$ac_link"
28185case "(($ac_try" in
28186 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
28187 *) ac_try_echo=$ac_try;;
28188esac
28189eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
28190 (eval "$ac_link") 2>conftest.er1
28191 ac_status=$?
28192 grep -v '^ *+' conftest.er1 >conftest.err
28193 rm -f conftest.er1
28194 cat conftest.err >&5
28195 echo "$as_me:$LINENO: \$? = $ac_status" >&5
28196 (exit $ac_status); } && {
28197 test -z "$ac_c_werror_flag" ||
28198 test ! -s conftest.err
28199 } && test -s conftest$ac_exeext &&
28200 $as_test_x conftest$ac_exeext; then
28201 ac_cv_lib_des_des_cbc_encrypt=yes
28202else
28203 echo "$as_me: failed program was:" >&5
28204sed 's/^/| /' conftest.$ac_ext >&5
28205
28206 ac_cv_lib_des_des_cbc_encrypt=no
28207fi
28208
28209rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
28210 conftest$ac_exeext conftest.$ac_ext
28211LIBS=$ac_check_lib_save_LIBS
28212fi
28213{ echo "$as_me:$LINENO: result: $ac_cv_lib_des_des_cbc_encrypt" >&5
28214echo "${ECHO_T}$ac_cv_lib_des_des_cbc_encrypt" >&6; }
28215if test $ac_cv_lib_des_des_cbc_encrypt = yes; then
28216 K5LIBS="$K5LIBS -ldes"
28217fi
28218
27176 28219
27177else 28220else
27178 echo "$as_me: failed program was:" >&5 28221 echo "$as_me: failed program was:" >&5
@@ -30361,7 +31404,11 @@ SED!$SED$ac_delim
30361ENT!$ENT$ac_delim 31404ENT!$ENT$ac_delim
30362TEST_MINUS_S_SH!$TEST_MINUS_S_SH$ac_delim 31405TEST_MINUS_S_SH!$TEST_MINUS_S_SH$ac_delim
30363SH!$SH$ac_delim 31406SH!$SH$ac_delim
31407GROFF!$GROFF$ac_delim
31408NROFF!$NROFF$ac_delim
31409MANDOC!$MANDOC$ac_delim
30364TEST_SHELL!$TEST_SHELL$ac_delim 31410TEST_SHELL!$TEST_SHELL$ac_delim
31411MANFMT!$MANFMT$ac_delim
30365PATH_GROUPADD_PROG!$PATH_GROUPADD_PROG$ac_delim 31412PATH_GROUPADD_PROG!$PATH_GROUPADD_PROG$ac_delim
30366PATH_USERADD_PROG!$PATH_USERADD_PROG$ac_delim 31413PATH_USERADD_PROG!$PATH_USERADD_PROG$ac_delim
30367MAKE_PACKAGE_SUPPORTED!$MAKE_PACKAGE_SUPPORTED$ac_delim 31414MAKE_PACKAGE_SUPPORTED!$MAKE_PACKAGE_SUPPORTED$ac_delim
@@ -30372,6 +31419,9 @@ LD!$LD$ac_delim
30372SSHDLIBS!$SSHDLIBS$ac_delim 31419SSHDLIBS!$SSHDLIBS$ac_delim
30373PKGCONFIG!$PKGCONFIG$ac_delim 31420PKGCONFIG!$PKGCONFIG$ac_delim
30374LIBEDIT!$LIBEDIT$ac_delim 31421LIBEDIT!$LIBEDIT$ac_delim
31422TEST_SSH_SHA256!$TEST_SSH_SHA256$ac_delim
31423TEST_SSH_ECC!$TEST_SSH_ECC$ac_delim
31424COMMENT_OUT_ECC!$COMMENT_OUT_ECC$ac_delim
30375INSTALL_SSH_RAND_HELPER!$INSTALL_SSH_RAND_HELPER$ac_delim 31425INSTALL_SSH_RAND_HELPER!$INSTALL_SSH_RAND_HELPER$ac_delim
30376SSH_PRIVSEP_USER!$SSH_PRIVSEP_USER$ac_delim 31426SSH_PRIVSEP_USER!$SSH_PRIVSEP_USER$ac_delim
30377PROG_LS!$PROG_LS$ac_delim 31427PROG_LS!$PROG_LS$ac_delim
@@ -30383,13 +31433,6 @@ PROG_PS!$PROG_PS$ac_delim
30383PROG_SAR!$PROG_SAR$ac_delim 31433PROG_SAR!$PROG_SAR$ac_delim
30384PROG_W!$PROG_W$ac_delim 31434PROG_W!$PROG_W$ac_delim
30385PROG_WHO!$PROG_WHO$ac_delim 31435PROG_WHO!$PROG_WHO$ac_delim
30386PROG_LAST!$PROG_LAST$ac_delim
30387PROG_LASTLOG!$PROG_LASTLOG$ac_delim
30388PROG_DF!$PROG_DF$ac_delim
30389PROG_VMSTAT!$PROG_VMSTAT$ac_delim
30390PROG_UPTIME!$PROG_UPTIME$ac_delim
30391PROG_IPCS!$PROG_IPCS$ac_delim
30392PROG_TAIL!$PROG_TAIL$ac_delim
30393_ACEOF 31436_ACEOF
30394 31437
30395 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then 31438 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -30431,13 +31474,19 @@ _ACEOF
30431ac_delim='%!_!# ' 31474ac_delim='%!_!# '
30432for ac_last_try in false false false false false :; do 31475for ac_last_try in false false false false false :; do
30433 cat >conf$$subs.sed <<_ACEOF 31476 cat >conf$$subs.sed <<_ACEOF
31477PROG_LAST!$PROG_LAST$ac_delim
31478PROG_LASTLOG!$PROG_LASTLOG$ac_delim
31479PROG_DF!$PROG_DF$ac_delim
31480PROG_VMSTAT!$PROG_VMSTAT$ac_delim
31481PROG_UPTIME!$PROG_UPTIME$ac_delim
31482PROG_IPCS!$PROG_IPCS$ac_delim
31483PROG_TAIL!$PROG_TAIL$ac_delim
30434INSTALL_SSH_PRNG_CMDS!$INSTALL_SSH_PRNG_CMDS$ac_delim 31484INSTALL_SSH_PRNG_CMDS!$INSTALL_SSH_PRNG_CMDS$ac_delim
30435KRB5CONF!$KRB5CONF$ac_delim 31485KRB5CONF!$KRB5CONF$ac_delim
30436PRIVSEP_PATH!$PRIVSEP_PATH$ac_delim 31486PRIVSEP_PATH!$PRIVSEP_PATH$ac_delim
30437xauth_path!$xauth_path$ac_delim 31487xauth_path!$xauth_path$ac_delim
30438STRIP_OPT!$STRIP_OPT$ac_delim 31488STRIP_OPT!$STRIP_OPT$ac_delim
30439XAUTH_PATH!$XAUTH_PATH$ac_delim 31489XAUTH_PATH!$XAUTH_PATH$ac_delim
30440NROFF!$NROFF$ac_delim
30441MANTYPE!$MANTYPE$ac_delim 31490MANTYPE!$MANTYPE$ac_delim
30442mansubdir!$mansubdir$ac_delim 31491mansubdir!$mansubdir$ac_delim
30443user_path!$user_path$ac_delim 31492user_path!$user_path$ac_delim
@@ -30447,7 +31496,7 @@ LIBOBJS!$LIBOBJS$ac_delim
30447LTLIBOBJS!$LTLIBOBJS$ac_delim 31496LTLIBOBJS!$LTLIBOBJS$ac_delim
30448_ACEOF 31497_ACEOF
30449 31498
30450 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 14; then 31499 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 20; then
30451 break 31500 break
30452 elif $ac_last_try; then 31501 elif $ac_last_try; then
30453 { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 31502 { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
@@ -30924,6 +31973,7 @@ echo " TCP Wrappers support: $TCPW_MSG"
30924echo " MD5 password support: $MD5_MSG" 31973echo " MD5 password support: $MD5_MSG"
30925echo " libedit support: $LIBEDIT_MSG" 31974echo " libedit support: $LIBEDIT_MSG"
30926echo " Solaris process contract support: $SPC_MSG" 31975echo " Solaris process contract support: $SPC_MSG"
31976echo " Solaris project support: $SP_MSG"
30927echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG" 31977echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
30928echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG" 31978echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
30929echo " BSD Auth support: $BSD_AUTH_MSG" 31979echo " BSD Auth support: $BSD_AUTH_MSG"
diff --git a/configure.ac b/configure.ac
index 510b803b4..d7d1a988d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
1# $Id: configure.ac,v 1.451 2010/08/16 03:15:23 dtucker Exp $ 1# $Id: configure.ac,v 1.469 2011/01/21 22:37:05 dtucker Exp $
2# 2#
3# Copyright (c) 1999-2004 Damien Miller 3# Copyright (c) 1999-2004 Damien Miller
4# 4#
@@ -15,9 +15,21 @@
15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 16
17AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org) 17AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org)
18AC_REVISION($Revision: 1.451 $) 18AC_REVISION($Revision: 1.469 $)
19AC_CONFIG_SRCDIR([ssh.c]) 19AC_CONFIG_SRCDIR([ssh.c])
20 20
21# local macros
22AC_DEFUN([OPENSSH_CHECK_CFLAG_COMPILE], [{
23 AC_MSG_CHECKING([if $CC supports $1])
24 saved_CFLAGS="$CFLAGS"
25 CFLAGS="$CFLAGS $1"
26 AC_COMPILE_IFELSE([void main(void) { return 0; }],
27 [ AC_MSG_RESULT(yes) ],
28 [ AC_MSG_RESULT(no)
29 CFLAGS="$saved_CFLAGS" ]
30 )
31}])
32
21AC_CONFIG_HEADER(config.h) 33AC_CONFIG_HEADER(config.h)
22AC_PROG_CC 34AC_PROG_CC
23AC_CANONICAL_HOST 35AC_CANONICAL_HOST
@@ -41,8 +53,24 @@ AC_PATH_PROG(TEST_MINUS_S_SH, bash)
41AC_PATH_PROG(TEST_MINUS_S_SH, ksh) 53AC_PATH_PROG(TEST_MINUS_S_SH, ksh)
42AC_PATH_PROG(TEST_MINUS_S_SH, sh) 54AC_PATH_PROG(TEST_MINUS_S_SH, sh)
43AC_PATH_PROG(SH, sh) 55AC_PATH_PROG(SH, sh)
56AC_PATH_PROG(GROFF, groff)
57AC_PATH_PROG(NROFF, nroff)
58AC_PATH_PROG(MANDOC, mandoc)
44AC_SUBST(TEST_SHELL,sh) 59AC_SUBST(TEST_SHELL,sh)
45 60
61dnl select manpage formatter
62if test "x$MANDOC" != "x" ; then
63 MANFMT="$MANDOC"
64elif test "x$NROFF" != "x" ; then
65 MANFMT="$NROFF -mandoc"
66elif test "x$GROFF" != "x" ; then
67 MANFMT="$GROFF -mandoc -Tascii"
68else
69 AC_MSG_WARN([no manpage formatted found])
70 MANFMT="false"
71fi
72AC_SUBST(MANFMT)
73
46dnl for buildpkg.sh 74dnl for buildpkg.sh
47AC_PATH_PROG(PATH_GROUPADD_PROG, groupadd, groupadd, 75AC_PATH_PROG(PATH_GROUPADD_PROG, groupadd, groupadd,
48 [/usr/sbin${PATH_SEPARATOR}/etc]) 76 [/usr/sbin${PATH_SEPARATOR}/etc])
@@ -97,20 +125,27 @@ AC_ARG_WITH(stackprotect,
97 use_stack_protector=0 125 use_stack_protector=0
98 fi ]) 126 fi ])
99 127
128
100if test "$GCC" = "yes" || test "$GCC" = "egcs"; then 129if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
101 CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wuninitialized" 130 OPENSSH_CHECK_CFLAG_COMPILE([-Wall])
131 OPENSSH_CHECK_CFLAG_COMPILE([-Wpointer-arith])
132 OPENSSH_CHECK_CFLAG_COMPILE([-Wuninitialized])
133 OPENSSH_CHECK_CFLAG_COMPILE([-Wsign-compare])
134 OPENSSH_CHECK_CFLAG_COMPILE([-Wformat-security])
135 OPENSSH_CHECK_CFLAG_COMPILE([-Wno-pointer-sign])
136 OPENSSH_CHECK_CFLAG_COMPILE([-Wno-unused-result])
137 OPENSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing])
138 AC_MSG_CHECKING(gcc version)
102 GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'` 139 GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
103 case $GCC_VER in 140 case $GCC_VER in
104 1.*) no_attrib_nonnull=1 ;; 141 1.*) no_attrib_nonnull=1 ;;
105 2.8* | 2.9*) 142 2.8* | 2.9*)
106 CFLAGS="$CFLAGS -Wsign-compare"
107 no_attrib_nonnull=1 143 no_attrib_nonnull=1
108 ;; 144 ;;
109 2.*) no_attrib_nonnull=1 ;; 145 2.*) no_attrib_nonnull=1 ;;
110 3.*) CFLAGS="$CFLAGS -Wsign-compare -Wformat-security" ;;
111 4.*) CFLAGS="$CFLAGS -Wsign-compare -Wno-pointer-sign -Wformat-security -fno-strict-aliasing" ;;
112 *) ;; 146 *) ;;
113 esac 147 esac
148 AC_MSG_RESULT($GCC_VER)
114 149
115 AC_MSG_CHECKING(if $CC accepts -fno-builtin-memset) 150 AC_MSG_CHECKING(if $CC accepts -fno-builtin-memset)
116 saved_CFLAGS="$CFLAGS" 151 saved_CFLAGS="$CFLAGS"
@@ -333,6 +368,7 @@ AC_CHECK_HEADERS(sys/mount.h, [], [], [
333# Messages for features tested for in target-specific section 368# Messages for features tested for in target-specific section
334SIA_MSG="no" 369SIA_MSG="no"
335SPC_MSG="no" 370SPC_MSG="no"
371SP_MSG="no"
336 372
337# Check for some target-specific stuff 373# Check for some target-specific stuff
338case "$host" in 374case "$host" in
@@ -447,6 +483,7 @@ int main(void) { exit(0); }
447 [Define if your platform needs to skip post auth 483 [Define if your platform needs to skip post auth
448 file descriptor passing]) 484 file descriptor passing])
449 AC_DEFINE(SSH_IOBUFSZ, 65535, [Windows is sensitive to read buffer size]) 485 AC_DEFINE(SSH_IOBUFSZ, 65535, [Windows is sensitive to read buffer size])
486 AC_DEFINE(FILESYSTEM_NO_BACKSLASH, 1, [File names may not contain backslash characters])
450 ;; 487 ;;
451*-*-dgux*) 488*-*-dgux*)
452 AC_DEFINE(IP_TOS_IS_BROKEN, 1, 489 AC_DEFINE(IP_TOS_IS_BROKEN, 1,
@@ -728,6 +765,17 @@ mips-sony-bsd|mips-sony-newsos4)
728 SPC_MSG="yes" ], ) 765 SPC_MSG="yes" ], )
729 ], 766 ],
730 ) 767 )
768 AC_ARG_WITH(solaris-projects,
769 [ --with-solaris-projects Enable Solaris projects (experimental)],
770 [
771 AC_CHECK_LIB(project, setproject,
772 [ AC_DEFINE(USE_SOLARIS_PROJECTS, 1,
773 [Define if you have Solaris projects])
774 SSHDLIBS="$SSHDLIBS -lproject"
775 AC_SUBST(SSHDLIBS)
776 SP_MSG="yes" ], )
777 ],
778 )
731 ;; 779 ;;
732*-*-sunos4*) 780*-*-sunos4*)
733 CPPFLAGS="$CPPFLAGS -DSUNOS4" 781 CPPFLAGS="$CPPFLAGS -DSUNOS4"
@@ -1142,6 +1190,28 @@ AC_TRY_COMPILE(
1142 ] 1190 ]
1143) 1191)
1144 1192
1193# Check for g.gl_statv glob() extension
1194AC_MSG_CHECKING(for gl_statv and GLOB_KEEPSTAT extensions for glob)
1195AC_TRY_COMPILE(
1196 [ #include <glob.h> ],
1197 [
1198#ifndef GLOB_KEEPSTAT
1199#error "glob does not support GLOB_KEEPSTAT extension"
1200#endif
1201glob_t g;
1202g.gl_statv = NULL;
1203],
1204 [
1205 AC_DEFINE(GLOB_HAS_GL_STATV, 1,
1206 [Define if your system glob() function has
1207 gl_statv options in glob_t])
1208 AC_MSG_RESULT(yes)
1209 ],
1210 [
1211 AC_MSG_RESULT(no)
1212 ]
1213)
1214
1145AC_CHECK_DECLS(GLOB_NOMATCH, , , [#include <glob.h>]) 1215AC_CHECK_DECLS(GLOB_NOMATCH, , , [#include <glob.h>])
1146 1216
1147AC_MSG_CHECKING([whether struct dirent allocates space for d_name]) 1217AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
@@ -1297,7 +1367,7 @@ AC_ARG_WITH(libedit,
1297 LDFLAGS="-L${withval}/lib ${LDFLAGS}" 1367 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1298 fi 1368 fi
1299 fi 1369 fi
1300 if test "x$use_pkgconfig_for_libedit" == "xyes"; then 1370 if test "x$use_pkgconfig_for_libedit" = "xyes"; then
1301 LIBEDIT=`$PKGCONFIG --libs-only-l libedit` 1371 LIBEDIT=`$PKGCONFIG --libs-only-l libedit`
1302 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`" 1372 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`"
1303 else 1373 else
@@ -1332,7 +1402,7 @@ int main(void)
1332 1402
1333AUDIT_MODULE=none 1403AUDIT_MODULE=none
1334AC_ARG_WITH(audit, 1404AC_ARG_WITH(audit,
1335 [ --with-audit=module Enable EXPERIMENTAL audit support (modules=debug,bsm)], 1405 [ --with-audit=module Enable audit support (modules=debug,bsm,linux)],
1336 [ 1406 [
1337 AC_MSG_CHECKING(for supported audit module) 1407 AC_MSG_CHECKING(for supported audit module)
1338 case "$withval" in 1408 case "$withval" in
@@ -1356,10 +1426,18 @@ AC_ARG_WITH(audit,
1356 AC_CHECK_FUNCS(getaudit_addr aug_get_machine) 1426 AC_CHECK_FUNCS(getaudit_addr aug_get_machine)
1357 AC_DEFINE(USE_BSM_AUDIT, 1, [Use BSM audit module]) 1427 AC_DEFINE(USE_BSM_AUDIT, 1, [Use BSM audit module])
1358 ;; 1428 ;;
1429 linux)
1430 AC_MSG_RESULT(linux)
1431 AUDIT_MODULE=linux
1432 dnl Checks for headers, libs and functions
1433 AC_CHECK_HEADERS(libaudit.h)
1434 SSHDLIBS="$SSHDLIBS -laudit"
1435 AC_DEFINE(USE_LINUX_AUDIT, 1, [Use Linux audit module])
1436 ;;
1359 debug) 1437 debug)
1360 AUDIT_MODULE=debug 1438 AUDIT_MODULE=debug
1361 AC_MSG_RESULT(debug) 1439 AC_MSG_RESULT(debug)
1362 AC_DEFINE(SSH_AUDIT_EVENTS, 1, Use audit debugging module) 1440 AC_DEFINE(SSH_AUDIT_EVENTS, 1, [Use audit debugging module])
1363 ;; 1441 ;;
1364 no) 1442 no)
1365 AC_MSG_RESULT(no) 1443 AC_MSG_RESULT(no)
@@ -1458,6 +1536,7 @@ AC_CHECK_FUNCS( \
1458 swap32 \ 1536 swap32 \
1459 sysconf \ 1537 sysconf \
1460 tcgetpgrp \ 1538 tcgetpgrp \
1539 timingsafe_bcmp \
1461 truncate \ 1540 truncate \
1462 unsetenv \ 1541 unsetenv \
1463 updwtmpx \ 1542 updwtmpx \
@@ -1468,6 +1547,17 @@ AC_CHECK_FUNCS( \
1468 waitpid \ 1547 waitpid \
1469) 1548)
1470 1549
1550AC_LINK_IFELSE(
1551[
1552#include <ctype.h>
1553int main(void)
1554{
1555 return (isblank('a'));
1556}
1557],
1558 [AC_DEFINE(HAVE_ISBLANK, 1, [Define if you have isblank(3C).])
1559])
1560
1471# PKCS#11 support requires dlopen() and co 1561# PKCS#11 support requires dlopen() and co
1472AC_SEARCH_LIBS(dlopen, dl, 1562AC_SEARCH_LIBS(dlopen, dl,
1473 AC_DEFINE([ENABLE_PKCS11], [], [Enable for PKCS#11 support]) 1563 AC_DEFINE([ENABLE_PKCS11], [], [Enable for PKCS#11 support])
@@ -2114,6 +2204,8 @@ int main(void) { SSLeay_add_all_algorithms(); }
2114 ] 2204 ]
2115) 2205)
2116 2206
2207AC_CHECK_FUNCS(RSA_generate_key_ex DSA_generate_parameters_ex BN_is_prime_ex RSA_get_default_method)
2208
2117AC_ARG_WITH(ssl-engine, 2209AC_ARG_WITH(ssl-engine,
2118 [ --with-ssl-engine Enable OpenSSL (hardware) ENGINE support ], 2210 [ --with-ssl-engine Enable OpenSSL (hardware) ENGINE support ],
2119 [ if test "x$withval" != "xno" ; then 2211 [ if test "x$withval" != "xno" ; then
@@ -2180,7 +2272,43 @@ if test "x$check_for_libcrypt_later" = "x1"; then
2180fi 2272fi
2181 2273
2182# Search for SHA256 support in libc and/or OpenSSL 2274# Search for SHA256 support in libc and/or OpenSSL
2183AC_CHECK_FUNCS(SHA256_Update EVP_sha256) 2275AC_CHECK_FUNCS(SHA256_Update EVP_sha256, [TEST_SSH_SHA256=yes],
2276 [TEST_SSH_SHA256=no])
2277AC_SUBST(TEST_SSH_SHA256)
2278
2279# Check complete ECC support in OpenSSL
2280AC_MSG_CHECKING([whether OpenSSL has complete ECC support])
2281AC_LINK_IFELSE(
2282 [AC_LANG_SOURCE([[
2283#include <openssl/ec.h>
2284#include <openssl/ecdh.h>
2285#include <openssl/ecdsa.h>
2286#include <openssl/evp.h>
2287#include <openssl/objects.h>
2288#include <openssl/opensslv.h>
2289#if OPENSSL_VERSION_NUMBER < 0x0090807f /* 0.9.8g */
2290# error "OpenSSL < 0.9.8g has unreliable ECC code"
2291#endif
2292int main(void) {
2293 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2294 const EVP_MD *m = EVP_sha512(); /* We need this too */
2295}
2296 ]])],
2297 [
2298 AC_MSG_RESULT(yes)
2299 AC_DEFINE(OPENSSL_HAS_ECC, 1,
2300 [libcrypto includes complete ECC support])
2301 TEST_SSH_ECC=yes
2302 COMMENT_OUT_ECC=""
2303 ],
2304 [
2305 AC_MSG_RESULT(no)
2306 TEST_SSH_ECC=no
2307 COMMENT_OUT_ECC="#no ecc#"
2308 ]
2309)
2310AC_SUBST(TEST_SSH_ECC)
2311AC_SUBST(COMMENT_OUT_ECC)
2184 2312
2185saved_LIBS="$LIBS" 2313saved_LIBS="$LIBS"
2186AC_CHECK_LIB(iaf, ia_openinfo, [ 2314AC_CHECK_LIB(iaf, ia_openinfo, [
@@ -3467,10 +3595,12 @@ AC_ARG_WITH(kerberos5,
3467 [ char *tmp = heimdal_version; ], 3595 [ char *tmp = heimdal_version; ],
3468 [ AC_MSG_RESULT(yes) 3596 [ AC_MSG_RESULT(yes)
3469 AC_DEFINE(HEIMDAL) 3597 AC_DEFINE(HEIMDAL)
3470 K5LIBS="-lkrb5 -ldes" 3598 K5LIBS="-lkrb5"
3471 K5LIBS="$K5LIBS -lcom_err -lasn1" 3599 K5LIBS="$K5LIBS -lcom_err -lasn1"
3472 AC_CHECK_LIB(roken, net_write, 3600 AC_CHECK_LIB(roken, net_write,
3473 [K5LIBS="$K5LIBS -lroken"]) 3601 [K5LIBS="$K5LIBS -lroken"])
3602 AC_CHECK_LIB(des, des_cbc_encrypt,
3603 [K5LIBS="$K5LIBS -ldes"])
3474 ], 3604 ],
3475 [ AC_MSG_RESULT(no) 3605 [ AC_MSG_RESULT(no)
3476 K5LIBS="-lkrb5 -lk5crypto -lcom_err" 3606 K5LIBS="-lkrb5 -lk5crypto -lcom_err"
@@ -4215,6 +4345,7 @@ echo " TCP Wrappers support: $TCPW_MSG"
4215echo " MD5 password support: $MD5_MSG" 4345echo " MD5 password support: $MD5_MSG"
4216echo " libedit support: $LIBEDIT_MSG" 4346echo " libedit support: $LIBEDIT_MSG"
4217echo " Solaris process contract support: $SPC_MSG" 4347echo " Solaris process contract support: $SPC_MSG"
4348echo " Solaris project support: $SP_MSG"
4218echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG" 4349echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
4219echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG" 4350echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
4220echo " BSD Auth support: $BSD_AUTH_MSG" 4351echo " BSD Auth support: $BSD_AUTH_MSG"
diff --git a/contrib/caldera/openssh.spec b/contrib/caldera/openssh.spec
index 515fe334d..23397b04d 100644
--- a/contrib/caldera/openssh.spec
+++ b/contrib/caldera/openssh.spec
@@ -16,7 +16,7 @@
16 16
17#old cvs stuff. please update before use. may be deprecated. 17#old cvs stuff. please update before use. may be deprecated.
18%define use_stable 1 18%define use_stable 1
19%define version 5.6p1 19%define version 5.7p1
20%if %{use_stable} 20%if %{use_stable}
21 %define cvs %{nil} 21 %define cvs %{nil}
22 %define release 1 22 %define release 1
@@ -57,7 +57,7 @@ BuildRequires : XFree86-imake
57# %{use_stable}==0: :pserver:cvs@bass.directhit.com:/cvs/openssh_cvs 57# %{use_stable}==0: :pserver:cvs@bass.directhit.com:/cvs/openssh_cvs
58Source0: see-above:/.../openssh-%{version}.tar.gz 58Source0: see-above:/.../openssh-%{version}.tar.gz
59%if %{use_stable} 59%if %{use_stable}
60Source1: see-above:/.../openssh-%{version}.tar.gz.sig 60Source1: see-above:/.../openssh-%{version}.tar.gz.asc
61%endif 61%endif
62Source2: http://www.jmknoble.net/software/%{xsa}/%{askpass}.tar.gz 62Source2: http://www.jmknoble.net/software/%{xsa}/%{askpass}.tar.gz
63Source3: http://www.openssh.com/faq.html 63Source3: http://www.openssh.com/faq.html
@@ -182,7 +182,7 @@ CFLAGS="$RPM_OPT_FLAGS" \
182 --with-privsep-path=%{_var}/empty/sshd \ 182 --with-privsep-path=%{_var}/empty/sshd \
183 #leave this line for easy edits. 183 #leave this line for easy edits.
184 184
185%__make CFLAGS="$RPM_OPT_FLAGS" 185%__make
186 186
187cd %{askpass} 187cd %{askpass}
188%configure \ 188%configure \
@@ -356,7 +356,11 @@ fi
356 356
357 357
358%ChangeLog 358%ChangeLog
359* Tue Jan 18 2011 Tim Rice <tim@multitalents.net>
360- Use CFLAGS from Makefile instead of RPM so build completes.
361- Signatures were changed to .asc since 4.1p1.
362
359* Mon Jan 01 1998 ... 363* Mon Jan 01 1998 ...
360Template Version: 1.31 364Template Version: 1.31
361 365
362$Id: openssh.spec,v 1.71 2010/08/08 16:32:09 djm Exp $ 366$Id: openssh.spec,v 1.73 2011/01/22 09:23:33 djm Exp $
diff --git a/contrib/redhat/openssh.spec b/contrib/redhat/openssh.spec
index 77e66252e..8fc76b625 100644
--- a/contrib/redhat/openssh.spec
+++ b/contrib/redhat/openssh.spec
@@ -1,4 +1,4 @@
1%define ver 5.6p1 1%define ver 5.7p1
2%define rel 1 2%define rel 1
3 3
4# OpenSSH privilege separation requires a user & group ID 4# OpenSSH privilege separation requires a user & group ID
diff --git a/contrib/redhat/sshd.init b/contrib/redhat/sshd.init
index e5d837cbc..854aff665 100755
--- a/contrib/redhat/sshd.init
+++ b/contrib/redhat/sshd.init
@@ -104,7 +104,7 @@ start()
104 do_dsa_keygen 104 do_dsa_keygen
105 105
106 echo -n $"Starting $prog:" 106 echo -n $"Starting $prog:"
107 initlog -c "$SSHD $OPTIONS" && success || failure 107 $SSHD $OPTIONS && success || failure
108 RETVAL=$? 108 RETVAL=$?
109 [ "$RETVAL" = 0 ] && touch /var/lock/subsys/sshd 109 [ "$RETVAL" = 0 ] && touch /var/lock/subsys/sshd
110 echo 110 echo
diff --git a/contrib/suse/openssh.spec b/contrib/suse/openssh.spec
index f099746f2..4573c52fd 100644
--- a/contrib/suse/openssh.spec
+++ b/contrib/suse/openssh.spec
@@ -13,7 +13,7 @@
13 13
14Summary: OpenSSH, a free Secure Shell (SSH) protocol implementation 14Summary: OpenSSH, a free Secure Shell (SSH) protocol implementation
15Name: openssh 15Name: openssh
16Version: 5.6p1 16Version: 5.7p1
17URL: http://www.openssh.com/ 17URL: http://www.openssh.com/
18Release: 1 18Release: 1
19Source0: openssh-%{version}.tar.gz 19Source0: openssh-%{version}.tar.gz
diff --git a/defines.h b/defines.h
index fe25170e6..cd273066d 100644
--- a/defines.h
+++ b/defines.h
@@ -25,7 +25,7 @@
25#ifndef _DEFINES_H 25#ifndef _DEFINES_H
26#define _DEFINES_H 26#define _DEFINES_H
27 27
28/* $Id: defines.h,v 1.160 2010/04/09 08:13:27 dtucker Exp $ */ 28/* $Id: defines.h,v 1.164 2011/01/17 10:15:31 dtucker Exp $ */
29 29
30 30
31/* Constants */ 31/* Constants */
@@ -42,6 +42,9 @@ enum
42# define SHUT_RDWR SHUT_RDWR 42# define SHUT_RDWR SHUT_RDWR
43#endif 43#endif
44 44
45/*
46 * Definitions for IP type of service (ip_tos)
47 */
45#ifndef IPTOS_LOWDELAY 48#ifndef IPTOS_LOWDELAY
46# define IPTOS_LOWDELAY 0x10 49# define IPTOS_LOWDELAY 0x10
47# define IPTOS_THROUGHPUT 0x08 50# define IPTOS_THROUGHPUT 0x08
@@ -50,6 +53,40 @@ enum
50# define IPTOS_MINCOST IPTOS_LOWCOST 53# define IPTOS_MINCOST IPTOS_LOWCOST
51#endif /* IPTOS_LOWDELAY */ 54#endif /* IPTOS_LOWDELAY */
52 55
56/*
57 * Definitions for DiffServ Codepoints as per RFC2474
58 */
59#include <netinet/in_systm.h>
60#include <netinet/ip.h>
61#ifndef IPTOS_DSCP_AF11
62# define IPTOS_DSCP_AF11 0x28
63# define IPTOS_DSCP_AF12 0x30
64# define IPTOS_DSCP_AF13 0x38
65# define IPTOS_DSCP_AF21 0x48
66# define IPTOS_DSCP_AF22 0x50
67# define IPTOS_DSCP_AF23 0x58
68# define IPTOS_DSCP_AF31 0x68
69# define IPTOS_DSCP_AF32 0x70
70# define IPTOS_DSCP_AF33 0x78
71# define IPTOS_DSCP_AF41 0x88
72# define IPTOS_DSCP_AF42 0x90
73# define IPTOS_DSCP_AF43 0x98
74# define IPTOS_DSCP_EF 0xb8
75#endif /* IPTOS_DSCP_AF11 */
76#ifndef IPTOS_DSCP_CS0
77# define IPTOS_DSCP_CS0 0x00
78# define IPTOS_DSCP_CS1 0x20
79# define IPTOS_DSCP_CS2 0x40
80# define IPTOS_DSCP_CS3 0x60
81# define IPTOS_DSCP_CS4 0x80
82# define IPTOS_DSCP_CS5 0xa0
83# define IPTOS_DSCP_CS6 0xc0
84# define IPTOS_DSCP_CS7 0xe0
85#endif /* IPTOS_DSCP_CS0 */
86#ifndef IPTOS_DSCP_EF
87# define IPTOS_DSCP_EF 0xb8
88#endif /* IPTOS_DSCP_EF */
89
53#ifndef MAXPATHLEN 90#ifndef MAXPATHLEN
54# ifdef PATH_MAX 91# ifdef PATH_MAX
55# define MAXPATHLEN PATH_MAX 92# define MAXPATHLEN PATH_MAX
@@ -256,6 +293,10 @@ typedef unsigned int size_t;
256# define SIZE_T_MAX UINT_MAX 293# define SIZE_T_MAX UINT_MAX
257#endif /* HAVE_SIZE_T */ 294#endif /* HAVE_SIZE_T */
258 295
296#ifndef SIZE_MAX
297#define SIZE_MAX SIZE_T_MAX
298#endif
299
259#ifndef HAVE_SSIZE_T 300#ifndef HAVE_SSIZE_T
260typedef int ssize_t; 301typedef int ssize_t;
261# define HAVE_SSIZE_T 302# define HAVE_SSIZE_T
@@ -566,6 +607,11 @@ struct winsize {
566# define CUSTOM_SSH_AUDIT_EVENTS 607# define CUSTOM_SSH_AUDIT_EVENTS
567#endif 608#endif
568 609
610#ifdef USE_LINUX_AUDIT
611# define SSH_AUDIT_EVENTS
612# define CUSTOM_SSH_AUDIT_EVENTS
613#endif
614
569#if !defined(HAVE___func__) && defined(HAVE___FUNCTION__) 615#if !defined(HAVE___func__) && defined(HAVE___FUNCTION__)
570# define __func__ __FUNCTION__ 616# define __func__ __FUNCTION__
571#elif !defined(HAVE___func__) 617#elif !defined(HAVE___func__)
diff --git a/dns.c b/dns.c
index 2e7bb5aae..131cb3d8b 100644
--- a/dns.c
+++ b/dns.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dns.c,v 1.26 2010/02/26 20:29:54 djm Exp $ */ 1/* $OpenBSD: dns.c,v 1.27 2010/08/31 11:54:45 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2003 Wesley Griffin. All rights reserved. 4 * Copyright (c) 2003 Wesley Griffin. All rights reserved.
@@ -86,6 +86,7 @@ dns_read_key(u_int8_t *algorithm, u_int8_t *digest_type,
86 case KEY_DSA: 86 case KEY_DSA:
87 *algorithm = SSHFP_KEY_DSA; 87 *algorithm = SSHFP_KEY_DSA;
88 break; 88 break;
89 /* XXX KEY_ECDSA */
89 default: 90 default:
90 *algorithm = SSHFP_KEY_RESERVED; /* 0 */ 91 *algorithm = SSHFP_KEY_RESERVED; /* 0 */
91 } 92 }
diff --git a/entropy.c b/entropy.c
index 8b705397f..a82166258 100644
--- a/entropy.c
+++ b/entropy.c
@@ -157,7 +157,7 @@ init_rng(void)
157 */ 157 */
158 if ((SSLeay() ^ OPENSSL_VERSION_NUMBER) & ~0xff0L) 158 if ((SSLeay() ^ OPENSSL_VERSION_NUMBER) & ~0xff0L)
159 fatal("OpenSSL version mismatch. Built against %lx, you " 159 fatal("OpenSSL version mismatch. Built against %lx, you "
160 "have %lx", OPENSSL_VERSION_NUMBER, SSLeay()); 160 "have %lx", (u_long)OPENSSL_VERSION_NUMBER, SSLeay());
161 161
162#ifndef OPENSSL_PRNG_ONLY 162#ifndef OPENSSL_PRNG_ONLY
163 original_uid = getuid(); 163 original_uid = getuid();
diff --git a/hostfile.c b/hostfile.c
index afab6dad1..b6f924b23 100644
--- a/hostfile.c
+++ b/hostfile.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: hostfile.c,v 1.48 2010/03/04 10:36:03 djm Exp $ */ 1/* $OpenBSD: hostfile.c,v 1.50 2010/12/04 13:31:37 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -56,6 +56,12 @@
56#include "key.h" 56#include "key.h"
57#include "hostfile.h" 57#include "hostfile.h"
58#include "log.h" 58#include "log.h"
59#include "misc.h"
60
61struct hostkeys {
62 struct hostkey_entry *entries;
63 u_int num_entries;
64};
59 65
60static int 66static int
61extract_salt(const char *s, u_int l, char *salt, size_t salt_len) 67extract_salt(const char *s, u_int l, char *salt, size_t salt_len)
@@ -164,26 +170,28 @@ hostfile_read_key(char **cpp, u_int *bitsp, Key *ret)
164 170
165 /* Return results. */ 171 /* Return results. */
166 *cpp = cp; 172 *cpp = cp;
167 *bitsp = key_size(ret); 173 if (bitsp != NULL)
174 *bitsp = key_size(ret);
168 return 1; 175 return 1;
169} 176}
170 177
171static int 178static int
172hostfile_check_key(int bits, const Key *key, const char *host, const char *filename, int linenum) 179hostfile_check_key(int bits, const Key *key, const char *host,
180 const char *filename, u_long linenum)
173{ 181{
174 if (key == NULL || key->type != KEY_RSA1 || key->rsa == NULL) 182 if (key == NULL || key->type != KEY_RSA1 || key->rsa == NULL)
175 return 1; 183 return 1;
176 if (bits != BN_num_bits(key->rsa->n)) { 184 if (bits != BN_num_bits(key->rsa->n)) {
177 logit("Warning: %s, line %d: keysize mismatch for host %s: " 185 logit("Warning: %s, line %lu: keysize mismatch for host %s: "
178 "actual %d vs. announced %d.", 186 "actual %d vs. announced %d.",
179 filename, linenum, host, BN_num_bits(key->rsa->n), bits); 187 filename, linenum, host, BN_num_bits(key->rsa->n), bits);
180 logit("Warning: replace %d with %d in %s, line %d.", 188 logit("Warning: replace %d with %d in %s, line %lu.",
181 bits, BN_num_bits(key->rsa->n), filename, linenum); 189 bits, BN_num_bits(key->rsa->n), filename, linenum);
182 } 190 }
183 return 1; 191 return 1;
184} 192}
185 193
186static enum { MRK_ERROR, MRK_NONE, MRK_REVOKE, MRK_CA } 194static HostkeyMarker
187check_markers(char **cpp) 195check_markers(char **cpp)
188{ 196{
189 char marker[32], *sp, *cp = *cpp; 197 char marker[32], *sp, *cp = *cpp;
@@ -218,49 +226,32 @@ check_markers(char **cpp)
218 return ret; 226 return ret;
219} 227}
220 228
221/* 229struct hostkeys *
222 * Checks whether the given host (which must be in all lowercase) is already 230init_hostkeys(void)
223 * in the list of our known hosts. Returns HOST_OK if the host is known and 231{
224 * has the specified key, HOST_NEW if the host is not known, and HOST_CHANGED 232 struct hostkeys *ret = xcalloc(1, sizeof(*ret));
225 * if the host is known but used to have a different host key.
226 *
227 * If no 'key' has been specified and a key of type 'keytype' is known
228 * for the specified host, then HOST_FOUND is returned.
229 */
230 233
231static HostStatus 234 ret->entries = NULL;
232check_host_in_hostfile_by_key_or_type(const char *filename, 235 return ret;
233 const char *host, const Key *key, int keytype, Key *found, 236}
234 int want_revocation, int *numret) 237
238void
239load_hostkeys(struct hostkeys *hostkeys, const char *host, const char *path)
235{ 240{
236 FILE *f; 241 FILE *f;
237 char line[8192]; 242 char line[8192];
238 int want, have, linenum = 0, want_cert = key_is_cert(key); 243 u_long linenum = 0, num_loaded = 0;
239 u_int kbits;
240 char *cp, *cp2, *hashed_host; 244 char *cp, *cp2, *hashed_host;
241 HostStatus end_return; 245 HostkeyMarker marker;
242 246 Key *key;
243 debug3("check_host_in_hostfile: host %s filename %s", host, filename); 247 int kbits;
244 248
245 if (want_revocation && (key == NULL || keytype != 0 || found != NULL)) 249 if ((f = fopen(path, "r")) == NULL)
246 fatal("%s: invalid arguments", __func__); 250 return;
247 251 debug3("%s: loading entries for host \"%.100s\" from file \"%s\"",
248 /* Open the file containing the list of known hosts. */ 252 __func__, host, path);
249 f = fopen(filename, "r"); 253 while (read_keyfile_line(f, path, line, sizeof(line), &linenum) == 0) {
250 if (!f)
251 return HOST_NEW;
252
253 /*
254 * Return value when the loop terminates. This is set to
255 * HOST_CHANGED if we have seen a different key for the host and have
256 * not found the proper one.
257 */
258 end_return = HOST_NEW;
259
260 /* Go through the file. */
261 while (fgets(line, sizeof(line), f)) {
262 cp = line; 254 cp = line;
263 linenum++;
264 255
265 /* Skip any leading whitespace, comments and empty lines. */ 256 /* Skip any leading whitespace, comments and empty lines. */
266 for (; *cp == ' ' || *cp == '\t'; cp++) 257 for (; *cp == ' ' || *cp == '\t'; cp++)
@@ -268,19 +259,11 @@ check_host_in_hostfile_by_key_or_type(const char *filename,
268 if (!*cp || *cp == '#' || *cp == '\n') 259 if (!*cp || *cp == '#' || *cp == '\n')
269 continue; 260 continue;
270 261
271 if (want_revocation) 262 if ((marker = check_markers(&cp)) == MRK_ERROR) {
272 want = MRK_REVOKE; 263 verbose("%s: invalid marker at %s:%lu",
273 else if (want_cert) 264 __func__, path, linenum);
274 want = MRK_CA;
275 else
276 want = MRK_NONE;
277
278 if ((have = check_markers(&cp)) == MRK_ERROR) {
279 verbose("%s: invalid marker at %s:%d",
280 __func__, filename, linenum);
281 continue;
282 } else if (want != have)
283 continue; 265 continue;
266 }
284 267
285 /* Find the end of the host name portion. */ 268 /* Find the end of the host name portion. */
286 for (cp2 = cp; *cp2 && *cp2 != ' ' && *cp2 != '\t'; cp2++) 269 for (cp2 = cp; *cp2 && *cp2 != ' ' && *cp2 != '\t'; cp2++)
@@ -292,8 +275,8 @@ check_host_in_hostfile_by_key_or_type(const char *filename,
292 continue; 275 continue;
293 hashed_host = host_hash(host, cp, (u_int) (cp2 - cp)); 276 hashed_host = host_hash(host, cp, (u_int) (cp2 - cp));
294 if (hashed_host == NULL) { 277 if (hashed_host == NULL) {
295 debug("Invalid hashed host line %d of %s", 278 debug("Invalid hashed host line %lu of %s",
296 linenum, filename); 279 linenum, path);
297 continue; 280 continue;
298 } 281 }
299 if (strncmp(hashed_host, cp, (u_int) (cp2 - cp)) != 0) 282 if (strncmp(hashed_host, cp, (u_int) (cp2 - cp)) != 0)
@@ -303,98 +286,167 @@ check_host_in_hostfile_by_key_or_type(const char *filename,
303 /* Got a match. Skip host name. */ 286 /* Got a match. Skip host name. */
304 cp = cp2; 287 cp = cp2;
305 288
306 if (want_revocation)
307 found = key_new(KEY_UNSPEC);
308
309 /* 289 /*
310 * Extract the key from the line. This will skip any leading 290 * Extract the key from the line. This will skip any leading
311 * whitespace. Ignore badly formatted lines. 291 * whitespace. Ignore badly formatted lines.
312 */ 292 */
313 if (!hostfile_read_key(&cp, &kbits, found)) 293 key = key_new(KEY_UNSPEC);
294 if (!hostfile_read_key(&cp, &kbits, key)) {
295 key_free(key);
296 key = key_new(KEY_RSA1);
297 if (!hostfile_read_key(&cp, &kbits, key)) {
298 key_free(key);
299 continue;
300 }
301 }
302 if (!hostfile_check_key(kbits, key, host, path, linenum))
314 continue; 303 continue;
315 304
316 if (numret != NULL) 305 debug3("%s: found %skey type %s in file %s:%lu", __func__,
317 *numret = linenum; 306 marker == MRK_NONE ? "" :
307 (marker == MRK_CA ? "ca " : "revoked "),
308 key_type(key), path, linenum);
309 hostkeys->entries = xrealloc(hostkeys->entries,
310 hostkeys->num_entries + 1, sizeof(*hostkeys->entries));
311 hostkeys->entries[hostkeys->num_entries].host = xstrdup(host);
312 hostkeys->entries[hostkeys->num_entries].file = xstrdup(path);
313 hostkeys->entries[hostkeys->num_entries].line = linenum;
314 hostkeys->entries[hostkeys->num_entries].key = key;
315 hostkeys->entries[hostkeys->num_entries].marker = marker;
316 hostkeys->num_entries++;
317 num_loaded++;
318 }
319 debug3("%s: loaded %lu keys", __func__, num_loaded);
320 fclose(f);
321 return;
322}
318 323
319 if (key == NULL) { 324void
320 /* we found a key of the requested type */ 325free_hostkeys(struct hostkeys *hostkeys)
321 if (found->type == keytype) { 326{
322 fclose(f); 327 u_int i;
323 return HOST_FOUND; 328
324 } 329 for (i = 0; i < hostkeys->num_entries; i++) {
325 continue; 330 xfree(hostkeys->entries[i].host);
326 } 331 xfree(hostkeys->entries[i].file);
332 key_free(hostkeys->entries[i].key);
333 bzero(hostkeys->entries + i, sizeof(*hostkeys->entries));
334 }
335 if (hostkeys->entries != NULL)
336 xfree(hostkeys->entries);
337 hostkeys->entries = NULL;
338 hostkeys->num_entries = 0;
339 xfree(hostkeys);
340}
341
342static int
343check_key_not_revoked(struct hostkeys *hostkeys, Key *k)
344{
345 int is_cert = key_is_cert(k);
346 u_int i;
327 347
328 if (!hostfile_check_key(kbits, found, host, filename, linenum)) 348 for (i = 0; i < hostkeys->num_entries; i++) {
349 if (hostkeys->entries[i].marker != MRK_REVOKE)
329 continue; 350 continue;
351 if (key_equal_public(k, hostkeys->entries[i].key))
352 return -1;
353 if (is_cert &&
354 key_equal_public(k->cert->signature_key,
355 hostkeys->entries[i].key))
356 return -1;
357 }
358 return 0;
359}
330 360
331 if (want_revocation) { 361/*
332 if (key_is_cert(key) && 362 * Match keys against a specified key, or look one up by key type.
333 key_equal_public(key->cert->signature_key, found)) { 363 *
334 verbose("check_host_in_hostfile: revoked CA " 364 * If looking for a keytype (key == NULL) and one is found then return
335 "line %d", linenum); 365 * HOST_FOUND, otherwise HOST_NEW.
336 key_free(found); 366 *
337 return HOST_REVOKED; 367 * If looking for a key (key != NULL):
338 } 368 * 1. If the key is a cert and a matching CA is found, return HOST_OK
339 if (key_equal_public(key, found)) { 369 * 2. If the key is not a cert and a matching key is found, return HOST_OK
340 verbose("check_host_in_hostfile: revoked key " 370 * 3. If no key matches but a key with a different type is found, then
341 "line %d", linenum); 371 * return HOST_CHANGED
342 key_free(found); 372 * 4. If no matching keys are found, then return HOST_NEW.
343 return HOST_REVOKED; 373 *
344 } 374 * Finally, check any found key is not revoked.
345 key_free(found); 375 */
376static HostStatus
377check_hostkeys_by_key_or_type(struct hostkeys *hostkeys,
378 Key *k, int keytype, const struct hostkey_entry **found)
379{
380 u_int i;
381 HostStatus end_return = HOST_NEW;
382 int want_cert = key_is_cert(k);
383 HostkeyMarker want_marker = want_cert ? MRK_CA : MRK_NONE;
384 int proto = (k ? k->type : keytype) == KEY_RSA1 ? 1 : 2;
385
386 if (found != NULL)
387 *found = NULL;
388
389 for (i = 0; i < hostkeys->num_entries; i++) {
390 if (proto == 1 && hostkeys->entries[i].key->type != KEY_RSA1)
391 continue;
392 if (proto == 2 && hostkeys->entries[i].key->type == KEY_RSA1)
346 continue; 393 continue;
394 if (hostkeys->entries[i].marker != want_marker)
395 continue;
396 if (k == NULL) {
397 if (hostkeys->entries[i].key->type != keytype)
398 continue;
399 end_return = HOST_FOUND;
400 if (found != NULL)
401 *found = hostkeys->entries + i;
402 k = hostkeys->entries[i].key;
403 break;
347 } 404 }
348 405 if (want_cert) {
349 /* Check if the current key is the same as the given key. */ 406 if (key_equal_public(k->cert->signature_key,
350 if (want_cert && key_equal(key->cert->signature_key, found)) { 407 hostkeys->entries[i].key)) {
351 /* Found CA cert for key */ 408 /* A matching CA exists */
352 debug3("check_host_in_hostfile: CA match line %d", 409 end_return = HOST_OK;
353 linenum); 410 if (found != NULL)
354 fclose(f); 411 *found = hostkeys->entries + i;
355 return HOST_OK; 412 break;
356 } else if (!want_cert && key_equal(key, found)) { 413 }
357 /* Found identical key */ 414 } else {
358 debug3("check_host_in_hostfile: match line %d", linenum); 415 if (key_equal(k, hostkeys->entries[i].key)) {
359 fclose(f); 416 end_return = HOST_OK;
360 return HOST_OK; 417 if (found != NULL)
418 *found = hostkeys->entries + i;
419 break;
420 }
421 /* A non-maching key exists */
422 end_return = HOST_CHANGED;
423 if (found != NULL)
424 *found = hostkeys->entries + i;
361 } 425 }
362 /*
363 * They do not match. We will continue to go through the
364 * file; however, we note that we will not return that it is
365 * new.
366 */
367 end_return = HOST_CHANGED;
368 } 426 }
369 /* Clear variables and close the file. */ 427 if (check_key_not_revoked(hostkeys, k) != 0) {
370 fclose(f); 428 end_return = HOST_REVOKED;
371 429 if (found != NULL)
372 /* 430 *found = NULL;
373 * Return either HOST_NEW or HOST_CHANGED, depending on whether we 431 }
374 * saw a different key for the host.
375 */
376 return end_return; 432 return end_return;
377} 433}
378 434
379HostStatus 435HostStatus
380check_host_in_hostfile(const char *filename, const char *host, const Key *key, 436check_key_in_hostkeys(struct hostkeys *hostkeys, Key *key,
381 Key *found, int *numret) 437 const struct hostkey_entry **found)
382{ 438{
383 if (key == NULL) 439 if (key == NULL)
384 fatal("no key to look up"); 440 fatal("no key to look up");
385 if (check_host_in_hostfile_by_key_or_type(filename, host, 441 return check_hostkeys_by_key_or_type(hostkeys, key, 0, found);
386 key, 0, NULL, 1, NULL) == HOST_REVOKED)
387 return HOST_REVOKED;
388 return check_host_in_hostfile_by_key_or_type(filename, host, key, 0,
389 found, 0, numret);
390} 442}
391 443
392int 444int
393lookup_key_in_hostfile_by_type(const char *filename, const char *host, 445lookup_key_in_hostkeys_by_type(struct hostkeys *hostkeys, int keytype,
394 int keytype, Key *found, int *numret) 446 const struct hostkey_entry **found)
395{ 447{
396 return (check_host_in_hostfile_by_key_or_type(filename, host, NULL, 448 return (check_hostkeys_by_key_or_type(hostkeys, NULL, keytype,
397 keytype, found, 0, numret) == HOST_FOUND); 449 found) == HOST_FOUND);
398} 450}
399 451
400/* 452/*
diff --git a/hostfile.h b/hostfile.h
index 1d460c1a9..d84d422ff 100644
--- a/hostfile.h
+++ b/hostfile.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: hostfile.h,v 1.18 2010/03/04 10:36:03 djm Exp $ */ 1/* $OpenBSD: hostfile.h,v 1.19 2010/11/29 23:45:51 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -18,12 +18,30 @@ typedef enum {
18 HOST_OK, HOST_NEW, HOST_CHANGED, HOST_REVOKED, HOST_FOUND 18 HOST_OK, HOST_NEW, HOST_CHANGED, HOST_REVOKED, HOST_FOUND
19} HostStatus; 19} HostStatus;
20 20
21typedef enum {
22 MRK_ERROR, MRK_NONE, MRK_REVOKE, MRK_CA
23} HostkeyMarker;
24
25struct hostkey_entry {
26 char *host;
27 char *file;
28 u_long line;
29 Key *key;
30 HostkeyMarker marker;
31};
32struct hostkeys;
33
34struct hostkeys *init_hostkeys(void);
35void load_hostkeys(struct hostkeys *, const char *, const char *);
36void free_hostkeys(struct hostkeys *);
37
38HostStatus check_key_in_hostkeys(struct hostkeys *, Key *,
39 const struct hostkey_entry **);
40int lookup_key_in_hostkeys_by_type(struct hostkeys *, int,
41 const struct hostkey_entry **);
42
21int hostfile_read_key(char **, u_int *, Key *); 43int hostfile_read_key(char **, u_int *, Key *);
22HostStatus check_host_in_hostfile(const char *, const char *, 44int add_host_to_hostfile(const char *, const char *, const Key *, int);
23 const Key *, Key *, int *);
24int add_host_to_hostfile(const char *, const char *, const Key *, int);
25int lookup_key_in_hostfile_by_type(const char *, const char *,
26 int, Key *, int *);
27 45
28#define HASH_MAGIC "|1|" 46#define HASH_MAGIC "|1|"
29#define HASH_DELIM '|' 47#define HASH_DELIM '|'
diff --git a/includes.h b/includes.h
index 6bb987807..b4c53d9b4 100644
--- a/includes.h
+++ b/includes.h
@@ -30,7 +30,7 @@
30# include <bstring.h> 30# include <bstring.h>
31#endif 31#endif
32#if defined(HAVE_GLOB_H) && defined(GLOB_HAS_ALTDIRFUNC) && \ 32#if defined(HAVE_GLOB_H) && defined(GLOB_HAS_ALTDIRFUNC) && \
33 defined(GLOB_HAS_GL_MATCHC) && \ 33 defined(GLOB_HAS_GL_MATCHC) && defined(GLOB_HAS_GL_STATV) && \
34 defined(HAVE_DECL_GLOB_NOMATCH) && HAVE_DECL_GLOB_NOMATCH != 0 && \ 34 defined(HAVE_DECL_GLOB_NOMATCH) && HAVE_DECL_GLOB_NOMATCH != 0 && \
35 !defined(BROKEN_GLOB) 35 !defined(BROKEN_GLOB)
36# include <glob.h> 36# include <glob.h>
diff --git a/jpake.c b/jpake.c
index cdf65f509..ac9a4bc34 100644
--- a/jpake.c
+++ b/jpake.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: jpake.c,v 1.4 2010/07/13 23:13:16 djm Exp $ */ 1/* $OpenBSD: jpake.c,v 1.6 2010/09/20 04:54:07 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2008 Damien Miller. All rights reserved. 3 * Copyright (c) 2008 Damien Miller. All rights reserved.
4 * 4 *
@@ -45,6 +45,7 @@
45#include "packet.h" 45#include "packet.h"
46#include "dispatch.h" 46#include "dispatch.h"
47#include "log.h" 47#include "log.h"
48#include "misc.h"
48 49
49#include "jpake.h" 50#include "jpake.h"
50#include "schnorr.h" 51#include "schnorr.h"
@@ -257,8 +258,12 @@ jpake_step2(struct modp_group *grp, BIGNUM *s,
257 /* Validate peer's step 1 values */ 258 /* Validate peer's step 1 values */
258 if (BN_cmp(theirpub1, BN_value_one()) <= 0) 259 if (BN_cmp(theirpub1, BN_value_one()) <= 0)
259 fatal("%s: theirpub1 <= 1", __func__); 260 fatal("%s: theirpub1 <= 1", __func__);
261 if (BN_cmp(theirpub1, grp->p) >= 0)
262 fatal("%s: theirpub1 >= p", __func__);
260 if (BN_cmp(theirpub2, BN_value_one()) <= 0) 263 if (BN_cmp(theirpub2, BN_value_one()) <= 0)
261 fatal("%s: theirpub2 <= 1", __func__); 264 fatal("%s: theirpub2 <= 1", __func__);
265 if (BN_cmp(theirpub2, grp->p) >= 0)
266 fatal("%s: theirpub2 >= p", __func__);
262 267
263 if (schnorr_verify_buf(grp->p, grp->q, grp->g, theirpub1, 268 if (schnorr_verify_buf(grp->p, grp->q, grp->g, theirpub1,
264 theirid, theirid_len, theirpub1_proof, theirpub1_proof_len) != 1) 269 theirid, theirid_len, theirpub1_proof, theirpub1_proof_len) != 1)
@@ -363,6 +368,8 @@ jpake_key_confirm(struct modp_group *grp, BIGNUM *s, BIGNUM *step2_val,
363 /* Validate step 2 values */ 368 /* Validate step 2 values */
364 if (BN_cmp(step2_val, BN_value_one()) <= 0) 369 if (BN_cmp(step2_val, BN_value_one()) <= 0)
365 fatal("%s: step2_val <= 1", __func__); 370 fatal("%s: step2_val <= 1", __func__);
371 if (BN_cmp(step2_val, grp->p) >= 0)
372 fatal("%s: step2_val >= p", __func__);
366 373
367 /* 374 /*
368 * theirpriv2_s_proof is calculated with a different generator: 375 * theirpriv2_s_proof is calculated with a different generator:
diff --git a/kex.c b/kex.c
index a09e25228..58349fc19 100644
--- a/kex.c
+++ b/kex.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kex.c,v 1.82 2009/10/24 11:13:54 andreas Exp $ */ 1/* $OpenBSD: kex.c,v 1.86 2010/09/22 05:01:29 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -66,6 +66,34 @@ extern const EVP_MD *evp_ssh_sha256(void);
66static void kex_kexinit_finish(Kex *); 66static void kex_kexinit_finish(Kex *);
67static void kex_choose_conf(Kex *); 67static void kex_choose_conf(Kex *);
68 68
69/* Validate KEX method name list */
70int
71kex_names_valid(const char *names)
72{
73 char *s, *cp, *p;
74
75 if (names == NULL || strcmp(names, "") == 0)
76 return 0;
77 s = cp = xstrdup(names);
78 for ((p = strsep(&cp, ",")); p && *p != '\0';
79 (p = strsep(&cp, ","))) {
80 if (strcmp(p, KEX_DHGEX_SHA256) != 0 &&
81 strcmp(p, KEX_DHGEX_SHA1) != 0 &&
82 strcmp(p, KEX_DH14) != 0 &&
83 strcmp(p, KEX_DH1) != 0 &&
84 (strncmp(p, KEX_ECDH_SHA2_STEM,
85 sizeof(KEX_ECDH_SHA2_STEM) - 1) != 0 ||
86 kex_ecdh_name_to_nid(p) == -1)) {
87 error("Unsupported KEX algorithm \"%.100s\"", p);
88 xfree(s);
89 return 0;
90 }
91 }
92 debug3("kex names ok: [%s]", names);
93 xfree(s);
94 return 1;
95}
96
69/* put algorithm proposal into buffer */ 97/* put algorithm proposal into buffer */
70static void 98static void
71kex_prop2buf(Buffer *b, char *proposal[PROPOSAL_MAX]) 99kex_prop2buf(Buffer *b, char *proposal[PROPOSAL_MAX])
@@ -102,7 +130,7 @@ kex_buf2prop(Buffer *raw, int *first_kex_follows)
102 buffer_get_char(&b); 130 buffer_get_char(&b);
103 /* extract kex init proposal strings */ 131 /* extract kex init proposal strings */
104 for (i = 0; i < PROPOSAL_MAX; i++) { 132 for (i = 0; i < PROPOSAL_MAX; i++) {
105 proposal[i] = buffer_get_string(&b,NULL); 133 proposal[i] = buffer_get_cstring(&b,NULL);
106 debug2("kex_parse_kexinit: %s", proposal[i]); 134 debug2("kex_parse_kexinit: %s", proposal[i]);
107 } 135 }
108 /* first kex follows / reserved */ 136 /* first kex follows / reserved */
@@ -329,6 +357,10 @@ choose_kex(Kex *k, char *client, char *server)
329 } else if (strcmp(k->name, KEX_DHGEX_SHA256) == 0) { 357 } else if (strcmp(k->name, KEX_DHGEX_SHA256) == 0) {
330 k->kex_type = KEX_DH_GEX_SHA256; 358 k->kex_type = KEX_DH_GEX_SHA256;
331 k->evp_md = evp_ssh_sha256(); 359 k->evp_md = evp_ssh_sha256();
360 } else if (strncmp(k->name, KEX_ECDH_SHA2_STEM,
361 sizeof(KEX_ECDH_SHA2_STEM) - 1) == 0) {
362 k->kex_type = KEX_ECDH_SHA2;
363 k->evp_md = kex_ecdh_name_to_evpmd(k->name);
332#endif 364#endif
333#ifdef GSSAPI 365#ifdef GSSAPI
334 } else if (strncmp(k->name, KEX_GSS_GEX_SHA1_ID, 366 } else if (strncmp(k->name, KEX_GSS_GEX_SHA1_ID,
@@ -577,11 +609,11 @@ derive_ssh1_session_id(BIGNUM *host_modulus, BIGNUM *server_modulus,
577 memset(&md, 0, sizeof(md)); 609 memset(&md, 0, sizeof(md));
578} 610}
579 611
580#if defined(DEBUG_KEX) || defined(DEBUG_KEXDH) 612#if defined(DEBUG_KEX) || defined(DEBUG_KEXDH) || defined(DEBUG_KEXECDH)
581void 613void
582dump_digest(char *msg, u_char *digest, int len) 614dump_digest(char *msg, u_char *digest, int len)
583{ 615{
584 u_int i; 616 int i;
585 617
586 fprintf(stderr, "%s\n", msg); 618 fprintf(stderr, "%s\n", msg);
587 for (i = 0; i < len; i++) { 619 for (i = 0; i < len; i++) {
diff --git a/kex.h b/kex.h
index d2668b149..fa50b2ccb 100644
--- a/kex.h
+++ b/kex.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: kex.h,v 1.49 2010/02/26 20:29:54 djm Exp $ */ 1/* $OpenBSD: kex.h,v 1.52 2010/09/22 05:01:29 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
@@ -29,6 +29,9 @@
29#include <signal.h> 29#include <signal.h>
30#include <openssl/evp.h> 30#include <openssl/evp.h>
31#include <openssl/hmac.h> 31#include <openssl/hmac.h>
32#ifdef OPENSSL_HAS_ECC
33#include <openssl/ec.h>
34#endif
32 35
33#define KEX_COOKIE_LEN 16 36#define KEX_COOKIE_LEN 16
34 37
@@ -37,6 +40,8 @@
37#define KEX_DHGEX_SHA1 "diffie-hellman-group-exchange-sha1" 40#define KEX_DHGEX_SHA1 "diffie-hellman-group-exchange-sha1"
38#define KEX_DHGEX_SHA256 "diffie-hellman-group-exchange-sha256" 41#define KEX_DHGEX_SHA256 "diffie-hellman-group-exchange-sha256"
39#define KEX_RESUME "resume@appgate.com" 42#define KEX_RESUME "resume@appgate.com"
43/* The following represents the family of ECDH methods */
44#define KEX_ECDH_SHA2_STEM "ecdh-sha2-"
40 45
41#define COMP_NONE 0 46#define COMP_NONE 0
42#define COMP_ZLIB 1 47#define COMP_ZLIB 1
@@ -67,6 +72,7 @@ enum kex_exchange {
67 KEX_DH_GRP14_SHA1, 72 KEX_DH_GRP14_SHA1,
68 KEX_DH_GEX_SHA1, 73 KEX_DH_GEX_SHA1,
69 KEX_DH_GEX_SHA256, 74 KEX_DH_GEX_SHA256,
75 KEX_ECDH_SHA2,
70 KEX_GSS_GRP1_SHA1, 76 KEX_GSS_GRP1_SHA1,
71 KEX_GSS_GRP14_SHA1, 77 KEX_GSS_GRP14_SHA1,
72 KEX_GSS_GEX_SHA1, 78 KEX_GSS_GEX_SHA1,
@@ -141,6 +147,8 @@ struct Kex {
141 void (*kex[KEX_MAX])(Kex *); 147 void (*kex[KEX_MAX])(Kex *);
142}; 148};
143 149
150int kex_names_valid(const char *);
151
144Kex *kex_setup(char *[PROPOSAL_MAX]); 152Kex *kex_setup(char *[PROPOSAL_MAX]);
145void kex_finish(Kex *); 153void kex_finish(Kex *);
146 154
@@ -154,6 +162,8 @@ void kexdh_client(Kex *);
154void kexdh_server(Kex *); 162void kexdh_server(Kex *);
155void kexgex_client(Kex *); 163void kexgex_client(Kex *);
156void kexgex_server(Kex *); 164void kexgex_server(Kex *);
165void kexecdh_client(Kex *);
166void kexecdh_server(Kex *);
157 167
158#ifdef GSSAPI 168#ifdef GSSAPI
159void kexgss_client(Kex *); 169void kexgss_client(Kex *);
@@ -167,11 +177,22 @@ void
167kexgex_hash(const EVP_MD *, char *, char *, char *, int, char *, 177kexgex_hash(const EVP_MD *, char *, char *, char *, int, char *,
168 int, u_char *, int, int, int, int, BIGNUM *, BIGNUM *, BIGNUM *, 178 int, u_char *, int, int, int, int, BIGNUM *, BIGNUM *, BIGNUM *,
169 BIGNUM *, BIGNUM *, u_char **, u_int *); 179 BIGNUM *, BIGNUM *, u_char **, u_int *);
180#ifdef OPENSSL_HAS_ECC
181void
182kex_ecdh_hash(const EVP_MD *, const EC_GROUP *, char *, char *, char *, int,
183 char *, int, u_char *, int, const EC_POINT *, const EC_POINT *,
184 const BIGNUM *, u_char **, u_int *);
185int kex_ecdh_name_to_nid(const char *);
186const EVP_MD *kex_ecdh_name_to_evpmd(const char *);
187#else
188# define kex_ecdh_name_to_nid(x) (-1)
189# define kex_ecdh_name_to_evpmd(x) (NULL)
190#endif
170 191
171void 192void
172derive_ssh1_session_id(BIGNUM *, BIGNUM *, u_int8_t[8], u_int8_t[16]); 193derive_ssh1_session_id(BIGNUM *, BIGNUM *, u_int8_t[8], u_int8_t[16]);
173 194
174#if defined(DEBUG_KEX) || defined(DEBUG_KEXDH) 195#if defined(DEBUG_KEX) || defined(DEBUG_KEXDH) || defined(DEBUG_KEXECDH)
175void dump_digest(char *, u_char *, int); 196void dump_digest(char *, u_char *, int);
176#endif 197#endif
177 198
diff --git a/kexdhc.c b/kexdhc.c
index d384c8052..76ceb5dd8 100644
--- a/kexdhc.c
+++ b/kexdhc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexdhc.c,v 1.11 2006/11/06 21:25:28 markus Exp $ */ 1/* $OpenBSD: kexdhc.c,v 1.12 2010/11/10 01:33:07 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -27,6 +27,8 @@
27 27
28#include <sys/types.h> 28#include <sys/types.h>
29 29
30#include <openssl/dh.h>
31
30#include <stdarg.h> 32#include <stdarg.h>
31#include <stdio.h> 33#include <stdio.h>
32#include <string.h> 34#include <string.h>
diff --git a/kexdhs.c b/kexdhs.c
index e722877d5..f56e88764 100644
--- a/kexdhs.c
+++ b/kexdhs.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexdhs.c,v 1.11 2010/02/26 20:29:54 djm Exp $ */ 1/* $OpenBSD: kexdhs.c,v 1.12 2010/11/10 01:33:07 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -31,6 +31,8 @@
31#include <string.h> 31#include <string.h>
32#include <signal.h> 32#include <signal.h>
33 33
34#include <openssl/dh.h>
35
34#include "xmalloc.h" 36#include "xmalloc.h"
35#include "buffer.h" 37#include "buffer.h"
36#include "key.h" 38#include "key.h"
diff --git a/kexecdh.c b/kexecdh.c
new file mode 100644
index 000000000..f13f69d3b
--- /dev/null
+++ b/kexecdh.c
@@ -0,0 +1,117 @@
1/* $OpenBSD: kexecdh.c,v 1.3 2010/09/22 05:01:29 djm Exp $ */
2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2010 Damien Miller. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include "includes.h"
28
29#ifdef OPENSSL_HAS_ECC
30
31#include <sys/types.h>
32
33#include <signal.h>
34#include <string.h>
35
36#include <openssl/bn.h>
37#include <openssl/evp.h>
38#include <openssl/ec.h>
39#include <openssl/ecdh.h>
40
41#include "buffer.h"
42#include "ssh2.h"
43#include "key.h"
44#include "cipher.h"
45#include "kex.h"
46#include "log.h"
47
48int
49kex_ecdh_name_to_nid(const char *kexname)
50{
51 if (strlen(kexname) < sizeof(KEX_ECDH_SHA2_STEM) - 1)
52 fatal("%s: kexname too short \"%s\"", __func__, kexname);
53 return key_curve_name_to_nid(kexname + sizeof(KEX_ECDH_SHA2_STEM) - 1);
54}
55
56const EVP_MD *
57kex_ecdh_name_to_evpmd(const char *kexname)
58{
59 int nid = kex_ecdh_name_to_nid(kexname);
60
61 if (nid == -1)
62 fatal("%s: unsupported ECDH curve \"%s\"", __func__, kexname);
63 return key_ec_nid_to_evpmd(nid);
64}
65
66void
67kex_ecdh_hash(
68 const EVP_MD *evp_md,
69 const EC_GROUP *ec_group,
70 char *client_version_string,
71 char *server_version_string,
72 char *ckexinit, int ckexinitlen,
73 char *skexinit, int skexinitlen,
74 u_char *serverhostkeyblob, int sbloblen,
75 const EC_POINT *client_dh_pub,
76 const EC_POINT *server_dh_pub,
77 const BIGNUM *shared_secret,
78 u_char **hash, u_int *hashlen)
79{
80 Buffer b;
81 EVP_MD_CTX md;
82 static u_char digest[EVP_MAX_MD_SIZE];
83
84 buffer_init(&b);
85 buffer_put_cstring(&b, client_version_string);
86 buffer_put_cstring(&b, server_version_string);
87
88 /* kexinit messages: fake header: len+SSH2_MSG_KEXINIT */
89 buffer_put_int(&b, ckexinitlen+1);
90 buffer_put_char(&b, SSH2_MSG_KEXINIT);
91 buffer_append(&b, ckexinit, ckexinitlen);
92 buffer_put_int(&b, skexinitlen+1);
93 buffer_put_char(&b, SSH2_MSG_KEXINIT);
94 buffer_append(&b, skexinit, skexinitlen);
95
96 buffer_put_string(&b, serverhostkeyblob, sbloblen);
97 buffer_put_ecpoint(&b, ec_group, client_dh_pub);
98 buffer_put_ecpoint(&b, ec_group, server_dh_pub);
99 buffer_put_bignum2(&b, shared_secret);
100
101#ifdef DEBUG_KEX
102 buffer_dump(&b);
103#endif
104 EVP_DigestInit(&md, evp_md);
105 EVP_DigestUpdate(&md, buffer_ptr(&b), buffer_len(&b));
106 EVP_DigestFinal(&md, digest, NULL);
107
108 buffer_free(&b);
109
110#ifdef DEBUG_KEX
111 dump_digest("hash", digest, EVP_MD_size(evp_md));
112#endif
113 *hash = digest;
114 *hashlen = EVP_MD_size(evp_md);
115}
116
117#endif /* OPENSSL_HAS_ECC */
diff --git a/kexecdhc.c b/kexecdhc.c
new file mode 100644
index 000000000..115d4bf83
--- /dev/null
+++ b/kexecdhc.c
@@ -0,0 +1,168 @@
1/* $OpenBSD: kexecdhc.c,v 1.2 2010/09/22 05:01:29 djm Exp $ */
2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2010 Damien Miller. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include "includes.h"
28
29#include <sys/types.h>
30
31#include <stdio.h>
32#include <string.h>
33#include <signal.h>
34
35#include "xmalloc.h"
36#include "buffer.h"
37#include "key.h"
38#include "cipher.h"
39#include "kex.h"
40#include "log.h"
41#include "packet.h"
42#include "dh.h"
43#include "ssh2.h"
44
45#ifdef OPENSSL_HAS_ECC
46
47#include <openssl/ecdh.h>
48
49void
50kexecdh_client(Kex *kex)
51{
52 EC_KEY *client_key;
53 EC_POINT *server_public;
54 const EC_GROUP *group;
55 BIGNUM *shared_secret;
56 Key *server_host_key;
57 u_char *server_host_key_blob = NULL, *signature = NULL;
58 u_char *kbuf, *hash;
59 u_int klen, slen, sbloblen, hashlen;
60 int curve_nid;
61
62 if ((curve_nid = kex_ecdh_name_to_nid(kex->name)) == -1)
63 fatal("%s: unsupported ECDH curve \"%s\"", __func__, kex->name);
64 if ((client_key = EC_KEY_new_by_curve_name(curve_nid)) == NULL)
65 fatal("%s: EC_KEY_new_by_curve_name failed", __func__);
66 if (EC_KEY_generate_key(client_key) != 1)
67 fatal("%s: EC_KEY_generate_key failed", __func__);
68 group = EC_KEY_get0_group(client_key);
69
70 packet_start(SSH2_MSG_KEX_ECDH_INIT);
71 packet_put_ecpoint(group, EC_KEY_get0_public_key(client_key));
72 packet_send();
73 debug("sending SSH2_MSG_KEX_ECDH_INIT");
74
75#ifdef DEBUG_KEXECDH
76 fputs("client private key:\n", stderr);
77 key_dump_ec_key(client_key);
78#endif
79
80 debug("expecting SSH2_MSG_KEX_ECDH_REPLY");
81 packet_read_expect(SSH2_MSG_KEX_ECDH_REPLY);
82
83 /* hostkey */
84 server_host_key_blob = packet_get_string(&sbloblen);
85 server_host_key = key_from_blob(server_host_key_blob, sbloblen);
86 if (server_host_key == NULL)
87 fatal("cannot decode server_host_key_blob");
88 if (server_host_key->type != kex->hostkey_type)
89 fatal("type mismatch for decoded server_host_key_blob");
90 if (kex->verify_host_key == NULL)
91 fatal("cannot verify server_host_key");
92 if (kex->verify_host_key(server_host_key) == -1)
93 fatal("server_host_key verification failed");
94
95 /* Q_S, server public key */
96 if ((server_public = EC_POINT_new(group)) == NULL)
97 fatal("%s: EC_POINT_new failed", __func__);
98 packet_get_ecpoint(group, server_public);
99
100 if (key_ec_validate_public(group, server_public) != 0)
101 fatal("%s: invalid server public key", __func__);
102
103#ifdef DEBUG_KEXECDH
104 fputs("server public key:\n", stderr);
105 key_dump_ec_point(group, server_public);
106#endif
107
108 /* signed H */
109 signature = packet_get_string(&slen);
110 packet_check_eom();
111
112 klen = (EC_GROUP_get_degree(group) + 7) / 8;
113 kbuf = xmalloc(klen);
114 if (ECDH_compute_key(kbuf, klen, server_public,
115 client_key, NULL) != (int)klen)
116 fatal("%s: ECDH_compute_key failed", __func__);
117
118#ifdef DEBUG_KEXECDH
119 dump_digest("shared secret", kbuf, klen);
120#endif
121 if ((shared_secret = BN_new()) == NULL)
122 fatal("%s: BN_new failed", __func__);
123 if (BN_bin2bn(kbuf, klen, shared_secret) == NULL)
124 fatal("%s: BN_bin2bn failed", __func__);
125 memset(kbuf, 0, klen);
126 xfree(kbuf);
127
128 /* calc and verify H */
129 kex_ecdh_hash(
130 kex->evp_md,
131 group,
132 kex->client_version_string,
133 kex->server_version_string,
134 buffer_ptr(&kex->my), buffer_len(&kex->my),
135 buffer_ptr(&kex->peer), buffer_len(&kex->peer),
136 server_host_key_blob, sbloblen,
137 EC_KEY_get0_public_key(client_key),
138 server_public,
139 shared_secret,
140 &hash, &hashlen
141 );
142 xfree(server_host_key_blob);
143 EC_POINT_clear_free(server_public);
144 EC_KEY_free(client_key);
145
146 if (key_verify(server_host_key, signature, slen, hash, hashlen) != 1)
147 fatal("key_verify failed for server_host_key");
148 key_free(server_host_key);
149 xfree(signature);
150
151 /* save session id */
152 if (kex->session_id == NULL) {
153 kex->session_id_len = hashlen;
154 kex->session_id = xmalloc(kex->session_id_len);
155 memcpy(kex->session_id, hash, kex->session_id_len);
156 }
157
158 kex_derive_keys(kex, hash, hashlen, shared_secret);
159 BN_clear_free(shared_secret);
160 kex_finish(kex);
161}
162#else /* OPENSSL_HAS_ECC */
163void
164kexecdh_client(Kex *kex)
165{
166 fatal("ECC support is not enabled");
167}
168#endif /* OPENSSL_HAS_ECC */
diff --git a/kexecdhs.c b/kexecdhs.c
new file mode 100644
index 000000000..8c515dfa6
--- /dev/null
+++ b/kexecdhs.c
@@ -0,0 +1,173 @@
1/* $OpenBSD: kexecdhs.c,v 1.2 2010/09/22 05:01:29 djm Exp $ */
2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2010 Damien Miller. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include "includes.h"
28
29#include <sys/types.h>
30#include <string.h>
31#include <signal.h>
32
33#include "xmalloc.h"
34#include "buffer.h"
35#include "key.h"
36#include "cipher.h"
37#include "kex.h"
38#include "log.h"
39#include "packet.h"
40#include "dh.h"
41#include "ssh2.h"
42#ifdef GSSAPI
43#include "ssh-gss.h"
44#endif
45#include "monitor_wrap.h"
46
47#ifdef OPENSSL_HAS_ECC
48
49#include <openssl/ecdh.h>
50
51void
52kexecdh_server(Kex *kex)
53{
54 EC_POINT *client_public;
55 EC_KEY *server_key;
56 const EC_GROUP *group;
57 BIGNUM *shared_secret;
58 Key *server_host_private, *server_host_public;
59 u_char *server_host_key_blob = NULL, *signature = NULL;
60 u_char *kbuf, *hash;
61 u_int klen, slen, sbloblen, hashlen;
62 int curve_nid;
63
64 if ((curve_nid = kex_ecdh_name_to_nid(kex->name)) == -1)
65 fatal("%s: unsupported ECDH curve \"%s\"", __func__, kex->name);
66 if ((server_key = EC_KEY_new_by_curve_name(curve_nid)) == NULL)
67 fatal("%s: EC_KEY_new_by_curve_name failed", __func__);
68 if (EC_KEY_generate_key(server_key) != 1)
69 fatal("%s: EC_KEY_generate_key failed", __func__);
70 group = EC_KEY_get0_group(server_key);
71
72#ifdef DEBUG_KEXECDH
73 fputs("server private key:\n", stderr);
74 key_dump_ec_key(server_key);
75#endif
76
77 if (kex->load_host_public_key == NULL ||
78 kex->load_host_private_key == NULL)
79 fatal("Cannot load hostkey");
80 server_host_public = kex->load_host_public_key(kex->hostkey_type);
81 if (server_host_public == NULL)
82 fatal("Unsupported hostkey type %d", kex->hostkey_type);
83 server_host_private = kex->load_host_private_key(kex->hostkey_type);
84 if (server_host_private == NULL)
85 fatal("Missing private key for hostkey type %d",
86 kex->hostkey_type);
87
88 debug("expecting SSH2_MSG_KEX_ECDH_INIT");
89 packet_read_expect(SSH2_MSG_KEX_ECDH_INIT);
90 if ((client_public = EC_POINT_new(group)) == NULL)
91 fatal("%s: EC_POINT_new failed", __func__);
92 packet_get_ecpoint(group, client_public);
93 packet_check_eom();
94
95 if (key_ec_validate_public(group, client_public) != 0)
96 fatal("%s: invalid client public key", __func__);
97
98#ifdef DEBUG_KEXECDH
99 fputs("client public key:\n", stderr);
100 key_dump_ec_point(group, client_public);
101#endif
102
103 /* Calculate shared_secret */
104 klen = (EC_GROUP_get_degree(group) + 7) / 8;
105 kbuf = xmalloc(klen);
106 if (ECDH_compute_key(kbuf, klen, client_public,
107 server_key, NULL) != (int)klen)
108 fatal("%s: ECDH_compute_key failed", __func__);
109
110#ifdef DEBUG_KEXDH
111 dump_digest("shared secret", kbuf, klen);
112#endif
113 if ((shared_secret = BN_new()) == NULL)
114 fatal("%s: BN_new failed", __func__);
115 if (BN_bin2bn(kbuf, klen, shared_secret) == NULL)
116 fatal("%s: BN_bin2bn failed", __func__);
117 memset(kbuf, 0, klen);
118 xfree(kbuf);
119
120 /* calc H */
121 key_to_blob(server_host_public, &server_host_key_blob, &sbloblen);
122 kex_ecdh_hash(
123 kex->evp_md,
124 group,
125 kex->client_version_string,
126 kex->server_version_string,
127 buffer_ptr(&kex->peer), buffer_len(&kex->peer),
128 buffer_ptr(&kex->my), buffer_len(&kex->my),
129 server_host_key_blob, sbloblen,
130 client_public,
131 EC_KEY_get0_public_key(server_key),
132 shared_secret,
133 &hash, &hashlen
134 );
135 EC_POINT_clear_free(client_public);
136
137 /* save session id := H */
138 if (kex->session_id == NULL) {
139 kex->session_id_len = hashlen;
140 kex->session_id = xmalloc(kex->session_id_len);
141 memcpy(kex->session_id, hash, kex->session_id_len);
142 }
143
144 /* sign H */
145 if (PRIVSEP(key_sign(server_host_private, &signature, &slen,
146 hash, hashlen)) < 0)
147 fatal("kexdh_server: key_sign failed");
148
149 /* destroy_sensitive_data(); */
150
151 /* send server hostkey, ECDH pubkey 'Q_S' and signed H */
152 packet_start(SSH2_MSG_KEX_ECDH_REPLY);
153 packet_put_string(server_host_key_blob, sbloblen);
154 packet_put_ecpoint(group, EC_KEY_get0_public_key(server_key));
155 packet_put_string(signature, slen);
156 packet_send();
157
158 xfree(signature);
159 xfree(server_host_key_blob);
160 /* have keys, free server key */
161 EC_KEY_free(server_key);
162
163 kex_derive_keys(kex, hash, hashlen, shared_secret);
164 BN_clear_free(shared_secret);
165 kex_finish(kex);
166}
167#else /* OPENSSL_HAS_ECC */
168void
169kexecdh_server(Kex *kex)
170{
171 fatal("ECC support is not enabled");
172}
173#endif /* OPENSSL_HAS_ECC */
diff --git a/kexgexc.c b/kexgexc.c
index adb973d5b..79552d709 100644
--- a/kexgexc.c
+++ b/kexgexc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexgexc.c,v 1.11 2006/11/06 21:25:28 markus Exp $ */ 1/* $OpenBSD: kexgexc.c,v 1.12 2010/11/10 01:33:07 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Niels Provos. All rights reserved. 3 * Copyright (c) 2000 Niels Provos. All rights reserved.
4 * Copyright (c) 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -28,6 +28,8 @@
28 28
29#include <sys/types.h> 29#include <sys/types.h>
30 30
31#include <openssl/dh.h>
32
31#include <stdarg.h> 33#include <stdarg.h>
32#include <stdio.h> 34#include <stdio.h>
33#include <string.h> 35#include <string.h>
diff --git a/kexgexs.c b/kexgexs.c
index f4156af96..a5e3df7bc 100644
--- a/kexgexs.c
+++ b/kexgexs.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexgexs.c,v 1.13 2010/02/26 20:29:54 djm Exp $ */ 1/* $OpenBSD: kexgexs.c,v 1.14 2010/11/10 01:33:07 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Niels Provos. All rights reserved. 3 * Copyright (c) 2000 Niels Provos. All rights reserved.
4 * Copyright (c) 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -33,6 +33,8 @@
33#include <string.h> 33#include <string.h>
34#include <signal.h> 34#include <signal.h>
35 35
36#include <openssl/dh.h>
37
36#include "xmalloc.h" 38#include "xmalloc.h"
37#include "buffer.h" 39#include "buffer.h"
38#include "key.h" 40#include "key.h"
diff --git a/key.c b/key.c
index 020f503b6..6ccfd8dcb 100644
--- a/key.c
+++ b/key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: key.c,v 1.90 2010/07/13 23:13:16 djm Exp $ */ 1/* $OpenBSD: key.c,v 1.95 2010/11/10 01:33:07 djm Exp $ */
2/* 2/*
3 * read_bignum(): 3 * read_bignum():
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -78,6 +78,8 @@ key_new(int type)
78 DSA *dsa; 78 DSA *dsa;
79 k = xcalloc(1, sizeof(*k)); 79 k = xcalloc(1, sizeof(*k));
80 k->type = type; 80 k->type = type;
81 k->ecdsa = NULL;
82 k->ecdsa_nid = -1;
81 k->dsa = NULL; 83 k->dsa = NULL;
82 k->rsa = NULL; 84 k->rsa = NULL;
83 k->cert = NULL; 85 k->cert = NULL;
@@ -109,6 +111,12 @@ key_new(int type)
109 fatal("key_new: BN_new failed"); 111 fatal("key_new: BN_new failed");
110 k->dsa = dsa; 112 k->dsa = dsa;
111 break; 113 break;
114#ifdef OPENSSL_HAS_ECC
115 case KEY_ECDSA:
116 case KEY_ECDSA_CERT:
117 /* Cannot do anything until we know the group */
118 break;
119#endif
112 case KEY_UNSPEC: 120 case KEY_UNSPEC:
113 break; 121 break;
114 default: 122 default:
@@ -149,6 +157,10 @@ key_add_private(Key *k)
149 if ((k->dsa->priv_key = BN_new()) == NULL) 157 if ((k->dsa->priv_key = BN_new()) == NULL)
150 fatal("key_new_private: BN_new failed"); 158 fatal("key_new_private: BN_new failed");
151 break; 159 break;
160 case KEY_ECDSA:
161 case KEY_ECDSA_CERT:
162 /* Cannot do anything until we know the group */
163 break;
152 case KEY_UNSPEC: 164 case KEY_UNSPEC:
153 break; 165 break;
154 default: 166 default:
@@ -204,6 +216,14 @@ key_free(Key *k)
204 DSA_free(k->dsa); 216 DSA_free(k->dsa);
205 k->dsa = NULL; 217 k->dsa = NULL;
206 break; 218 break;
219#ifdef OPENSSL_HAS_ECC
220 case KEY_ECDSA:
221 case KEY_ECDSA_CERT:
222 if (k->ecdsa != NULL)
223 EC_KEY_free(k->ecdsa);
224 k->ecdsa = NULL;
225 break;
226#endif
207 case KEY_UNSPEC: 227 case KEY_UNSPEC:
208 break; 228 break;
209 default: 229 default:
@@ -241,6 +261,10 @@ cert_compare(struct KeyCert *a, struct KeyCert *b)
241int 261int
242key_equal_public(const Key *a, const Key *b) 262key_equal_public(const Key *a, const Key *b)
243{ 263{
264#ifdef OPENSSL_HAS_ECC
265 BN_CTX *bnctx;
266#endif
267
244 if (a == NULL || b == NULL || 268 if (a == NULL || b == NULL ||
245 key_type_plain(a->type) != key_type_plain(b->type)) 269 key_type_plain(a->type) != key_type_plain(b->type))
246 return 0; 270 return 0;
@@ -261,6 +285,26 @@ key_equal_public(const Key *a, const Key *b)
261 BN_cmp(a->dsa->q, b->dsa->q) == 0 && 285 BN_cmp(a->dsa->q, b->dsa->q) == 0 &&
262 BN_cmp(a->dsa->g, b->dsa->g) == 0 && 286 BN_cmp(a->dsa->g, b->dsa->g) == 0 &&
263 BN_cmp(a->dsa->pub_key, b->dsa->pub_key) == 0; 287 BN_cmp(a->dsa->pub_key, b->dsa->pub_key) == 0;
288#ifdef OPENSSL_HAS_ECC
289 case KEY_ECDSA_CERT:
290 case KEY_ECDSA:
291 if (a->ecdsa == NULL || b->ecdsa == NULL ||
292 EC_KEY_get0_public_key(a->ecdsa) == NULL ||
293 EC_KEY_get0_public_key(b->ecdsa) == NULL)
294 return 0;
295 if ((bnctx = BN_CTX_new()) == NULL)
296 fatal("%s: BN_CTX_new failed", __func__);
297 if (EC_GROUP_cmp(EC_KEY_get0_group(a->ecdsa),
298 EC_KEY_get0_group(b->ecdsa), bnctx) != 0 ||
299 EC_POINT_cmp(EC_KEY_get0_group(a->ecdsa),
300 EC_KEY_get0_public_key(a->ecdsa),
301 EC_KEY_get0_public_key(b->ecdsa), bnctx) != 0) {
302 BN_CTX_free(bnctx);
303 return 0;
304 }
305 BN_CTX_free(bnctx);
306 return 1;
307#endif /* OPENSSL_HAS_ECC */
264 default: 308 default:
265 fatal("key_equal: bad key type %d", a->type); 309 fatal("key_equal: bad key type %d", a->type);
266 } 310 }
@@ -312,12 +356,14 @@ key_fingerprint_raw(Key *k, enum fp_type dgst_type, u_int *dgst_raw_length)
312 BN_bn2bin(k->rsa->e, blob + nlen); 356 BN_bn2bin(k->rsa->e, blob + nlen);
313 break; 357 break;
314 case KEY_DSA: 358 case KEY_DSA:
359 case KEY_ECDSA:
315 case KEY_RSA: 360 case KEY_RSA:
316 key_to_blob(k, &blob, &len); 361 key_to_blob(k, &blob, &len);
317 break; 362 break;
318 case KEY_DSA_CERT_V00: 363 case KEY_DSA_CERT_V00:
319 case KEY_RSA_CERT_V00: 364 case KEY_RSA_CERT_V00:
320 case KEY_DSA_CERT: 365 case KEY_DSA_CERT:
366 case KEY_ECDSA_CERT:
321 case KEY_RSA_CERT: 367 case KEY_RSA_CERT:
322 /* We want a fingerprint of the _key_ not of the cert */ 368 /* We want a fingerprint of the _key_ not of the cert */
323 otype = k->type; 369 otype = k->type;
@@ -615,6 +661,9 @@ key_read(Key *ret, char **cpp)
615 int len, n, type; 661 int len, n, type;
616 u_int bits; 662 u_int bits;
617 u_char *blob; 663 u_char *blob;
664#ifdef OPENSSL_HAS_ECC
665 int curve_nid = -1;
666#endif
618 667
619 cp = *cpp; 668 cp = *cpp;
620 669
@@ -644,9 +693,11 @@ key_read(Key *ret, char **cpp)
644 case KEY_UNSPEC: 693 case KEY_UNSPEC:
645 case KEY_RSA: 694 case KEY_RSA:
646 case KEY_DSA: 695 case KEY_DSA:
696 case KEY_ECDSA:
647 case KEY_DSA_CERT_V00: 697 case KEY_DSA_CERT_V00:
648 case KEY_RSA_CERT_V00: 698 case KEY_RSA_CERT_V00:
649 case KEY_DSA_CERT: 699 case KEY_DSA_CERT:
700 case KEY_ECDSA_CERT:
650 case KEY_RSA_CERT: 701 case KEY_RSA_CERT:
651 space = strchr(cp, ' '); 702 space = strchr(cp, ' ');
652 if (space == NULL) { 703 if (space == NULL) {
@@ -655,6 +706,13 @@ key_read(Key *ret, char **cpp)
655 } 706 }
656 *space = '\0'; 707 *space = '\0';
657 type = key_type_from_name(cp); 708 type = key_type_from_name(cp);
709#ifdef OPENSSL_HAS_ECC
710 if (key_type_plain(type) == KEY_ECDSA &&
711 (curve_nid = key_ecdsa_nid_from_name(cp)) == -1) {
712 debug("key_read: invalid curve");
713 return -1;
714 }
715#endif
658 *space = ' '; 716 *space = ' ';
659 if (type == KEY_UNSPEC) { 717 if (type == KEY_UNSPEC) {
660 debug3("key_read: missing keytype"); 718 debug3("key_read: missing keytype");
@@ -691,6 +749,14 @@ key_read(Key *ret, char **cpp)
691 key_free(k); 749 key_free(k);
692 return -1; 750 return -1;
693 } 751 }
752#ifdef OPENSSL_HAS_ECC
753 if (key_type_plain(type) == KEY_ECDSA &&
754 curve_nid != k->ecdsa_nid) {
755 error("key_read: type mismatch: EC curve mismatch");
756 key_free(k);
757 return -1;
758 }
759#endif
694/*XXXX*/ 760/*XXXX*/
695 if (key_is_cert(ret)) { 761 if (key_is_cert(ret)) {
696 if (!key_is_cert(k)) { 762 if (!key_is_cert(k)) {
@@ -721,6 +787,19 @@ key_read(Key *ret, char **cpp)
721 DSA_print_fp(stderr, ret->dsa, 8); 787 DSA_print_fp(stderr, ret->dsa, 8);
722#endif 788#endif
723 } 789 }
790#ifdef OPENSSL_HAS_ECC
791 if (key_type_plain(ret->type) == KEY_ECDSA) {
792 if (ret->ecdsa != NULL)
793 EC_KEY_free(ret->ecdsa);
794 ret->ecdsa = k->ecdsa;
795 ret->ecdsa_nid = k->ecdsa_nid;
796 k->ecdsa = NULL;
797 k->ecdsa_nid = -1;
798#ifdef DEBUG_PK
799 key_dump_ec_key(ret->ecdsa);
800#endif
801 }
802#endif
724 success = 1; 803 success = 1;
725/*XXXX*/ 804/*XXXX*/
726 key_free(k); 805 key_free(k);
@@ -777,6 +856,13 @@ key_write(const Key *key, FILE *f)
777 if (key->dsa == NULL) 856 if (key->dsa == NULL)
778 return 0; 857 return 0;
779 break; 858 break;
859#ifdef OPENSSL_HAS_ECC
860 case KEY_ECDSA:
861 case KEY_ECDSA_CERT:
862 if (key->ecdsa == NULL)
863 return 0;
864 break;
865#endif
780 case KEY_RSA: 866 case KEY_RSA:
781 case KEY_RSA_CERT_V00: 867 case KEY_RSA_CERT_V00:
782 case KEY_RSA_CERT: 868 case KEY_RSA_CERT:
@@ -810,6 +896,10 @@ key_type(const Key *k)
810 return "RSA"; 896 return "RSA";
811 case KEY_DSA: 897 case KEY_DSA:
812 return "DSA"; 898 return "DSA";
899#ifdef OPENSSL_HAS_ECC
900 case KEY_ECDSA:
901 return "ECDSA";
902#endif
813 case KEY_RSA_CERT_V00: 903 case KEY_RSA_CERT_V00:
814 return "RSA-CERT-V00"; 904 return "RSA-CERT-V00";
815 case KEY_DSA_CERT_V00: 905 case KEY_DSA_CERT_V00:
@@ -818,6 +908,10 @@ key_type(const Key *k)
818 return "RSA-CERT"; 908 return "RSA-CERT";
819 case KEY_DSA_CERT: 909 case KEY_DSA_CERT:
820 return "DSA-CERT"; 910 return "DSA-CERT";
911#ifdef OPENSSL_HAS_ECC
912 case KEY_ECDSA_CERT:
913 return "ECDSA-CERT";
914#endif
821 } 915 }
822 return "unknown"; 916 return "unknown";
823} 917}
@@ -835,10 +929,10 @@ key_cert_type(const Key *k)
835 } 929 }
836} 930}
837 931
838const char * 932static const char *
839key_ssh_name(const Key *k) 933key_ssh_name_from_type_nid(int type, int nid)
840{ 934{
841 switch (k->type) { 935 switch (type) {
842 case KEY_RSA: 936 case KEY_RSA:
843 return "ssh-rsa"; 937 return "ssh-rsa";
844 case KEY_DSA: 938 case KEY_DSA:
@@ -851,12 +945,51 @@ key_ssh_name(const Key *k)
851 return "ssh-rsa-cert-v01@openssh.com"; 945 return "ssh-rsa-cert-v01@openssh.com";
852 case KEY_DSA_CERT: 946 case KEY_DSA_CERT:
853 return "ssh-dss-cert-v01@openssh.com"; 947 return "ssh-dss-cert-v01@openssh.com";
948#ifdef OPENSSL_HAS_ECC
949 case KEY_ECDSA:
950 switch (nid) {
951 case NID_X9_62_prime256v1:
952 return "ecdsa-sha2-nistp256";
953 case NID_secp384r1:
954 return "ecdsa-sha2-nistp384";
955 case NID_secp521r1:
956 return "ecdsa-sha2-nistp521";
957 default:
958 break;
959 }
960 break;
961 case KEY_ECDSA_CERT:
962 switch (nid) {
963 case NID_X9_62_prime256v1:
964 return "ecdsa-sha2-nistp256-cert-v01@openssh.com";
965 case NID_secp384r1:
966 return "ecdsa-sha2-nistp384-cert-v01@openssh.com";
967 case NID_secp521r1:
968 return "ecdsa-sha2-nistp521-cert-v01@openssh.com";
969 default:
970 break;
971 }
972 break;
973#endif /* OPENSSL_HAS_ECC */
854 case KEY_NULL: 974 case KEY_NULL:
855 return "null"; 975 return "null";
856 } 976 }
857 return "ssh-unknown"; 977 return "ssh-unknown";
858} 978}
859 979
980const char *
981key_ssh_name(const Key *k)
982{
983 return key_ssh_name_from_type_nid(k->type, k->ecdsa_nid);
984}
985
986const char *
987key_ssh_name_plain(const Key *k)
988{
989 return key_ssh_name_from_type_nid(key_type_plain(k->type),
990 k->ecdsa_nid);
991}
992
860u_int 993u_int
861key_size(const Key *k) 994key_size(const Key *k)
862{ 995{
@@ -870,6 +1003,11 @@ key_size(const Key *k)
870 case KEY_DSA_CERT_V00: 1003 case KEY_DSA_CERT_V00:
871 case KEY_DSA_CERT: 1004 case KEY_DSA_CERT:
872 return BN_num_bits(k->dsa->p); 1005 return BN_num_bits(k->dsa->p);
1006#ifdef OPENSSL_HAS_ECC
1007 case KEY_ECDSA:
1008 case KEY_ECDSA_CERT:
1009 return key_curve_nid_to_bits(k->ecdsa_nid);
1010#endif
873 } 1011 }
874 return 0; 1012 return 0;
875} 1013}
@@ -877,27 +1015,115 @@ key_size(const Key *k)
877static RSA * 1015static RSA *
878rsa_generate_private_key(u_int bits) 1016rsa_generate_private_key(u_int bits)
879{ 1017{
880 RSA *private; 1018 RSA *private = RSA_new();
1019 BIGNUM *f4 = BN_new();
881 1020
882 private = RSA_generate_key(bits, RSA_F4, NULL, NULL);
883 if (private == NULL) 1021 if (private == NULL)
884 fatal("rsa_generate_private_key: key generation failed."); 1022 fatal("%s: RSA_new failed", __func__);
1023 if (f4 == NULL)
1024 fatal("%s: BN_new failed", __func__);
1025 if (!BN_set_word(f4, RSA_F4))
1026 fatal("%s: BN_new failed", __func__);
1027 if (!RSA_generate_key_ex(private, bits, f4, NULL))
1028 fatal("%s: key generation failed.", __func__);
1029 BN_free(f4);
885 return private; 1030 return private;
886} 1031}
887 1032
888static DSA* 1033static DSA*
889dsa_generate_private_key(u_int bits) 1034dsa_generate_private_key(u_int bits)
890{ 1035{
891 DSA *private = DSA_generate_parameters(bits, NULL, 0, NULL, NULL, NULL, NULL); 1036 DSA *private = DSA_new();
892 1037
893 if (private == NULL) 1038 if (private == NULL)
894 fatal("dsa_generate_private_key: DSA_generate_parameters failed"); 1039 fatal("%s: DSA_new failed", __func__);
1040 if (!DSA_generate_parameters_ex(private, bits, NULL, 0, NULL,
1041 NULL, NULL))
1042 fatal("%s: DSA_generate_parameters failed", __func__);
895 if (!DSA_generate_key(private)) 1043 if (!DSA_generate_key(private))
896 fatal("dsa_generate_private_key: DSA_generate_key failed."); 1044 fatal("%s: DSA_generate_key failed.", __func__);
897 if (private == NULL) 1045 return private;
898 fatal("dsa_generate_private_key: NULL."); 1046}
1047
1048int
1049key_ecdsa_bits_to_nid(int bits)
1050{
1051 switch (bits) {
1052#ifdef OPENSSL_HAS_ECC
1053 case 256:
1054 return NID_X9_62_prime256v1;
1055 case 384:
1056 return NID_secp384r1;
1057 case 521:
1058 return NID_secp521r1;
1059#endif
1060 default:
1061 return -1;
1062 }
1063}
1064
1065#ifdef OPENSSL_HAS_ECC
1066int
1067key_ecdsa_key_to_nid(EC_KEY *k)
1068{
1069 EC_GROUP *eg;
1070 int nids[] = {
1071 NID_X9_62_prime256v1,
1072 NID_secp384r1,
1073 NID_secp521r1,
1074 -1
1075 };
1076 int nid;
1077 u_int i;
1078 BN_CTX *bnctx;
1079 const EC_GROUP *g = EC_KEY_get0_group(k);
1080
1081 /*
1082 * The group may be stored in a ASN.1 encoded private key in one of two
1083 * ways: as a "named group", which is reconstituted by ASN.1 object ID
1084 * or explicit group parameters encoded into the key blob. Only the
1085 * "named group" case sets the group NID for us, but we can figure
1086 * it out for the other case by comparing against all the groups that
1087 * are supported.
1088 */
1089 if ((nid = EC_GROUP_get_curve_name(g)) > 0)
1090 return nid;
1091 if ((bnctx = BN_CTX_new()) == NULL)
1092 fatal("%s: BN_CTX_new() failed", __func__);
1093 for (i = 0; nids[i] != -1; i++) {
1094 if ((eg = EC_GROUP_new_by_curve_name(nids[i])) == NULL)
1095 fatal("%s: EC_GROUP_new_by_curve_name failed",
1096 __func__);
1097 if (EC_GROUP_cmp(g, eg, bnctx) == 0)
1098 break;
1099 EC_GROUP_free(eg);
1100 }
1101 BN_CTX_free(bnctx);
1102 debug3("%s: nid = %d", __func__, nids[i]);
1103 if (nids[i] != -1) {
1104 /* Use the group with the NID attached */
1105 EC_GROUP_set_asn1_flag(eg, OPENSSL_EC_NAMED_CURVE);
1106 if (EC_KEY_set_group(k, eg) != 1)
1107 fatal("%s: EC_KEY_set_group", __func__);
1108 }
1109 return nids[i];
1110}
1111
1112static EC_KEY*
1113ecdsa_generate_private_key(u_int bits, int *nid)
1114{
1115 EC_KEY *private;
1116
1117 if ((*nid = key_ecdsa_bits_to_nid(bits)) == -1)
1118 fatal("%s: invalid key length", __func__);
1119 if ((private = EC_KEY_new_by_curve_name(*nid)) == NULL)
1120 fatal("%s: EC_KEY_new_by_curve_name failed", __func__);
1121 if (EC_KEY_generate_key(private) != 1)
1122 fatal("%s: EC_KEY_generate_key failed", __func__);
1123 EC_KEY_set_asn1_flag(private, OPENSSL_EC_NAMED_CURVE);
899 return private; 1124 return private;
900} 1125}
1126#endif /* OPENSSL_HAS_ECC */
901 1127
902Key * 1128Key *
903key_generate(int type, u_int bits) 1129key_generate(int type, u_int bits)
@@ -907,6 +1133,11 @@ key_generate(int type, u_int bits)
907 case KEY_DSA: 1133 case KEY_DSA:
908 k->dsa = dsa_generate_private_key(bits); 1134 k->dsa = dsa_generate_private_key(bits);
909 break; 1135 break;
1136#ifdef OPENSSL_HAS_ECC
1137 case KEY_ECDSA:
1138 k->ecdsa = ecdsa_generate_private_key(bits, &k->ecdsa_nid);
1139 break;
1140#endif
910 case KEY_RSA: 1141 case KEY_RSA:
911 case KEY_RSA1: 1142 case KEY_RSA1:
912 k->rsa = rsa_generate_private_key(bits); 1143 k->rsa = rsa_generate_private_key(bits);
@@ -983,6 +1214,18 @@ key_from_private(const Key *k)
983 (BN_copy(n->dsa->pub_key, k->dsa->pub_key) == NULL)) 1214 (BN_copy(n->dsa->pub_key, k->dsa->pub_key) == NULL))
984 fatal("key_from_private: BN_copy failed"); 1215 fatal("key_from_private: BN_copy failed");
985 break; 1216 break;
1217#ifdef OPENSSL_HAS_ECC
1218 case KEY_ECDSA:
1219 case KEY_ECDSA_CERT:
1220 n = key_new(k->type);
1221 n->ecdsa_nid = k->ecdsa_nid;
1222 if ((n->ecdsa = EC_KEY_new_by_curve_name(k->ecdsa_nid)) == NULL)
1223 fatal("%s: EC_KEY_new_by_curve_name failed", __func__);
1224 if (EC_KEY_set_public_key(n->ecdsa,
1225 EC_KEY_get0_public_key(k->ecdsa)) != 1)
1226 fatal("%s: EC_KEY_set_public_key failed", __func__);
1227 break;
1228#endif
986 case KEY_RSA: 1229 case KEY_RSA:
987 case KEY_RSA1: 1230 case KEY_RSA1:
988 case KEY_RSA_CERT_V00: 1231 case KEY_RSA_CERT_V00:
@@ -1014,6 +1257,13 @@ key_type_from_name(char *name)
1014 return KEY_RSA; 1257 return KEY_RSA;
1015 } else if (strcmp(name, "ssh-dss") == 0) { 1258 } else if (strcmp(name, "ssh-dss") == 0) {
1016 return KEY_DSA; 1259 return KEY_DSA;
1260#ifdef OPENSSL_HAS_ECC
1261 } else if (strcmp(name, "ecdsa") == 0 ||
1262 strcmp(name, "ecdsa-sha2-nistp256") == 0 ||
1263 strcmp(name, "ecdsa-sha2-nistp384") == 0 ||
1264 strcmp(name, "ecdsa-sha2-nistp521") == 0) {
1265 return KEY_ECDSA;
1266#endif
1017 } else if (strcmp(name, "ssh-rsa-cert-v00@openssh.com") == 0) { 1267 } else if (strcmp(name, "ssh-rsa-cert-v00@openssh.com") == 0) {
1018 return KEY_RSA_CERT_V00; 1268 return KEY_RSA_CERT_V00;
1019 } else if (strcmp(name, "ssh-dss-cert-v00@openssh.com") == 0) { 1269 } else if (strcmp(name, "ssh-dss-cert-v00@openssh.com") == 0) {
@@ -1022,14 +1272,40 @@ key_type_from_name(char *name)
1022 return KEY_RSA_CERT; 1272 return KEY_RSA_CERT;
1023 } else if (strcmp(name, "ssh-dss-cert-v01@openssh.com") == 0) { 1273 } else if (strcmp(name, "ssh-dss-cert-v01@openssh.com") == 0) {
1024 return KEY_DSA_CERT; 1274 return KEY_DSA_CERT;
1275#ifdef OPENSSL_HAS_ECC
1276 } else if (strcmp(name, "ecdsa-sha2-nistp256-cert-v01@openssh.com") == 0 ||
1277 strcmp(name, "ecdsa-sha2-nistp384-cert-v01@openssh.com") == 0 ||
1278 strcmp(name, "ecdsa-sha2-nistp521-cert-v01@openssh.com") == 0) {
1279 return KEY_ECDSA_CERT;
1280#endif
1025 } else if (strcmp(name, "null") == 0) { 1281 } else if (strcmp(name, "null") == 0) {
1026 return KEY_NULL; 1282 return KEY_NULL;
1027 } 1283 }
1284
1028 debug2("key_type_from_name: unknown key type '%s'", name); 1285 debug2("key_type_from_name: unknown key type '%s'", name);
1029 return KEY_UNSPEC; 1286 return KEY_UNSPEC;
1030} 1287}
1031 1288
1032int 1289int
1290key_ecdsa_nid_from_name(const char *name)
1291{
1292#ifdef OPENSSL_HAS_ECC
1293 if (strcmp(name, "ecdsa-sha2-nistp256") == 0 ||
1294 strcmp(name, "ecdsa-sha2-nistp256-cert-v01@openssh.com") == 0)
1295 return NID_X9_62_prime256v1;
1296 if (strcmp(name, "ecdsa-sha2-nistp384") == 0 ||
1297 strcmp(name, "ecdsa-sha2-nistp384-cert-v01@openssh.com") == 0)
1298 return NID_secp384r1;
1299 if (strcmp(name, "ecdsa-sha2-nistp521") == 0 ||
1300 strcmp(name, "ecdsa-sha2-nistp521-cert-v01@openssh.com") == 0)
1301 return NID_secp521r1;
1302#endif /* OPENSSL_HAS_ECC */
1303
1304 debug2("%s: unknown/non-ECDSA key type '%s'", __func__, name);
1305 return -1;
1306}
1307
1308int
1033key_names_valid2(const char *names) 1309key_names_valid2(const char *names)
1034{ 1310{
1035 char *s, *cp, *p; 1311 char *s, *cp, *p;
@@ -1071,7 +1347,7 @@ cert_parse(Buffer *b, Key *key, const u_char *blob, u_int blen)
1071 principals = exts = critical = sig_key = sig = NULL; 1347 principals = exts = critical = sig_key = sig = NULL;
1072 if ((!v00 && buffer_get_int64_ret(&key->cert->serial, b) != 0) || 1348 if ((!v00 && buffer_get_int64_ret(&key->cert->serial, b) != 0) ||
1073 buffer_get_int_ret(&key->cert->type, b) != 0 || 1349 buffer_get_int_ret(&key->cert->type, b) != 0 ||
1074 (key->cert->key_id = buffer_get_string_ret(b, &kidlen)) == NULL || 1350 (key->cert->key_id = buffer_get_cstring_ret(b, &kidlen)) == NULL ||
1075 (principals = buffer_get_string_ret(b, &plen)) == NULL || 1351 (principals = buffer_get_string_ret(b, &plen)) == NULL ||
1076 buffer_get_int64_ret(&key->cert->valid_after, b) != 0 || 1352 buffer_get_int64_ret(&key->cert->valid_after, b) != 0 ||
1077 buffer_get_int64_ret(&key->cert->valid_before, b) != 0 || 1353 buffer_get_int64_ret(&key->cert->valid_before, b) != 0 ||
@@ -1109,15 +1385,10 @@ cert_parse(Buffer *b, Key *key, const u_char *blob, u_int blen)
1109 error("%s: Too many principals", __func__); 1385 error("%s: Too many principals", __func__);
1110 goto out; 1386 goto out;
1111 } 1387 }
1112 if ((principal = buffer_get_string_ret(&tmp, &plen)) == NULL) { 1388 if ((principal = buffer_get_cstring_ret(&tmp, &plen)) == NULL) {
1113 error("%s: Principals data invalid", __func__); 1389 error("%s: Principals data invalid", __func__);
1114 goto out; 1390 goto out;
1115 } 1391 }
1116 if (strlen(principal) != plen) {
1117 error("%s: Principal contains \\0 character",
1118 __func__);
1119 goto out;
1120 }
1121 key->cert->principals = xrealloc(key->cert->principals, 1392 key->cert->principals = xrealloc(key->cert->principals,
1122 key->cert->nprincipals + 1, sizeof(*key->cert->principals)); 1393 key->cert->nprincipals + 1, sizeof(*key->cert->principals));
1123 key->cert->principals[key->cert->nprincipals++] = principal; 1394 key->cert->principals[key->cert->nprincipals++] = principal;
@@ -1155,7 +1426,8 @@ cert_parse(Buffer *b, Key *key, const u_char *blob, u_int blen)
1155 goto out; 1426 goto out;
1156 } 1427 }
1157 if (key->cert->signature_key->type != KEY_RSA && 1428 if (key->cert->signature_key->type != KEY_RSA &&
1158 key->cert->signature_key->type != KEY_DSA) { 1429 key->cert->signature_key->type != KEY_DSA &&
1430 key->cert->signature_key->type != KEY_ECDSA) {
1159 error("%s: Invalid signature key type %s (%d)", __func__, 1431 error("%s: Invalid signature key type %s (%d)", __func__,
1160 key_type(key->cert->signature_key), 1432 key_type(key->cert->signature_key),
1161 key->cert->signature_key->type); 1433 key->cert->signature_key->type);
@@ -1196,20 +1468,28 @@ key_from_blob(const u_char *blob, u_int blen)
1196{ 1468{
1197 Buffer b; 1469 Buffer b;
1198 int rlen, type; 1470 int rlen, type;
1199 char *ktype = NULL; 1471 char *ktype = NULL, *curve = NULL;
1200 Key *key = NULL; 1472 Key *key = NULL;
1473#ifdef OPENSSL_HAS_ECC
1474 EC_POINT *q = NULL;
1475 int nid = -1;
1476#endif
1201 1477
1202#ifdef DEBUG_PK 1478#ifdef DEBUG_PK
1203 dump_base64(stderr, blob, blen); 1479 dump_base64(stderr, blob, blen);
1204#endif 1480#endif
1205 buffer_init(&b); 1481 buffer_init(&b);
1206 buffer_append(&b, blob, blen); 1482 buffer_append(&b, blob, blen);
1207 if ((ktype = buffer_get_string_ret(&b, NULL)) == NULL) { 1483 if ((ktype = buffer_get_cstring_ret(&b, NULL)) == NULL) {
1208 error("key_from_blob: can't read key type"); 1484 error("key_from_blob: can't read key type");
1209 goto out; 1485 goto out;
1210 } 1486 }
1211 1487
1212 type = key_type_from_name(ktype); 1488 type = key_type_from_name(ktype);
1489#ifdef OPENSSL_HAS_ECC
1490 if (key_type_plain(type) == KEY_ECDSA)
1491 nid = key_ecdsa_nid_from_name(ktype);
1492#endif
1213 1493
1214 switch (type) { 1494 switch (type) {
1215 case KEY_RSA_CERT: 1495 case KEY_RSA_CERT:
@@ -1247,6 +1527,43 @@ key_from_blob(const u_char *blob, u_int blen)
1247 DSA_print_fp(stderr, key->dsa, 8); 1527 DSA_print_fp(stderr, key->dsa, 8);
1248#endif 1528#endif
1249 break; 1529 break;
1530#ifdef OPENSSL_HAS_ECC
1531 case KEY_ECDSA_CERT:
1532 (void)buffer_get_string_ptr_ret(&b, NULL); /* Skip nonce */
1533 /* FALLTHROUGH */
1534 case KEY_ECDSA:
1535 key = key_new(type);
1536 key->ecdsa_nid = nid;
1537 if ((curve = buffer_get_string_ret(&b, NULL)) == NULL) {
1538 error("key_from_blob: can't read ecdsa curve");
1539 goto badkey;
1540 }
1541 if (key->ecdsa_nid != key_curve_name_to_nid(curve)) {
1542 error("key_from_blob: ecdsa curve doesn't match type");
1543 goto badkey;
1544 }
1545 if (key->ecdsa != NULL)
1546 EC_KEY_free(key->ecdsa);
1547 if ((key->ecdsa = EC_KEY_new_by_curve_name(key->ecdsa_nid))
1548 == NULL)
1549 fatal("key_from_blob: EC_KEY_new_by_curve_name failed");
1550 if ((q = EC_POINT_new(EC_KEY_get0_group(key->ecdsa))) == NULL)
1551 fatal("key_from_blob: EC_POINT_new failed");
1552 if (buffer_get_ecpoint_ret(&b, EC_KEY_get0_group(key->ecdsa),
1553 q) == -1) {
1554 error("key_from_blob: can't read ecdsa key point");
1555 goto badkey;
1556 }
1557 if (key_ec_validate_public(EC_KEY_get0_group(key->ecdsa),
1558 q) != 0)
1559 goto badkey;
1560 if (EC_KEY_set_public_key(key->ecdsa, q) != 1)
1561 fatal("key_from_blob: EC_KEY_set_public_key failed");
1562#ifdef DEBUG_PK
1563 key_dump_ec_point(EC_KEY_get0_group(key->ecdsa), q);
1564#endif
1565 break;
1566#endif /* OPENSSL_HAS_ECC */
1250 case KEY_UNSPEC: 1567 case KEY_UNSPEC:
1251 key = key_new(type); 1568 key = key_new(type);
1252 break; 1569 break;
@@ -1264,6 +1581,12 @@ key_from_blob(const u_char *blob, u_int blen)
1264 out: 1581 out:
1265 if (ktype != NULL) 1582 if (ktype != NULL)
1266 xfree(ktype); 1583 xfree(ktype);
1584 if (curve != NULL)
1585 xfree(curve);
1586#ifdef OPENSSL_HAS_ECC
1587 if (q != NULL)
1588 EC_POINT_free(q);
1589#endif
1267 buffer_free(&b); 1590 buffer_free(&b);
1268 return key; 1591 return key;
1269} 1592}
@@ -1283,6 +1606,7 @@ key_to_blob(const Key *key, u_char **blobp, u_int *lenp)
1283 case KEY_DSA_CERT_V00: 1606 case KEY_DSA_CERT_V00:
1284 case KEY_RSA_CERT_V00: 1607 case KEY_RSA_CERT_V00:
1285 case KEY_DSA_CERT: 1608 case KEY_DSA_CERT:
1609 case KEY_ECDSA_CERT:
1286 case KEY_RSA_CERT: 1610 case KEY_RSA_CERT:
1287 /* Use the existing blob */ 1611 /* Use the existing blob */
1288 buffer_append(&b, buffer_ptr(&key->cert->certblob), 1612 buffer_append(&b, buffer_ptr(&key->cert->certblob),
@@ -1295,6 +1619,14 @@ key_to_blob(const Key *key, u_char **blobp, u_int *lenp)
1295 buffer_put_bignum2(&b, key->dsa->g); 1619 buffer_put_bignum2(&b, key->dsa->g);
1296 buffer_put_bignum2(&b, key->dsa->pub_key); 1620 buffer_put_bignum2(&b, key->dsa->pub_key);
1297 break; 1621 break;
1622#ifdef OPENSSL_HAS_ECC
1623 case KEY_ECDSA:
1624 buffer_put_cstring(&b, key_ssh_name(key));
1625 buffer_put_cstring(&b, key_curve_nid_to_name(key->ecdsa_nid));
1626 buffer_put_ecpoint(&b, EC_KEY_get0_group(key->ecdsa),
1627 EC_KEY_get0_public_key(key->ecdsa));
1628 break;
1629#endif
1298 case KEY_RSA: 1630 case KEY_RSA:
1299 buffer_put_cstring(&b, key_ssh_name(key)); 1631 buffer_put_cstring(&b, key_ssh_name(key));
1300 buffer_put_bignum2(&b, key->rsa->e); 1632 buffer_put_bignum2(&b, key->rsa->e);
@@ -1328,6 +1660,11 @@ key_sign(
1328 case KEY_DSA_CERT: 1660 case KEY_DSA_CERT:
1329 case KEY_DSA: 1661 case KEY_DSA:
1330 return ssh_dss_sign(key, sigp, lenp, data, datalen); 1662 return ssh_dss_sign(key, sigp, lenp, data, datalen);
1663#ifdef OPENSSL_HAS_ECC
1664 case KEY_ECDSA_CERT:
1665 case KEY_ECDSA:
1666 return ssh_ecdsa_sign(key, sigp, lenp, data, datalen);
1667#endif
1331 case KEY_RSA_CERT_V00: 1668 case KEY_RSA_CERT_V00:
1332 case KEY_RSA_CERT: 1669 case KEY_RSA_CERT:
1333 case KEY_RSA: 1670 case KEY_RSA:
@@ -1356,6 +1693,11 @@ key_verify(
1356 case KEY_DSA_CERT: 1693 case KEY_DSA_CERT:
1357 case KEY_DSA: 1694 case KEY_DSA:
1358 return ssh_dss_verify(key, signature, signaturelen, data, datalen); 1695 return ssh_dss_verify(key, signature, signaturelen, data, datalen);
1696#ifdef OPENSSL_HAS_ECC
1697 case KEY_ECDSA_CERT:
1698 case KEY_ECDSA:
1699 return ssh_ecdsa_verify(key, signature, signaturelen, data, datalen);
1700#endif
1359 case KEY_RSA_CERT_V00: 1701 case KEY_RSA_CERT_V00:
1360 case KEY_RSA_CERT: 1702 case KEY_RSA_CERT:
1361 case KEY_RSA: 1703 case KEY_RSA:
@@ -1375,7 +1717,9 @@ key_demote(const Key *k)
1375 pk = xcalloc(1, sizeof(*pk)); 1717 pk = xcalloc(1, sizeof(*pk));
1376 pk->type = k->type; 1718 pk->type = k->type;
1377 pk->flags = k->flags; 1719 pk->flags = k->flags;
1720 pk->ecdsa_nid = k->ecdsa_nid;
1378 pk->dsa = NULL; 1721 pk->dsa = NULL;
1722 pk->ecdsa = NULL;
1379 pk->rsa = NULL; 1723 pk->rsa = NULL;
1380 1724
1381 switch (k->type) { 1725 switch (k->type) {
@@ -1408,6 +1752,18 @@ key_demote(const Key *k)
1408 if ((pk->dsa->pub_key = BN_dup(k->dsa->pub_key)) == NULL) 1752 if ((pk->dsa->pub_key = BN_dup(k->dsa->pub_key)) == NULL)
1409 fatal("key_demote: BN_dup failed"); 1753 fatal("key_demote: BN_dup failed");
1410 break; 1754 break;
1755#ifdef OPENSSL_HAS_ECC
1756 case KEY_ECDSA_CERT:
1757 key_cert_copy(k, pk);
1758 /* FALLTHROUGH */
1759 case KEY_ECDSA:
1760 if ((pk->ecdsa = EC_KEY_new_by_curve_name(pk->ecdsa_nid)) == NULL)
1761 fatal("key_demote: EC_KEY_new_by_curve_name failed");
1762 if (EC_KEY_set_public_key(pk->ecdsa,
1763 EC_KEY_get0_public_key(k->ecdsa)) != 1)
1764 fatal("key_demote: EC_KEY_set_public_key failed");
1765 break;
1766#endif
1411 default: 1767 default:
1412 fatal("key_free: bad key type %d", k->type); 1768 fatal("key_free: bad key type %d", k->type);
1413 break; 1769 break;
@@ -1426,6 +1782,7 @@ key_is_cert(const Key *k)
1426 case KEY_DSA_CERT_V00: 1782 case KEY_DSA_CERT_V00:
1427 case KEY_RSA_CERT: 1783 case KEY_RSA_CERT:
1428 case KEY_DSA_CERT: 1784 case KEY_DSA_CERT:
1785 case KEY_ECDSA_CERT:
1429 return 1; 1786 return 1;
1430 default: 1787 default:
1431 return 0; 1788 return 0;
@@ -1443,6 +1800,8 @@ key_type_plain(int type)
1443 case KEY_DSA_CERT_V00: 1800 case KEY_DSA_CERT_V00:
1444 case KEY_DSA_CERT: 1801 case KEY_DSA_CERT:
1445 return KEY_DSA; 1802 return KEY_DSA;
1803 case KEY_ECDSA_CERT:
1804 return KEY_ECDSA;
1446 default: 1805 default:
1447 return type; 1806 return type;
1448 } 1807 }
@@ -1461,6 +1820,10 @@ key_to_certified(Key *k, int legacy)
1461 k->cert = cert_new(); 1820 k->cert = cert_new();
1462 k->type = legacy ? KEY_DSA_CERT_V00 : KEY_DSA_CERT; 1821 k->type = legacy ? KEY_DSA_CERT_V00 : KEY_DSA_CERT;
1463 return 0; 1822 return 0;
1823 case KEY_ECDSA:
1824 k->cert = cert_new();
1825 k->type = KEY_ECDSA_CERT;
1826 return 0;
1464 default: 1827 default:
1465 error("%s: key has incorrect type %s", __func__, key_type(k)); 1828 error("%s: key has incorrect type %s", __func__, key_type(k));
1466 return -1; 1829 return -1;
@@ -1482,13 +1845,20 @@ key_drop_cert(Key *k)
1482 cert_free(k->cert); 1845 cert_free(k->cert);
1483 k->type = KEY_DSA; 1846 k->type = KEY_DSA;
1484 return 0; 1847 return 0;
1848 case KEY_ECDSA_CERT:
1849 cert_free(k->cert);
1850 k->type = KEY_ECDSA;
1851 return 0;
1485 default: 1852 default:
1486 error("%s: key has incorrect type %s", __func__, key_type(k)); 1853 error("%s: key has incorrect type %s", __func__, key_type(k));
1487 return -1; 1854 return -1;
1488 } 1855 }
1489} 1856}
1490 1857
1491/* Sign a KEY_RSA_CERT or KEY_DSA_CERT, (re-)generating the signed certblob */ 1858/*
1859 * Sign a KEY_RSA_CERT, KEY_DSA_CERT or KEY_ECDSA_CERT, (re-)generating
1860 * the signed certblob
1861 */
1492int 1862int
1493key_certify(Key *k, Key *ca) 1863key_certify(Key *k, Key *ca)
1494{ 1864{
@@ -1507,7 +1877,8 @@ key_certify(Key *k, Key *ca)
1507 return -1; 1877 return -1;
1508 } 1878 }
1509 1879
1510 if (ca->type != KEY_RSA && ca->type != KEY_DSA) { 1880 if (ca->type != KEY_RSA && ca->type != KEY_DSA &&
1881 ca->type != KEY_ECDSA) {
1511 error("%s: CA key has unsupported type %s", __func__, 1882 error("%s: CA key has unsupported type %s", __func__,
1512 key_type(ca)); 1883 key_type(ca));
1513 return -1; 1884 return -1;
@@ -1519,7 +1890,7 @@ key_certify(Key *k, Key *ca)
1519 buffer_put_cstring(&k->cert->certblob, key_ssh_name(k)); 1890 buffer_put_cstring(&k->cert->certblob, key_ssh_name(k));
1520 1891
1521 /* -v01 certs put nonce first */ 1892 /* -v01 certs put nonce first */
1522 if (k->type == KEY_DSA_CERT || k->type == KEY_RSA_CERT) { 1893 if (!key_cert_is_legacy(k)) {
1523 arc4random_buf(&nonce, sizeof(nonce)); 1894 arc4random_buf(&nonce, sizeof(nonce));
1524 buffer_put_string(&k->cert->certblob, nonce, sizeof(nonce)); 1895 buffer_put_string(&k->cert->certblob, nonce, sizeof(nonce));
1525 } 1896 }
@@ -1532,6 +1903,15 @@ key_certify(Key *k, Key *ca)
1532 buffer_put_bignum2(&k->cert->certblob, k->dsa->g); 1903 buffer_put_bignum2(&k->cert->certblob, k->dsa->g);
1533 buffer_put_bignum2(&k->cert->certblob, k->dsa->pub_key); 1904 buffer_put_bignum2(&k->cert->certblob, k->dsa->pub_key);
1534 break; 1905 break;
1906#ifdef OPENSSL_HAS_ECC
1907 case KEY_ECDSA_CERT:
1908 buffer_put_cstring(&k->cert->certblob,
1909 key_curve_nid_to_name(k->ecdsa_nid));
1910 buffer_put_ecpoint(&k->cert->certblob,
1911 EC_KEY_get0_group(k->ecdsa),
1912 EC_KEY_get0_public_key(k->ecdsa));
1913 break;
1914#endif
1535 case KEY_RSA_CERT_V00: 1915 case KEY_RSA_CERT_V00:
1536 case KEY_RSA_CERT: 1916 case KEY_RSA_CERT:
1537 buffer_put_bignum2(&k->cert->certblob, k->rsa->e); 1917 buffer_put_bignum2(&k->cert->certblob, k->rsa->e);
@@ -1545,7 +1925,7 @@ key_certify(Key *k, Key *ca)
1545 } 1925 }
1546 1926
1547 /* -v01 certs have a serial number next */ 1927 /* -v01 certs have a serial number next */
1548 if (k->type == KEY_DSA_CERT || k->type == KEY_RSA_CERT) 1928 if (!key_cert_is_legacy(k))
1549 buffer_put_int64(&k->cert->certblob, k->cert->serial); 1929 buffer_put_int64(&k->cert->certblob, k->cert->serial);
1550 1930
1551 buffer_put_int(&k->cert->certblob, k->cert->type); 1931 buffer_put_int(&k->cert->certblob, k->cert->type);
@@ -1564,14 +1944,14 @@ key_certify(Key *k, Key *ca)
1564 buffer_ptr(&k->cert->critical), buffer_len(&k->cert->critical)); 1944 buffer_ptr(&k->cert->critical), buffer_len(&k->cert->critical));
1565 1945
1566 /* -v01 certs have non-critical options here */ 1946 /* -v01 certs have non-critical options here */
1567 if (k->type == KEY_DSA_CERT || k->type == KEY_RSA_CERT) { 1947 if (!key_cert_is_legacy(k)) {
1568 buffer_put_string(&k->cert->certblob, 1948 buffer_put_string(&k->cert->certblob,
1569 buffer_ptr(&k->cert->extensions), 1949 buffer_ptr(&k->cert->extensions),
1570 buffer_len(&k->cert->extensions)); 1950 buffer_len(&k->cert->extensions));
1571 } 1951 }
1572 1952
1573 /* -v00 certs put the nonce at the end */ 1953 /* -v00 certs put the nonce at the end */
1574 if (k->type == KEY_DSA_CERT_V00 || k->type == KEY_RSA_CERT_V00) 1954 if (key_cert_is_legacy(k))
1575 buffer_put_string(&k->cert->certblob, nonce, sizeof(nonce)); 1955 buffer_put_string(&k->cert->certblob, nonce, sizeof(nonce));
1576 1956
1577 buffer_put_string(&k->cert->certblob, NULL, 0); /* reserved */ 1957 buffer_put_string(&k->cert->certblob, NULL, 0); /* reserved */
@@ -1656,3 +2036,240 @@ key_cert_is_legacy(Key *k)
1656 return 0; 2036 return 0;
1657 } 2037 }
1658} 2038}
2039
2040/* XXX: these are really begging for a table-driven approach */
2041int
2042key_curve_name_to_nid(const char *name)
2043{
2044#ifdef OPENSSL_HAS_ECC
2045 if (strcmp(name, "nistp256") == 0)
2046 return NID_X9_62_prime256v1;
2047 else if (strcmp(name, "nistp384") == 0)
2048 return NID_secp384r1;
2049 else if (strcmp(name, "nistp521") == 0)
2050 return NID_secp521r1;
2051#endif
2052
2053 debug("%s: unsupported EC curve name \"%.100s\"", __func__, name);
2054 return -1;
2055}
2056
2057u_int
2058key_curve_nid_to_bits(int nid)
2059{
2060 switch (nid) {
2061#ifdef OPENSSL_HAS_ECC
2062 case NID_X9_62_prime256v1:
2063 return 256;
2064 case NID_secp384r1:
2065 return 384;
2066 case NID_secp521r1:
2067 return 521;
2068#endif
2069 default:
2070 error("%s: unsupported EC curve nid %d", __func__, nid);
2071 return 0;
2072 }
2073}
2074
2075const char *
2076key_curve_nid_to_name(int nid)
2077{
2078#ifdef OPENSSL_HAS_ECC
2079 if (nid == NID_X9_62_prime256v1)
2080 return "nistp256";
2081 else if (nid == NID_secp384r1)
2082 return "nistp384";
2083 else if (nid == NID_secp521r1)
2084 return "nistp521";
2085#endif
2086 error("%s: unsupported EC curve nid %d", __func__, nid);
2087 return NULL;
2088}
2089
2090#ifdef OPENSSL_HAS_ECC
2091const EVP_MD *
2092key_ec_nid_to_evpmd(int nid)
2093{
2094 int kbits = key_curve_nid_to_bits(nid);
2095
2096 if (kbits == 0)
2097 fatal("%s: invalid nid %d", __func__, nid);
2098 /* RFC5656 section 6.2.1 */
2099 if (kbits <= 256)
2100 return EVP_sha256();
2101 else if (kbits <= 384)
2102 return EVP_sha384();
2103 else
2104 return EVP_sha512();
2105}
2106
2107int
2108key_ec_validate_public(const EC_GROUP *group, const EC_POINT *public)
2109{
2110 BN_CTX *bnctx;
2111 EC_POINT *nq = NULL;
2112 BIGNUM *order, *x, *y, *tmp;
2113 int ret = -1;
2114
2115 if ((bnctx = BN_CTX_new()) == NULL)
2116 fatal("%s: BN_CTX_new failed", __func__);
2117 BN_CTX_start(bnctx);
2118
2119 /*
2120 * We shouldn't ever hit this case because bignum_get_ecpoint()
2121 * refuses to load GF2m points.
2122 */
2123 if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) !=
2124 NID_X9_62_prime_field) {
2125 error("%s: group is not a prime field", __func__);
2126 goto out;
2127 }
2128
2129 /* Q != infinity */
2130 if (EC_POINT_is_at_infinity(group, public)) {
2131 error("%s: received degenerate public key (infinity)",
2132 __func__);
2133 goto out;
2134 }
2135
2136 if ((x = BN_CTX_get(bnctx)) == NULL ||
2137 (y = BN_CTX_get(bnctx)) == NULL ||
2138 (order = BN_CTX_get(bnctx)) == NULL ||
2139 (tmp = BN_CTX_get(bnctx)) == NULL)
2140 fatal("%s: BN_CTX_get failed", __func__);
2141
2142 /* log2(x) > log2(order)/2, log2(y) > log2(order)/2 */
2143 if (EC_GROUP_get_order(group, order, bnctx) != 1)
2144 fatal("%s: EC_GROUP_get_order failed", __func__);
2145 if (EC_POINT_get_affine_coordinates_GFp(group, public,
2146 x, y, bnctx) != 1)
2147 fatal("%s: EC_POINT_get_affine_coordinates_GFp", __func__);
2148 if (BN_num_bits(x) <= BN_num_bits(order) / 2) {
2149 error("%s: public key x coordinate too small: "
2150 "bits(x) = %d, bits(order)/2 = %d", __func__,
2151 BN_num_bits(x), BN_num_bits(order) / 2);
2152 goto out;
2153 }
2154 if (BN_num_bits(y) <= BN_num_bits(order) / 2) {
2155 error("%s: public key y coordinate too small: "
2156 "bits(y) = %d, bits(order)/2 = %d", __func__,
2157 BN_num_bits(x), BN_num_bits(order) / 2);
2158 goto out;
2159 }
2160
2161 /* nQ == infinity (n == order of subgroup) */
2162 if ((nq = EC_POINT_new(group)) == NULL)
2163 fatal("%s: BN_CTX_tmp failed", __func__);
2164 if (EC_POINT_mul(group, nq, NULL, public, order, bnctx) != 1)
2165 fatal("%s: EC_GROUP_mul failed", __func__);
2166 if (EC_POINT_is_at_infinity(group, nq) != 1) {
2167 error("%s: received degenerate public key (nQ != infinity)",
2168 __func__);
2169 goto out;
2170 }
2171
2172 /* x < order - 1, y < order - 1 */
2173 if (!BN_sub(tmp, order, BN_value_one()))
2174 fatal("%s: BN_sub failed", __func__);
2175 if (BN_cmp(x, tmp) >= 0) {
2176 error("%s: public key x coordinate >= group order - 1",
2177 __func__);
2178 goto out;
2179 }
2180 if (BN_cmp(y, tmp) >= 0) {
2181 error("%s: public key y coordinate >= group order - 1",
2182 __func__);
2183 goto out;
2184 }
2185 ret = 0;
2186 out:
2187 BN_CTX_free(bnctx);
2188 EC_POINT_free(nq);
2189 return ret;
2190}
2191
2192int
2193key_ec_validate_private(const EC_KEY *key)
2194{
2195 BN_CTX *bnctx;
2196 BIGNUM *order, *tmp;
2197 int ret = -1;
2198
2199 if ((bnctx = BN_CTX_new()) == NULL)
2200 fatal("%s: BN_CTX_new failed", __func__);
2201 BN_CTX_start(bnctx);
2202
2203 if ((order = BN_CTX_get(bnctx)) == NULL ||
2204 (tmp = BN_CTX_get(bnctx)) == NULL)
2205 fatal("%s: BN_CTX_get failed", __func__);
2206
2207 /* log2(private) > log2(order)/2 */
2208 if (EC_GROUP_get_order(EC_KEY_get0_group(key), order, bnctx) != 1)
2209 fatal("%s: EC_GROUP_get_order failed", __func__);
2210 if (BN_num_bits(EC_KEY_get0_private_key(key)) <=
2211 BN_num_bits(order) / 2) {
2212 error("%s: private key too small: "
2213 "bits(y) = %d, bits(order)/2 = %d", __func__,
2214 BN_num_bits(EC_KEY_get0_private_key(key)),
2215 BN_num_bits(order) / 2);
2216 goto out;
2217 }
2218
2219 /* private < order - 1 */
2220 if (!BN_sub(tmp, order, BN_value_one()))
2221 fatal("%s: BN_sub failed", __func__);
2222 if (BN_cmp(EC_KEY_get0_private_key(key), tmp) >= 0) {
2223 error("%s: private key >= group order - 1", __func__);
2224 goto out;
2225 }
2226 ret = 0;
2227 out:
2228 BN_CTX_free(bnctx);
2229 return ret;
2230}
2231
2232#if defined(DEBUG_KEXECDH) || defined(DEBUG_PK)
2233void
2234key_dump_ec_point(const EC_GROUP *group, const EC_POINT *point)
2235{
2236 BIGNUM *x, *y;
2237 BN_CTX *bnctx;
2238
2239 if (point == NULL) {
2240 fputs("point=(NULL)\n", stderr);
2241 return;
2242 }
2243 if ((bnctx = BN_CTX_new()) == NULL)
2244 fatal("%s: BN_CTX_new failed", __func__);
2245 BN_CTX_start(bnctx);
2246 if ((x = BN_CTX_get(bnctx)) == NULL || (y = BN_CTX_get(bnctx)) == NULL)
2247 fatal("%s: BN_CTX_get failed", __func__);
2248 if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) !=
2249 NID_X9_62_prime_field)
2250 fatal("%s: group is not a prime field", __func__);
2251 if (EC_POINT_get_affine_coordinates_GFp(group, point, x, y, bnctx) != 1)
2252 fatal("%s: EC_POINT_get_affine_coordinates_GFp", __func__);
2253 fputs("x=", stderr);
2254 BN_print_fp(stderr, x);
2255 fputs("\ny=", stderr);
2256 BN_print_fp(stderr, y);
2257 fputs("\n", stderr);
2258 BN_CTX_free(bnctx);
2259}
2260
2261void
2262key_dump_ec_key(const EC_KEY *key)
2263{
2264 const BIGNUM *exponent;
2265
2266 key_dump_ec_point(EC_KEY_get0_group(key), EC_KEY_get0_public_key(key));
2267 fputs("exponent=", stderr);
2268 if ((exponent = EC_KEY_get0_private_key(key)) == NULL)
2269 fputs("(NULL)", stderr);
2270 else
2271 BN_print_fp(stderr, EC_KEY_get0_private_key(key));
2272 fputs("\n", stderr);
2273}
2274#endif /* defined(DEBUG_KEXECDH) || defined(DEBUG_PK) */
2275#endif /* OPENSSL_HAS_ECC */
diff --git a/key.h b/key.h
index 810f2aaae..8b5c5659c 100644
--- a/key.h
+++ b/key.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: key.h,v 1.30 2010/04/16 01:47:26 djm Exp $ */ 1/* $OpenBSD: key.h,v 1.33 2010/10/28 11:22:09 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
@@ -29,14 +29,19 @@
29#include "buffer.h" 29#include "buffer.h"
30#include <openssl/rsa.h> 30#include <openssl/rsa.h>
31#include <openssl/dsa.h> 31#include <openssl/dsa.h>
32#ifdef OPENSSL_HAS_ECC
33#include <openssl/ec.h>
34#endif
32 35
33typedef struct Key Key; 36typedef struct Key Key;
34enum types { 37enum types {
35 KEY_RSA1, 38 KEY_RSA1,
36 KEY_RSA, 39 KEY_RSA,
37 KEY_DSA, 40 KEY_DSA,
41 KEY_ECDSA,
38 KEY_RSA_CERT, 42 KEY_RSA_CERT,
39 KEY_DSA_CERT, 43 KEY_DSA_CERT,
44 KEY_ECDSA_CERT,
40 KEY_RSA_CERT_V00, 45 KEY_RSA_CERT_V00,
41 KEY_DSA_CERT_V00, 46 KEY_DSA_CERT_V00,
42 KEY_NULL, 47 KEY_NULL,
@@ -74,6 +79,12 @@ struct Key {
74 int flags; 79 int flags;
75 RSA *rsa; 80 RSA *rsa;
76 DSA *dsa; 81 DSA *dsa;
82 int ecdsa_nid; /* NID of curve */
83#ifdef OPENSSL_HAS_ECC
84 EC_KEY *ecdsa;
85#else
86 void *ecdsa;
87#endif
77 struct KeyCert *cert; 88 struct KeyCert *cert;
78}; 89};
79 90
@@ -105,9 +116,22 @@ int key_cert_check_authority(const Key *, int, int, const char *,
105 const char **); 116 const char **);
106int key_cert_is_legacy(Key *); 117int key_cert_is_legacy(Key *);
107 118
119int key_ecdsa_nid_from_name(const char *);
120int key_curve_name_to_nid(const char *);
121const char * key_curve_nid_to_name(int);
122u_int key_curve_nid_to_bits(int);
123int key_ecdsa_bits_to_nid(int);
124#ifdef OPENSSL_HAS_ECC
125int key_ecdsa_key_to_nid(EC_KEY *);
126const EVP_MD * key_ec_nid_to_evpmd(int nid);
127int key_ec_validate_public(const EC_GROUP *, const EC_POINT *);
128int key_ec_validate_private(const EC_KEY *);
129#endif
130
108Key *key_from_blob(const u_char *, u_int); 131Key *key_from_blob(const u_char *, u_int);
109int key_to_blob(const Key *, u_char **, u_int *); 132int key_to_blob(const Key *, u_char **, u_int *);
110const char *key_ssh_name(const Key *); 133const char *key_ssh_name(const Key *);
134const char *key_ssh_name_plain(const Key *);
111int key_names_valid2(const char *); 135int key_names_valid2(const char *);
112 136
113int key_sign(const Key *, u_char **, u_int *, const u_char *, u_int); 137int key_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
@@ -115,7 +139,14 @@ int key_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
115 139
116int ssh_dss_sign(const Key *, u_char **, u_int *, const u_char *, u_int); 140int ssh_dss_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
117int ssh_dss_verify(const Key *, const u_char *, u_int, const u_char *, u_int); 141int ssh_dss_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
142int ssh_ecdsa_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
143int ssh_ecdsa_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
118int ssh_rsa_sign(const Key *, u_char **, u_int *, const u_char *, u_int); 144int ssh_rsa_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
119int ssh_rsa_verify(const Key *, const u_char *, u_int, const u_char *, u_int); 145int ssh_rsa_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
120 146
147#if defined(OPENSSL_HAS_ECC) && (defined(DEBUG_KEXECDH) || defined(DEBUG_PK))
148void key_dump_ec_point(const EC_GROUP *, const EC_POINT *);
149void key_dump_ec_key(const EC_KEY *);
150#endif
151
121#endif 152#endif
diff --git a/loginrec.c b/loginrec.c
index 6f655cb16..32941c985 100644
--- a/loginrec.c
+++ b/loginrec.c
@@ -273,7 +273,7 @@ login_logout(struct logininfo *li)
273 * try to retrieve lastlog information from wtmp/wtmpx. 273 * try to retrieve lastlog information from wtmp/wtmpx.
274 */ 274 */
275unsigned int 275unsigned int
276login_get_lastlog_time(const int uid) 276login_get_lastlog_time(const uid_t uid)
277{ 277{
278 struct logininfo li; 278 struct logininfo li;
279 279
@@ -297,7 +297,7 @@ login_get_lastlog_time(const int uid)
297 * 0 on failure (will use OpenSSH's logging facilities for diagnostics) 297 * 0 on failure (will use OpenSSH's logging facilities for diagnostics)
298 */ 298 */
299struct logininfo * 299struct logininfo *
300login_get_lastlog(struct logininfo *li, const int uid) 300login_get_lastlog(struct logininfo *li, const uid_t uid)
301{ 301{
302 struct passwd *pw; 302 struct passwd *pw;
303 303
@@ -311,7 +311,8 @@ login_get_lastlog(struct logininfo *li, const int uid)
311 */ 311 */
312 pw = getpwuid(uid); 312 pw = getpwuid(uid);
313 if (pw == NULL) 313 if (pw == NULL)
314 fatal("%s: Cannot find account for uid %i", __func__, uid); 314 fatal("%s: Cannot find account for uid %ld", __func__,
315 (long)uid);
315 316
316 /* No MIN_SIZEOF here - we absolutely *must not* truncate the 317 /* No MIN_SIZEOF here - we absolutely *must not* truncate the
317 * username (XXX - so check for trunc!) */ 318 * username (XXX - so check for trunc!) */
@@ -335,7 +336,7 @@ login_get_lastlog(struct logininfo *li, const int uid)
335 * allocation fails, the program halts. 336 * allocation fails, the program halts.
336 */ 337 */
337struct 338struct
338logininfo *login_alloc_entry(int pid, const char *username, 339logininfo *login_alloc_entry(pid_t pid, const char *username,
339 const char *hostname, const char *line) 340 const char *hostname, const char *line)
340{ 341{
341 struct logininfo *newli; 342 struct logininfo *newli;
@@ -363,7 +364,7 @@ login_free_entry(struct logininfo *li)
363 * Returns: 1 364 * Returns: 1
364 */ 365 */
365int 366int
366login_init_entry(struct logininfo *li, int pid, const char *username, 367login_init_entry(struct logininfo *li, pid_t pid, const char *username,
367 const char *hostname, const char *line) 368 const char *hostname, const char *line)
368{ 369{
369 struct passwd *pw; 370 struct passwd *pw;
@@ -468,9 +469,9 @@ login_write(struct logininfo *li)
468#endif 469#endif
469#ifdef SSH_AUDIT_EVENTS 470#ifdef SSH_AUDIT_EVENTS
470 if (li->type == LTYPE_LOGIN) 471 if (li->type == LTYPE_LOGIN)
471 audit_session_open(li->line); 472 audit_session_open(li);
472 else if (li->type == LTYPE_LOGOUT) 473 else if (li->type == LTYPE_LOGOUT)
473 audit_session_close(li->line); 474 audit_session_close(li);
474#endif 475#endif
475 return (0); 476 return (0);
476} 477}
@@ -872,11 +873,13 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut)
872 pos = (off_t)tty * sizeof(struct utmp); 873 pos = (off_t)tty * sizeof(struct utmp);
873 if ((ret = lseek(fd, pos, SEEK_SET)) == -1) { 874 if ((ret = lseek(fd, pos, SEEK_SET)) == -1) {
874 logit("%s: lseek: %s", __func__, strerror(errno)); 875 logit("%s: lseek: %s", __func__, strerror(errno));
876 close(fd);
875 return (0); 877 return (0);
876 } 878 }
877 if (ret != pos) { 879 if (ret != pos) {
878 logit("%s: Couldn't seek to tty %d slot in %s", 880 logit("%s: Couldn't seek to tty %d slot in %s",
879 __func__, tty, UTMP_FILE); 881 __func__, tty, UTMP_FILE);
882 close(fd);
880 return (0); 883 return (0);
881 } 884 }
882 /* 885 /*
@@ -892,16 +895,20 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut)
892 895
893 if ((ret = lseek(fd, pos, SEEK_SET)) == -1) { 896 if ((ret = lseek(fd, pos, SEEK_SET)) == -1) {
894 logit("%s: lseek: %s", __func__, strerror(errno)); 897 logit("%s: lseek: %s", __func__, strerror(errno));
898 close(fd);
895 return (0); 899 return (0);
896 } 900 }
897 if (ret != pos) { 901 if (ret != pos) {
898 logit("%s: Couldn't seek to tty %d slot in %s", 902 logit("%s: Couldn't seek to tty %d slot in %s",
899 __func__, tty, UTMP_FILE); 903 __func__, tty, UTMP_FILE);
904 close(fd);
900 return (0); 905 return (0);
901 } 906 }
902 if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut)) { 907 if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut)) {
903 logit("%s: error writing %s: %s", __func__, 908 logit("%s: error writing %s: %s", __func__,
904 UTMP_FILE, strerror(errno)); 909 UTMP_FILE, strerror(errno));
910 close(fd);
911 return (0);
905 } 912 }
906 913
907 close(fd); 914 close(fd);
@@ -1205,7 +1212,7 @@ wtmp_get_entry(struct logininfo *li)
1205 close (fd); 1212 close (fd);
1206 return (0); 1213 return (0);
1207 } 1214 }
1208 if ( wtmp_islogin(li, &ut) ) { 1215 if (wtmp_islogin(li, &ut) ) {
1209 found = 1; 1216 found = 1;
1210 /* 1217 /*
1211 * We've already checked for a time in struct 1218 * We've already checked for a time in struct
@@ -1496,11 +1503,12 @@ lastlog_openseek(struct logininfo *li, int *fd, int filemode)
1496 1503
1497 if (S_ISREG(st.st_mode)) { 1504 if (S_ISREG(st.st_mode)) {
1498 /* find this uid's offset in the lastlog file */ 1505 /* find this uid's offset in the lastlog file */
1499 offset = (off_t) ((long)li->uid * sizeof(struct lastlog)); 1506 offset = (off_t) ((u_long)li->uid * sizeof(struct lastlog));
1500 1507
1501 if (lseek(*fd, offset, SEEK_SET) != offset) { 1508 if (lseek(*fd, offset, SEEK_SET) != offset) {
1502 logit("%s: %s->lseek(): %s", __func__, 1509 logit("%s: %s->lseek(): %s", __func__,
1503 lastlog_file, strerror(errno)); 1510 lastlog_file, strerror(errno));
1511 close(*fd);
1504 return (0); 1512 return (0);
1505 } 1513 }
1506 } 1514 }
@@ -1672,7 +1680,7 @@ record_failed_login(const char *username, const char *hostname,
1672 strerror(errno)); 1680 strerror(errno));
1673 goto out; 1681 goto out;
1674 } 1682 }
1675 if((fst.st_mode & (S_IRWXG | S_IRWXO)) || (fst.st_uid != 0)){ 1683 if((fst.st_mode & (S_IXGRP | S_IRWXO)) || (fst.st_uid != 0)){
1676 logit("Excess permission or bad ownership on file %s", 1684 logit("Excess permission or bad ownership on file %s",
1677 _PATH_BTMP); 1685 _PATH_BTMP);
1678 goto out; 1686 goto out;
diff --git a/loginrec.h b/loginrec.h
index 84b486590..28923e781 100644
--- a/loginrec.h
+++ b/loginrec.h
@@ -63,8 +63,8 @@ struct logininfo {
63 char progname[LINFO_PROGSIZE]; /* name of program (for PAM) */ 63 char progname[LINFO_PROGSIZE]; /* name of program (for PAM) */
64 int progname_null; 64 int progname_null;
65 short int type; /* type of login (LTYPE_*) */ 65 short int type; /* type of login (LTYPE_*) */
66 int pid; /* PID of login process */ 66 pid_t pid; /* PID of login process */
67 int uid; /* UID of this user */ 67 uid_t uid; /* UID of this user */
68 char line[LINFO_LINESIZE]; /* tty/pty name */ 68 char line[LINFO_LINESIZE]; /* tty/pty name */
69 char username[LINFO_NAMESIZE]; /* login username */ 69 char username[LINFO_NAMESIZE]; /* login username */
70 char hostname[LINFO_HOSTSIZE]; /* remote hostname */ 70 char hostname[LINFO_HOSTSIZE]; /* remote hostname */
@@ -86,12 +86,12 @@ struct logininfo {
86/** 'public' functions */ 86/** 'public' functions */
87 87
88/* construct a new login entry */ 88/* construct a new login entry */
89struct logininfo *login_alloc_entry(int pid, const char *username, 89struct logininfo *login_alloc_entry(pid_t pid, const char *username,
90 const char *hostname, const char *line); 90 const char *hostname, const char *line);
91/* free a structure */ 91/* free a structure */
92void login_free_entry(struct logininfo *li); 92void login_free_entry(struct logininfo *li);
93/* fill out a pre-allocated structure with useful information */ 93/* fill out a pre-allocated structure with useful information */
94int login_init_entry(struct logininfo *li, int pid, const char *username, 94int login_init_entry(struct logininfo *li, pid_t pid, const char *username,
95 const char *hostname, const char *line); 95 const char *hostname, const char *line);
96/* place the current time in a logininfo struct */ 96/* place the current time in a logininfo struct */
97void login_set_current_time(struct logininfo *li); 97void login_set_current_time(struct logininfo *li);
@@ -117,9 +117,9 @@ void login_set_addr(struct logininfo *li, const struct sockaddr *sa,
117 * lastlog retrieval functions 117 * lastlog retrieval functions
118 */ 118 */
119/* lastlog *entry* functions fill out a logininfo */ 119/* lastlog *entry* functions fill out a logininfo */
120struct logininfo *login_get_lastlog(struct logininfo *li, const int uid); 120struct logininfo *login_get_lastlog(struct logininfo *li, const uid_t uid);
121/* lastlog *time* functions return time_t equivalent (uint) */ 121/* lastlog *time* functions return time_t equivalent (uint) */
122unsigned int login_get_lastlog_time(const int uid); 122unsigned int login_get_lastlog_time(const uid_t uid);
123 123
124/* produce various forms of the line filename */ 124/* produce various forms of the line filename */
125char *line_fullname(char *dst, const char *src, u_int dstsize); 125char *line_fullname(char *dst, const char *src, u_int dstsize);
diff --git a/misc.c b/misc.c
index a82e7936e..919b04e6b 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.80 2010/07/21 02:10:58 djm Exp $ */ 1/* $OpenBSD: misc.c,v 1.84 2010/11/21 01:01:13 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved. 4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@@ -35,9 +35,12 @@
35#include <stdio.h> 35#include <stdio.h>
36#include <stdlib.h> 36#include <stdlib.h>
37#include <string.h> 37#include <string.h>
38#include <time.h>
38#include <unistd.h> 39#include <unistd.h>
39 40
40#include <netinet/in.h> 41#include <netinet/in.h>
42#include <netinet/in_systm.h>
43#include <netinet/ip.h>
41#include <netinet/tcp.h> 44#include <netinet/tcp.h>
42 45
43#include <errno.h> 46#include <errno.h>
@@ -850,16 +853,138 @@ ms_to_timeval(struct timeval *tv, int ms)
850 tv->tv_usec = (ms % 1000) * 1000; 853 tv->tv_usec = (ms % 1000) * 1000;
851} 854}
852 855
856void
857bandwidth_limit_init(struct bwlimit *bw, u_int64_t kbps, size_t buflen)
858{
859 bw->buflen = buflen;
860 bw->rate = kbps;
861 bw->thresh = bw->rate;
862 bw->lamt = 0;
863 timerclear(&bw->bwstart);
864 timerclear(&bw->bwend);
865}
866
867/* Callback from read/write loop to insert bandwidth-limiting delays */
868void
869bandwidth_limit(struct bwlimit *bw, size_t read_len)
870{
871 u_int64_t waitlen;
872 struct timespec ts, rm;
873
874 if (!timerisset(&bw->bwstart)) {
875 gettimeofday(&bw->bwstart, NULL);
876 return;
877 }
878
879 bw->lamt += read_len;
880 if (bw->lamt < bw->thresh)
881 return;
882
883 gettimeofday(&bw->bwend, NULL);
884 timersub(&bw->bwend, &bw->bwstart, &bw->bwend);
885 if (!timerisset(&bw->bwend))
886 return;
887
888 bw->lamt *= 8;
889 waitlen = (double)1000000L * bw->lamt / bw->rate;
890
891 bw->bwstart.tv_sec = waitlen / 1000000L;
892 bw->bwstart.tv_usec = waitlen % 1000000L;
893
894 if (timercmp(&bw->bwstart, &bw->bwend, >)) {
895 timersub(&bw->bwstart, &bw->bwend, &bw->bwend);
896
897 /* Adjust the wait time */
898 if (bw->bwend.tv_sec) {
899 bw->thresh /= 2;
900 if (bw->thresh < bw->buflen / 4)
901 bw->thresh = bw->buflen / 4;
902 } else if (bw->bwend.tv_usec < 10000) {
903 bw->thresh *= 2;
904 if (bw->thresh > bw->buflen * 8)
905 bw->thresh = bw->buflen * 8;
906 }
907
908 TIMEVAL_TO_TIMESPEC(&bw->bwend, &ts);
909 while (nanosleep(&ts, &rm) == -1) {
910 if (errno != EINTR)
911 break;
912 ts = rm;
913 }
914 }
915
916 bw->lamt = 0;
917 gettimeofday(&bw->bwstart, NULL);
918}
919
920/* Make a template filename for mk[sd]temp() */
921void
922mktemp_proto(char *s, size_t len)
923{
924 const char *tmpdir;
925 int r;
926
927 if ((tmpdir = getenv("TMPDIR")) != NULL) {
928 r = snprintf(s, len, "%s/ssh-XXXXXXXXXXXX", tmpdir);
929 if (r > 0 && (size_t)r < len)
930 return;
931 }
932 r = snprintf(s, len, "/tmp/ssh-XXXXXXXXXXXX");
933 if (r < 0 || (size_t)r >= len)
934 fatal("%s: template string too short", __func__);
935}
936
937static const struct {
938 const char *name;
939 int value;
940} ipqos[] = {
941 { "af11", IPTOS_DSCP_AF11 },
942 { "af12", IPTOS_DSCP_AF12 },
943 { "af13", IPTOS_DSCP_AF13 },
944 { "af14", IPTOS_DSCP_AF21 },
945 { "af22", IPTOS_DSCP_AF22 },
946 { "af23", IPTOS_DSCP_AF23 },
947 { "af31", IPTOS_DSCP_AF31 },
948 { "af32", IPTOS_DSCP_AF32 },
949 { "af33", IPTOS_DSCP_AF33 },
950 { "af41", IPTOS_DSCP_AF41 },
951 { "af42", IPTOS_DSCP_AF42 },
952 { "af43", IPTOS_DSCP_AF43 },
953 { "cs0", IPTOS_DSCP_CS0 },
954 { "cs1", IPTOS_DSCP_CS1 },
955 { "cs2", IPTOS_DSCP_CS2 },
956 { "cs3", IPTOS_DSCP_CS3 },
957 { "cs4", IPTOS_DSCP_CS4 },
958 { "cs5", IPTOS_DSCP_CS5 },
959 { "cs6", IPTOS_DSCP_CS6 },
960 { "cs7", IPTOS_DSCP_CS7 },
961 { "ef", IPTOS_DSCP_EF },
962 { "lowdelay", IPTOS_LOWDELAY },
963 { "throughput", IPTOS_THROUGHPUT },
964 { "reliability", IPTOS_RELIABILITY },
965 { NULL, -1 }
966};
967
853int 968int
854timingsafe_bcmp(const void *b1, const void *b2, size_t n) 969parse_ipqos(const char *cp)
855{ 970{
856 const unsigned char *p1 = b1, *p2 = b2; 971 u_int i;
857 int ret = 0; 972 char *ep;
973 long val;
858 974
859 for (; n > 0; n--) 975 if (cp == NULL)
860 ret |= *p1++ ^ *p2++; 976 return -1;
861 return (ret != 0); 977 for (i = 0; ipqos[i].name != NULL; i++) {
978 if (strcasecmp(cp, ipqos[i].name) == 0)
979 return ipqos[i].value;
980 }
981 /* Try parsing as an integer */
982 val = strtol(cp, &ep, 0);
983 if (*cp == '\0' || *ep != '\0' || val < 0 || val > 255)
984 return -1;
985 return val;
862} 986}
987
863void 988void
864sock_set_v6only(int s) 989sock_set_v6only(int s)
865{ 990{
diff --git a/misc.h b/misc.h
index bb799f616..65cf4a616 100644
--- a/misc.h
+++ b/misc.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.h,v 1.43 2010/07/13 23:13:16 djm Exp $ */ 1/* $OpenBSD: misc.h,v 1.47 2010/11/21 01:01:13 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -36,7 +36,6 @@ void sanitise_stdfd(void);
36void ms_subtract_diff(struct timeval *, int *); 36void ms_subtract_diff(struct timeval *, int *);
37void ms_to_timeval(struct timeval *, int); 37void ms_to_timeval(struct timeval *, int);
38void sock_set_v6only(int); 38void sock_set_v6only(int);
39int timingsafe_bcmp(const void *, const void *, size_t);
40 39
41struct passwd *pwcopy(struct passwd *); 40struct passwd *pwcopy(struct passwd *);
42const char *ssh_gai_strerror(int); 41const char *ssh_gai_strerror(int);
@@ -80,6 +79,17 @@ void put_u32(void *, u_int32_t)
80void put_u16(void *, u_int16_t) 79void put_u16(void *, u_int16_t)
81 __attribute__((__bounded__( __minbytes__, 1, 2))); 80 __attribute__((__bounded__( __minbytes__, 1, 2)));
82 81
82struct bwlimit {
83 size_t buflen;
84 u_int64_t rate, thresh, lamt;
85 struct timeval bwstart, bwend;
86};
87
88void bandwidth_limit_init(struct bwlimit *, u_int64_t, size_t);
89void bandwidth_limit(struct bwlimit *, size_t);
90
91int parse_ipqos(const char *);
92void mktemp_proto(char *, size_t);
83 93
84/* readpass.c */ 94/* readpass.c */
85 95
diff --git a/moduli.0 b/moduli.0
index 6d707ff82..af4b37511 100644
--- a/moduli.0
+++ b/moduli.0
@@ -17,7 +17,6 @@ DESCRIPTION
17 The file consists of newline-separated records, one per modulus, 17 The file consists of newline-separated records, one per modulus,
18 containing seven space separated fields. These fields are as follows: 18 containing seven space separated fields. These fields are as follows:
19 19
20
21 timestamp The time that the modulus was last processed as 20 timestamp The time that the modulus was last processed as
22 YYYYMMDDHHMMSS. 21 YYYYMMDDHHMMSS.
23 22
diff --git a/moduli.c b/moduli.c
index f737cb3f5..2964a8b3d 100644
--- a/moduli.c
+++ b/moduli.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: moduli.c,v 1.21 2008/06/26 09:19:40 djm Exp $ */ 1/* $OpenBSD: moduli.c,v 1.22 2010/11/10 01:33:07 djm Exp $ */
2/* 2/*
3 * Copyright 1994 Phil Karn <karn@qualcomm.com> 3 * Copyright 1994 Phil Karn <karn@qualcomm.com>
4 * Copyright 1996-1998, 2003 William Allen Simpson <wsimpson@greendragon.com> 4 * Copyright 1996-1998, 2003 William Allen Simpson <wsimpson@greendragon.com>
@@ -54,6 +54,8 @@
54#include "dh.h" 54#include "dh.h"
55#include "log.h" 55#include "log.h"
56 56
57#include "openbsd-compat/openssl-compat.h"
58
57/* 59/*
58 * File output defines 60 * File output defines
59 */ 61 */
@@ -600,7 +602,7 @@ prime_test(FILE *in, FILE *out, u_int32_t trials, u_int32_t generator_wanted)
600 * that p is also prime. A single pass will weed out the 602 * that p is also prime. A single pass will weed out the
601 * vast majority of composite q's. 603 * vast majority of composite q's.
602 */ 604 */
603 if (BN_is_prime(q, 1, NULL, ctx, NULL) <= 0) { 605 if (BN_is_prime_ex(q, 1, ctx, NULL) <= 0) {
604 debug("%10u: q failed first possible prime test", 606 debug("%10u: q failed first possible prime test",
605 count_in); 607 count_in);
606 continue; 608 continue;
@@ -613,14 +615,14 @@ prime_test(FILE *in, FILE *out, u_int32_t trials, u_int32_t generator_wanted)
613 * will show up on the first Rabin-Miller iteration so it 615 * will show up on the first Rabin-Miller iteration so it
614 * doesn't hurt to specify a high iteration count. 616 * doesn't hurt to specify a high iteration count.
615 */ 617 */
616 if (!BN_is_prime(p, trials, NULL, ctx, NULL)) { 618 if (!BN_is_prime_ex(p, trials, ctx, NULL)) {
617 debug("%10u: p is not prime", count_in); 619 debug("%10u: p is not prime", count_in);
618 continue; 620 continue;
619 } 621 }
620 debug("%10u: p is almost certainly prime", count_in); 622 debug("%10u: p is almost certainly prime", count_in);
621 623
622 /* recheck q more rigorously */ 624 /* recheck q more rigorously */
623 if (!BN_is_prime(q, trials - 1, NULL, ctx, NULL)) { 625 if (!BN_is_prime_ex(q, trials - 1, ctx, NULL)) {
624 debug("%10u: q is not prime", count_in); 626 debug("%10u: q is not prime", count_in);
625 continue; 627 continue;
626 } 628 }
diff --git a/monitor.c b/monitor.c
index 517acf3dc..73702d174 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor.c,v 1.108 2010/07/13 23:13:16 djm Exp $ */ 1/* $OpenBSD: monitor.c,v 1.110 2010/09/09 10:45:45 djm Exp $ */
2/* 2/*
3 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 3 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4 * Copyright 2002 Markus Friedl <markus@openbsd.org> 4 * Copyright 2002 Markus Friedl <markus@openbsd.org>
@@ -607,10 +607,10 @@ mm_answer_sign(int sock, Buffer *m)
607 p = buffer_get_string(m, &datlen); 607 p = buffer_get_string(m, &datlen);
608 608
609 /* 609 /*
610 * Supported KEX types will only return SHA1 (20 byte) or 610 * Supported KEX types use SHA1 (20 bytes), SHA256 (32 bytes),
611 * SHA256 (32 byte) hashes 611 * SHA384 (48 bytes) and SHA512 (64 bytes).
612 */ 612 */
613 if (datlen != 20 && datlen != 32) 613 if (datlen != 20 && datlen != 32 && datlen != 48 && datlen != 64)
614 fatal("%s: data length incorrect: %u", __func__, datlen); 614 fatal("%s: data length incorrect: %u", __func__, datlen);
615 615
616 /* save session id, it will be passed on the first call */ 616 /* save session id, it will be passed on the first call */
@@ -1708,6 +1708,7 @@ mm_get_kex(Buffer *m)
1708 kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server; 1708 kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server;
1709 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; 1709 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
1710 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; 1710 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
1711 kex->kex[KEX_ECDH_SHA2] = kexecdh_server;
1711#ifdef GSSAPI 1712#ifdef GSSAPI
1712 if (options.gss_keyex) { 1713 if (options.gss_keyex) {
1713 kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server; 1714 kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
diff --git a/monitor_wrap.c b/monitor_wrap.c
index a01500c81..20c37ebd2 100644
--- a/monitor_wrap.c
+++ b/monitor_wrap.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor_wrap.c,v 1.69 2010/03/07 11:57:13 dtucker Exp $ */ 1/* $OpenBSD: monitor_wrap.c,v 1.70 2010/08/31 11:54:45 djm Exp $ */
2/* 2/*
3 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 3 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4 * Copyright 2002 Markus Friedl <markus@openbsd.org> 4 * Copyright 2002 Markus Friedl <markus@openbsd.org>
@@ -73,6 +73,7 @@
73#include "misc.h" 73#include "misc.h"
74#include "schnorr.h" 74#include "schnorr.h"
75#include "jpake.h" 75#include "jpake.h"
76#include "uuencode.h"
76 77
77#include "channels.h" 78#include "channels.h"
78#include "session.h" 79#include "session.h"
diff --git a/mux.c b/mux.c
index 5c3857ee8..e370462db 100644
--- a/mux.c
+++ b/mux.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mux.c,v 1.21 2010/06/25 23:15:36 djm Exp $ */ 1/* $OpenBSD: mux.c,v 1.24 2011/01/13 21:54:53 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -879,7 +879,7 @@ process_mux_stdio_fwd(u_int rid, Channel *c, Buffer *m, Buffer *r)
879 879
880 if (options.control_master == SSHCTL_MASTER_ASK || 880 if (options.control_master == SSHCTL_MASTER_ASK ||
881 options.control_master == SSHCTL_MASTER_AUTO_ASK) { 881 options.control_master == SSHCTL_MASTER_AUTO_ASK) {
882 if (!ask_permission("Allow forward to to %s:%u? ", 882 if (!ask_permission("Allow forward to %s:%u? ",
883 chost, cport)) { 883 chost, cport)) {
884 debug2("%s: stdio fwd refused by user", __func__); 884 debug2("%s: stdio fwd refused by user", __func__);
885 /* prepare reply */ 885 /* prepare reply */
@@ -1026,6 +1026,9 @@ muxserver_listen(void)
1026 struct sockaddr_un addr; 1026 struct sockaddr_un addr;
1027 socklen_t sun_len; 1027 socklen_t sun_len;
1028 mode_t old_umask; 1028 mode_t old_umask;
1029 char *orig_control_path = options.control_path;
1030 char rbuf[16+1];
1031 u_int i, r;
1029 1032
1030 if (options.control_path == NULL || 1033 if (options.control_path == NULL ||
1031 options.control_master == SSHCTL_MASTER_NO) 1034 options.control_master == SSHCTL_MASTER_NO)
@@ -1033,6 +1036,23 @@ muxserver_listen(void)
1033 1036
1034 debug("setting up multiplex master socket"); 1037 debug("setting up multiplex master socket");
1035 1038
1039 /*
1040 * Use a temporary path before listen so we can pseudo-atomically
1041 * establish the listening socket in its final location to avoid
1042 * other processes racing in between bind() and listen() and hitting
1043 * an unready socket.
1044 */
1045 for (i = 0; i < sizeof(rbuf) - 1; i++) {
1046 r = arc4random_uniform(26+26+10);
1047 rbuf[i] = (r < 26) ? 'a' + r :
1048 (r < 26*2) ? 'A' + r - 26 :
1049 '0' + r - 26 - 26;
1050 }
1051 rbuf[sizeof(rbuf) - 1] = '\0';
1052 options.control_path = NULL;
1053 xasprintf(&options.control_path, "%s.%s", orig_control_path, rbuf);
1054 debug3("%s: temporary control path %s", __func__, options.control_path);
1055
1036 memset(&addr, '\0', sizeof(addr)); 1056 memset(&addr, '\0', sizeof(addr));
1037 addr.sun_family = AF_UNIX; 1057 addr.sun_family = AF_UNIX;
1038 sun_len = offsetof(struct sockaddr_un, sun_path) + 1058 sun_len = offsetof(struct sockaddr_un, sun_path) +
@@ -1051,6 +1071,7 @@ muxserver_listen(void)
1051 if (errno == EINVAL || errno == EADDRINUSE) { 1071 if (errno == EINVAL || errno == EADDRINUSE) {
1052 error("ControlSocket %s already exists, " 1072 error("ControlSocket %s already exists, "
1053 "disabling multiplexing", options.control_path); 1073 "disabling multiplexing", options.control_path);
1074 disable_mux_master:
1054 close(muxserver_sock); 1075 close(muxserver_sock);
1055 muxserver_sock = -1; 1076 muxserver_sock = -1;
1056 xfree(options.control_path); 1077 xfree(options.control_path);
@@ -1065,12 +1086,29 @@ muxserver_listen(void)
1065 if (listen(muxserver_sock, 64) == -1) 1086 if (listen(muxserver_sock, 64) == -1)
1066 fatal("%s listen(): %s", __func__, strerror(errno)); 1087 fatal("%s listen(): %s", __func__, strerror(errno));
1067 1088
1089 /* Now atomically "move" the mux socket into position */
1090 if (link(options.control_path, orig_control_path) != 0) {
1091 if (errno != EEXIST) {
1092 fatal("%s: link mux listener %s => %s: %s", __func__,
1093 options.control_path, orig_control_path,
1094 strerror(errno));
1095 }
1096 error("ControlSocket %s already exists, disabling multiplexing",
1097 orig_control_path);
1098 xfree(orig_control_path);
1099 unlink(options.control_path);
1100 goto disable_mux_master;
1101 }
1102 unlink(options.control_path);
1103 xfree(options.control_path);
1104 options.control_path = orig_control_path;
1105
1068 set_nonblock(muxserver_sock); 1106 set_nonblock(muxserver_sock);
1069 1107
1070 mux_listener_channel = channel_new("mux listener", 1108 mux_listener_channel = channel_new("mux listener",
1071 SSH_CHANNEL_MUX_LISTENER, muxserver_sock, muxserver_sock, -1, 1109 SSH_CHANNEL_MUX_LISTENER, muxserver_sock, muxserver_sock, -1,
1072 CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, 1110 CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT,
1073 0, addr.sun_path, 1); 1111 0, options.control_path, 1);
1074 mux_listener_channel->mux_rcb = mux_master_read_cb; 1112 mux_listener_channel->mux_rcb = mux_master_read_cb;
1075 debug3("%s: mux listener channel %d fd %d", __func__, 1113 debug3("%s: mux listener channel %d fd %d", __func__,
1076 mux_listener_channel->self, mux_listener_channel->sock); 1114 mux_listener_channel->self, mux_listener_channel->sock);
@@ -1492,7 +1530,7 @@ mux_client_request_forward(int fd, u_int ftype, Forward *fwd)
1492 case MUX_S_FAILURE: 1530 case MUX_S_FAILURE:
1493 e = buffer_get_string(&m, NULL); 1531 e = buffer_get_string(&m, NULL);
1494 buffer_free(&m); 1532 buffer_free(&m);
1495 error("%s: session request failed: %s", __func__, e); 1533 error("%s: forwarding request failed: %s", __func__, e);
1496 return -1; 1534 return -1;
1497 default: 1535 default:
1498 fatal("%s: unexpected response from master 0x%08x", 1536 fatal("%s: unexpected response from master 0x%08x",
@@ -1611,12 +1649,12 @@ mux_client_request_session(int fd)
1611 case MUX_S_PERMISSION_DENIED: 1649 case MUX_S_PERMISSION_DENIED:
1612 e = buffer_get_string(&m, NULL); 1650 e = buffer_get_string(&m, NULL);
1613 buffer_free(&m); 1651 buffer_free(&m);
1614 error("Master refused forwarding request: %s", e); 1652 error("Master refused session request: %s", e);
1615 return -1; 1653 return -1;
1616 case MUX_S_FAILURE: 1654 case MUX_S_FAILURE:
1617 e = buffer_get_string(&m, NULL); 1655 e = buffer_get_string(&m, NULL);
1618 buffer_free(&m); 1656 buffer_free(&m);
1619 error("%s: forwarding request failed: %s", __func__, e); 1657 error("%s: session request failed: %s", __func__, e);
1620 return -1; 1658 return -1;
1621 default: 1659 default:
1622 buffer_free(&m); 1660 buffer_free(&m);
@@ -1743,7 +1781,7 @@ mux_client_request_stdio_fwd(int fd)
1743 case MUX_S_PERMISSION_DENIED: 1781 case MUX_S_PERMISSION_DENIED:
1744 e = buffer_get_string(&m, NULL); 1782 e = buffer_get_string(&m, NULL);
1745 buffer_free(&m); 1783 buffer_free(&m);
1746 fatal("Master refused forwarding request: %s", e); 1784 fatal("Master refused stdio forwarding request: %s", e);
1747 case MUX_S_FAILURE: 1785 case MUX_S_FAILURE:
1748 e = buffer_get_string(&m, NULL); 1786 e = buffer_get_string(&m, NULL);
1749 buffer_free(&m); 1787 buffer_free(&m);
@@ -1823,9 +1861,13 @@ muxclient(const char *path)
1823 fatal("Control socket connect(%.100s): %s", path, 1861 fatal("Control socket connect(%.100s): %s", path,
1824 strerror(errno)); 1862 strerror(errno));
1825 } 1863 }
1826 if (errno == ENOENT) 1864 if (errno == ECONNREFUSED &&
1865 options.control_master != SSHCTL_MASTER_NO) {
1866 debug("Stale control socket %.100s, unlinking", path);
1867 unlink(path);
1868 } else if (errno == ENOENT) {
1827 debug("Control socket \"%.100s\" does not exist", path); 1869 debug("Control socket \"%.100s\" does not exist", path);
1828 else { 1870 } else {
1829 error("Control socket connect(%.100s): %s", path, 1871 error("Control socket connect(%.100s): %s", path,
1830 strerror(errno)); 1872 strerror(errno));
1831 } 1873 }
diff --git a/myproposal.h b/myproposal.h
index 7bedfab0a..2c43607a7 100644
--- a/myproposal.h
+++ b/myproposal.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: myproposal.h,v 1.25 2010/04/16 01:47:26 djm Exp $ */ 1/* $OpenBSD: myproposal.h,v 1.27 2010/09/01 22:42:13 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -26,26 +26,49 @@
26 26
27#include <openssl/opensslv.h> 27#include <openssl/opensslv.h>
28 28
29#ifdef OPENSSL_HAS_ECC
30# define KEX_ECDH_METHODS \
31 "ecdh-sha2-nistp256," \
32 "ecdh-sha2-nistp384," \
33 "ecdh-sha2-nistp521,"
34# define HOSTKEY_ECDSA_CERT_METHODS \
35 "ecdsa-sha2-nistp256-cert-v01@openssh.com," \
36 "ecdsa-sha2-nistp384-cert-v01@openssh.com," \
37 "ecdsa-sha2-nistp521-cert-v01@openssh.com,"
38# define HOSTKEY_ECDSA_METHODS \
39 "ecdsa-sha2-nistp256," \
40 "ecdsa-sha2-nistp384," \
41 "ecdsa-sha2-nistp521,"
42#else
43# define KEX_ECDH_METHODS
44# define HOSTKEY_ECDSA_CERT_METHODS
45# define HOSTKEY_ECDSA_METHODS
46#endif
47
29/* Old OpenSSL doesn't support what we need for DHGEX-sha256 */ 48/* Old OpenSSL doesn't support what we need for DHGEX-sha256 */
30#if OPENSSL_VERSION_NUMBER < 0x00907000L 49#if OPENSSL_VERSION_NUMBER >= 0x00907000L
31# define KEX_DEFAULT_KEX \ 50# define KEX_SHA256_METHODS \
32 "diffie-hellman-group-exchange-sha1," \ 51 "diffie-hellman-group-exchange-sha256,"
33 "diffie-hellman-group14-sha1," \
34 "diffie-hellman-group1-sha1"
35#else 52#else
36# define KEX_DEFAULT_KEX \ 53# define KEX_SHA256_METHODS
37 "diffie-hellman-group-exchange-sha256," \ 54#endif
55
56# define KEX_DEFAULT_KEX \
57 KEX_ECDH_METHODS \
58 KEX_SHA256_METHODS \
38 "diffie-hellman-group-exchange-sha1," \ 59 "diffie-hellman-group-exchange-sha1," \
39 "diffie-hellman-group14-sha1," \ 60 "diffie-hellman-group14-sha1," \
40 "diffie-hellman-group1-sha1" 61 "diffie-hellman-group1-sha1"
41#endif
42 62
43#define KEX_DEFAULT_PK_ALG \ 63#define KEX_DEFAULT_PK_ALG \
44 "ssh-rsa-cert-v01@openssh.com," \ 64 HOSTKEY_ECDSA_CERT_METHODS \
45 "ssh-dss-cert-v01@openssh.com," \ 65 "ssh-rsa-cert-v01@openssh.com," \
46 "ssh-rsa-cert-v00@openssh.com," \ 66 "ssh-dss-cert-v01@openssh.com," \
47 "ssh-dss-cert-v00@openssh.com," \ 67 "ssh-rsa-cert-v00@openssh.com," \
48 "ssh-rsa,ssh-dss" 68 "ssh-dss-cert-v00@openssh.com," \
69 HOSTKEY_ECDSA_METHODS \
70 "ssh-rsa," \
71 "ssh-dss"
49 72
50#define KEX_DEFAULT_ENCRYPT \ 73#define KEX_DEFAULT_ENCRYPT \
51 "aes128-ctr,aes192-ctr,aes256-ctr," \ 74 "aes128-ctr,aes192-ctr,aes256-ctr," \
diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in
index d22efd66c..41b22d837 100644
--- a/openbsd-compat/Makefile.in
+++ b/openbsd-compat/Makefile.in
@@ -1,4 +1,4 @@
1# $Id: Makefile.in,v 1.45 2010/08/16 03:15:23 dtucker Exp $ 1# $Id: Makefile.in,v 1.46 2010/10/07 11:19:24 djm Exp $
2 2
3sysconfdir=@sysconfdir@ 3sysconfdir=@sysconfdir@
4piddir=@piddir@ 4piddir=@piddir@
@@ -16,7 +16,7 @@ RANLIB=@RANLIB@
16INSTALL=@INSTALL@ 16INSTALL=@INSTALL@
17LDFLAGS=-L. @LDFLAGS@ 17LDFLAGS=-L. @LDFLAGS@
18 18
19OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o fmt_scaled.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o pwcache.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sha2.o sigact.o strlcat.o strlcpy.o strmode.o strptime.o strsep.o strtonum.o strtoll.o strtoul.o vis.o 19OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o fmt_scaled.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o pwcache.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sha2.o sigact.o strlcat.o strlcpy.o strmode.o strptime.o strsep.o strtonum.o strtoll.o strtoul.o timingsafe_bcmp.o vis.o
20 20
21COMPAT=bsd-arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o 21COMPAT=bsd-arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o
22 22
diff --git a/openbsd-compat/bindresvport.c b/openbsd-compat/bindresvport.c
index c0d5bdb5c..c89f21403 100644
--- a/openbsd-compat/bindresvport.c
+++ b/openbsd-compat/bindresvport.c
@@ -89,7 +89,7 @@ bindresvport_sa(int sd, struct sockaddr *sa)
89 89
90 port = ntohs(*portp); 90 port = ntohs(*portp);
91 if (port == 0) 91 if (port == 0)
92 port = (arc4random() % NPORTS) + STARTPORT; 92 port = arc4random_uniform(NPORTS) + STARTPORT;
93 93
94 /* Avoid warning */ 94 /* Avoid warning */
95 error = -1; 95 error = -1;
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index 55f100ac0..3ef373f56 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -240,3 +240,10 @@ strdup(const char *str)
240 return NULL; 240 return NULL;
241} 241}
242#endif 242#endif
243
244#ifndef HAVE_ISBLANK
245int isblank(int c)
246{
247 return (c == ' ' || c == '\t');
248}
249#endif
diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h
index b61ec4244..e70c3f9e9 100644
--- a/openbsd-compat/bsd-misc.h
+++ b/openbsd-compat/bsd-misc.h
@@ -1,4 +1,4 @@
1/* $Id: bsd-misc.h,v 1.18 2005/02/25 23:07:38 dtucker Exp $ */ 1/* $Id: bsd-misc.h,v 1.19 2010/11/08 22:26:23 tim Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999-2004 Damien Miller <djm@mindrot.org> 4 * Copyright (c) 1999-2004 Damien Miller <djm@mindrot.org>
@@ -95,4 +95,8 @@ mysig_t mysignal(int sig, mysig_t act);
95 95
96#define signal(a,b) mysignal(a,b) 96#define signal(a,b) mysignal(a,b)
97 97
98#ifndef HAVE_ISBLANK
99int isblank(int);
100#endif
101
98#endif /* _BSD_MISC_H */ 102#endif /* _BSD_MISC_H */
diff --git a/openbsd-compat/charclass.h b/openbsd-compat/charclass.h
new file mode 100644
index 000000000..91f517447
--- /dev/null
+++ b/openbsd-compat/charclass.h
@@ -0,0 +1,31 @@
1/*
2 * Public domain, 2008, Todd C. Miller <Todd.Miller@courtesan.com>
3 *
4 * $OpenBSD: charclass.h,v 1.1 2008/10/01 23:04:13 millert Exp $
5 */
6
7/* OPENBSD ORIGINAL: lib/libc/gen/charclass.h */
8
9/*
10 * POSIX character class support for fnmatch() and glob().
11 */
12static struct cclass {
13 const char *name;
14 int (*isctype)(int);
15} cclasses[] = {
16 { "alnum", isalnum },
17 { "alpha", isalpha },
18 { "blank", isblank },
19 { "cntrl", iscntrl },
20 { "digit", isdigit },
21 { "graph", isgraph },
22 { "lower", islower },
23 { "print", isprint },
24 { "punct", ispunct },
25 { "space", isspace },
26 { "upper", isupper },
27 { "xdigit", isxdigit },
28 { NULL, NULL }
29};
30
31#define NCCLASSES (sizeof(cclasses) / sizeof(cclasses[0]) - 1)
diff --git a/openbsd-compat/glob.c b/openbsd-compat/glob.c
index 74b506403..0341225cd 100644
--- a/openbsd-compat/glob.c
+++ b/openbsd-compat/glob.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: glob.c,v 1.26 2005/11/28 17:50:12 deraadt Exp $ */ 1/* $OpenBSD: glob.c,v 1.35 2011/01/12 01:53:14 djm Exp $ */
2/* 2/*
3 * Copyright (c) 1989, 1993 3 * Copyright (c) 1989, 1993
4 * The Regents of the University of California. All rights reserved. 4 * The Regents of the University of California. All rights reserved.
@@ -33,36 +33,6 @@
33 33
34/* OPENBSD ORIGINAL: lib/libc/gen/glob.c */ 34/* OPENBSD ORIGINAL: lib/libc/gen/glob.c */
35 35
36#include "includes.h"
37
38#include <sys/types.h>
39#include <sys/stat.h>
40
41#include <dirent.h>
42#include <ctype.h>
43#include <errno.h>
44#include <pwd.h>
45#include <stdlib.h>
46#include <string.h>
47#include <unistd.h>
48
49#if !defined(HAVE_GLOB) || !defined(GLOB_HAS_ALTDIRFUNC) || \
50 !defined(GLOB_HAS_GL_MATCHC) || \
51 !defined(HAVE_DECL_GLOB_NOMATCH) || HAVE_DECL_GLOB_NOMATCH == 0 || \
52 defined(BROKEN_GLOB)
53
54static long
55get_arg_max(void)
56{
57#ifdef ARG_MAX
58 return(ARG_MAX);
59#elif defined(HAVE_SYSCONF) && defined(_SC_ARG_MAX)
60 return(sysconf(_SC_ARG_MAX));
61#else
62 return(256); /* XXX: arbitrary */
63#endif
64}
65
66/* 36/*
67 * glob(3) -- a superset of the one defined in POSIX 1003.2. 37 * glob(3) -- a superset of the one defined in POSIX 1003.2.
68 * 38 *
@@ -88,6 +58,25 @@ get_arg_max(void)
88 * Number of matches in the current invocation of glob. 58 * Number of matches in the current invocation of glob.
89 */ 59 */
90 60
61#include "includes.h"
62
63#include <sys/types.h>
64#include <sys/stat.h>
65
66#include <dirent.h>
67#include <ctype.h>
68#include <errno.h>
69#include <pwd.h>
70#include <stdlib.h>
71#include <string.h>
72#include <unistd.h>
73
74#if !defined(HAVE_GLOB) || !defined(GLOB_HAS_ALTDIRFUNC) || \
75 !defined(GLOB_HAS_GL_MATCHC) || !defined(GLOB_HAS_GL_STATV) || \
76 !defined(HAVE_DECL_GLOB_NOMATCH) || HAVE_DECL_GLOB_NOMATCH == 0 || \
77 defined(BROKEN_GLOB)
78
79#include "charclass.h"
91 80
92#define DOLLAR '$' 81#define DOLLAR '$'
93#define DOT '.' 82#define DOT '.'
@@ -100,7 +89,6 @@ get_arg_max(void)
100#define RBRACKET ']' 89#define RBRACKET ']'
101#define SEP '/' 90#define SEP '/'
102#define STAR '*' 91#define STAR '*'
103#undef TILDE /* Some platforms may already define it */
104#define TILDE '~' 92#define TILDE '~'
105#define UNDERSCORE '_' 93#define UNDERSCORE '_'
106#define LBRACE '{' 94#define LBRACE '{'
@@ -137,26 +125,39 @@ typedef char Char;
137#define M_ONE META('?') 125#define M_ONE META('?')
138#define M_RNG META('-') 126#define M_RNG META('-')
139#define M_SET META('[') 127#define M_SET META('[')
128#define M_CLASS META(':')
140#define ismeta(c) (((c)&M_QUOTE) != 0) 129#define ismeta(c) (((c)&M_QUOTE) != 0)
141 130
131#define GLOB_LIMIT_MALLOC 65536
132#define GLOB_LIMIT_STAT 128
133#define GLOB_LIMIT_READDIR 16384
134
135struct glob_lim {
136 size_t glim_malloc;
137 size_t glim_stat;
138 size_t glim_readdir;
139};
142 140
143static int compare(const void *, const void *); 141static int compare(const void *, const void *);
144static int g_Ctoc(const Char *, char *, u_int); 142static int g_Ctoc(const Char *, char *, u_int);
145static int g_lstat(Char *, struct stat *, glob_t *); 143static int g_lstat(Char *, struct stat *, glob_t *);
146static DIR *g_opendir(Char *, glob_t *); 144static DIR *g_opendir(Char *, glob_t *);
147static Char *g_strchr(Char *, int); 145static Char *g_strchr(const Char *, int);
146static int g_strncmp(const Char *, const char *, size_t);
148static int g_stat(Char *, struct stat *, glob_t *); 147static int g_stat(Char *, struct stat *, glob_t *);
149static int glob0(const Char *, glob_t *); 148static int glob0(const Char *, glob_t *, struct glob_lim *);
150static int glob1(Char *, Char *, glob_t *, size_t *); 149static int glob1(Char *, Char *, glob_t *, struct glob_lim *);
151static int glob2(Char *, Char *, Char *, Char *, Char *, Char *, 150static int glob2(Char *, Char *, Char *, Char *, Char *, Char *,
152 glob_t *, size_t *); 151 glob_t *, struct glob_lim *);
153static int glob3(Char *, Char *, Char *, Char *, Char *, 152static int glob3(Char *, Char *, Char *, Char *, Char *,
154 Char *, Char *, glob_t *, size_t *); 153 Char *, Char *, glob_t *, struct glob_lim *);
155static int globextend(const Char *, glob_t *, size_t *); 154static int globextend(const Char *, glob_t *, struct glob_lim *,
155 struct stat *);
156static const Char * 156static const Char *
157 globtilde(const Char *, Char *, size_t, glob_t *); 157 globtilde(const Char *, Char *, size_t, glob_t *);
158static int globexp1(const Char *, glob_t *); 158static int globexp1(const Char *, glob_t *, struct glob_lim *);
159static int globexp2(const Char *, const Char *, glob_t *, int *); 159static int globexp2(const Char *, const Char *, glob_t *,
160 struct glob_lim *);
160static int match(Char *, Char *, Char *); 161static int match(Char *, Char *, Char *);
161#ifdef DEBUG 162#ifdef DEBUG
162static void qprintf(const char *, Char *); 163static void qprintf(const char *, Char *);
@@ -169,11 +170,13 @@ glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
169 const u_char *patnext; 170 const u_char *patnext;
170 int c; 171 int c;
171 Char *bufnext, *bufend, patbuf[MAXPATHLEN]; 172 Char *bufnext, *bufend, patbuf[MAXPATHLEN];
173 struct glob_lim limit = { 0, 0, 0 };
172 174
173 patnext = (u_char *) pattern; 175 patnext = (u_char *) pattern;
174 if (!(flags & GLOB_APPEND)) { 176 if (!(flags & GLOB_APPEND)) {
175 pglob->gl_pathc = 0; 177 pglob->gl_pathc = 0;
176 pglob->gl_pathv = NULL; 178 pglob->gl_pathv = NULL;
179 pglob->gl_statv = NULL;
177 if (!(flags & GLOB_DOOFFS)) 180 if (!(flags & GLOB_DOOFFS))
178 pglob->gl_offs = 0; 181 pglob->gl_offs = 0;
179 } 182 }
@@ -181,6 +184,11 @@ glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
181 pglob->gl_errfunc = errfunc; 184 pglob->gl_errfunc = errfunc;
182 pglob->gl_matchc = 0; 185 pglob->gl_matchc = 0;
183 186
187 if (pglob->gl_offs < 0 || pglob->gl_pathc < 0 ||
188 pglob->gl_offs >= INT_MAX || pglob->gl_pathc >= INT_MAX ||
189 pglob->gl_pathc >= INT_MAX - pglob->gl_offs - 1)
190 return GLOB_NOSPACE;
191
184 bufnext = patbuf; 192 bufnext = patbuf;
185 bufend = bufnext + MAXPATHLEN - 1; 193 bufend = bufnext + MAXPATHLEN - 1;
186 if (flags & GLOB_NOESCAPE) 194 if (flags & GLOB_NOESCAPE)
@@ -201,9 +209,9 @@ glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
201 *bufnext = EOS; 209 *bufnext = EOS;
202 210
203 if (flags & GLOB_BRACE) 211 if (flags & GLOB_BRACE)
204 return globexp1(patbuf, pglob); 212 return globexp1(patbuf, pglob, &limit);
205 else 213 else
206 return glob0(patbuf, pglob); 214 return glob0(patbuf, pglob, &limit);
207} 215}
208 216
209/* 217/*
@@ -212,20 +220,18 @@ glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
212 * characters 220 * characters
213 */ 221 */
214static int 222static int
215globexp1(const Char *pattern, glob_t *pglob) 223globexp1(const Char *pattern, glob_t *pglob, struct glob_lim *limitp)
216{ 224{
217 const Char* ptr = pattern; 225 const Char* ptr = pattern;
218 int rv;
219 226
220 /* Protect a single {}, for find(1), like csh */ 227 /* Protect a single {}, for find(1), like csh */
221 if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS) 228 if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS)
222 return glob0(pattern, pglob); 229 return glob0(pattern, pglob, limitp);
223 230
224 while ((ptr = (const Char *) g_strchr((Char *) ptr, LBRACE)) != NULL) 231 if ((ptr = (const Char *) g_strchr(ptr, LBRACE)) != NULL)
225 if (!globexp2(ptr, pattern, pglob, &rv)) 232 return globexp2(ptr, pattern, pglob, limitp);
226 return rv;
227 233
228 return glob0(pattern, pglob); 234 return glob0(pattern, pglob, limitp);
229} 235}
230 236
231 237
@@ -235,9 +241,10 @@ globexp1(const Char *pattern, glob_t *pglob)
235 * If it fails then it tries to glob the rest of the pattern and returns. 241 * If it fails then it tries to glob the rest of the pattern and returns.
236 */ 242 */
237static int 243static int
238globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv) 244globexp2(const Char *ptr, const Char *pattern, glob_t *pglob,
245 struct glob_lim *limitp)
239{ 246{
240 int i; 247 int i, rv;
241 Char *lm, *ls; 248 Char *lm, *ls;
242 const Char *pe, *pm, *pl; 249 const Char *pe, *pm, *pl;
243 Char patbuf[MAXPATHLEN]; 250 Char patbuf[MAXPATHLEN];
@@ -270,10 +277,8 @@ globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv)
270 } 277 }
271 278
272 /* Non matching braces; just glob the pattern */ 279 /* Non matching braces; just glob the pattern */
273 if (i != 0 || *pe == EOS) { 280 if (i != 0 || *pe == EOS)
274 *rv = glob0(patbuf, pglob); 281 return glob0(patbuf, pglob, limitp);
275 return 0;
276 }
277 282
278 for (i = 0, pl = pm = ptr; pm <= pe; pm++) { 283 for (i = 0, pl = pm = ptr; pm <= pe; pm++) {
279 switch (*pm) { 284 switch (*pm) {
@@ -319,7 +324,9 @@ globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv)
319#ifdef DEBUG 324#ifdef DEBUG
320 qprintf("globexp2:", patbuf); 325 qprintf("globexp2:", patbuf);
321#endif 326#endif
322 *rv = globexp1(patbuf, pglob); 327 rv = globexp1(patbuf, pglob, limitp);
328 if (rv && rv != GLOB_NOMATCH)
329 return rv;
323 330
324 /* move after the comma, to the next string */ 331 /* move after the comma, to the next string */
325 pl = pm + 1; 332 pl = pm + 1;
@@ -330,7 +337,6 @@ globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv)
330 break; 337 break;
331 } 338 }
332 } 339 }
333 *rv = 0;
334 return 0; 340 return 0;
335} 341}
336 342
@@ -399,6 +405,47 @@ globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
399 return patbuf; 405 return patbuf;
400} 406}
401 407
408static int
409g_strncmp(const Char *s1, const char *s2, size_t n)
410{
411 int rv = 0;
412
413 while (n--) {
414 rv = *(Char *)s1 - *(const unsigned char *)s2++;
415 if (rv)
416 break;
417 if (*s1++ == '\0')
418 break;
419 }
420 return rv;
421}
422
423static int
424g_charclass(const Char **patternp, Char **bufnextp)
425{
426 const Char *pattern = *patternp + 1;
427 Char *bufnext = *bufnextp;
428 const Char *colon;
429 struct cclass *cc;
430 size_t len;
431
432 if ((colon = g_strchr(pattern, ':')) == NULL || colon[1] != ']')
433 return 1; /* not a character class */
434
435 len = (size_t)(colon - pattern);
436 for (cc = cclasses; cc->name != NULL; cc++) {
437 if (!g_strncmp(pattern, cc->name, len) && cc->name[len] == '\0')
438 break;
439 }
440 if (cc->name == NULL)
441 return -1; /* invalid character class */
442 *bufnext++ = M_CLASS;
443 *bufnext++ = (Char)(cc - &cclasses[0]);
444 *bufnextp = bufnext;
445 *patternp += len + 3;
446
447 return 0;
448}
402 449
403/* 450/*
404 * The main glob() routine: compiles the pattern (optionally processing 451 * The main glob() routine: compiles the pattern (optionally processing
@@ -408,12 +455,11 @@ globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
408 * to find no matches. 455 * to find no matches.
409 */ 456 */
410static int 457static int
411glob0(const Char *pattern, glob_t *pglob) 458glob0(const Char *pattern, glob_t *pglob, struct glob_lim *limitp)
412{ 459{
413 const Char *qpatnext; 460 const Char *qpatnext;
414 int c, err, oldpathc; 461 int c, err, oldpathc;
415 Char *bufnext, patbuf[MAXPATHLEN]; 462 Char *bufnext, patbuf[MAXPATHLEN];
416 size_t limit = 0;
417 463
418 qpatnext = globtilde(pattern, patbuf, MAXPATHLEN, pglob); 464 qpatnext = globtilde(pattern, patbuf, MAXPATHLEN, pglob);
419 oldpathc = pglob->gl_pathc; 465 oldpathc = pglob->gl_pathc;
@@ -427,7 +473,7 @@ glob0(const Char *pattern, glob_t *pglob)
427 if (c == NOT) 473 if (c == NOT)
428 ++qpatnext; 474 ++qpatnext;
429 if (*qpatnext == EOS || 475 if (*qpatnext == EOS ||
430 g_strchr((Char *) qpatnext+1, RBRACKET) == NULL) { 476 g_strchr(qpatnext+1, RBRACKET) == NULL) {
431 *bufnext++ = LBRACKET; 477 *bufnext++ = LBRACKET;
432 if (c == NOT) 478 if (c == NOT)
433 --qpatnext; 479 --qpatnext;
@@ -438,6 +484,20 @@ glob0(const Char *pattern, glob_t *pglob)
438 *bufnext++ = M_NOT; 484 *bufnext++ = M_NOT;
439 c = *qpatnext++; 485 c = *qpatnext++;
440 do { 486 do {
487 if (c == LBRACKET && *qpatnext == ':') {
488 do {
489 err = g_charclass(&qpatnext,
490 &bufnext);
491 if (err)
492 break;
493 c = *qpatnext++;
494 } while (c == LBRACKET && *qpatnext == ':');
495 if (err == -1 &&
496 !(pglob->gl_flags & GLOB_NOCHECK))
497 return GLOB_NOMATCH;
498 if (c == RBRACKET)
499 break;
500 }
441 *bufnext++ = CHAR(c); 501 *bufnext++ = CHAR(c);
442 if (*qpatnext == RANGE && 502 if (*qpatnext == RANGE &&
443 (c = qpatnext[1]) != RBRACKET) { 503 (c = qpatnext[1]) != RBRACKET) {
@@ -471,7 +531,7 @@ glob0(const Char *pattern, glob_t *pglob)
471 qprintf("glob0:", patbuf); 531 qprintf("glob0:", patbuf);
472#endif 532#endif
473 533
474 if ((err = glob1(patbuf, patbuf+MAXPATHLEN-1, pglob, &limit)) != 0) 534 if ((err = glob1(patbuf, patbuf+MAXPATHLEN-1, pglob, limitp)) != 0)
475 return(err); 535 return(err);
476 536
477 /* 537 /*
@@ -484,7 +544,7 @@ glob0(const Char *pattern, glob_t *pglob)
484 if ((pglob->gl_flags & GLOB_NOCHECK) || 544 if ((pglob->gl_flags & GLOB_NOCHECK) ||
485 ((pglob->gl_flags & GLOB_NOMAGIC) && 545 ((pglob->gl_flags & GLOB_NOMAGIC) &&
486 !(pglob->gl_flags & GLOB_MAGCHAR))) 546 !(pglob->gl_flags & GLOB_MAGCHAR)))
487 return(globextend(pattern, pglob, &limit)); 547 return(globextend(pattern, pglob, limitp, NULL));
488 else 548 else
489 return(GLOB_NOMATCH); 549 return(GLOB_NOMATCH);
490 } 550 }
@@ -501,7 +561,7 @@ compare(const void *p, const void *q)
501} 561}
502 562
503static int 563static int
504glob1(Char *pattern, Char *pattern_last, glob_t *pglob, size_t *limitp) 564glob1(Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp)
505{ 565{
506 Char pathbuf[MAXPATHLEN]; 566 Char pathbuf[MAXPATHLEN];
507 567
@@ -520,7 +580,7 @@ glob1(Char *pattern, Char *pattern_last, glob_t *pglob, size_t *limitp)
520 */ 580 */
521static int 581static int
522glob2(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last, 582glob2(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
523 Char *pattern, Char *pattern_last, glob_t *pglob, size_t *limitp) 583 Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp)
524{ 584{
525 struct stat sb; 585 struct stat sb;
526 Char *p, *q; 586 Char *p, *q;
@@ -536,6 +596,14 @@ glob2(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
536 if (g_lstat(pathbuf, &sb, pglob)) 596 if (g_lstat(pathbuf, &sb, pglob))
537 return(0); 597 return(0);
538 598
599 if ((pglob->gl_flags & GLOB_LIMIT) &&
600 limitp->glim_stat++ >= GLOB_LIMIT_STAT) {
601 errno = 0;
602 *pathend++ = SEP;
603 *pathend = EOS;
604 return(GLOB_NOSPACE);
605 }
606
539 if (((pglob->gl_flags & GLOB_MARK) && 607 if (((pglob->gl_flags & GLOB_MARK) &&
540 pathend[-1] != SEP) && (S_ISDIR(sb.st_mode) || 608 pathend[-1] != SEP) && (S_ISDIR(sb.st_mode) ||
541 (S_ISLNK(sb.st_mode) && 609 (S_ISLNK(sb.st_mode) &&
@@ -547,7 +615,7 @@ glob2(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
547 *pathend = EOS; 615 *pathend = EOS;
548 } 616 }
549 ++pglob->gl_matchc; 617 ++pglob->gl_matchc;
550 return(globextend(pathbuf, pglob, limitp)); 618 return(globextend(pathbuf, pglob, limitp, &sb));
551 } 619 }
552 620
553 /* Find end of next segment, copy tentatively to pathend. */ 621 /* Find end of next segment, copy tentatively to pathend. */
@@ -581,7 +649,7 @@ glob2(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
581static int 649static int
582glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last, 650glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
583 Char *pattern, Char *restpattern, Char *restpattern_last, glob_t *pglob, 651 Char *pattern, Char *restpattern, Char *restpattern_last, glob_t *pglob,
584 size_t *limitp) 652 struct glob_lim *limitp)
585{ 653{
586 struct dirent *dp; 654 struct dirent *dp;
587 DIR *dirp; 655 DIR *dirp;
@@ -624,6 +692,14 @@ glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
624 u_char *sc; 692 u_char *sc;
625 Char *dc; 693 Char *dc;
626 694
695 if ((pglob->gl_flags & GLOB_LIMIT) &&
696 limitp->glim_readdir++ >= GLOB_LIMIT_READDIR) {
697 errno = 0;
698 *pathend++ = SEP;
699 *pathend = EOS;
700 return(GLOB_NOSPACE);
701 }
702
627 /* Initial DOT must be matched literally. */ 703 /* Initial DOT must be matched literally. */
628 if (dp->d_name[0] == DOT && *pattern != DOT) 704 if (dp->d_name[0] == DOT && *pattern != DOT)
629 continue; 705 continue;
@@ -670,25 +746,44 @@ glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
670 * gl_pathv points to (gl_offs + gl_pathc + 1) items. 746 * gl_pathv points to (gl_offs + gl_pathc + 1) items.
671 */ 747 */
672static int 748static int
673globextend(const Char *path, glob_t *pglob, size_t *limitp) 749globextend(const Char *path, glob_t *pglob, struct glob_lim *limitp,
750 struct stat *sb)
674{ 751{
675 char **pathv; 752 char **pathv;
676 int i; 753 ssize_t i;
677 u_int newsize, len; 754 size_t newn, len;
678 char *copy; 755 char *copy = NULL;
679 const Char *p; 756 const Char *p;
680 757 struct stat **statv;
681 newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs); 758
682 pathv = pglob->gl_pathv ? realloc((char *)pglob->gl_pathv, newsize) : 759 newn = 2 + pglob->gl_pathc + pglob->gl_offs;
683 malloc(newsize); 760 if (pglob->gl_offs >= INT_MAX ||
684 if (pathv == NULL) { 761 pglob->gl_pathc >= INT_MAX ||
762 newn >= INT_MAX ||
763 SIZE_MAX / sizeof(*pathv) <= newn ||
764 SIZE_MAX / sizeof(*statv) <= newn) {
765 nospace:
766 for (i = pglob->gl_offs; i < (ssize_t)(newn - 2); i++) {
767 if (pglob->gl_pathv && pglob->gl_pathv[i])
768 free(pglob->gl_pathv[i]);
769 if ((pglob->gl_flags & GLOB_KEEPSTAT) != 0 &&
770 pglob->gl_pathv && pglob->gl_pathv[i])
771 free(pglob->gl_statv[i]);
772 }
685 if (pglob->gl_pathv) { 773 if (pglob->gl_pathv) {
686 free(pglob->gl_pathv); 774 free(pglob->gl_pathv);
687 pglob->gl_pathv = NULL; 775 pglob->gl_pathv = NULL;
688 } 776 }
777 if (pglob->gl_statv) {
778 free(pglob->gl_statv);
779 pglob->gl_statv = NULL;
780 }
689 return(GLOB_NOSPACE); 781 return(GLOB_NOSPACE);
690 } 782 }
691 783
784 pathv = realloc(pglob->gl_pathv, newn * sizeof(*pathv));
785 if (pathv == NULL)
786 goto nospace;
692 if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) { 787 if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
693 /* first time around -- clear initial gl_offs items */ 788 /* first time around -- clear initial gl_offs items */
694 pathv += pglob->gl_offs; 789 pathv += pglob->gl_offs;
@@ -697,10 +792,39 @@ globextend(const Char *path, glob_t *pglob, size_t *limitp)
697 } 792 }
698 pglob->gl_pathv = pathv; 793 pglob->gl_pathv = pathv;
699 794
795 if ((pglob->gl_flags & GLOB_KEEPSTAT) != 0) {
796 statv = realloc(pglob->gl_statv, newn * sizeof(*statv));
797 if (statv == NULL)
798 goto nospace;
799 if (pglob->gl_statv == NULL && pglob->gl_offs > 0) {
800 /* first time around -- clear initial gl_offs items */
801 statv += pglob->gl_offs;
802 for (i = pglob->gl_offs; --i >= 0; )
803 *--statv = NULL;
804 }
805 pglob->gl_statv = statv;
806 if (sb == NULL)
807 statv[pglob->gl_offs + pglob->gl_pathc] = NULL;
808 else {
809 limitp->glim_malloc += sizeof(**statv);
810 if ((pglob->gl_flags & GLOB_LIMIT) &&
811 limitp->glim_malloc >= GLOB_LIMIT_MALLOC) {
812 errno = 0;
813 return(GLOB_NOSPACE);
814 }
815 if ((statv[pglob->gl_offs + pglob->gl_pathc] =
816 malloc(sizeof(**statv))) == NULL)
817 goto copy_error;
818 memcpy(statv[pglob->gl_offs + pglob->gl_pathc], sb,
819 sizeof(*sb));
820 }
821 statv[pglob->gl_offs + pglob->gl_pathc + 1] = NULL;
822 }
823
700 for (p = path; *p++;) 824 for (p = path; *p++;)
701 ; 825 ;
702 len = (size_t)(p - path); 826 len = (size_t)(p - path);
703 *limitp += len; 827 limitp->glim_malloc += len;
704 if ((copy = malloc(len)) != NULL) { 828 if ((copy = malloc(len)) != NULL) {
705 if (g_Ctoc(path, copy, len)) { 829 if (g_Ctoc(path, copy, len)) {
706 free(copy); 830 free(copy);
@@ -711,11 +835,12 @@ globextend(const Char *path, glob_t *pglob, size_t *limitp)
711 pathv[pglob->gl_offs + pglob->gl_pathc] = NULL; 835 pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
712 836
713 if ((pglob->gl_flags & GLOB_LIMIT) && 837 if ((pglob->gl_flags & GLOB_LIMIT) &&
714 newsize + *limitp >= (u_int) get_arg_max()) { 838 (newn * sizeof(*pathv)) + limitp->glim_malloc >
839 GLOB_LIMIT_MALLOC) {
715 errno = 0; 840 errno = 0;
716 return(GLOB_NOSPACE); 841 return(GLOB_NOSPACE);
717 } 842 }
718 843 copy_error:
719 return(copy == NULL ? GLOB_NOSPACE : 0); 844 return(copy == NULL ? GLOB_NOSPACE : 0);
720} 845}
721 846
@@ -751,13 +876,21 @@ match(Char *name, Char *pat, Char *patend)
751 return(0); 876 return(0);
752 if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS) 877 if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS)
753 ++pat; 878 ++pat;
754 while (((c = *pat++) & M_MASK) != M_END) 879 while (((c = *pat++) & M_MASK) != M_END) {
880 if ((c & M_MASK) == M_CLASS) {
881 Char idx = *pat & M_MASK;
882 if (idx < NCCLASSES &&
883 cclasses[idx].isctype(k))
884 ok = 1;
885 ++pat;
886 }
755 if ((*pat & M_MASK) == M_RNG) { 887 if ((*pat & M_MASK) == M_RNG) {
756 if (c <= k && k <= pat[1]) 888 if (c <= k && k <= pat[1])
757 ok = 1; 889 ok = 1;
758 pat += 2; 890 pat += 2;
759 } else if (c == k) 891 } else if (c == k)
760 ok = 1; 892 ok = 1;
893 }
761 if (ok == negate_range) 894 if (ok == negate_range)
762 return(0); 895 return(0);
763 break; 896 break;
@@ -785,6 +918,14 @@ globfree(glob_t *pglob)
785 free(pglob->gl_pathv); 918 free(pglob->gl_pathv);
786 pglob->gl_pathv = NULL; 919 pglob->gl_pathv = NULL;
787 } 920 }
921 if (pglob->gl_statv != NULL) {
922 for (i = 0; i < pglob->gl_pathc; i++) {
923 if (pglob->gl_statv[i] != NULL)
924 free(pglob->gl_statv[i]);
925 }
926 free(pglob->gl_statv);
927 pglob->gl_statv = NULL;
928 }
788} 929}
789 930
790static DIR * 931static DIR *
@@ -830,11 +971,11 @@ g_stat(Char *fn, struct stat *sb, glob_t *pglob)
830} 971}
831 972
832static Char * 973static Char *
833g_strchr(Char *str, int ch) 974g_strchr(const Char *str, int ch)
834{ 975{
835 do { 976 do {
836 if (*str == ch) 977 if (*str == ch)
837 return (str); 978 return ((Char *)str);
838 } while (*str++); 979 } while (*str++);
839 return (NULL); 980 return (NULL);
840} 981}
@@ -870,5 +1011,4 @@ qprintf(const char *str, Char *s)
870#endif 1011#endif
871 1012
872#endif /* !defined(HAVE_GLOB) || !defined(GLOB_HAS_ALTDIRFUNC) || 1013#endif /* !defined(HAVE_GLOB) || !defined(GLOB_HAS_ALTDIRFUNC) ||
873 !defined(GLOB_HAS_GL_MATCHC) */ 1014 !defined(GLOB_HAS_GL_MATCHC) || !defined(GLOB_HAS_GL_STATV) */
874
diff --git a/openbsd-compat/glob.h b/openbsd-compat/glob.h
index a2b36f974..f8a7fa5ff 100644
--- a/openbsd-compat/glob.h
+++ b/openbsd-compat/glob.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: glob.h,v 1.10 2005/12/13 00:35:22 millert Exp $ */ 1/* $OpenBSD: glob.h,v 1.11 2010/09/24 13:32:55 djm Exp $ */
2/* $NetBSD: glob.h,v 1.5 1994/10/26 00:55:56 cgd Exp $ */ 2/* $NetBSD: glob.h,v 1.5 1994/10/26 00:55:56 cgd Exp $ */
3 3
4/* 4/*
@@ -38,13 +38,15 @@
38/* OPENBSD ORIGINAL: include/glob.h */ 38/* OPENBSD ORIGINAL: include/glob.h */
39 39
40#if !defined(HAVE_GLOB_H) || !defined(GLOB_HAS_ALTDIRFUNC) || \ 40#if !defined(HAVE_GLOB_H) || !defined(GLOB_HAS_ALTDIRFUNC) || \
41 !defined(GLOB_HAS_GL_MATCHC) || \ 41 !defined(GLOB_HAS_GL_MATCHC) || !defined(GLOB_HAS_GL_STATV) || \
42 !defined(HAVE_DECL_GLOB_NOMATCH) || HAVE_DECL_GLOB_NOMATCH == 0 || \ 42 !defined(HAVE_DECL_GLOB_NOMATCH) || HAVE_DECL_GLOB_NOMATCH == 0 || \
43 defined(BROKEN_GLOB) 43 defined(BROKEN_GLOB)
44 44
45#ifndef _GLOB_H_ 45#ifndef _GLOB_H_
46#define _GLOB_H_ 46#define _GLOB_H_
47 47
48#include <sys/stat.h>
49
48struct stat; 50struct stat;
49typedef struct { 51typedef struct {
50 int gl_pathc; /* Count of total paths so far. */ 52 int gl_pathc; /* Count of total paths so far. */
@@ -52,6 +54,7 @@ typedef struct {
52 int gl_offs; /* Reserved at beginning of gl_pathv. */ 54 int gl_offs; /* Reserved at beginning of gl_pathv. */
53 int gl_flags; /* Copy of flags parameter to glob. */ 55 int gl_flags; /* Copy of flags parameter to glob. */
54 char **gl_pathv; /* List of paths matching pattern. */ 56 char **gl_pathv; /* List of paths matching pattern. */
57 struct stat **gl_statv; /* Stat entries corresponding to gl_pathv */
55 /* Copy of errfunc parameter to glob. */ 58 /* Copy of errfunc parameter to glob. */
56 int (*gl_errfunc)(const char *, int); 59 int (*gl_errfunc)(const char *, int);
57 60
@@ -75,12 +78,10 @@ typedef struct {
75#define GLOB_NOSORT 0x0020 /* Don't sort. */ 78#define GLOB_NOSORT 0x0020 /* Don't sort. */
76#define GLOB_NOESCAPE 0x1000 /* Disable backslash escaping. */ 79#define GLOB_NOESCAPE 0x1000 /* Disable backslash escaping. */
77 80
78/* Error values returned by glob(3) */
79#define GLOB_NOSPACE (-1) /* Malloc call failed. */ 81#define GLOB_NOSPACE (-1) /* Malloc call failed. */
80#define GLOB_ABORTED (-2) /* Unignored error. */ 82#define GLOB_ABORTED (-2) /* Unignored error. */
81#define GLOB_NOMATCH (-3) /* No match and GLOB_NOCHECK not set. */ 83#define GLOB_NOMATCH (-3) /* No match and GLOB_NOCHECK not set. */
82#define GLOB_NOSYS (-4) /* Function not supported. */ 84#define GLOB_NOSYS (-4) /* Function not supported. */
83#define GLOB_ABEND GLOB_ABORTED
84 85
85#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */ 86#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */
86#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */ 87#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */
@@ -89,6 +90,8 @@ typedef struct {
89#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */ 90#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */
90#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */ 91#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */
91#define GLOB_LIMIT 0x2000 /* Limit pattern match output to ARG_MAX */ 92#define GLOB_LIMIT 0x2000 /* Limit pattern match output to ARG_MAX */
93#define GLOB_KEEPSTAT 0x4000 /* Retain stat data for paths in gl_statv. */
94#define GLOB_ABEND GLOB_ABORTED /* backward compatibility */
92 95
93int glob(const char *, int, int (*)(const char *, int), glob_t *); 96int glob(const char *, int, int (*)(const char *, int), glob_t *);
94void globfree(glob_t *); 97void globfree(glob_t *);
@@ -96,5 +99,5 @@ void globfree(glob_t *);
96#endif /* !_GLOB_H_ */ 99#endif /* !_GLOB_H_ */
97 100
98#endif /* !defined(HAVE_GLOB_H) || !defined(GLOB_HAS_ALTDIRFUNC) || 101#endif /* !defined(HAVE_GLOB_H) || !defined(GLOB_HAS_ALTDIRFUNC) ||
99 !defined(GLOB_HAS_GL_MATCHC */ 102 !defined(GLOB_HAS_GL_MATCHC) || !defined(GLOH_HAS_GL_STATV) */
100 103
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h
index e15d2bd96..77c5ed2b1 100644
--- a/openbsd-compat/openbsd-compat.h
+++ b/openbsd-compat/openbsd-compat.h
@@ -1,4 +1,4 @@
1/* $Id: openbsd-compat.h,v 1.50 2010/08/16 03:15:23 dtucker Exp $ */ 1/* $Id: openbsd-compat.h,v 1.51 2010/10/07 10:25:29 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999-2003 Damien Miller. All rights reserved. 4 * Copyright (c) 1999-2003 Damien Miller. All rights reserved.
@@ -213,6 +213,10 @@ char *user_from_uid(uid_t, int);
213char *group_from_gid(gid_t, int); 213char *group_from_gid(gid_t, int);
214#endif 214#endif
215 215
216#ifndef HAVE_TIMINGSAFE_BCMP
217int timingsafe_bcmp(const void *, const void *, size_t);
218#endif
219
216void *xmmap(size_t size); 220void *xmmap(size_t size);
217char *xcrypt(const char *password, const char *salt); 221char *xcrypt(const char *password, const char *salt);
218char *shadow_pw(struct passwd *pw); 222char *shadow_pw(struct passwd *pw);
diff --git a/openbsd-compat/openssl-compat.c b/openbsd-compat/openssl-compat.c
index 420496caa..b617fdf19 100644
--- a/openbsd-compat/openssl-compat.c
+++ b/openbsd-compat/openssl-compat.c
@@ -1,4 +1,4 @@
1/* $Id: openssl-compat.c,v 1.9 2010/01/28 23:54:11 dtucker Exp $ */ 1/* $Id: openssl-compat.c,v 1.13 2011/01/21 22:37:06 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au> 4 * Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au>
@@ -18,10 +18,20 @@
18 18
19#include "includes.h" 19#include "includes.h"
20 20
21#include <stdarg.h>
22#include <string.h>
23
21#ifdef USE_OPENSSL_ENGINE 24#ifdef USE_OPENSSL_ENGINE
22# include <openssl/engine.h> 25# include <openssl/engine.h>
26# include <openssl/conf.h>
27#endif
28
29#ifndef HAVE_RSA_GET_DEFAULT_METHOD
30# include <openssl/rsa.h>
23#endif 31#endif
24 32
33#include "log.h"
34
25#define SSH_DONT_OVERLOAD_OPENSSL_FUNCS 35#define SSH_DONT_OVERLOAD_OPENSSL_FUNCS
26#include "openssl-compat.h" 36#include "openssl-compat.h"
27 37
@@ -58,6 +68,70 @@ ssh_EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt)
58} 68}
59#endif 69#endif
60 70
71#ifndef HAVE_BN_IS_PRIME_EX
72int
73BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, void *cb)
74{
75 if (cb != NULL)
76 fatal("%s: callback args not supported", __func__);
77 return BN_is_prime(p, nchecks, NULL, ctx, NULL);
78}
79#endif
80
81#ifndef HAVE_RSA_GENERATE_KEY_EX
82int
83RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *bn_e, void *cb)
84{
85 RSA *new_rsa, tmp_rsa;
86 unsigned long e;
87
88 if (cb != NULL)
89 fatal("%s: callback args not supported", __func__);
90 e = BN_get_word(bn_e);
91 if (e == 0xffffffffL)
92 fatal("%s: value of e too large", __func__);
93 new_rsa = RSA_generate_key(bits, e, NULL, NULL);
94 if (new_rsa == NULL)
95 return 0;
96 /* swap rsa/new_rsa then free new_rsa */
97 tmp_rsa = *rsa;
98 *rsa = *new_rsa;
99 *new_rsa = tmp_rsa;
100 RSA_free(new_rsa);
101 return 1;
102}
103#endif
104
105#ifndef HAVE_DSA_GENERATE_PARAMETERS_EX
106int
107DSA_generate_parameters_ex(DSA *dsa, int bits, const unsigned char *seed,
108 int seed_len, int *counter_ret, unsigned long *h_ret, void *cb)
109{
110 DSA *new_dsa, tmp_dsa;
111
112 if (cb != NULL)
113 fatal("%s: callback args not supported", __func__);
114 new_dsa = DSA_generate_parameters(bits, (unsigned char *)seed, seed_len,
115 counter_ret, h_ret, NULL, NULL);
116 if (new_dsa == NULL)
117 return 0;
118 /* swap dsa/new_dsa then free new_dsa */
119 tmp_dsa = *dsa;
120 *dsa = *new_dsa;
121 *new_dsa = tmp_dsa;
122 DSA_free(new_dsa);
123 return 1;
124}
125#endif
126
127#ifndef HAVE_RSA_GET_DEFAULT_METHOD
128RSA_METHOD *
129RSA_get_default_method(void)
130{
131 return RSA_PKCS1_SSLeay();
132}
133#endif
134
61#ifdef USE_OPENSSL_ENGINE 135#ifdef USE_OPENSSL_ENGINE
62void 136void
63ssh_SSLeay_add_all_algorithms(void) 137ssh_SSLeay_add_all_algorithms(void)
diff --git a/openbsd-compat/openssl-compat.h b/openbsd-compat/openssl-compat.h
index b7caa650c..6d4f3f215 100644
--- a/openbsd-compat/openssl-compat.h
+++ b/openbsd-compat/openssl-compat.h
@@ -1,4 +1,4 @@
1/* $Id: openssl-compat.h,v 1.15 2010/05/12 07:50:02 djm Exp $ */ 1/* $Id: openssl-compat.h,v 1.18 2011/01/21 22:37:06 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au> 4 * Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au>
@@ -17,6 +17,7 @@
17 */ 17 */
18 18
19#include "includes.h" 19#include "includes.h"
20#include <openssl/opensslv.h>
20#include <openssl/evp.h> 21#include <openssl/evp.h>
21#include <openssl/rsa.h> 22#include <openssl/rsa.h>
22#include <openssl/dsa.h> 23#include <openssl/dsa.h>
@@ -39,6 +40,12 @@
39# define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data) 40# define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data)
40#endif 41#endif
41 42
43#if OPENSSL_VERSION_NUMBER < 0x1000000fL
44# define LIBCRYPTO_EVP_INL_TYPE unsigned int
45#else
46# define LIBCRYPTO_EVP_INL_TYPE size_t
47#endif
48
42#if (OPENSSL_VERSION_NUMBER < 0x00907000L) || defined(OPENSSL_LOBOTOMISED_AES) 49#if (OPENSSL_VERSION_NUMBER < 0x00907000L) || defined(OPENSSL_LOBOTOMISED_AES)
43# define USE_BUILTIN_RIJNDAEL 50# define USE_BUILTIN_RIJNDAEL
44#endif 51#endif
@@ -71,6 +78,10 @@ extern const EVP_CIPHER *evp_acss(void);
71# define EVP_CIPHER_CTX_key_length(c) ((c)->key_len) 78# define EVP_CIPHER_CTX_key_length(c) ((c)->key_len)
72#endif 79#endif
73 80
81#ifndef HAVE_RSA_GET_DEFAULT_METHOD
82RSA_METHOD *RSA_get_default_method(void);
83#endif
84
74/* 85/*
75 * We overload some of the OpenSSL crypto functions with ssh_* equivalents 86 * We overload some of the OpenSSL crypto functions with ssh_* equivalents
76 * which cater for older and/or less featureful OpenSSL version. 87 * which cater for older and/or less featureful OpenSSL version.
@@ -101,6 +112,19 @@ extern const EVP_CIPHER *evp_acss(void);
101# define SSLeay_add_all_algorithms() ssh_SSLeay_add_all_algorithms() 112# define SSLeay_add_all_algorithms() ssh_SSLeay_add_all_algorithms()
102# endif 113# endif
103 114
115# ifndef HAVE_BN_IS_PRIME_EX
116int BN_is_prime_ex(const BIGNUM *, int, BN_CTX *, void *);
117# endif
118
119# ifndef HAVE_DSA_GENERATE_PARAMETERS_EX
120int DSA_generate_parameters_ex(DSA *, int, const unsigned char *, int, int *,
121 unsigned long *, void *);
122# endif
123
124# ifndef HAVE_RSA_GENERATE_KEY_EX
125int RSA_generate_key_ex(RSA *, int, BIGNUM *, void *);
126# endif
127
104int ssh_EVP_CipherInit(EVP_CIPHER_CTX *, const EVP_CIPHER *, unsigned char *, 128int ssh_EVP_CipherInit(EVP_CIPHER_CTX *, const EVP_CIPHER *, unsigned char *,
105 unsigned char *, int); 129 unsigned char *, int);
106int ssh_EVP_Cipher(EVP_CIPHER_CTX *, char *, char *, int); 130int ssh_EVP_Cipher(EVP_CIPHER_CTX *, char *, char *, int);
diff --git a/openbsd-compat/port-linux.c b/openbsd-compat/port-linux.c
index 89b9a7340..5b1cf402c 100644
--- a/openbsd-compat/port-linux.c
+++ b/openbsd-compat/port-linux.c
@@ -1,4 +1,4 @@
1/* $Id: port-linux.c,v 1.8 2010/03/01 04:52:50 dtucker Exp $ */ 1/* $Id: port-linux.c,v 1.11 2011/01/17 07:50:24 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005 Daniel Walsh <dwalsh@redhat.com> 4 * Copyright (c) 2005 Daniel Walsh <dwalsh@redhat.com>
@@ -45,7 +45,7 @@ ssh_selinux_enabled(void)
45 static int enabled = -1; 45 static int enabled = -1;
46 46
47 if (enabled == -1) { 47 if (enabled == -1) {
48 enabled = is_selinux_enabled(); 48 enabled = (is_selinux_enabled() == 1);
49 debug("SELinux support %s", enabled ? "enabled" : "disabled"); 49 debug("SELinux support %s", enabled ? "enabled" : "disabled");
50 } 50 }
51 51
@@ -208,14 +208,22 @@ ssh_selinux_change_context(const char *newname)
208#endif /* WITH_SELINUX */ 208#endif /* WITH_SELINUX */
209 209
210#ifdef LINUX_OOM_ADJUST 210#ifdef LINUX_OOM_ADJUST
211#define OOM_ADJ_PATH "/proc/self/oom_adj"
212/* 211/*
213 * The magic "don't kill me", as documented in eg: 212 * The magic "don't kill me" values, old and new, as documented in eg:
214 * http://lxr.linux.no/#linux+v2.6.32/Documentation/filesystems/proc.txt 213 * http://lxr.linux.no/#linux+v2.6.32/Documentation/filesystems/proc.txt
214 * http://lxr.linux.no/#linux+v2.6.36/Documentation/filesystems/proc.txt
215 */ 215 */
216#define OOM_ADJ_NOKILL -17
217 216
218static int oom_adj_save = INT_MIN; 217static int oom_adj_save = INT_MIN;
218static char *oom_adj_path = NULL;
219struct {
220 char *path;
221 int value;
222} oom_adjust[] = {
223 {"/proc/self/oom_score_adj", -1000}, /* kernels >= 2.6.36 */
224 {"/proc/self/oom_adj", -17}, /* kernels <= 2.6.35 */
225 {NULL, 0},
226};
219 227
220/* 228/*
221 * Tell the kernel's out-of-memory killer to avoid sshd. 229 * Tell the kernel's out-of-memory killer to avoid sshd.
@@ -224,23 +232,31 @@ static int oom_adj_save = INT_MIN;
224void 232void
225oom_adjust_setup(void) 233oom_adjust_setup(void)
226{ 234{
235 int i, value;
227 FILE *fp; 236 FILE *fp;
228 237
229 debug3("%s", __func__); 238 debug3("%s", __func__);
230 if ((fp = fopen(OOM_ADJ_PATH, "r+")) != NULL) { 239 for (i = 0; oom_adjust[i].path != NULL; i++) {
231 if (fscanf(fp, "%d", &oom_adj_save) != 1) 240 oom_adj_path = oom_adjust[i].path;
232 verbose("error reading %s: %s", OOM_ADJ_PATH, strerror(errno)); 241 value = oom_adjust[i].value;
233 else { 242 if ((fp = fopen(oom_adj_path, "r+")) != NULL) {
234 rewind(fp); 243 if (fscanf(fp, "%d", &oom_adj_save) != 1)
235 if (fprintf(fp, "%d\n", OOM_ADJ_NOKILL) <= 0) 244 verbose("error reading %s: %s", oom_adj_path,
236 verbose("error writing %s: %s", 245 strerror(errno));
237 OOM_ADJ_PATH, strerror(errno)); 246 else {
238 else 247 rewind(fp);
239 verbose("Set %s from %d to %d", 248 if (fprintf(fp, "%d\n", value) <= 0)
240 OOM_ADJ_PATH, oom_adj_save, OOM_ADJ_NOKILL); 249 verbose("error writing %s: %s",
250 oom_adj_path, strerror(errno));
251 else
252 verbose("Set %s from %d to %d",
253 oom_adj_path, oom_adj_save, value);
254 }
255 fclose(fp);
256 return;
241 } 257 }
242 fclose(fp);
243 } 258 }
259 oom_adj_path = NULL;
244} 260}
245 261
246/* Restore the saved OOM adjustment */ 262/* Restore the saved OOM adjustment */
@@ -250,13 +266,14 @@ oom_adjust_restore(void)
250 FILE *fp; 266 FILE *fp;
251 267
252 debug3("%s", __func__); 268 debug3("%s", __func__);
253 if (oom_adj_save == INT_MIN || (fp = fopen(OOM_ADJ_PATH, "w")) == NULL) 269 if (oom_adj_save == INT_MIN || oom_adj_path == NULL ||
270 (fp = fopen(oom_adj_path, "w")) == NULL)
254 return; 271 return;
255 272
256 if (fprintf(fp, "%d\n", oom_adj_save) <= 0) 273 if (fprintf(fp, "%d\n", oom_adj_save) <= 0)
257 verbose("error writing %s: %s", OOM_ADJ_PATH, strerror(errno)); 274 verbose("error writing %s: %s", oom_adj_path, strerror(errno));
258 else 275 else
259 verbose("Set %s to %d", OOM_ADJ_PATH, oom_adj_save); 276 verbose("Set %s to %d", oom_adj_path, oom_adj_save);
260 277
261 fclose(fp); 278 fclose(fp);
262 return; 279 return;
diff --git a/openbsd-compat/port-solaris.c b/openbsd-compat/port-solaris.c
index 2ab64d487..25382f1c9 100644
--- a/openbsd-compat/port-solaris.c
+++ b/openbsd-compat/port-solaris.c
@@ -1,4 +1,4 @@
1/* $Id: port-solaris.c,v 1.3 2006/10/31 23:28:49 dtucker Exp $ */ 1/* $Id: port-solaris.c,v 1.4 2010/11/05 01:03:05 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006 Chad Mynhier. 4 * Copyright (c) 2006 Chad Mynhier.
@@ -197,3 +197,33 @@ solaris_contract_post_fork_parent(pid_t pid)
197 close(ctl_fd); 197 close(ctl_fd);
198} 198}
199#endif 199#endif
200
201#ifdef USE_SOLARIS_PROJECTS
202#include <sys/task.h>
203#include <project.h>
204
205/*
206 * Get/set solaris default project.
207 * If we fail, just run along gracefully.
208 */
209void
210solaris_set_default_project(struct passwd *pw)
211{
212 struct project *defaultproject;
213 struct project tempproject;
214 char buf[1024];
215
216 /* get default project, if we fail just return gracefully */
217 if ((defaultproject = getdefaultproj(pw->pw_name, &tempproject, &buf,
218 sizeof(buf))) > 0) {
219 /* set default project */
220 if (setproject(defaultproject->pj_name, pw->pw_name,
221 TASK_NORMAL) != 0)
222 debug("setproject(%s): %s", defaultproject->pj_name,
223 strerror(errno));
224 } else {
225 /* debug on getdefaultproj() error */
226 debug("getdefaultproj(%s): %s", pw->pw_name, strerror(errno));
227 }
228}
229#endif /* USE_SOLARIS_PROJECTS */
diff --git a/openbsd-compat/port-solaris.h b/openbsd-compat/port-solaris.h
index 4c324871e..cd442e78b 100644
--- a/openbsd-compat/port-solaris.h
+++ b/openbsd-compat/port-solaris.h
@@ -1,4 +1,4 @@
1/* $Id: port-solaris.h,v 1.1 2006/08/30 17:24:42 djm Exp $ */ 1/* $Id: port-solaris.h,v 1.2 2010/11/05 01:03:05 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006 Chad Mynhier. 4 * Copyright (c) 2006 Chad Mynhier.
@@ -20,8 +20,11 @@
20 20
21#include <sys/types.h> 21#include <sys/types.h>
22 22
23#include <pwd.h>
24
23void solaris_contract_pre_fork(void); 25void solaris_contract_pre_fork(void);
24void solaris_contract_post_fork_child(void); 26void solaris_contract_post_fork_child(void);
25void solaris_contract_post_fork_parent(pid_t pid); 27void solaris_contract_post_fork_parent(pid_t pid);
28void solaris_set_default_project(struct passwd *);
26 29
27#endif 30#endif
diff --git a/openbsd-compat/timingsafe_bcmp.c b/openbsd-compat/timingsafe_bcmp.c
new file mode 100644
index 000000000..7e28c0e2a
--- /dev/null
+++ b/openbsd-compat/timingsafe_bcmp.c
@@ -0,0 +1,34 @@
1/* $OpenBSD: timingsafe_bcmp.c,v 1.1 2010/09/24 13:33:00 matthew Exp $ */
2/*
3 * Copyright (c) 2010 Damien Miller. All rights reserved.
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18/* OPENBSD ORIGINAL: lib/libc/string/timingsafe_bcmp.c */
19
20#include "includes.h"
21#ifndef HAVE_TIMINGSAFE_BCMP
22
23int
24timingsafe_bcmp(const void *b1, const void *b2, size_t n)
25{
26 const unsigned char *p1 = b1, *p2 = b2;
27 int ret = 0;
28
29 for (; n > 0; n--)
30 ret |= *p1++ ^ *p2++;
31 return (ret != 0);
32}
33
34#endif /* TIMINGSAFE_BCMP */
diff --git a/opensshd.init.in b/opensshd.init.in
index d0aff7794..0db60caa7 100755
--- a/opensshd.init.in
+++ b/opensshd.init.in
@@ -20,6 +20,7 @@ SSH_KEYGEN=$prefix/bin/ssh-keygen
20HOST_KEY_RSA1=$sysconfdir/ssh_host_key 20HOST_KEY_RSA1=$sysconfdir/ssh_host_key
21HOST_KEY_DSA=$sysconfdir/ssh_host_dsa_key 21HOST_KEY_DSA=$sysconfdir/ssh_host_dsa_key
22HOST_KEY_RSA=$sysconfdir/ssh_host_rsa_key 22HOST_KEY_RSA=$sysconfdir/ssh_host_rsa_key
23@COMMENT_OUT_ECC@HOST_KEY_ECDSA=$sysconfdir/ssh_host_ecdsa_key
23 24
24 25
25checkkeys() { 26checkkeys() {
@@ -32,6 +33,9 @@ checkkeys() {
32 if [ ! -f $HOST_KEY_RSA ]; then 33 if [ ! -f $HOST_KEY_RSA ]; then
33 ${SSH_KEYGEN} -t rsa -f ${HOST_KEY_RSA} -N "" 34 ${SSH_KEYGEN} -t rsa -f ${HOST_KEY_RSA} -N ""
34 fi 35 fi
36@COMMENT_OUT_ECC@ if [ ! -f $HOST_KEY_ECDSA ]; then
37@COMMENT_OUT_ECC@ ${SSH_KEYGEN} -t ecdsa -f ${HOST_KEY_ECDSA} -N ""
38@COMMENT_OUT_ECC@ fi
35} 39}
36 40
37stop_service() { 41stop_service() {
diff --git a/packet.c b/packet.c
index 48f7fe613..b4e01f716 100644
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: packet.c,v 1.168 2010/07/13 23:13:16 djm Exp $ */ 1/* $OpenBSD: packet.c,v 1.172 2010/11/13 23:27:50 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -199,13 +199,13 @@ static struct session_state *active_state, *backup_state;
199static struct session_state * 199static struct session_state *
200alloc_session_state(void) 200alloc_session_state(void)
201{ 201{
202 struct session_state *s = xcalloc(1, sizeof(*s)); 202 struct session_state *s = xcalloc(1, sizeof(*s));
203 203
204 s->connection_in = -1; 204 s->connection_in = -1;
205 s->connection_out = -1; 205 s->connection_out = -1;
206 s->max_packet_size = 32768; 206 s->max_packet_size = 32768;
207 s->packet_timeout_ms = -1; 207 s->packet_timeout_ms = -1;
208 return s; 208 return s;
209} 209}
210 210
211/* 211/*
@@ -391,8 +391,8 @@ packet_get_ssh1_cipher(void)
391} 391}
392 392
393void 393void
394packet_get_state(int mode, u_int32_t *seqnr, u_int64_t *blocks, u_int32_t *packets, 394packet_get_state(int mode, u_int32_t *seqnr, u_int64_t *blocks,
395 u_int64_t *bytes) 395 u_int32_t *packets, u_int64_t *bytes)
396{ 396{
397 struct packet_state *state; 397 struct packet_state *state;
398 398
@@ -547,8 +547,7 @@ packet_start_compression(int level)
547 */ 547 */
548 548
549void 549void
550packet_set_encryption_key(const u_char *key, u_int keylen, 550packet_set_encryption_key(const u_char *key, u_int keylen, int number)
551 int number)
552{ 551{
553 Cipher *cipher = cipher_by_number(number); 552 Cipher *cipher = cipher_by_number(number);
554 553
@@ -641,6 +640,14 @@ packet_put_bignum2(BIGNUM * value)
641 buffer_put_bignum2(&active_state->outgoing_packet, value); 640 buffer_put_bignum2(&active_state->outgoing_packet, value);
642} 641}
643 642
643#ifdef OPENSSL_HAS_ECC
644void
645packet_put_ecpoint(const EC_GROUP *curve, const EC_POINT *point)
646{
647 buffer_put_ecpoint(&active_state->outgoing_packet, curve, point);
648}
649#endif
650
644/* 651/*
645 * Finalizes and sends the packet. If the encryption key has been set, 652 * Finalizes and sends the packet. If the encryption key has been set,
646 * encrypts the packet before sending. 653 * encrypts the packet before sending.
@@ -1511,6 +1518,14 @@ packet_get_bignum2(BIGNUM * value)
1511 buffer_get_bignum2(&active_state->incoming_packet, value); 1518 buffer_get_bignum2(&active_state->incoming_packet, value);
1512} 1519}
1513 1520
1521#ifdef OPENSSL_HAS_ECC
1522void
1523packet_get_ecpoint(const EC_GROUP *curve, EC_POINT *point)
1524{
1525 buffer_get_ecpoint(&active_state->incoming_packet, curve, point);
1526}
1527#endif
1528
1514void * 1529void *
1515packet_get_raw(u_int *length_ptr) 1530packet_get_raw(u_int *length_ptr)
1516{ 1531{
@@ -1546,6 +1561,13 @@ packet_get_string_ptr(u_int *length_ptr)
1546 return buffer_get_string_ptr(&active_state->incoming_packet, length_ptr); 1561 return buffer_get_string_ptr(&active_state->incoming_packet, length_ptr);
1547} 1562}
1548 1563
1564/* Ensures the returned string has no embedded \0 characters in it. */
1565char *
1566packet_get_cstring(u_int *length_ptr)
1567{
1568 return buffer_get_cstring(&active_state->incoming_packet, length_ptr);
1569}
1570
1549/* 1571/*
1550 * Sends a diagnostic message from the server to the client. This message 1572 * Sends a diagnostic message from the server to the client. This message
1551 * can be sent at any time (but not while constructing another message). The 1573 * can be sent at any time (but not while constructing another message). The
@@ -1728,14 +1750,13 @@ packet_not_very_much_data_to_write(void)
1728} 1750}
1729 1751
1730static void 1752static void
1731packet_set_tos(int interactive) 1753packet_set_tos(int tos)
1732{ 1754{
1733#if defined(IP_TOS) && !defined(IP_TOS_IS_BROKEN) 1755#if defined(IP_TOS) && !defined(IP_TOS_IS_BROKEN)
1734 int tos = interactive ? IPTOS_LOWDELAY : IPTOS_THROUGHPUT;
1735
1736 if (!packet_connection_is_on_socket() || 1756 if (!packet_connection_is_on_socket() ||
1737 !packet_connection_is_ipv4()) 1757 !packet_connection_is_ipv4())
1738 return; 1758 return;
1759 debug3("%s: set IP_TOS 0x%02x", __func__, tos);
1739 if (setsockopt(active_state->connection_in, IPPROTO_IP, IP_TOS, &tos, 1760 if (setsockopt(active_state->connection_in, IPPROTO_IP, IP_TOS, &tos,
1740 sizeof(tos)) < 0) 1761 sizeof(tos)) < 0)
1741 error("setsockopt IP_TOS %d: %.100s:", 1762 error("setsockopt IP_TOS %d: %.100s:",
@@ -1746,7 +1767,7 @@ packet_set_tos(int interactive)
1746/* Informs that the current session is interactive. Sets IP flags for that. */ 1767/* Informs that the current session is interactive. Sets IP flags for that. */
1747 1768
1748void 1769void
1749packet_set_interactive(int interactive) 1770packet_set_interactive(int interactive, int qos_interactive, int qos_bulk)
1750{ 1771{
1751 if (active_state->set_interactive_called) 1772 if (active_state->set_interactive_called)
1752 return; 1773 return;
@@ -1759,7 +1780,7 @@ packet_set_interactive(int interactive)
1759 if (!packet_connection_is_on_socket()) 1780 if (!packet_connection_is_on_socket())
1760 return; 1781 return;
1761 set_nodelay(active_state->connection_in); 1782 set_nodelay(active_state->connection_in);
1762 packet_set_tos(interactive); 1783 packet_set_tos(interactive ? qos_interactive : qos_bulk);
1763} 1784}
1764 1785
1765/* Returns true if the current connection is interactive. */ 1786/* Returns true if the current connection is interactive. */
diff --git a/packet.h b/packet.h
index 33523d750..d516aae8d 100644
--- a/packet.h
+++ b/packet.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: packet.h,v 1.52 2009/06/27 09:29:06 andreas Exp $ */ 1/* $OpenBSD: packet.h,v 1.55 2010/11/13 23:27:50 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -19,6 +19,9 @@
19#include <termios.h> 19#include <termios.h>
20 20
21#include <openssl/bn.h> 21#include <openssl/bn.h>
22#ifdef OPENSSL_HAS_ECC
23#include <openssl/ec.h>
24#endif
22 25
23void packet_set_connection(int, int); 26void packet_set_connection(int, int);
24void packet_set_timeout(int, int); 27void packet_set_timeout(int, int);
@@ -31,7 +34,7 @@ u_int packet_get_encryption_key(u_char *);
31void packet_set_protocol_flags(u_int); 34void packet_set_protocol_flags(u_int);
32u_int packet_get_protocol_flags(void); 35u_int packet_get_protocol_flags(void);
33void packet_start_compression(int); 36void packet_start_compression(int);
34void packet_set_interactive(int); 37void packet_set_interactive(int, int, int);
35int packet_is_interactive(void); 38int packet_is_interactive(void);
36void packet_set_server(void); 39void packet_set_server(void);
37void packet_set_authenticated(void); 40void packet_set_authenticated(void);
@@ -42,6 +45,9 @@ void packet_put_int(u_int value);
42void packet_put_int64(u_int64_t value); 45void packet_put_int64(u_int64_t value);
43void packet_put_bignum(BIGNUM * value); 46void packet_put_bignum(BIGNUM * value);
44void packet_put_bignum2(BIGNUM * value); 47void packet_put_bignum2(BIGNUM * value);
48#ifdef OPENSSL_HAS_ECC
49void packet_put_ecpoint(const EC_GROUP *, const EC_POINT *);
50#endif
45void packet_put_string(const void *buf, u_int len); 51void packet_put_string(const void *buf, u_int len);
46void packet_put_cstring(const char *str); 52void packet_put_cstring(const char *str);
47void packet_put_raw(const void *buf, u_int len); 53void packet_put_raw(const void *buf, u_int len);
@@ -59,8 +65,12 @@ u_int packet_get_int(void);
59u_int64_t packet_get_int64(void); 65u_int64_t packet_get_int64(void);
60void packet_get_bignum(BIGNUM * value); 66void packet_get_bignum(BIGNUM * value);
61void packet_get_bignum2(BIGNUM * value); 67void packet_get_bignum2(BIGNUM * value);
68#ifdef OPENSSL_HAS_ECC
69void packet_get_ecpoint(const EC_GROUP *, EC_POINT *);
70#endif
62void *packet_get_raw(u_int *length_ptr); 71void *packet_get_raw(u_int *length_ptr);
63void *packet_get_string(u_int *length_ptr); 72void *packet_get_string(u_int *length_ptr);
73char *packet_get_cstring(u_int *length_ptr);
64void *packet_get_string_ptr(u_int *length_ptr); 74void *packet_get_string_ptr(u_int *length_ptr);
65void packet_disconnect(const char *fmt,...) __attribute__((format(printf, 1, 2))); 75void packet_disconnect(const char *fmt,...) __attribute__((format(printf, 1, 2)));
66void packet_send_debug(const char *fmt,...) __attribute__((format(printf, 1, 2))); 76void packet_send_debug(const char *fmt,...) __attribute__((format(printf, 1, 2)));
diff --git a/pathnames.h b/pathnames.h
index 9e50950fe..e2dd49a9b 100644
--- a/pathnames.h
+++ b/pathnames.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: pathnames.h,v 1.19 2010/02/11 20:37:47 djm Exp $ */ 1/* $OpenBSD: pathnames.h,v 1.20 2010/08/31 11:54:45 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -38,6 +38,7 @@
38#define _PATH_HOST_CONFIG_FILE SSHDIR "/ssh_config" 38#define _PATH_HOST_CONFIG_FILE SSHDIR "/ssh_config"
39#define _PATH_HOST_KEY_FILE SSHDIR "/ssh_host_key" 39#define _PATH_HOST_KEY_FILE SSHDIR "/ssh_host_key"
40#define _PATH_HOST_DSA_KEY_FILE SSHDIR "/ssh_host_dsa_key" 40#define _PATH_HOST_DSA_KEY_FILE SSHDIR "/ssh_host_dsa_key"
41#define _PATH_HOST_ECDSA_KEY_FILE SSHDIR "/ssh_host_ecdsa_key"
41#define _PATH_HOST_RSA_KEY_FILE SSHDIR "/ssh_host_rsa_key" 42#define _PATH_HOST_RSA_KEY_FILE SSHDIR "/ssh_host_rsa_key"
42#define _PATH_DH_MODULI SSHDIR "/moduli" 43#define _PATH_DH_MODULI SSHDIR "/moduli"
43/* Backwards compatibility */ 44/* Backwards compatibility */
@@ -74,6 +75,7 @@
74 */ 75 */
75#define _PATH_SSH_CLIENT_IDENTITY ".ssh/identity" 76#define _PATH_SSH_CLIENT_IDENTITY ".ssh/identity"
76#define _PATH_SSH_CLIENT_ID_DSA ".ssh/id_dsa" 77#define _PATH_SSH_CLIENT_ID_DSA ".ssh/id_dsa"
78#define _PATH_SSH_CLIENT_ID_ECDSA ".ssh/id_ecdsa"
77#define _PATH_SSH_CLIENT_ID_RSA ".ssh/id_rsa" 79#define _PATH_SSH_CLIENT_ID_RSA ".ssh/id_rsa"
78 80
79/* 81/*
diff --git a/platform.c b/platform.c
index e3a428aaa..a455472b3 100644
--- a/platform.c
+++ b/platform.c
@@ -1,4 +1,4 @@
1/* $Id: platform.c,v 1.3 2009/12/20 23:49:22 dtucker Exp $ */ 1/* $Id: platform.c,v 1.18 2011/01/11 06:02:25 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006 Darren Tucker. All rights reserved. 4 * Copyright (c) 2006 Darren Tucker. All rights reserved.
@@ -16,11 +16,27 @@
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */ 17 */
18 18
19#include "config.h" 19#include "includes.h"
20
21#include <sys/types.h>
22
23#include <stdarg.h>
24#include <unistd.h>
25
26#include "log.h"
27#include "buffer.h"
28#include "servconf.h"
29#include "key.h"
30#include "hostfile.h"
31#include "auth.h"
32#include "auth-pam.h"
20#include "platform.h" 33#include "platform.h"
21 34
22#include "openbsd-compat/openbsd-compat.h" 35#include "openbsd-compat/openbsd-compat.h"
23 36
37extern int use_privsep;
38extern ServerOptions options;
39
24void 40void
25platform_pre_listen(void) 41platform_pre_listen(void)
26{ 42{
@@ -57,6 +73,118 @@ platform_post_fork_child(void)
57#endif 73#endif
58} 74}
59 75
76/* return 1 if we are running with privilege to swap UIDs, 0 otherwise */
77int
78platform_privileged_uidswap(void)
79{
80#ifdef HAVE_CYGWIN
81 /* uid 0 is not special on Cygwin so always try */
82 return 1;
83#else
84 return (getuid() == 0 || geteuid() == 0);
85#endif
86}
87
88/*
89 * This gets called before switching UIDs, and is called even when sshd is
90 * not running as root.
91 */
92void
93platform_setusercontext(struct passwd *pw)
94{
95#ifdef WITH_SELINUX
96 /* Cache selinux status for later use */
97 (void)ssh_selinux_enabled();
98#endif
99
100#ifdef USE_SOLARIS_PROJECTS
101 /* if solaris projects were detected, set the default now */
102 if (getuid() == 0 || geteuid() == 0)
103 solaris_set_default_project(pw);
104#endif
105
106#if defined(HAVE_LOGIN_CAP) && defined (__bsdi__)
107 if (getuid() == 0 || geteuid() == 0)
108 setpgid(0, 0);
109# endif
110
111#if defined(HAVE_LOGIN_CAP) && defined(USE_PAM)
112 /*
113 * If we have both LOGIN_CAP and PAM, we want to establish creds
114 * before calling setusercontext (in session.c:do_setusercontext).
115 */
116 if (getuid() == 0 || geteuid() == 0) {
117 if (options.use_pam) {
118 do_pam_setcred(use_privsep);
119 }
120 }
121# endif /* USE_PAM */
122
123#if !defined(HAVE_LOGIN_CAP) && defined(HAVE_GETLUID) && defined(HAVE_SETLUID)
124 if (getuid() == 0 || geteuid() == 0) {
125 /* Sets login uid for accounting */
126 if (getluid() == -1 && setluid(pw->pw_uid) == -1)
127 error("setluid: %s", strerror(errno));
128 }
129#endif
130}
131
132/*
133 * This gets called after we've established the user's groups, and is only
134 * called if sshd is running as root.
135 */
136void
137platform_setusercontext_post_groups(struct passwd *pw)
138{
139#if !defined(HAVE_LOGIN_CAP) && defined(USE_PAM)
140 /*
141 * PAM credentials may take the form of supplementary groups.
142 * These will have been wiped by the above initgroups() call.
143 * Reestablish them here.
144 */
145 if (options.use_pam) {
146 do_pam_setcred(use_privsep);
147 }
148#endif /* USE_PAM */
149
150#if !defined(HAVE_LOGIN_CAP) && (defined(WITH_IRIX_PROJECT) || \
151 defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY))
152 irix_setusercontext(pw);
153#endif /* defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) */
154
155#ifdef _AIX
156 aix_usrinfo(pw);
157#endif /* _AIX */
158
159#if !defined(HAVE_LOGIN_CAP) && defined(USE_LIBIAF)
160 if (set_id(pw->pw_name) != 0) {
161 exit(1);
162 }
163# endif /* USE_LIBIAF */
164
165#ifdef HAVE_SETPCRED
166 /*
167 * If we have a chroot directory, we set all creds except real
168 * uid which we will need for chroot. If we don't have a
169 * chroot directory, we don't override anything.
170 */
171 {
172 char **creds = NULL, *chroot_creds[] =
173 { "REAL_USER=root", NULL };
174
175 if (options.chroot_directory != NULL &&
176 strcasecmp(options.chroot_directory, "none") != 0)
177 creds = chroot_creds;
178
179 if (setpcred(pw->pw_name, creds) == -1)
180 fatal("Failed to set process credentials");
181 }
182#endif /* HAVE_SETPCRED */
183#ifdef WITH_SELINUX
184 ssh_selinux_setup_exec_context(pw->pw_name);
185#endif
186}
187
60char * 188char *
61platform_krb5_get_principal_name(const char *pw_name) 189platform_krb5_get_principal_name(const char *pw_name)
62{ 190{
diff --git a/platform.h b/platform.h
index 30a1d2259..944d2c340 100644
--- a/platform.h
+++ b/platform.h
@@ -1,4 +1,4 @@
1/* $Id: platform.h,v 1.4 2010/01/14 01:44:16 djm Exp $ */ 1/* $Id: platform.h,v 1.7 2010/11/05 03:47:01 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006 Darren Tucker. All rights reserved. 4 * Copyright (c) 2006 Darren Tucker. All rights reserved.
@@ -18,10 +18,15 @@
18 18
19#include <sys/types.h> 19#include <sys/types.h>
20 20
21#include <pwd.h>
22
21void platform_pre_listen(void); 23void platform_pre_listen(void);
22void platform_pre_fork(void); 24void platform_pre_fork(void);
23void platform_post_fork_parent(pid_t child_pid); 25void platform_post_fork_parent(pid_t child_pid);
24void platform_post_fork_child(void); 26void platform_post_fork_child(void);
27int platform_privileged_uidswap(void);
28void platform_setusercontext(struct passwd *);
29void platform_setusercontext_post_groups(struct passwd *);
25char *platform_get_krb5_client(const char *); 30char *platform_get_krb5_client(const char *);
26char *platform_krb5_get_principal_name(const char *); 31char *platform_krb5_get_principal_name(const char *);
27 32
diff --git a/readconf.c b/readconf.c
index 0d551b9ae..091029a19 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.187 2010/07/19 09:15:12 djm Exp $ */ 1/* $OpenBSD: readconf.c,v 1.190 2010/11/13 23:27:50 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -19,6 +19,8 @@
19#include <sys/socket.h> 19#include <sys/socket.h>
20 20
21#include <netinet/in.h> 21#include <netinet/in.h>
22#include <netinet/in_systm.h>
23#include <netinet/ip.h>
22 24
23#include <ctype.h> 25#include <ctype.h>
24#include <errno.h> 26#include <errno.h>
@@ -134,6 +136,7 @@ typedef enum {
134 oHashKnownHosts, 136 oHashKnownHosts,
135 oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand, 137 oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand,
136 oVisualHostKey, oUseRoaming, oZeroKnowledgePasswordAuthentication, 138 oVisualHostKey, oUseRoaming, oZeroKnowledgePasswordAuthentication,
139 oKexAlgorithms, oIPQoS,
137 oDeprecated, oUnsupported 140 oDeprecated, oUnsupported
138} OpCodes; 141} OpCodes;
139 142
@@ -251,6 +254,8 @@ static struct {
251#else 254#else
252 { "zeroknowledgepasswordauthentication", oUnsupported }, 255 { "zeroknowledgepasswordauthentication", oUnsupported },
253#endif 256#endif
257 { "kexalgorithms", oKexAlgorithms },
258 { "ipqos", oIPQoS },
254 259
255 { NULL, oBadOption } 260 { NULL, oBadOption }
256}; 261};
@@ -730,6 +735,18 @@ parse_int:
730 options->macs = xstrdup(arg); 735 options->macs = xstrdup(arg);
731 break; 736 break;
732 737
738 case oKexAlgorithms:
739 arg = strdelim(&s);
740 if (!arg || *arg == '\0')
741 fatal("%.200s line %d: Missing argument.",
742 filename, linenum);
743 if (!kex_names_valid(arg))
744 fatal("%.200s line %d: Bad SSH2 KexAlgorithms '%s'.",
745 filename, linenum, arg ? arg : "<NONE>");
746 if (*activep && options->kex_algorithms == NULL)
747 options->kex_algorithms = xstrdup(arg);
748 break;
749
733 case oHostKeyAlgorithms: 750 case oHostKeyAlgorithms:
734 arg = strdelim(&s); 751 arg = strdelim(&s);
735 if (!arg || *arg == '\0') 752 if (!arg || *arg == '\0')
@@ -990,6 +1007,23 @@ parse_int:
990 intptr = &options->visual_host_key; 1007 intptr = &options->visual_host_key;
991 goto parse_flag; 1008 goto parse_flag;
992 1009
1010 case oIPQoS:
1011 arg = strdelim(&s);
1012 if ((value = parse_ipqos(arg)) == -1)
1013 fatal("%s line %d: Bad IPQoS value: %s",
1014 filename, linenum, arg);
1015 arg = strdelim(&s);
1016 if (arg == NULL)
1017 value2 = value;
1018 else if ((value2 = parse_ipqos(arg)) == -1)
1019 fatal("%s line %d: Bad IPQoS value: %s",
1020 filename, linenum, arg);
1021 if (*activep) {
1022 options->ip_qos_interactive = value;
1023 options->ip_qos_bulk = value2;
1024 }
1025 break;
1026
993 case oUseRoaming: 1027 case oUseRoaming:
994 intptr = &options->use_roaming; 1028 intptr = &options->use_roaming;
995 goto parse_flag; 1029 goto parse_flag;
@@ -1114,6 +1148,7 @@ initialize_options(Options * options)
1114 options->cipher = -1; 1148 options->cipher = -1;
1115 options->ciphers = NULL; 1149 options->ciphers = NULL;
1116 options->macs = NULL; 1150 options->macs = NULL;
1151 options->kex_algorithms = NULL;
1117 options->hostkeyalgorithms = NULL; 1152 options->hostkeyalgorithms = NULL;
1118 options->protocol = SSH_PROTO_UNKNOWN; 1153 options->protocol = SSH_PROTO_UNKNOWN;
1119 options->num_identity_files = 0; 1154 options->num_identity_files = 0;
@@ -1156,6 +1191,8 @@ initialize_options(Options * options)
1156 options->use_roaming = -1; 1191 options->use_roaming = -1;
1157 options->visual_host_key = -1; 1192 options->visual_host_key = -1;
1158 options->zero_knowledge_password_authentication = -1; 1193 options->zero_knowledge_password_authentication = -1;
1194 options->ip_qos_interactive = -1;
1195 options->ip_qos_bulk = -1;
1159} 1196}
1160 1197
1161/* 1198/*
@@ -1233,6 +1270,7 @@ fill_default_options(Options * options)
1233 options->cipher = SSH_CIPHER_NOT_SET; 1270 options->cipher = SSH_CIPHER_NOT_SET;
1234 /* options->ciphers, default set in myproposals.h */ 1271 /* options->ciphers, default set in myproposals.h */
1235 /* options->macs, default set in myproposals.h */ 1272 /* options->macs, default set in myproposals.h */
1273 /* options->kex_algorithms, default set in myproposals.h */
1236 /* options->hostkeyalgorithms, default set in myproposals.h */ 1274 /* options->hostkeyalgorithms, default set in myproposals.h */
1237 if (options->protocol == SSH_PROTO_UNKNOWN) 1275 if (options->protocol == SSH_PROTO_UNKNOWN)
1238 options->protocol = SSH_PROTO_2; 1276 options->protocol = SSH_PROTO_2;
@@ -1256,6 +1294,13 @@ fill_default_options(Options * options)
1256 xmalloc(len); 1294 xmalloc(len);
1257 snprintf(options->identity_files[options->num_identity_files++], 1295 snprintf(options->identity_files[options->num_identity_files++],
1258 len, "~/%.100s", _PATH_SSH_CLIENT_ID_DSA); 1296 len, "~/%.100s", _PATH_SSH_CLIENT_ID_DSA);
1297#ifdef OPENSSL_HAS_ECC
1298 len = 2 + strlen(_PATH_SSH_CLIENT_ID_ECDSA) + 1;
1299 options->identity_files[options->num_identity_files] =
1300 xmalloc(len);
1301 snprintf(options->identity_files[options->num_identity_files++],
1302 len, "~/%.100s", _PATH_SSH_CLIENT_ID_ECDSA);
1303#endif
1259 } 1304 }
1260 } 1305 }
1261 if (options->escape_char == -1) 1306 if (options->escape_char == -1)
@@ -1308,6 +1353,10 @@ fill_default_options(Options * options)
1308 options->visual_host_key = 0; 1353 options->visual_host_key = 0;
1309 if (options->zero_knowledge_password_authentication == -1) 1354 if (options->zero_knowledge_password_authentication == -1)
1310 options->zero_knowledge_password_authentication = 0; 1355 options->zero_knowledge_password_authentication = 0;
1356 if (options->ip_qos_interactive == -1)
1357 options->ip_qos_interactive = IPTOS_LOWDELAY;
1358 if (options->ip_qos_bulk == -1)
1359 options->ip_qos_bulk = IPTOS_THROUGHPUT;
1311 /* options->local_command should not be set by default */ 1360 /* options->local_command should not be set by default */
1312 /* options->proxy_command should not be set by default */ 1361 /* options->proxy_command should not be set by default */
1313 /* options->user will be set in the main program if appropriate */ 1362 /* options->user will be set in the main program if appropriate */
diff --git a/readconf.h b/readconf.h
index bb3ff0481..3e5435576 100644
--- a/readconf.h
+++ b/readconf.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.h,v 1.86 2010/07/19 09:15:12 djm Exp $ */ 1/* $OpenBSD: readconf.h,v 1.88 2010/11/13 23:27:50 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -64,6 +64,8 @@ typedef struct {
64 int compression_level; /* Compression level 1 (fast) to 9 64 int compression_level; /* Compression level 1 (fast) to 9
65 * (best). */ 65 * (best). */
66 int tcp_keep_alive; /* Set SO_KEEPALIVE. */ 66 int tcp_keep_alive; /* Set SO_KEEPALIVE. */
67 int ip_qos_interactive; /* IP ToS/DSCP/class for interactive */
68 int ip_qos_bulk; /* IP ToS/DSCP/class for bulk traffic */
67 LogLevel log_level; /* Level for logging. */ 69 LogLevel log_level; /* Level for logging. */
68 70
69 int port; /* Port to connect. */ 71 int port; /* Port to connect. */
@@ -78,6 +80,7 @@ typedef struct {
78 char *ciphers; /* SSH2 ciphers in order of preference. */ 80 char *ciphers; /* SSH2 ciphers in order of preference. */
79 char *macs; /* SSH2 macs in order of preference. */ 81 char *macs; /* SSH2 macs in order of preference. */
80 char *hostkeyalgorithms; /* SSH2 server key types in order of preference. */ 82 char *hostkeyalgorithms; /* SSH2 server key types in order of preference. */
83 char *kex_algorithms; /* SSH2 kex methods in order of preference. */
81 int protocol; /* Protocol in order of preference. */ 84 int protocol; /* Protocol in order of preference. */
82 char *hostname; /* Real host to connect. */ 85 char *hostname; /* Real host to connect. */
83 char *host_key_alias; /* hostname alias for .ssh/known_hosts */ 86 char *host_key_alias; /* hostname alias for .ssh/known_hosts */
diff --git a/readpass.c b/readpass.c
index bd144c2e3..599c8ef9a 100644
--- a/readpass.c
+++ b/readpass.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readpass.c,v 1.47 2006/08/03 03:34:42 deraadt Exp $ */ 1/* $OpenBSD: readpass.c,v 1.48 2010/12/15 00:49:27 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -33,6 +33,7 @@
33#ifdef HAVE_PATHS_H 33#ifdef HAVE_PATHS_H
34# include <paths.h> 34# include <paths.h>
35#endif 35#endif
36#include <signal.h>
36#include <stdarg.h> 37#include <stdarg.h>
37#include <stdio.h> 38#include <stdio.h>
38#include <stdlib.h> 39#include <stdlib.h>
@@ -49,11 +50,12 @@
49static char * 50static char *
50ssh_askpass(char *askpass, const char *msg) 51ssh_askpass(char *askpass, const char *msg)
51{ 52{
52 pid_t pid; 53 pid_t pid, ret;
53 size_t len; 54 size_t len;
54 char *pass; 55 char *pass;
55 int p[2], status, ret; 56 int p[2], status;
56 char buf[1024]; 57 char buf[1024];
58 void (*osigchld)(int);
57 59
58 if (fflush(stdout) != 0) 60 if (fflush(stdout) != 0)
59 error("ssh_askpass: fflush: %s", strerror(errno)); 61 error("ssh_askpass: fflush: %s", strerror(errno));
@@ -63,8 +65,10 @@ ssh_askpass(char *askpass, const char *msg)
63 error("ssh_askpass: pipe: %s", strerror(errno)); 65 error("ssh_askpass: pipe: %s", strerror(errno));
64 return NULL; 66 return NULL;
65 } 67 }
68 osigchld = signal(SIGCHLD, SIG_DFL);
66 if ((pid = fork()) < 0) { 69 if ((pid = fork()) < 0) {
67 error("ssh_askpass: fork: %s", strerror(errno)); 70 error("ssh_askpass: fork: %s", strerror(errno));
71 signal(SIGCHLD, osigchld);
68 return NULL; 72 return NULL;
69 } 73 }
70 if (pid == 0) { 74 if (pid == 0) {
@@ -77,23 +81,24 @@ ssh_askpass(char *askpass, const char *msg)
77 } 81 }
78 close(p[1]); 82 close(p[1]);
79 83
80 len = ret = 0; 84 len = 0;
81 do { 85 do {
82 ret = read(p[0], buf + len, sizeof(buf) - 1 - len); 86 ssize_t r = read(p[0], buf + len, sizeof(buf) - 1 - len);
83 if (ret == -1 && errno == EINTR) 87
88 if (r == -1 && errno == EINTR)
84 continue; 89 continue;
85 if (ret <= 0) 90 if (r <= 0)
86 break; 91 break;
87 len += ret; 92 len += r;
88 } while (sizeof(buf) - 1 - len > 0); 93 } while (sizeof(buf) - 1 - len > 0);
89 buf[len] = '\0'; 94 buf[len] = '\0';
90 95
91 close(p[0]); 96 close(p[0]);
92 while (waitpid(pid, &status, 0) < 0) 97 while ((ret = waitpid(pid, &status, 0)) < 0)
93 if (errno != EINTR) 98 if (errno != EINTR)
94 break; 99 break;
95 100 signal(SIGCHLD, osigchld);
96 if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { 101 if (ret == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) {
97 memset(buf, 0, sizeof(buf)); 102 memset(buf, 0, sizeof(buf));
98 return NULL; 103 return NULL;
99 } 104 }
diff --git a/regress/Makefile b/regress/Makefile
index 9762ab204..f114c27e9 100644
--- a/regress/Makefile
+++ b/regress/Makefile
@@ -1,6 +1,6 @@
1# $OpenBSD: Makefile,v 1.54 2010/06/27 19:19:56 phessler Exp $ 1# $OpenBSD: Makefile,v 1.58 2011/01/06 22:46:21 djm Exp $
2 2
3REGRESS_TARGETS= t1 t2 t3 t4 t5 t6 t7 t-exec 3REGRESS_TARGETS= t1 t2 t3 t4 t5 t6 t7 t8 t9 t-exec
4tests: $(REGRESS_TARGETS) 4tests: $(REGRESS_TARGETS)
5 5
6# Interop tests are not run by default 6# Interop tests are not run by default
@@ -53,14 +53,20 @@ LTESTS= connect \
53 localcommand \ 53 localcommand \
54 forcecommand \ 54 forcecommand \
55 portnum \ 55 portnum \
56 keytype \
57 kextype \
56 cert-hostkey \ 58 cert-hostkey \
57 cert-userkey 59 cert-userkey \
60 host-expand
58 61
59INTEROP_TESTS= putty-transfer putty-ciphers putty-kex conch-ciphers 62INTEROP_TESTS= putty-transfer putty-ciphers putty-kex conch-ciphers
60#INTEROP_TESTS+=ssh-com ssh-com-client ssh-com-keygen ssh-com-sftp 63#INTEROP_TESTS+=ssh-com ssh-com-client ssh-com-keygen ssh-com-sftp
61 64
65#LTESTS= cipher-speed
66
62USER!= id -un 67USER!= id -un
63CLEANFILES= t2.out t6.out1 t6.out2 t7.out t7.out.pub copy.1 copy.2 \ 68CLEANFILES= t2.out t3.out t6.out1 t6.out2 t7.out t7.out.pub copy.1 copy.2 \
69 t8.out t8.out.pub t9.out t9.out.pub \
64 authorized_keys_${USER} known_hosts pidfile \ 70 authorized_keys_${USER} known_hosts pidfile \
65 ssh_config sshd_config.orig ssh_proxy sshd_config sshd_proxy \ 71 ssh_config sshd_config.orig ssh_proxy sshd_config sshd_proxy \
66 rsa.pub rsa rsa1.pub rsa1 host.rsa host.rsa1 \ 72 rsa.pub rsa rsa1.pub rsa1 host.rsa host.rsa1 \
@@ -69,45 +75,68 @@ CLEANFILES= t2.out t6.out1 t6.out2 t7.out t7.out.pub copy.1 copy.2 \
69 scp-ssh-wrapper.scp ssh_proxy_envpass remote_pid \ 75 scp-ssh-wrapper.scp ssh_proxy_envpass remote_pid \
70 sshd_proxy_bak rsa_ssh2_cr.prv rsa_ssh2_crnl.prv \ 76 sshd_proxy_bak rsa_ssh2_cr.prv rsa_ssh2_crnl.prv \
71 known_hosts-cert host_ca_key* cert_host_key* \ 77 known_hosts-cert host_ca_key* cert_host_key* \
72 putty.rsa2 sshd_proxy_orig \ 78 putty.rsa2 sshd_proxy_orig ssh_proxy_bak \
73 authorized_principals_${USER} 79 key.rsa-* key.dsa-* key.ecdsa-* \
80 authorized_principals_${USER} expect actual
74 81
75# Enable all malloc(3) randomisations and checks 82# Enable all malloc(3) randomisations and checks
76TEST_ENV= "MALLOC_OPTIONS=AFGJPRX" 83TEST_ENV= "MALLOC_OPTIONS=AFGJPRX"
77 84
85TEST_SSH_SSHKEYGEN?=ssh-keygen
86
78t1: 87t1:
79 ssh-keygen -if ${.CURDIR}/rsa_ssh2.prv | diff - ${.CURDIR}/rsa_openssh.prv 88 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/rsa_ssh2.prv | diff - ${.CURDIR}/rsa_openssh.prv
89 tr '\n' '\r' <${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_cr.prv
90 ${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_cr.prv | diff - ${.CURDIR}/rsa_openssh.prv
91 awk '{print $$0 "\r"}' ${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_crnl.prv
92 ${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_crnl.prv | diff - ${.CURDIR}/rsa_openssh.prv
80 93
81t2: 94t2:
82 cat ${.CURDIR}/rsa_openssh.prv > $(OBJ)/t2.out 95 cat ${.CURDIR}/rsa_openssh.prv > $(OBJ)/t2.out
83 chmod 600 $(OBJ)/t2.out 96 chmod 600 $(OBJ)/t2.out
84 ssh-keygen -yf $(OBJ)/t2.out | diff - ${.CURDIR}/rsa_openssh.pub 97 ${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t2.out | diff - ${.CURDIR}/rsa_openssh.pub
85 98
86t3: 99t3:
87 ssh-keygen -ef ${.CURDIR}/rsa_openssh.pub >$(OBJ)/rsa_secsh.pub 100 ${TEST_SSH_SSHKEYGEN} -ef ${.CURDIR}/rsa_openssh.pub >$(OBJ)/t3.out
88 ssh-keygen -if $(OBJ)/rsa_secsh.pub | diff - ${.CURDIR}/rsa_openssh.pub 101 ${TEST_SSH_SSHKEYGEN} -if $(OBJ)/t3.out | diff - ${.CURDIR}/rsa_openssh.pub
89 rm -f ${.CURDIR}/rsa_secsh.pub
90 102
91t4: 103t4:
92 ssh-keygen -lf ${.CURDIR}/rsa_openssh.pub |\ 104 ${TEST_SSH_SSHKEYGEN} -lf ${.CURDIR}/rsa_openssh.pub |\
93 awk '{print $$2}' | diff - ${.CURDIR}/t4.ok 105 awk '{print $$2}' | diff - ${.CURDIR}/t4.ok
94 106
95t5: 107t5:
96 ssh-keygen -Bf ${.CURDIR}/rsa_openssh.pub |\ 108 ${TEST_SSH_SSHKEYGEN} -Bf ${.CURDIR}/rsa_openssh.pub |\
97 awk '{print $$2}' | diff - ${.CURDIR}/t5.ok 109 awk '{print $$2}' | diff - ${.CURDIR}/t5.ok
98 110
99t6: 111t6:
100 ssh-keygen -if ${.CURDIR}/dsa_ssh2.prv > $(OBJ)/t6.out1 112 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.prv > $(OBJ)/t6.out1
101 ssh-keygen -if ${.CURDIR}/dsa_ssh2.pub > $(OBJ)/t6.out2 113 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.pub > $(OBJ)/t6.out2
102 chmod 600 $(OBJ)/t6.out1 114 chmod 600 $(OBJ)/t6.out1
103 ssh-keygen -yf $(OBJ)/t6.out1 | diff - $(OBJ)/t6.out2 115 ${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t6.out1 | diff - $(OBJ)/t6.out2
104 116
105$(OBJ)/t7.out: 117$(OBJ)/t7.out:
106 ssh-keygen -q -t rsa -N '' -f $@ 118 ${TEST_SSH_SSHKEYGEN} -q -t rsa -N '' -f $@
107 119
108t7: $(OBJ)/t7.out 120t7: $(OBJ)/t7.out
109 ssh-keygen -lf $(OBJ)/t7.out > /dev/null 121 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t7.out > /dev/null
110 ssh-keygen -Bf $(OBJ)/t7.out > /dev/null 122 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t7.out > /dev/null
123
124$(OBJ)/t8.out:
125 ${TEST_SSH_SSHKEYGEN} -q -t dsa -N '' -f $@
126
127t8: $(OBJ)/t8.out
128 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t8.out > /dev/null
129 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t8.out > /dev/null
130
131$(OBJ)/t9.out:
132 test "${TEST_SSH_ECC}" != yes || \
133 ${TEST_SSH_SSHKEYGEN} -q -t ecdsa -N '' -f $@
134
135t9: $(OBJ)/t9.out
136 test "${TEST_SSH_ECC}" != yes || \
137 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t9.out > /dev/null
138 test "${TEST_SSH_ECC}" != yes || \
139 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t9.out > /dev/null
111 140
112t-exec: ${LTESTS:=.sh} 141t-exec: ${LTESTS:=.sh}
113 @if [ "x$?" = "x" ]; then exit 0; fi; \ 142 @if [ "x$?" = "x" ]; then exit 0; fi; \
@@ -123,3 +152,5 @@ t-exec-interop: ${INTEROP_TESTS:=.sh}
123 (env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} sh ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \ 152 (env SUDO="${SUDO}" TEST_ENV=${TEST_ENV} sh ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \
124 done 153 done
125 154
155# Not run by default
156interop: ${INTEROP_TARGETS}
diff --git a/regress/agent-getpeereid.sh b/regress/agent-getpeereid.sh
index 5d7f73291..faf654c04 100644
--- a/regress/agent-getpeereid.sh
+++ b/regress/agent-getpeereid.sh
@@ -7,10 +7,9 @@ UNPRIV=nobody
7ASOCK=${OBJ}/agent 7ASOCK=${OBJ}/agent
8SSH_AUTH_SOCK=/nonexistent 8SSH_AUTH_SOCK=/nonexistent
9 9
10if grep "#undef.*HAVE_GETPEEREID" ${BUILDDIR}/config.h >/dev/null 2>&1 && \ 10if config_defined HAVE_GETPEEREID HAVE_GETPEERUCRED HAVE_SO_PEERCRED ; then
11 grep "#undef.*HAVE_GETPEERUCRED" ${BUILDDIR}/config.h >/dev/null && \ 11 :
12 grep "#undef.*HAVE_SO_PEERCRED" ${BUILDDIR}/config.h >/dev/null 12else
13then
14 echo "skipped (not supported on this platform)" 13 echo "skipped (not supported on this platform)"
15 exit 0 14 exit 0
16fi 15fi
@@ -34,7 +33,7 @@ else
34 fail "ssh-add failed with $r != 1" 33 fail "ssh-add failed with $r != 1"
35 fi 34 fi
36 35
37 < /dev/null ${SUDO} -S -u ${UNPRIV} ssh-add -l > /dev/null 2>&1 36 < /dev/null ${SUDO} -S -u ${UNPRIV} ssh-add -l 2>/dev/null
38 r=$? 37 r=$?
39 if [ $r -lt 2 ]; then 38 if [ $r -lt 2 ]; then
40 fail "ssh-add did not fail for ${UNPRIV}: $r < 2" 39 fail "ssh-add did not fail for ${UNPRIV}: $r < 2"
diff --git a/regress/agent-ptrace.sh b/regress/agent-ptrace.sh
index d5892ed03..9f29464c5 100644
--- a/regress/agent-ptrace.sh
+++ b/regress/agent-ptrace.sh
@@ -41,7 +41,7 @@ EOF
41 if [ $? -ne 0 ]; then 41 if [ $? -ne 0 ]; then
42 fail "gdb failed: exit code $?" 42 fail "gdb failed: exit code $?"
43 fi 43 fi
44 egrep 'ptrace: Operation not permitted.|procfs:.*Permission denied.|ttrace.*Permission denied.|procfs:.*: Invalid argument.' >/dev/null ${OBJ}/gdb.out 44 egrep 'ptrace: Operation not permitted.|procfs:.*Permission denied.|ttrace.*Permission denied.|procfs:.*: Invalid argument.|Unable to access task ' >/dev/null ${OBJ}/gdb.out
45 r=$? 45 r=$?
46 rm -f ${OBJ}/gdb.out 46 rm -f ${OBJ}/gdb.out
47 if [ $r -ne 0 ]; then 47 if [ $r -ne 0 ]; then
diff --git a/regress/cert-hostkey.sh b/regress/cert-hostkey.sh
index 0265e8f6b..3b147b9f7 100644
--- a/regress/cert-hostkey.sh
+++ b/regress/cert-hostkey.sh
@@ -1,8 +1,14 @@
1# $OpenBSD: cert-hostkey.sh,v 1.4 2010/04/16 01:58:45 djm Exp $ 1# $OpenBSD: cert-hostkey.sh,v 1.5 2010/08/31 12:24:09 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="certified host keys" 4tid="certified host keys"
5 5
6# used to disable ECC based tests on platforms without ECC
7ecdsa=""
8if test "x$TEST_SSH_ECC" = "xyes"; then
9 ecdsa=ecdsa
10fi
11
6rm -f $OBJ/known_hosts-cert $OBJ/host_ca_key* $OBJ/cert_host_key* 12rm -f $OBJ/known_hosts-cert $OBJ/host_ca_key* $OBJ/cert_host_key*
7cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak 13cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
8 14
@@ -18,7 +24,7 @@ ${SSHKEYGEN} -q -N '' -t rsa -f $OBJ/host_ca_key ||\
18) > $OBJ/known_hosts-cert 24) > $OBJ/known_hosts-cert
19 25
20# Generate and sign host keys 26# Generate and sign host keys
21for ktype in rsa dsa ; do 27for ktype in rsa dsa $ecdsa ; do
22 verbose "$tid: sign host ${ktype} cert" 28 verbose "$tid: sign host ${ktype} cert"
23 # Generate and sign a host key 29 # Generate and sign a host key
24 ${SSHKEYGEN} -q -N '' -t ${ktype} \ 30 ${SSHKEYGEN} -q -N '' -t ${ktype} \
@@ -28,6 +34,8 @@ for ktype in rsa dsa ; do
28 -I "regress host key for $USER" \ 34 -I "regress host key for $USER" \
29 -n $HOSTS $OBJ/cert_host_key_${ktype} || 35 -n $HOSTS $OBJ/cert_host_key_${ktype} ||
30 fail "couldn't sign cert_host_key_${ktype}" 36 fail "couldn't sign cert_host_key_${ktype}"
37 # v00 ecdsa certs do not exist
38 test "${ktype}" = "ecdsa" && continue
31 cp $OBJ/cert_host_key_${ktype} $OBJ/cert_host_key_${ktype}_v00 39 cp $OBJ/cert_host_key_${ktype} $OBJ/cert_host_key_${ktype}_v00
32 cp $OBJ/cert_host_key_${ktype}.pub $OBJ/cert_host_key_${ktype}_v00.pub 40 cp $OBJ/cert_host_key_${ktype}.pub $OBJ/cert_host_key_${ktype}_v00.pub
33 ${SSHKEYGEN} -t v00 -h -q -s $OBJ/host_ca_key \ 41 ${SSHKEYGEN} -t v00 -h -q -s $OBJ/host_ca_key \
@@ -38,7 +46,7 @@ done
38 46
39# Basic connect tests 47# Basic connect tests
40for privsep in yes no ; do 48for privsep in yes no ; do
41 for ktype in rsa dsa rsa_v00 dsa_v00; do 49 for ktype in rsa dsa $ecdsa rsa_v00 dsa_v00; do
42 verbose "$tid: host ${ktype} cert connect privsep $privsep" 50 verbose "$tid: host ${ktype} cert connect privsep $privsep"
43 ( 51 (
44 cat $OBJ/sshd_proxy_bak 52 cat $OBJ/sshd_proxy_bak
@@ -64,6 +72,11 @@ done
64 echon '@revoked ' 72 echon '@revoked '
65 echon "* " 73 echon "* "
66 cat $OBJ/cert_host_key_rsa.pub 74 cat $OBJ/cert_host_key_rsa.pub
75 if test "x$TEST_SSH_ECC" = "xyes"; then
76 echon '@revoked '
77 echon "* "
78 cat $OBJ/cert_host_key_ecdsa.pub
79 fi
67 echon '@revoked ' 80 echon '@revoked '
68 echon "* " 81 echon "* "
69 cat $OBJ/cert_host_key_dsa.pub 82 cat $OBJ/cert_host_key_dsa.pub
@@ -75,7 +88,7 @@ done
75 cat $OBJ/cert_host_key_dsa_v00.pub 88 cat $OBJ/cert_host_key_dsa_v00.pub
76) > $OBJ/known_hosts-cert 89) > $OBJ/known_hosts-cert
77for privsep in yes no ; do 90for privsep in yes no ; do
78 for ktype in rsa dsa rsa_v00 dsa_v00; do 91 for ktype in rsa dsa $ecdsa rsa_v00 dsa_v00; do
79 verbose "$tid: host ${ktype} revoked cert privsep $privsep" 92 verbose "$tid: host ${ktype} revoked cert privsep $privsep"
80 ( 93 (
81 cat $OBJ/sshd_proxy_bak 94 cat $OBJ/sshd_proxy_bak
@@ -102,7 +115,7 @@ done
102 echon "* " 115 echon "* "
103 cat $OBJ/host_ca_key.pub 116 cat $OBJ/host_ca_key.pub
104) > $OBJ/known_hosts-cert 117) > $OBJ/known_hosts-cert
105for ktype in rsa dsa rsa_v00 dsa_v00 ; do 118for ktype in rsa dsa $ecdsa rsa_v00 dsa_v00 ; do
106 verbose "$tid: host ${ktype} revoked cert" 119 verbose "$tid: host ${ktype} revoked cert"
107 ( 120 (
108 cat $OBJ/sshd_proxy_bak 121 cat $OBJ/sshd_proxy_bak
@@ -173,7 +186,9 @@ test_one "cert has constraints" failure "-h -Oforce-command=false"
173 186
174# Check downgrade of cert to raw key when no CA found 187# Check downgrade of cert to raw key when no CA found
175for v in v01 v00 ; do 188for v in v01 v00 ; do
176 for ktype in rsa dsa ; do 189 for ktype in rsa dsa $ecdsa ; do
190 # v00 ecdsa certs do not exist.
191 test "${v}${ktype}" = "v00ecdsa" && continue
177 rm -f $OBJ/known_hosts-cert $OBJ/cert_host_key* 192 rm -f $OBJ/known_hosts-cert $OBJ/cert_host_key*
178 verbose "$tid: host ${ktype} ${v} cert downgrade to raw key" 193 verbose "$tid: host ${ktype} ${v} cert downgrade to raw key"
179 # Generate and sign a host key 194 # Generate and sign a host key
@@ -210,7 +225,9 @@ done
210 cat $OBJ/host_ca_key.pub 225 cat $OBJ/host_ca_key.pub
211) > $OBJ/known_hosts-cert 226) > $OBJ/known_hosts-cert
212for v in v01 v00 ; do 227for v in v01 v00 ; do
213 for kt in rsa dsa ; do 228 for kt in rsa dsa $ecdsa ; do
229 # v00 ecdsa certs do not exist.
230 test "${v}${ktype}" = "v00ecdsa" && continue
214 rm -f $OBJ/cert_host_key* 231 rm -f $OBJ/cert_host_key*
215 # Self-sign key 232 # Self-sign key
216 ${SSHKEYGEN} -q -N '' -t ${kt} \ 233 ${SSHKEYGEN} -q -N '' -t ${kt} \
diff --git a/regress/cert-userkey.sh b/regress/cert-userkey.sh
index a41a9a9c0..fcca3708b 100644
--- a/regress/cert-userkey.sh
+++ b/regress/cert-userkey.sh
@@ -1,8 +1,14 @@
1# $OpenBSD: cert-userkey.sh,v 1.6 2010/06/29 23:59:54 djm Exp $ 1# $OpenBSD: cert-userkey.sh,v 1.7 2010/08/31 12:24:09 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="certified user keys" 4tid="certified user keys"
5 5
6# used to disable ECC based tests on platforms without ECC
7ecdsa=""
8if test "x$TEST_SSH_ECC" = "xyes"; then
9 ecdsa=ecdsa
10fi
11
6rm -f $OBJ/authorized_keys_$USER $OBJ/user_ca_key* $OBJ/cert_user_key* 12rm -f $OBJ/authorized_keys_$USER $OBJ/user_ca_key* $OBJ/cert_user_key*
7cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak 13cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
8 14
@@ -11,7 +17,7 @@ ${SSHKEYGEN} -q -N '' -t rsa -f $OBJ/user_ca_key ||\
11 fail "ssh-keygen of user_ca_key failed" 17 fail "ssh-keygen of user_ca_key failed"
12 18
13# Generate and sign user keys 19# Generate and sign user keys
14for ktype in rsa dsa ; do 20for ktype in rsa dsa $ecdsa ; do
15 verbose "$tid: sign user ${ktype} cert" 21 verbose "$tid: sign user ${ktype} cert"
16 ${SSHKEYGEN} -q -N '' -t ${ktype} \ 22 ${SSHKEYGEN} -q -N '' -t ${ktype} \
17 -f $OBJ/cert_user_key_${ktype} || \ 23 -f $OBJ/cert_user_key_${ktype} || \
@@ -20,6 +26,8 @@ for ktype in rsa dsa ; do
20 "regress user key for $USER" \ 26 "regress user key for $USER" \
21 -n ${USER},mekmitasdigoat $OBJ/cert_user_key_${ktype} || 27 -n ${USER},mekmitasdigoat $OBJ/cert_user_key_${ktype} ||
22 fail "couldn't sign cert_user_key_${ktype}" 28 fail "couldn't sign cert_user_key_${ktype}"
29 # v00 ecdsa certs do not exist
30 test "{ktype}" = "ecdsa" && continue
23 cp $OBJ/cert_user_key_${ktype} $OBJ/cert_user_key_${ktype}_v00 31 cp $OBJ/cert_user_key_${ktype} $OBJ/cert_user_key_${ktype}_v00
24 cp $OBJ/cert_user_key_${ktype}.pub $OBJ/cert_user_key_${ktype}_v00.pub 32 cp $OBJ/cert_user_key_${ktype}.pub $OBJ/cert_user_key_${ktype}_v00.pub
25 ${SSHKEYGEN} -q -t v00 -s $OBJ/user_ca_key -I \ 33 ${SSHKEYGEN} -q -t v00 -s $OBJ/user_ca_key -I \
@@ -29,7 +37,7 @@ for ktype in rsa dsa ; do
29done 37done
30 38
31# Test explicitly-specified principals 39# Test explicitly-specified principals
32for ktype in rsa dsa rsa_v00 dsa_v00 ; do 40for ktype in rsa dsa $ecdsa rsa_v00 dsa_v00 ; do
33 for privsep in yes no ; do 41 for privsep in yes no ; do
34 _prefix="${ktype} privsep $privsep" 42 _prefix="${ktype} privsep $privsep"
35 43
@@ -155,7 +163,7 @@ basic_tests() {
155 extra_sshd="TrustedUserCAKeys $OBJ/user_ca_key.pub" 163 extra_sshd="TrustedUserCAKeys $OBJ/user_ca_key.pub"
156 fi 164 fi
157 165
158 for ktype in rsa dsa rsa_v00 dsa_v00 ; do 166 for ktype in rsa dsa $ecdsa rsa_v00 dsa_v00 ; do
159 for privsep in yes no ; do 167 for privsep in yes no ; do
160 _prefix="${ktype} privsep $privsep $auth" 168 _prefix="${ktype} privsep $privsep $auth"
161 # Simple connect 169 # Simple connect
@@ -230,6 +238,11 @@ test_one() {
230 238
231 for auth in $auth_choice ; do 239 for auth in $auth_choice ; do
232 for ktype in rsa rsa_v00 ; do 240 for ktype in rsa rsa_v00 ; do
241 case $ktype in
242 *_v00) keyv="-t v00" ;;
243 *) keyv="" ;;
244 esac
245
233 cat $OBJ/sshd_proxy_bak > $OBJ/sshd_proxy 246 cat $OBJ/sshd_proxy_bak > $OBJ/sshd_proxy
234 if test "x$auth" = "xauthorized_keys" ; then 247 if test "x$auth" = "xauthorized_keys" ; then
235 # Add CA to authorized_keys 248 # Add CA to authorized_keys
@@ -249,7 +262,7 @@ test_one() {
249 verbose "$tid: $ident auth $auth expect $result $ktype" 262 verbose "$tid: $ident auth $auth expect $result $ktype"
250 ${SSHKEYGEN} -q -s $OBJ/user_ca_key \ 263 ${SSHKEYGEN} -q -s $OBJ/user_ca_key \
251 -I "regress user key for $USER" \ 264 -I "regress user key for $USER" \
252 $sign_opts \ 265 $sign_opts $keyv \
253 $OBJ/cert_user_key_${ktype} || 266 $OBJ/cert_user_key_${ktype} ||
254 fail "couldn't sign cert_user_key_${ktype}" 267 fail "couldn't sign cert_user_key_${ktype}"
255 268
@@ -302,7 +315,7 @@ test_one "principals key option no principals" failure "" \
302 315
303# Wrong certificate 316# Wrong certificate
304cat $OBJ/sshd_proxy_bak > $OBJ/sshd_proxy 317cat $OBJ/sshd_proxy_bak > $OBJ/sshd_proxy
305for ktype in rsa dsa rsa_v00 dsa_v00 ; do 318for ktype in rsa dsa $ecdsa rsa_v00 dsa_v00 ; do
306 case $ktype in 319 case $ktype in
307 *_v00) args="-t v00" ;; 320 *_v00) args="-t v00" ;;
308 *) args="" ;; 321 *) args="" ;;
diff --git a/regress/host-expand.sh b/regress/host-expand.sh
new file mode 100644
index 000000000..a0188363d
--- /dev/null
+++ b/regress/host-expand.sh
@@ -0,0 +1,18 @@
1# Placed in the Public Domain.
2
3tid="expand %h and %n"
4
5echo 'PermitLocalCommand yes' >> $OBJ/ssh_proxy
6printf 'LocalCommand printf "%%%%s\\n" "%%n" "%%h"\n' >> $OBJ/ssh_proxy
7
8cat >$OBJ/expect <<EOE
9somehost
10127.0.0.1
11EOE
12
13for p in 1 2; do
14 verbose "test $tid: proto $p"
15 ${SSH} -F $OBJ/ssh_proxy -$p somehost true >$OBJ/actual
16 diff $OBJ/expect $OBJ/actual || fail "$tid proto $p"
17done
18
diff --git a/regress/kextype.sh b/regress/kextype.sh
new file mode 100644
index 000000000..79c0817bb
--- /dev/null
+++ b/regress/kextype.sh
@@ -0,0 +1,30 @@
1# $OpenBSD: kextype.sh,v 1.1 2010/09/22 12:26:05 djm Exp $
2# Placed in the Public Domain.
3
4tid="login with different key exchange algorithms"
5
6TIME=/usr/bin/time
7cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
8cp $OBJ/ssh_proxy $OBJ/ssh_proxy_bak
9
10if test "$TEST_SSH_ECC" = "yes"; then
11 kextypes="ecdh-sha2-nistp256 ecdh-sha2-nistp384 ecdh-sha2-nistp521"
12fi
13if test "$TEST_SSH_SHA256" = "yes"; then
14 kextypes="$kextypes diffie-hellman-group-exchange-sha256"
15fi
16kextypes="$kextypes diffie-hellman-group-exchange-sha1"
17kextypes="$kextypes diffie-hellman-group14-sha1"
18kextypes="$kextypes diffie-hellman-group1-sha1"
19
20tries="1 2 3 4"
21for k in $kextypes; do
22 verbose "kex $k"
23 for i in $tries; do
24 ${SSH} -F $OBJ/ssh_proxy -o KexAlgorithms=$k x true
25 if [ $? -ne 0 ]; then
26 fail "ssh kex $k"
27 fi
28 done
29done
30
diff --git a/regress/keytype.sh b/regress/keytype.sh
new file mode 100644
index 000000000..2cbf132bd
--- /dev/null
+++ b/regress/keytype.sh
@@ -0,0 +1,55 @@
1# $OpenBSD: keytype.sh,v 1.1 2010/09/02 16:12:55 markus Exp $
2# Placed in the Public Domain.
3
4tid="login with different key types"
5
6TIME=`which time` 2>/dev/null
7if test ! -x "$TIME"; then
8 TIME=""
9fi
10
11cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
12cp $OBJ/ssh_proxy $OBJ/ssh_proxy_bak
13
14ktypes="dsa-1024 rsa-2048 rsa-3072"
15if test "$TEST_SSH_ECC" = "yes"; then
16 ktypes="$ktypes ecdsa-256 ecdsa-384 ecdsa-521"
17fi
18
19for kt in $ktypes; do
20 rm -f $OBJ/key.$kt
21 bits=`echo ${kt} | awk -F- '{print $2}'`
22 type=`echo ${kt} | awk -F- '{print $1}'`
23 printf "keygen $type, $bits bits:\t"
24 ${TIME} ${SSHKEYGEN} -b $bits -q -N '' -t $type -f $OBJ/key.$kt ||\
25 fail "ssh-keygen for type $type, $bits bits failed"
26done
27
28tries="1 2 3"
29for ut in $ktypes; do
30 htypes=$ut
31 #htypes=$ktypes
32 for ht in $htypes; do
33 trace "ssh connect, userkey $ut, hostkey $ht"
34 (
35 grep -v HostKey $OBJ/sshd_proxy_bak
36 echo HostKey $OBJ/key.$ht
37 ) > $OBJ/sshd_proxy
38 (
39 grep -v IdentityFile $OBJ/ssh_proxy_bak
40 echo IdentityFile $OBJ/key.$ut
41 ) > $OBJ/ssh_proxy
42 (
43 echon 'localhost-with-alias,127.0.0.1,::1 '
44 cat $OBJ/key.$ht.pub
45 ) > $OBJ/known_hosts
46 cat $OBJ/key.$ut.pub > $OBJ/authorized_keys_$USER
47 for i in $tries; do
48 printf "userkey $ut, hostkey ${ht}:\t"
49 ${TIME} ${SSH} -F $OBJ/ssh_proxy 999.999.999.999 true
50 if [ $? -ne 0 ]; then
51 fail "ssh userkey $ut, hostkey $ht failed"
52 fi
53 done
54 done
55done
diff --git a/regress/multiplex.sh b/regress/multiplex.sh
index 8a98a6e54..b94cdf02f 100644
--- a/regress/multiplex.sh
+++ b/regress/multiplex.sh
@@ -5,8 +5,7 @@ CTL=/tmp/openssh.regress.ctl-sock.$$
5 5
6tid="connection multiplexing" 6tid="connection multiplexing"
7 7
8if grep "#define.*DISABLE_FD_PASSING" ${BUILDDIR}/config.h >/dev/null 2>&1 8if config_defined DISABLE_FD_PASSING ; then
9then
10 echo "skipped (not supported on this platform)" 9 echo "skipped (not supported on this platform)"
11 exit 0 10 exit 0
12fi 11fi
diff --git a/regress/sftp-cmds.sh b/regress/sftp-cmds.sh
index c4d6ae2de..1c67b6476 100644
--- a/regress/sftp-cmds.sh
+++ b/regress/sftp-cmds.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: sftp-cmds.sh,v 1.10 2009/08/13 01:11:55 djm Exp $ 1# $OpenBSD: sftp-cmds.sh,v 1.11 2010/12/04 00:21:19 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4# XXX - TODO: 4# XXX - TODO:
@@ -209,7 +209,13 @@ test -d ${COPY}.dd2 || fail "missing newname after rename directory"
209 209
210verbose "$tid: ln" 210verbose "$tid: ln"
211echo "ln ${COPY}.1 ${COPY}.2" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 || fail "ln failed" 211echo "ln ${COPY}.1 ${COPY}.2" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 || fail "ln failed"
212test -h ${COPY}.2 || fail "missing file after ln" 212test -f ${COPY}.2 || fail "missing file after ln"
213cmp ${COPY}.1 ${COPY}.2 || fail "created file is not equal after ln"
214
215verbose "$tid: ln -s"
216rm -f ${COPY}.2
217echo "ln -s ${COPY}.1 ${COPY}.2" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 || fail "ln -s failed"
218test -h ${COPY}.2 || fail "missing file after ln -s"
213 219
214verbose "$tid: mkdir" 220verbose "$tid: mkdir"
215echo "mkdir ${COPY}.dd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ 221echo "mkdir ${COPY}.dd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \
diff --git a/regress/sftp-glob.sh b/regress/sftp-glob.sh
index 72bb17d75..8d4df2c98 100644
--- a/regress/sftp-glob.sh
+++ b/regress/sftp-glob.sh
@@ -3,11 +3,18 @@
3 3
4tid="sftp glob" 4tid="sftp glob"
5 5
6config_defined FILESYSTEM_NO_BACKSLASH && nobs="not supported on this platform"
7
6sftp_ls() { 8sftp_ls() {
7 target=$1 9 target=$1
8 errtag=$2 10 errtag=$2
9 expected=$3 11 expected=$3
10 unexpected=$4 12 unexpected=$4
13 skip=$5
14 if test "x$skip" != "x" ; then
15 verbose "$tid: $errtag (skipped: $skip)"
16 return
17 fi
11 verbose "$tid: $errtag" 18 verbose "$tid: $errtag"
12 printf "ls -l %s" "${target}" | \ 19 printf "ls -l %s" "${target}" | \
13 ${SFTP} -b - -D ${SFTPSERVER} 2>/dev/null | \ 20 ${SFTP} -b - -D ${SFTPSERVER} 2>/dev/null | \
@@ -44,8 +51,8 @@ SPACE="${DIR}/g-q space"
44 51
45rm -rf ${BASE} 52rm -rf ${BASE}
46mkdir -p ${DIR} 53mkdir -p ${DIR}
47touch "${DATA}" "${GLOB1}" "${GLOB2}" "${QUOTE}" 54touch "${DATA}" "${GLOB1}" "${GLOB2}" "${QUOTE}" "${SPACE}"
48touch "${QSLASH}" "${ESLASH}" "${SLASH}" "${SPACE}" 55test "x$nobs" = "x" && touch "${QSLASH}" "${ESLASH}" "${SLASH}"
49 56
50# target message expected unexpected 57# target message expected unexpected
51sftp_ls "${DIR}/fil*" "file glob" "${DATA}" "" 58sftp_ls "${DIR}/fil*" "file glob" "${DATA}" ""
@@ -55,14 +62,14 @@ sftp_ls "${DIR}/g-wild\*" "escaped glob" "g-wild*" "g-wildx"
55sftp_ls "${DIR}/g-quote\\\"" "escaped quote" "g-quote\"" "" 62sftp_ls "${DIR}/g-quote\\\"" "escaped quote" "g-quote\"" ""
56sftp_ls "\"${DIR}/g-quote\\\"\"" "quoted quote" "g-quote\"" "" 63sftp_ls "\"${DIR}/g-quote\\\"\"" "quoted quote" "g-quote\"" ""
57sftp_ls "'${DIR}/g-quote\"'" "single-quoted quote" "g-quote\"" "" 64sftp_ls "'${DIR}/g-quote\"'" "single-quoted quote" "g-quote\"" ""
58sftp_ls "${DIR}/g-sl\\\\ash" "escaped slash" "g-sl\\ash" ""
59sftp_ls "'${DIR}/g-sl\\\\ash'" "quoted slash" "g-sl\\ash" ""
60sftp_ls "${DIR}/g-slash\\\\" "escaped slash at EOL" "g-slash\\" ""
61sftp_ls "'${DIR}/g-slash\\\\'" "quoted slash at EOL" "g-slash\\" ""
62sftp_ls "${DIR}/g-qs\\\\\\\"" "escaped slash+quote" "g-qs\\\"" ""
63sftp_ls "'${DIR}/g-qs\\\\\"'" "quoted slash+quote" "g-qs\\\"" ""
64sftp_ls "${DIR}/g-q\\ space" "escaped space" "g-q space" "" 65sftp_ls "${DIR}/g-q\\ space" "escaped space" "g-q space" ""
65sftp_ls "'${DIR}/g-q space'" "quoted space" "g-q space" "" 66sftp_ls "'${DIR}/g-q space'" "quoted space" "g-q space" ""
67sftp_ls "${DIR}/g-sl\\\\ash" "escaped slash" "g-sl\\ash" "" "$nobs"
68sftp_ls "'${DIR}/g-sl\\\\ash'" "quoted slash" "g-sl\\ash" "" "$nobs"
69sftp_ls "${DIR}/g-slash\\\\" "escaped slash at EOL" "g-slash\\" "" "$nobs"
70sftp_ls "'${DIR}/g-slash\\\\'" "quoted slash at EOL" "g-slash\\" "" "$nobs"
71sftp_ls "${DIR}/g-qs\\\\\\\"" "escaped slash+quote" "g-qs\\\"" "" "$nobs"
72sftp_ls "'${DIR}/g-qs\\\\\"'" "quoted slash+quote" "g-qs\\\"" "" "$nobs"
66 73
67rm -rf ${BASE} 74rm -rf ${BASE}
68 75
diff --git a/regress/test-exec.sh b/regress/test-exec.sh
index b64dcdbcf..5c56aefff 100644
--- a/regress/test-exec.sh
+++ b/regress/test-exec.sh
@@ -221,6 +221,17 @@ fatal ()
221 exit $RESULT 221 exit $RESULT
222} 222}
223 223
224# Check whether preprocessor symbols are defined in config.h.
225config_defined ()
226{
227 str=$1
228 while test "x$2" != "x" ; do
229 str="$str|$2"
230 shift
231 done
232 egrep "^#define.*($str)" ${BUILDDIR}/config.h >/dev/null 2>&1
233}
234
224RESULT=0 235RESULT=0
225PIDFILE=$OBJ/pidfile 236PIDFILE=$OBJ/pidfile
226 237
diff --git a/schnorr.c b/schnorr.c
index c17ff3241..4d54d6881 100644
--- a/schnorr.c
+++ b/schnorr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: schnorr.c,v 1.3 2009/03/05 07:18:19 djm Exp $ */ 1/* $OpenBSD: schnorr.c,v 1.5 2010/12/03 23:49:26 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2008 Damien Miller. All rights reserved. 3 * Copyright (c) 2008 Damien Miller. All rights reserved.
4 * 4 *
@@ -138,6 +138,10 @@ schnorr_sign(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
138 error("%s: g_x < 1", __func__); 138 error("%s: g_x < 1", __func__);
139 return -1; 139 return -1;
140 } 140 }
141 if (BN_cmp(g_x, grp_p) >= 0) {
142 error("%s: g_x > g", __func__);
143 return -1;
144 }
141 145
142 h = g_v = r = tmp = v = NULL; 146 h = g_v = r = tmp = v = NULL;
143 if ((bn_ctx = BN_CTX_new()) == NULL) { 147 if ((bn_ctx = BN_CTX_new()) == NULL) {
@@ -254,14 +258,19 @@ schnorr_verify(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
254 const BIGNUM *r, const BIGNUM *e) 258 const BIGNUM *r, const BIGNUM *e)
255{ 259{
256 int success = -1; 260 int success = -1;
257 BIGNUM *h, *g_xh, *g_r, *expected; 261 BIGNUM *h = NULL, *g_xh = NULL, *g_r = NULL, *gx_q = NULL;
262 BIGNUM *expected = NULL;
258 BN_CTX *bn_ctx; 263 BN_CTX *bn_ctx;
259 264
260 SCHNORR_DEBUG_BN((g_x, "%s: g_x = ", __func__)); 265 SCHNORR_DEBUG_BN((g_x, "%s: g_x = ", __func__));
261 266
262 /* Avoid degenerate cases: g^0 yields a spoofable signature */ 267 /* Avoid degenerate cases: g^0 yields a spoofable signature */
263 if (BN_cmp(g_x, BN_value_one()) <= 0) { 268 if (BN_cmp(g_x, BN_value_one()) <= 0) {
264 error("%s: g_x < 1", __func__); 269 error("%s: g_x <= 1", __func__);
270 return -1;
271 }
272 if (BN_cmp(g_x, grp_p) >= 0) {
273 error("%s: g_x >= p", __func__);
265 return -1; 274 return -1;
266 } 275 }
267 276
@@ -272,6 +281,7 @@ schnorr_verify(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
272 } 281 }
273 if ((g_xh = BN_new()) == NULL || 282 if ((g_xh = BN_new()) == NULL ||
274 (g_r = BN_new()) == NULL || 283 (g_r = BN_new()) == NULL ||
284 (gx_q = BN_new()) == NULL ||
275 (expected = BN_new()) == NULL) { 285 (expected = BN_new()) == NULL) {
276 error("%s: BN_new", __func__); 286 error("%s: BN_new", __func__);
277 goto out; 287 goto out;
@@ -280,6 +290,17 @@ schnorr_verify(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
280 SCHNORR_DEBUG_BN((e, "%s: e = ", __func__)); 290 SCHNORR_DEBUG_BN((e, "%s: e = ", __func__));
281 SCHNORR_DEBUG_BN((r, "%s: r = ", __func__)); 291 SCHNORR_DEBUG_BN((r, "%s: r = ", __func__));
282 292
293 /* gx_q = (g^x)^q must === 1 mod p */
294 if (BN_mod_exp(gx_q, g_x, grp_q, grp_p, bn_ctx) == -1) {
295 error("%s: BN_mod_exp (g_x^q mod p)", __func__);
296 goto out;
297 }
298 if (BN_cmp(gx_q, BN_value_one()) != 0) {
299 error("%s: Invalid signature (g^x)^q != 1 mod p", __func__);
300 goto out;
301 }
302
303 SCHNORR_DEBUG_BN((g_xh, "%s: g_xh = ", __func__));
283 /* h = H(g || g^v || g^x || id) */ 304 /* h = H(g || g^v || g^x || id) */
284 if ((h = schnorr_hash(grp_p, grp_q, grp_g, evp_md, e, g_x, 305 if ((h = schnorr_hash(grp_p, grp_q, grp_g, evp_md, e, g_x,
285 id, idlen)) == NULL) { 306 id, idlen)) == NULL) {
@@ -314,9 +335,14 @@ schnorr_verify(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
314 BN_CTX_free(bn_ctx); 335 BN_CTX_free(bn_ctx);
315 if (h != NULL) 336 if (h != NULL)
316 BN_clear_free(h); 337 BN_clear_free(h);
317 BN_clear_free(g_xh); 338 if (gx_q != NULL)
318 BN_clear_free(g_r); 339 BN_clear_free(gx_q);
319 BN_clear_free(expected); 340 if (g_xh != NULL)
341 BN_clear_free(g_xh);
342 if (g_r != NULL)
343 BN_clear_free(g_r);
344 if (expected != NULL)
345 BN_clear_free(expected);
320 return success; 346 return success;
321} 347}
322 348
diff --git a/scp.0 b/scp.0
index f5af8ccd5..f00631626 100644
--- a/scp.0
+++ b/scp.0
@@ -4,7 +4,7 @@ NAME
4 scp - secure copy (remote file copy program) 4 scp - secure copy (remote file copy program)
5 5
6SYNOPSIS 6SYNOPSIS
7 scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] 7 scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
8 [-l limit] [-o ssh_option] [-P port] [-S program] 8 [-l limit] [-o ssh_option] [-P port] [-S program]
9 [[user@]host1:]file1 ... [[user@]host2:]file2 9 [[user@]host1:]file1 ... [[user@]host2:]file2
10 10
@@ -26,6 +26,11 @@ DESCRIPTION
26 26
27 -2 Forces scp to use protocol 2. 27 -2 Forces scp to use protocol 2.
28 28
29 -3 Copies between two remote hosts are transferred through the local
30 host. Without this option the data is copied directly between
31 the two remote hosts. Note that this option disables the
32 progress meter.
33
29 -4 Forces scp to use IPv4 addresses only. 34 -4 Forces scp to use IPv4 addresses only.
30 35
31 -6 Forces scp to use IPv6 addresses only. 36 -6 Forces scp to use IPv6 addresses only.
@@ -83,7 +88,9 @@ DESCRIPTION
83 HostName 88 HostName
84 IdentityFile 89 IdentityFile
85 IdentitiesOnly 90 IdentitiesOnly
91 IPQoS
86 KbdInteractiveDevices 92 KbdInteractiveDevices
93 KexAlgorithms
87 LogLevel 94 LogLevel
88 MACs 95 MACs
89 NoHostAuthenticationForLocalhost 96 NoHostAuthenticationForLocalhost
@@ -131,6 +138,7 @@ DESCRIPTION
131 about their progress. This is helpful in debugging connection, 138 about their progress. This is helpful in debugging connection,
132 authentication, and configuration problems. 139 authentication, and configuration problems.
133 140
141EXIT STATUS
134 The scp utility exits 0 on success, and >0 if an error occurs. 142 The scp utility exits 0 on success, and >0 if an error occurs.
135 143
136SEE ALSO 144SEE ALSO
@@ -145,4 +153,4 @@ AUTHORS
145 Timo Rinne <tri@iki.fi> 153 Timo Rinne <tri@iki.fi>
146 Tatu Ylonen <ylo@cs.hut.fi> 154 Tatu Ylonen <ylo@cs.hut.fi>
147 155
148OpenBSD 4.8 February 8, 2010 OpenBSD 4.8 156OpenBSD 4.8 December 9, 2010 OpenBSD 4.8
diff --git a/scp.1 b/scp.1
index bc5e259f5..577dd52c1 100644
--- a/scp.1
+++ b/scp.1
@@ -1,4 +1,3 @@
1.\" -*- nroff -*-
2.\" 1.\"
3.\" scp.1 2.\" scp.1
4.\" 3.\"
@@ -9,9 +8,9 @@
9.\" 8.\"
10.\" Created: Sun May 7 00:14:37 1995 ylo 9.\" Created: Sun May 7 00:14:37 1995 ylo
11.\" 10.\"
12.\" $OpenBSD: scp.1,v 1.50 2010/02/08 10:50:20 markus Exp $ 11.\" $OpenBSD: scp.1,v 1.56 2010/12/09 14:13:32 jmc Exp $
13.\" 12.\"
14.Dd $Mdocdate: February 8 2010 $ 13.Dd $Mdocdate: December 9 2010 $
15.Dt SCP 1 14.Dt SCP 1
16.Os 15.Os
17.Sh NAME 16.Sh NAME
@@ -20,7 +19,7 @@
20.Sh SYNOPSIS 19.Sh SYNOPSIS
21.Nm scp 20.Nm scp
22.Bk -words 21.Bk -words
23.Op Fl 1246BCpqrv 22.Op Fl 12346BCpqrv
24.Op Fl c Ar cipher 23.Op Fl c Ar cipher
25.Op Fl F Ar ssh_config 24.Op Fl F Ar ssh_config
26.Op Fl i Ar identity_file 25.Op Fl i Ar identity_file
@@ -76,6 +75,11 @@ to use protocol 1.
76Forces 75Forces
77.Nm 76.Nm
78to use protocol 2. 77to use protocol 2.
78.It Fl 3
79Copies between two remote hosts are transferred through the local host.
80Without this option the data is copied directly between the two remote
81hosts.
82Note that this option disables the progress meter.
79.It Fl 4 83.It Fl 4
80Forces 84Forces
81.Nm 85.Nm
@@ -147,7 +151,9 @@ For full details of the options listed below, and their possible values, see
147.It HostName 151.It HostName
148.It IdentityFile 152.It IdentityFile
149.It IdentitiesOnly 153.It IdentitiesOnly
154.It IPQoS
150.It KbdInteractiveDevices 155.It KbdInteractiveDevices
156.It KexAlgorithms
151.It LogLevel 157.It LogLevel
152.It MACs 158.It MACs
153.It NoHostAuthenticationForLocalhost 159.It NoHostAuthenticationForLocalhost
@@ -209,7 +215,7 @@ to print debugging messages about their progress.
209This is helpful in 215This is helpful in
210debugging connection, authentication, and configuration problems. 216debugging connection, authentication, and configuration problems.
211.El 217.El
212.Pp 218.Sh EXIT STATUS
213.Ex -std scp 219.Ex -std scp
214.Sh SEE ALSO 220.Sh SEE ALSO
215.Xr rcp 1 , 221.Xr rcp 1 ,
diff --git a/scp.c b/scp.c
index e07de42f7..18b2597fe 100644
--- a/scp.c
+++ b/scp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: scp.c,v 1.166 2010/07/01 13:06:59 millert Exp $ */ 1/* $OpenBSD: scp.c,v 1.170 2010/12/09 14:13:33 jmc Exp $ */
2/* 2/*
3 * scp - secure remote copy. This is basically patched BSD rcp which 3 * scp - secure remote copy. This is basically patched BSD rcp which
4 * uses ssh to do the data transfer (instead of using rcmd). 4 * uses ssh to do the data transfer (instead of using rcmd).
@@ -119,14 +119,15 @@ extern char *__progname;
119#define COPY_BUFLEN 16384 119#define COPY_BUFLEN 16384
120 120
121int do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout); 121int do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout);
122 122int do_cmd2(char *host, char *remuser, char *cmd, int fdin, int fdout);
123void bwlimit(int);
124 123
125/* Struct for addargs */ 124/* Struct for addargs */
126arglist args; 125arglist args;
126arglist remote_remote_args;
127 127
128/* Bandwidth limit */ 128/* Bandwidth limit */
129off_t limit_rate = 0; 129long long limit_kbps = 0;
130struct bwlimit bwlimit;
130 131
131/* Name of current file being transferred. */ 132/* Name of current file being transferred. */
132char *curfile; 133char *curfile;
@@ -137,6 +138,12 @@ int verbose_mode = 0;
137/* This is set to zero if the progressmeter is not desired. */ 138/* This is set to zero if the progressmeter is not desired. */
138int showprogress = 1; 139int showprogress = 1;
139 140
141/*
142 * This is set to non-zero if remote-remote copy should be piped
143 * through this process.
144 */
145int throughlocal = 0;
146
140/* This is the program to execute for the secured connection. ("ssh" or -S) */ 147/* This is the program to execute for the secured connection. ("ssh" or -S) */
141char *ssh_program = _PATH_SSH_PROGRAM; 148char *ssh_program = _PATH_SSH_PROGRAM;
142 149
@@ -287,6 +294,50 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
287 return 0; 294 return 0;
288} 295}
289 296
297/*
298 * This functions executes a command simlar to do_cmd(), but expects the
299 * input and output descriptors to be setup by a previous call to do_cmd().
300 * This way the input and output of two commands can be connected.
301 */
302int
303do_cmd2(char *host, char *remuser, char *cmd, int fdin, int fdout)
304{
305 pid_t pid;
306 int status;
307
308 if (verbose_mode)
309 fprintf(stderr,
310 "Executing: 2nd program %s host %s, user %s, command %s\n",
311 ssh_program, host,
312 remuser ? remuser : "(unspecified)", cmd);
313
314 /* Fork a child to execute the command on the remote host using ssh. */
315 pid = fork();
316 if (pid == 0) {
317 dup2(fdin, 0);
318 dup2(fdout, 1);
319
320 replacearg(&args, 0, "%s", ssh_program);
321 if (remuser != NULL) {
322 addargs(&args, "-l");
323 addargs(&args, "%s", remuser);
324 }
325 addargs(&args, "--");
326 addargs(&args, "%s", host);
327 addargs(&args, "%s", cmd);
328
329 execvp(ssh_program, args.list);
330 perror(ssh_program);
331 exit(1);
332 } else if (pid == -1) {
333 fatal("fork: %s", strerror(errno));
334 }
335 while (waitpid(pid, &status, 0) == -1)
336 if (errno != EINTR)
337 fatal("do_cmd2: waitpid: %s", strerror(errno));
338 return 0;
339}
340
290typedef struct { 341typedef struct {
291 size_t cnt; 342 size_t cnt;
292 char *buf; 343 char *buf;
@@ -312,15 +363,14 @@ void sink(int, char *[]);
312void source(int, char *[]); 363void source(int, char *[]);
313void tolocal(int, char *[]); 364void tolocal(int, char *[]);
314void toremote(char *, int, char *[]); 365void toremote(char *, int, char *[]);
315size_t scpio(ssize_t (*)(int, void *, size_t), int, void *, size_t, off_t *);
316void usage(void); 366void usage(void);
317 367
318int 368int
319main(int argc, char **argv) 369main(int argc, char **argv)
320{ 370{
321 int ch, fflag, tflag, status, n; 371 int ch, fflag, tflag, status, n;
322 double speed; 372 char *targ, **newargv;
323 char *targ, *endp, **newargv; 373 const char *errstr;
324 extern char *optarg; 374 extern char *optarg;
325 extern int optind; 375 extern int optind;
326 376
@@ -336,15 +386,16 @@ main(int argc, char **argv)
336 __progname = ssh_get_progname(argv[0]); 386 __progname = ssh_get_progname(argv[0]);
337 387
338 memset(&args, '\0', sizeof(args)); 388 memset(&args, '\0', sizeof(args));
339 args.list = NULL; 389 memset(&remote_remote_args, '\0', sizeof(remote_remote_args));
390 args.list = remote_remote_args.list = NULL;
340 addargs(&args, "%s", ssh_program); 391 addargs(&args, "%s", ssh_program);
341 addargs(&args, "-x"); 392 addargs(&args, "-x");
342 addargs(&args, "-oForwardAgent no"); 393 addargs(&args, "-oForwardAgent=no");
343 addargs(&args, "-oPermitLocalCommand no"); 394 addargs(&args, "-oPermitLocalCommand=no");
344 addargs(&args, "-oClearAllForwardings yes"); 395 addargs(&args, "-oClearAllForwardings=yes");
345 396
346 fflag = tflag = 0; 397 fflag = tflag = 0;
347 while ((ch = getopt(argc, argv, "dfl:prtvBCc:i:P:q1246S:o:F:")) != -1) 398 while ((ch = getopt(argc, argv, "dfl:prtvBCc:i:P:q12346S:o:F:")) != -1)
348 switch (ch) { 399 switch (ch) {
349 /* User-visible flags. */ 400 /* User-visible flags. */
350 case '1': 401 case '1':
@@ -353,26 +404,37 @@ main(int argc, char **argv)
353 case '6': 404 case '6':
354 case 'C': 405 case 'C':
355 addargs(&args, "-%c", ch); 406 addargs(&args, "-%c", ch);
407 addargs(&remote_remote_args, "-%c", ch);
408 break;
409 case '3':
410 throughlocal = 1;
356 break; 411 break;
357 case 'o': 412 case 'o':
358 case 'c': 413 case 'c':
359 case 'i': 414 case 'i':
360 case 'F': 415 case 'F':
416 addargs(&remote_remote_args, "-%c", ch);
417 addargs(&remote_remote_args, "%s", optarg);
361 addargs(&args, "-%c", ch); 418 addargs(&args, "-%c", ch);
362 addargs(&args, "%s", optarg); 419 addargs(&args, "%s", optarg);
363 break; 420 break;
364 case 'P': 421 case 'P':
422 addargs(&remote_remote_args, "-p");
423 addargs(&remote_remote_args, "%s", optarg);
365 addargs(&args, "-p"); 424 addargs(&args, "-p");
366 addargs(&args, "%s", optarg); 425 addargs(&args, "%s", optarg);
367 break; 426 break;
368 case 'B': 427 case 'B':
369 addargs(&args, "-oBatchmode yes"); 428 addargs(&remote_remote_args, "-oBatchmode=yes");
429 addargs(&args, "-oBatchmode=yes");
370 break; 430 break;
371 case 'l': 431 case 'l':
372 speed = strtod(optarg, &endp); 432 limit_kbps = strtonum(optarg, 1, 100 * 1024 * 1024,
373 if (speed <= 0 || *endp != '\0') 433 &errstr);
434 if (errstr != NULL)
374 usage(); 435 usage();
375 limit_rate = speed * 1024; 436 limit_kbps *= 1024; /* kbps */
437 bandwidth_limit_init(&bwlimit, limit_kbps, COPY_BUFLEN);
376 break; 438 break;
377 case 'p': 439 case 'p':
378 pflag = 1; 440 pflag = 1;
@@ -385,10 +447,12 @@ main(int argc, char **argv)
385 break; 447 break;
386 case 'v': 448 case 'v':
387 addargs(&args, "-v"); 449 addargs(&args, "-v");
450 addargs(&remote_remote_args, "-v");
388 verbose_mode = 1; 451 verbose_mode = 1;
389 break; 452 break;
390 case 'q': 453 case 'q':
391 addargs(&args, "-q"); 454 addargs(&args, "-q");
455 addargs(&remote_remote_args, "-q");
392 showprogress = 0; 456 showprogress = 0;
393 break; 457 break;
394 458
@@ -474,41 +538,16 @@ main(int argc, char **argv)
474 exit(errs != 0); 538 exit(errs != 0);
475} 539}
476 540
477/* 541/* Callback from atomicio6 to update progress meter and limit bandwidth */
478 * atomicio-like wrapper that also applies bandwidth limits and updates 542static int
479 * the progressmeter counter. 543scpio(void *_cnt, size_t s)
480 */
481size_t
482scpio(ssize_t (*f)(int, void *, size_t), int fd, void *_p, size_t l, off_t *c)
483{ 544{
484 u_char *p = (u_char *)_p; 545 off_t *cnt = (off_t *)_cnt;
485 size_t offset; 546
486 ssize_t r; 547 *cnt += s;
487 struct pollfd pfd; 548 if (limit_kbps > 0)
488 549 bandwidth_limit(&bwlimit, s);
489 pfd.fd = fd; 550 return 0;
490 pfd.events = f == read ? POLLIN : POLLOUT;
491 for (offset = 0; offset < l;) {
492 r = f(fd, p + offset, l - offset);
493 if (r == 0) {
494 errno = EPIPE;
495 return offset;
496 }
497 if (r < 0) {
498 if (errno == EINTR)
499 continue;
500 if (errno == EAGAIN || errno == EWOULDBLOCK) {
501 (void)poll(&pfd, 1, -1); /* Ignore errors */
502 continue;
503 }
504 return offset;
505 }
506 offset += (size_t)r;
507 *c += (off_t)r;
508 if (limit_rate)
509 bwlimit(r);
510 }
511 return offset;
512} 551}
513 552
514void 553void
@@ -517,6 +556,7 @@ toremote(char *targ, int argc, char **argv)
517 char *bp, *host, *src, *suser, *thost, *tuser, *arg; 556 char *bp, *host, *src, *suser, *thost, *tuser, *arg;
518 arglist alist; 557 arglist alist;
519 int i; 558 int i;
559 u_int j;
520 560
521 memset(&alist, '\0', sizeof(alist)); 561 memset(&alist, '\0', sizeof(alist));
522 alist.list = NULL; 562 alist.list = NULL;
@@ -544,15 +584,45 @@ toremote(char *targ, int argc, char **argv)
544 584
545 for (i = 0; i < argc - 1; i++) { 585 for (i = 0; i < argc - 1; i++) {
546 src = colon(argv[i]); 586 src = colon(argv[i]);
547 if (src) { /* remote to remote */ 587 if (src && throughlocal) { /* extended remote to remote */
588 *src++ = 0;
589 if (*src == 0)
590 src = ".";
591 host = strrchr(argv[i], '@');
592 if (host) {
593 *host++ = 0;
594 host = cleanhostname(host);
595 suser = argv[i];
596 if (*suser == '\0')
597 suser = pwd->pw_name;
598 else if (!okname(suser))
599 continue;
600 } else {
601 host = cleanhostname(argv[i]);
602 suser = NULL;
603 }
604 xasprintf(&bp, "%s -f -- %s", cmd, src);
605 if (do_cmd(host, suser, bp, &remin, &remout) < 0)
606 exit(1);
607 (void) xfree(bp);
608 host = cleanhostname(thost);
609 xasprintf(&bp, "%s -t -- %s", cmd, targ);
610 if (do_cmd2(host, tuser, bp, remin, remout) < 0)
611 exit(1);
612 (void) xfree(bp);
613 (void) close(remin);
614 (void) close(remout);
615 remin = remout = -1;
616 } else if (src) { /* standard remote to remote */
548 freeargs(&alist); 617 freeargs(&alist);
549 addargs(&alist, "%s", ssh_program); 618 addargs(&alist, "%s", ssh_program);
550 if (verbose_mode)
551 addargs(&alist, "-v");
552 addargs(&alist, "-x"); 619 addargs(&alist, "-x");
553 addargs(&alist, "-oClearAllForwardings yes"); 620 addargs(&alist, "-oClearAllForwardings=yes");
554 addargs(&alist, "-n"); 621 addargs(&alist, "-n");
555 622 for (j = 0; j < remote_remote_args.num; j++) {
623 addargs(&alist, "%s",
624 remote_remote_args.list[j]);
625 }
556 *src++ = 0; 626 *src++ = 0;
557 if (*src == 0) 627 if (*src == 0)
558 src = "."; 628 src = ".";
@@ -750,7 +820,7 @@ next: if (fd != -1) {
750 (void)atomicio(vwrite, remout, bp->buf, amt); 820 (void)atomicio(vwrite, remout, bp->buf, amt);
751 continue; 821 continue;
752 } 822 }
753 if (scpio(vwrite, remout, bp->buf, amt, 823 if (atomicio6(vwrite, remout, bp->buf, amt, scpio,
754 &statbytes) != amt) 824 &statbytes) != amt)
755 haderr = errno; 825 haderr = errno;
756 } 826 }
@@ -825,60 +895,6 @@ rsource(char *name, struct stat *statp)
825} 895}
826 896
827void 897void
828bwlimit(int amount)
829{
830 static struct timeval bwstart, bwend;
831 static int lamt, thresh = 16384;
832 u_int64_t waitlen;
833 struct timespec ts, rm;
834
835 if (!timerisset(&bwstart)) {
836 gettimeofday(&bwstart, NULL);
837 return;
838 }
839
840 lamt += amount;
841 if (lamt < thresh)
842 return;
843
844 gettimeofday(&bwend, NULL);
845 timersub(&bwend, &bwstart, &bwend);
846 if (!timerisset(&bwend))
847 return;
848
849 lamt *= 8;
850 waitlen = (double)1000000L * lamt / limit_rate;
851
852 bwstart.tv_sec = waitlen / 1000000L;
853 bwstart.tv_usec = waitlen % 1000000L;
854
855 if (timercmp(&bwstart, &bwend, >)) {
856 timersub(&bwstart, &bwend, &bwend);
857
858 /* Adjust the wait time */
859 if (bwend.tv_sec) {
860 thresh /= 2;
861 if (thresh < 2048)
862 thresh = 2048;
863 } else if (bwend.tv_usec < 10000) {
864 thresh *= 2;
865 if (thresh > COPY_BUFLEN * 4)
866 thresh = COPY_BUFLEN * 4;
867 }
868
869 TIMEVAL_TO_TIMESPEC(&bwend, &ts);
870 while (nanosleep(&ts, &rm) == -1) {
871 if (errno != EINTR)
872 break;
873 ts = rm;
874 }
875 }
876
877 lamt = 0;
878 gettimeofday(&bwstart, NULL);
879}
880
881void
882sink(int argc, char **argv) 898sink(int argc, char **argv)
883{ 899{
884 static BUF buffer; 900 static BUF buffer;
@@ -1071,7 +1087,8 @@ bad: run_err("%s: %s", np, strerror(errno));
1071 amt = size - i; 1087 amt = size - i;
1072 count += amt; 1088 count += amt;
1073 do { 1089 do {
1074 j = scpio(read, remin, cp, amt, &statbytes); 1090 j = atomicio6(read, remin, cp, amt,
1091 scpio, &statbytes);
1075 if (j == 0) { 1092 if (j == 0) {
1076 run_err("%s", j != EPIPE ? 1093 run_err("%s", j != EPIPE ?
1077 strerror(errno) : 1094 strerror(errno) :
@@ -1197,7 +1214,7 @@ void
1197usage(void) 1214usage(void)
1198{ 1215{
1199 (void) fprintf(stderr, 1216 (void) fprintf(stderr,
1200 "usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]\n" 1217 "usage: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]\n"
1201 " [-l limit] [-o ssh_option] [-P port] [-S program]\n" 1218 " [-l limit] [-o ssh_option] [-P port] [-S program]\n"
1202 " [[user@]host1:]file1 ... [[user@]host2:]file2\n"); 1219 " [[user@]host1:]file1 ... [[user@]host2:]file2\n");
1203 exit(1); 1220 exit(1);
diff --git a/servconf.c b/servconf.c
index 3ce2397c3..b08772601 100644
--- a/servconf.c
+++ b/servconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: servconf.c,v 1.209 2010/06/22 04:22:59 djm Exp $ */ 1/* $OpenBSD: servconf.c,v 1.213 2010/11/13 23:27:50 djm Exp $ */
2/* 2/*
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4 * All rights reserved 4 * All rights reserved
@@ -15,6 +15,10 @@
15#include <sys/types.h> 15#include <sys/types.h>
16#include <sys/socket.h> 16#include <sys/socket.h>
17 17
18#include <netinet/in.h>
19#include <netinet/in_systm.h>
20#include <netinet/ip.h>
21
18#include <netdb.h> 22#include <netdb.h>
19#include <pwd.h> 23#include <pwd.h>
20#include <stdio.h> 24#include <stdio.h>
@@ -112,6 +116,7 @@ initialize_server_options(ServerOptions *options)
112 options->num_deny_groups = 0; 116 options->num_deny_groups = 0;
113 options->ciphers = NULL; 117 options->ciphers = NULL;
114 options->macs = NULL; 118 options->macs = NULL;
119 options->kex_algorithms = NULL;
115 options->protocol = SSH_PROTO_UNKNOWN; 120 options->protocol = SSH_PROTO_UNKNOWN;
116 options->gateway_ports = -1; 121 options->gateway_ports = -1;
117 options->num_subsystems = 0; 122 options->num_subsystems = 0;
@@ -135,6 +140,8 @@ initialize_server_options(ServerOptions *options)
135 options->revoked_keys_file = NULL; 140 options->revoked_keys_file = NULL;
136 options->trusted_user_ca_keys = NULL; 141 options->trusted_user_ca_keys = NULL;
137 options->authorized_principals_file = NULL; 142 options->authorized_principals_file = NULL;
143 options->ip_qos_interactive = -1;
144 options->ip_qos_bulk = -1;
138} 145}
139 146
140void 147void
@@ -157,6 +164,10 @@ fill_default_server_options(ServerOptions *options)
157 _PATH_HOST_RSA_KEY_FILE; 164 _PATH_HOST_RSA_KEY_FILE;
158 options->host_key_files[options->num_host_key_files++] = 165 options->host_key_files[options->num_host_key_files++] =
159 _PATH_HOST_DSA_KEY_FILE; 166 _PATH_HOST_DSA_KEY_FILE;
167#ifdef OPENSSL_HAS_ECC
168 options->host_key_files[options->num_host_key_files++] =
169 _PATH_HOST_ECDSA_KEY_FILE;
170#endif
160 } 171 }
161 } 172 }
162 /* No certificates by default */ 173 /* No certificates by default */
@@ -265,16 +276,20 @@ fill_default_server_options(ServerOptions *options)
265 if (options->authorized_keys_file2 == NULL) { 276 if (options->authorized_keys_file2 == NULL) {
266 /* authorized_keys_file2 falls back to authorized_keys_file */ 277 /* authorized_keys_file2 falls back to authorized_keys_file */
267 if (options->authorized_keys_file != NULL) 278 if (options->authorized_keys_file != NULL)
268 options->authorized_keys_file2 = options->authorized_keys_file; 279 options->authorized_keys_file2 = xstrdup(options->authorized_keys_file);
269 else 280 else
270 options->authorized_keys_file2 = _PATH_SSH_USER_PERMITTED_KEYS2; 281 options->authorized_keys_file2 = xstrdup(_PATH_SSH_USER_PERMITTED_KEYS2);
271 } 282 }
272 if (options->authorized_keys_file == NULL) 283 if (options->authorized_keys_file == NULL)
273 options->authorized_keys_file = _PATH_SSH_USER_PERMITTED_KEYS; 284 options->authorized_keys_file = xstrdup(_PATH_SSH_USER_PERMITTED_KEYS);
274 if (options->permit_tun == -1) 285 if (options->permit_tun == -1)
275 options->permit_tun = SSH_TUNMODE_NO; 286 options->permit_tun = SSH_TUNMODE_NO;
276 if (options->zero_knowledge_password_authentication == -1) 287 if (options->zero_knowledge_password_authentication == -1)
277 options->zero_knowledge_password_authentication = 0; 288 options->zero_knowledge_password_authentication = 0;
289 if (options->ip_qos_interactive == -1)
290 options->ip_qos_interactive = IPTOS_LOWDELAY;
291 if (options->ip_qos_bulk == -1)
292 options->ip_qos_bulk = IPTOS_THROUGHPUT;
278 293
279 /* Turn privilege separation on by default */ 294 /* Turn privilege separation on by default */
280 if (use_privsep == -1) 295 if (use_privsep == -1)
@@ -323,6 +338,7 @@ typedef enum {
323 sUsePrivilegeSeparation, sAllowAgentForwarding, 338 sUsePrivilegeSeparation, sAllowAgentForwarding,
324 sZeroKnowledgePasswordAuthentication, sHostCertificate, 339 sZeroKnowledgePasswordAuthentication, sHostCertificate,
325 sRevokedKeys, sTrustedUserCAKeys, sAuthorizedPrincipalsFile, 340 sRevokedKeys, sTrustedUserCAKeys, sAuthorizedPrincipalsFile,
341 sKexAlgorithms, sIPQoS,
326 sDeprecated, sUnsupported 342 sDeprecated, sUnsupported
327} ServerOpCodes; 343} ServerOpCodes;
328 344
@@ -455,6 +471,8 @@ static struct {
455 { "revokedkeys", sRevokedKeys, SSHCFG_ALL }, 471 { "revokedkeys", sRevokedKeys, SSHCFG_ALL },
456 { "trustedusercakeys", sTrustedUserCAKeys, SSHCFG_ALL }, 472 { "trustedusercakeys", sTrustedUserCAKeys, SSHCFG_ALL },
457 { "authorizedprincipalsfile", sAuthorizedPrincipalsFile, SSHCFG_ALL }, 473 { "authorizedprincipalsfile", sAuthorizedPrincipalsFile, SSHCFG_ALL },
474 { "kexalgorithms", sKexAlgorithms, SSHCFG_GLOBAL },
475 { "ipqos", sIPQoS, SSHCFG_ALL },
458 { NULL, sBadOption, 0 } 476 { NULL, sBadOption, 0 }
459}; 477};
460 478
@@ -684,7 +702,7 @@ process_server_config_line(ServerOptions *options, char *line,
684 const char *host, const char *address) 702 const char *host, const char *address)
685{ 703{
686 char *cp, **charptr, *arg, *p; 704 char *cp, **charptr, *arg, *p;
687 int cmdline = 0, *intptr, value, n; 705 int cmdline = 0, *intptr, value, value2, n;
688 SyslogFacility *log_facility_ptr; 706 SyslogFacility *log_facility_ptr;
689 LogLevel *log_level_ptr; 707 LogLevel *log_level_ptr;
690 ServerOpCodes opcode; 708 ServerOpCodes opcode;
@@ -1162,6 +1180,18 @@ process_server_config_line(ServerOptions *options, char *line,
1162 options->macs = xstrdup(arg); 1180 options->macs = xstrdup(arg);
1163 break; 1181 break;
1164 1182
1183 case sKexAlgorithms:
1184 arg = strdelim(&cp);
1185 if (!arg || *arg == '\0')
1186 fatal("%s line %d: Missing argument.",
1187 filename, linenum);
1188 if (!kex_names_valid(arg))
1189 fatal("%s line %d: Bad SSH2 KexAlgorithms '%s'.",
1190 filename, linenum, arg ? arg : "<NONE>");
1191 if (options->kex_algorithms == NULL)
1192 options->kex_algorithms = xstrdup(arg);
1193 break;
1194
1165 case sProtocol: 1195 case sProtocol:
1166 intptr = &options->protocol; 1196 intptr = &options->protocol;
1167 arg = strdelim(&cp); 1197 arg = strdelim(&cp);
@@ -1384,6 +1414,23 @@ process_server_config_line(ServerOptions *options, char *line,
1384 charptr = &options->revoked_keys_file; 1414 charptr = &options->revoked_keys_file;
1385 goto parse_filename; 1415 goto parse_filename;
1386 1416
1417 case sIPQoS:
1418 arg = strdelim(&cp);
1419 if ((value = parse_ipqos(arg)) == -1)
1420 fatal("%s line %d: Bad IPQoS value: %s",
1421 filename, linenum, arg);
1422 arg = strdelim(&cp);
1423 if (arg == NULL)
1424 value2 = value;
1425 else if ((value2 = parse_ipqos(arg)) == -1)
1426 fatal("%s line %d: Bad IPQoS value: %s",
1427 filename, linenum, arg);
1428 if (*activep) {
1429 options->ip_qos_interactive = value;
1430 options->ip_qos_bulk = value2;
1431 }
1432 break;
1433
1387 case sDeprecated: 1434 case sDeprecated:
1388 logit("%s line %d: Deprecated option %s", 1435 logit("%s line %d: Deprecated option %s",
1389 filename, linenum, arg); 1436 filename, linenum, arg);
@@ -1494,6 +1541,8 @@ copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth)
1494 M_CP_INTOPT(x11_use_localhost); 1541 M_CP_INTOPT(x11_use_localhost);
1495 M_CP_INTOPT(max_sessions); 1542 M_CP_INTOPT(max_sessions);
1496 M_CP_INTOPT(max_authtries); 1543 M_CP_INTOPT(max_authtries);
1544 M_CP_INTOPT(ip_qos_interactive);
1545 M_CP_INTOPT(ip_qos_bulk);
1497 1546
1498 M_CP_STROPT(banner); 1547 M_CP_STROPT(banner);
1499 if (preauth) 1548 if (preauth)
@@ -1762,5 +1811,7 @@ dump_config(ServerOptions *o)
1762 } 1811 }
1763 dump_cfg_string(sPermitTunnel, s); 1812 dump_cfg_string(sPermitTunnel, s);
1764 1813
1814 printf("ipqos 0x%02x 0x%02x\n", o->ip_qos_interactive, o->ip_qos_bulk);
1815
1765 channel_print_adm_permitted_opens(); 1816 channel_print_adm_permitted_opens();
1766} 1817}
diff --git a/servconf.h b/servconf.h
index ef7cc214a..38de13502 100644
--- a/servconf.h
+++ b/servconf.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: servconf.h,v 1.93 2010/05/07 11:30:30 djm Exp $ */ 1/* $OpenBSD: servconf.h,v 1.95 2010/11/13 23:27:50 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -70,8 +70,11 @@ typedef struct {
70 char *xauth_location; /* Location of xauth program */ 70 char *xauth_location; /* Location of xauth program */
71 int strict_modes; /* If true, require string home dir modes. */ 71 int strict_modes; /* If true, require string home dir modes. */
72 int tcp_keep_alive; /* If true, set SO_KEEPALIVE. */ 72 int tcp_keep_alive; /* If true, set SO_KEEPALIVE. */
73 int ip_qos_interactive; /* IP ToS/DSCP/class for interactive */
74 int ip_qos_bulk; /* IP ToS/DSCP/class for bulk traffic */
73 char *ciphers; /* Supported SSH2 ciphers. */ 75 char *ciphers; /* Supported SSH2 ciphers. */
74 char *macs; /* Supported SSH2 macs. */ 76 char *macs; /* Supported SSH2 macs. */
77 char *kex_algorithms; /* SSH2 kex methods in order of preference. */
75 int protocol; /* Supported protocol versions. */ 78 int protocol; /* Supported protocol versions. */
76 int gateway_ports; /* If true, allow remote connects to forwarded ports. */ 79 int gateway_ports; /* If true, allow remote connects to forwarded ports. */
77 SyslogFacility log_facility; /* Facility for system logging. */ 80 SyslogFacility log_facility; /* Facility for system logging. */
diff --git a/session.c b/session.c
index 71e4fbe7c..fff31b02e 100644
--- a/session.c
+++ b/session.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: session.c,v 1.256 2010/06/25 07:20:04 djm Exp $ */ 1/* $OpenBSD: session.c,v 1.258 2010/11/25 04:10:09 djm Exp $ */
2/* 2/*
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4 * All rights reserved 4 * All rights reserved
@@ -585,7 +585,8 @@ do_exec_no_pty(Session *s, const char *command)
585 585
586 s->pid = pid; 586 s->pid = pid;
587 /* Set interactive/non-interactive mode. */ 587 /* Set interactive/non-interactive mode. */
588 packet_set_interactive(s->display != NULL); 588 packet_set_interactive(s->display != NULL,
589 options.ip_qos_interactive, options.ip_qos_bulk);
589 590
590 /* 591 /*
591 * Clear loginmsg, since it's the child's responsibility to display 592 * Clear loginmsg, since it's the child's responsibility to display
@@ -739,7 +740,8 @@ do_exec_pty(Session *s, const char *command)
739 740
740 /* Enter interactive session. */ 741 /* Enter interactive session. */
741 s->ptymaster = ptymaster; 742 s->ptymaster = ptymaster;
742 packet_set_interactive(1); 743 packet_set_interactive(1,
744 options.ip_qos_interactive, options.ip_qos_bulk);
743 if (compat20) { 745 if (compat20) {
744 session_set_fds(s, ptyfd, fdout, -1, 1, 1); 746 session_set_fds(s, ptyfd, fdout, -1, 1, 1);
745 } else { 747 } else {
@@ -1469,36 +1471,16 @@ do_setusercontext(struct passwd *pw)
1469{ 1471{
1470 char *chroot_path, *tmp; 1472 char *chroot_path, *tmp;
1471 1473
1472#ifdef WITH_SELINUX 1474 platform_setusercontext(pw);
1473 /* Cache selinux status for later use */
1474 (void)ssh_selinux_enabled();
1475#endif
1476 1475
1477#ifndef HAVE_CYGWIN 1476 if (platform_privileged_uidswap()) {
1478 if (getuid() == 0 || geteuid() == 0)
1479#endif /* HAVE_CYGWIN */
1480 {
1481#ifdef HAVE_LOGIN_CAP 1477#ifdef HAVE_LOGIN_CAP
1482# ifdef __bsdi__
1483 setpgid(0, 0);
1484# endif
1485# ifdef USE_PAM
1486 if (options.use_pam) {
1487 do_pam_setcred(use_privsep);
1488 }
1489# endif /* USE_PAM */
1490 if (setusercontext(lc, pw, pw->pw_uid, 1478 if (setusercontext(lc, pw, pw->pw_uid,
1491 (LOGIN_SETALL & ~(LOGIN_SETPATH|LOGIN_SETUSER))) < 0) { 1479 (LOGIN_SETALL & ~(LOGIN_SETPATH|LOGIN_SETUSER))) < 0) {
1492 perror("unable to set user context"); 1480 perror("unable to set user context");
1493 exit(1); 1481 exit(1);
1494 } 1482 }
1495#else 1483#else
1496# if defined(HAVE_GETLUID) && defined(HAVE_SETLUID)
1497 /* Sets login uid for accounting */
1498 if (getluid() == -1 && setluid(pw->pw_uid) == -1)
1499 error("setluid: %s", strerror(errno));
1500# endif /* defined(HAVE_GETLUID) && defined(HAVE_SETLUID) */
1501
1502 if (setlogin(pw->pw_name) < 0) 1484 if (setlogin(pw->pw_name) < 0)
1503 error("setlogin failed: %s", strerror(errno)); 1485 error("setlogin failed: %s", strerror(errno));
1504 if (setgid(pw->pw_gid) < 0) { 1486 if (setgid(pw->pw_gid) < 0) {
@@ -1511,50 +1493,9 @@ do_setusercontext(struct passwd *pw)
1511 exit(1); 1493 exit(1);
1512 } 1494 }
1513 endgrent(); 1495 endgrent();
1514# ifdef USE_PAM
1515 /*
1516 * PAM credentials may take the form of supplementary groups.
1517 * These will have been wiped by the above initgroups() call.
1518 * Reestablish them here.
1519 */
1520 if (options.use_pam) {
1521 do_pam_setcred(use_privsep);
1522 }
1523# endif /* USE_PAM */
1524# if defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY)
1525 irix_setusercontext(pw);
1526# endif /* defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) */
1527# ifdef _AIX
1528 aix_usrinfo(pw);
1529# endif /* _AIX */
1530# ifdef USE_LIBIAF
1531 if (set_id(pw->pw_name) != 0) {
1532 exit(1);
1533 }
1534# endif /* USE_LIBIAF */
1535#endif 1496#endif
1536#ifdef HAVE_SETPCRED
1537 /*
1538 * If we have a chroot directory, we set all creds except real
1539 * uid which we will need for chroot. If we don't have a
1540 * chroot directory, we don't override anything.
1541 */
1542 {
1543 char **creds = NULL, *chroot_creds[] =
1544 { "REAL_USER=root", NULL };
1545
1546 if (options.chroot_directory != NULL &&
1547 strcasecmp(options.chroot_directory, "none") != 0)
1548 creds = chroot_creds;
1549
1550 if (setpcred(pw->pw_name, creds) == -1)
1551 fatal("Failed to set process credentials");
1552 }
1553#endif /* HAVE_SETPCRED */
1554 1497
1555#ifdef WITH_SELINUX 1498 platform_setusercontext_post_groups(pw);
1556 ssh_selinux_setup_exec_context(pw->pw_name);
1557#endif
1558 1499
1559 if (options.chroot_directory != NULL && 1500 if (options.chroot_directory != NULL &&
1560 strcasecmp(options.chroot_directory, "none") != 0) { 1501 strcasecmp(options.chroot_directory, "none") != 0) {
@@ -1628,8 +1569,6 @@ launch_login(struct passwd *pw, const char *hostname)
1628static void 1569static void
1629child_close_fds(void) 1570child_close_fds(void)
1630{ 1571{
1631 int i;
1632
1633 if (packet_get_connection_in() == packet_get_connection_out()) 1572 if (packet_get_connection_in() == packet_get_connection_out())
1634 close(packet_get_connection_in()); 1573 close(packet_get_connection_in());
1635 else { 1574 else {
@@ -1655,8 +1594,7 @@ child_close_fds(void)
1655 * initgroups, because at least on Solaris 2.3 it leaves file 1594 * initgroups, because at least on Solaris 2.3 it leaves file
1656 * descriptors open. 1595 * descriptors open.
1657 */ 1596 */
1658 for (i = 3; i < 64; i++) 1597 closefrom(STDERR_FILENO + 1);
1659 close(i);
1660} 1598}
1661 1599
1662/* 1600/*
diff --git a/sftp-client.c b/sftp-client.c
index 9dab47780..caa384b4e 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-client.c,v 1.92 2010/07/19 03:16:33 djm Exp $ */ 1/* $OpenBSD: sftp-client.c,v 1.94 2010/12/04 00:18:01 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -75,15 +75,28 @@ struct sftp_conn {
75#define SFTP_EXT_POSIX_RENAME 0x00000001 75#define SFTP_EXT_POSIX_RENAME 0x00000001
76#define SFTP_EXT_STATVFS 0x00000002 76#define SFTP_EXT_STATVFS 0x00000002
77#define SFTP_EXT_FSTATVFS 0x00000004 77#define SFTP_EXT_FSTATVFS 0x00000004
78#define SFTP_EXT_HARDLINK 0x00000008
78 u_int exts; 79 u_int exts;
80 u_int64_t limit_kbps;
81 struct bwlimit bwlimit_in, bwlimit_out;
79}; 82};
80 83
81static char * 84static char *
82get_handle(int fd, u_int expected_id, u_int *len, const char *errfmt, ...) 85get_handle(struct sftp_conn *conn, u_int expected_id, u_int *len,
83 __attribute__((format(printf, 4, 5))); 86 const char *errfmt, ...) __attribute__((format(printf, 4, 5)));
87
88/* ARGSUSED */
89static int
90sftpio(void *_bwlimit, size_t amount)
91{
92 struct bwlimit *bwlimit = (struct bwlimit *)_bwlimit;
93
94 bandwidth_limit(bwlimit, amount);
95 return 0;
96}
84 97
85static void 98static void
86send_msg(int fd, Buffer *m) 99send_msg(struct sftp_conn *conn, Buffer *m)
87{ 100{
88 u_char mlen[4]; 101 u_char mlen[4];
89 struct iovec iov[2]; 102 struct iovec iov[2];
@@ -98,19 +111,22 @@ send_msg(int fd, Buffer *m)
98 iov[1].iov_base = buffer_ptr(m); 111 iov[1].iov_base = buffer_ptr(m);
99 iov[1].iov_len = buffer_len(m); 112 iov[1].iov_len = buffer_len(m);
100 113
101 if (atomiciov(writev, fd, iov, 2) != buffer_len(m) + sizeof(mlen)) 114 if (atomiciov6(writev, conn->fd_out, iov, 2,
115 conn->limit_kbps > 0 ? sftpio : NULL, &conn->bwlimit_out) !=
116 buffer_len(m) + sizeof(mlen))
102 fatal("Couldn't send packet: %s", strerror(errno)); 117 fatal("Couldn't send packet: %s", strerror(errno));
103 118
104 buffer_clear(m); 119 buffer_clear(m);
105} 120}
106 121
107static void 122static void
108get_msg(int fd, Buffer *m) 123get_msg(struct sftp_conn *conn, Buffer *m)
109{ 124{
110 u_int msg_len; 125 u_int msg_len;
111 126
112 buffer_append_space(m, 4); 127 buffer_append_space(m, 4);
113 if (atomicio(read, fd, buffer_ptr(m), 4) != 4) { 128 if (atomicio6(read, conn->fd_in, buffer_ptr(m), 4,
129 conn->limit_kbps > 0 ? sftpio : NULL, &conn->bwlimit_in) != 4) {
114 if (errno == EPIPE) 130 if (errno == EPIPE)
115 fatal("Connection closed"); 131 fatal("Connection closed");
116 else 132 else
@@ -122,7 +138,9 @@ get_msg(int fd, Buffer *m)
122 fatal("Received message too long %u", msg_len); 138 fatal("Received message too long %u", msg_len);
123 139
124 buffer_append_space(m, msg_len); 140 buffer_append_space(m, msg_len);
125 if (atomicio(read, fd, buffer_ptr(m), msg_len) != msg_len) { 141 if (atomicio6(read, conn->fd_in, buffer_ptr(m), msg_len,
142 conn->limit_kbps > 0 ? sftpio : NULL, &conn->bwlimit_in)
143 != msg_len) {
126 if (errno == EPIPE) 144 if (errno == EPIPE)
127 fatal("Connection closed"); 145 fatal("Connection closed");
128 else 146 else
@@ -131,7 +149,7 @@ get_msg(int fd, Buffer *m)
131} 149}
132 150
133static void 151static void
134send_string_request(int fd, u_int id, u_int code, char *s, 152send_string_request(struct sftp_conn *conn, u_int id, u_int code, char *s,
135 u_int len) 153 u_int len)
136{ 154{
137 Buffer msg; 155 Buffer msg;
@@ -140,14 +158,14 @@ send_string_request(int fd, u_int id, u_int code, char *s,
140 buffer_put_char(&msg, code); 158 buffer_put_char(&msg, code);
141 buffer_put_int(&msg, id); 159 buffer_put_int(&msg, id);
142 buffer_put_string(&msg, s, len); 160 buffer_put_string(&msg, s, len);
143 send_msg(fd, &msg); 161 send_msg(conn, &msg);
144 debug3("Sent message fd %d T:%u I:%u", fd, code, id); 162 debug3("Sent message fd %d T:%u I:%u", conn->fd_out, code, id);
145 buffer_free(&msg); 163 buffer_free(&msg);
146} 164}
147 165
148static void 166static void
149send_string_attrs_request(int fd, u_int id, u_int code, char *s, 167send_string_attrs_request(struct sftp_conn *conn, u_int id, u_int code,
150 u_int len, Attrib *a) 168 char *s, u_int len, Attrib *a)
151{ 169{
152 Buffer msg; 170 Buffer msg;
153 171
@@ -156,19 +174,19 @@ send_string_attrs_request(int fd, u_int id, u_int code, char *s,
156 buffer_put_int(&msg, id); 174 buffer_put_int(&msg, id);
157 buffer_put_string(&msg, s, len); 175 buffer_put_string(&msg, s, len);
158 encode_attrib(&msg, a); 176 encode_attrib(&msg, a);
159 send_msg(fd, &msg); 177 send_msg(conn, &msg);
160 debug3("Sent message fd %d T:%u I:%u", fd, code, id); 178 debug3("Sent message fd %d T:%u I:%u", conn->fd_out, code, id);
161 buffer_free(&msg); 179 buffer_free(&msg);
162} 180}
163 181
164static u_int 182static u_int
165get_status(int fd, u_int expected_id) 183get_status(struct sftp_conn *conn, u_int expected_id)
166{ 184{
167 Buffer msg; 185 Buffer msg;
168 u_int type, id, status; 186 u_int type, id, status;
169 187
170 buffer_init(&msg); 188 buffer_init(&msg);
171 get_msg(fd, &msg); 189 get_msg(conn, &msg);
172 type = buffer_get_char(&msg); 190 type = buffer_get_char(&msg);
173 id = buffer_get_int(&msg); 191 id = buffer_get_int(&msg);
174 192
@@ -183,11 +201,12 @@ get_status(int fd, u_int expected_id)
183 201
184 debug3("SSH2_FXP_STATUS %u", status); 202 debug3("SSH2_FXP_STATUS %u", status);
185 203
186 return(status); 204 return status;
187} 205}
188 206
189static char * 207static char *
190get_handle(int fd, u_int expected_id, u_int *len, const char *errfmt, ...) 208get_handle(struct sftp_conn *conn, u_int expected_id, u_int *len,
209 const char *errfmt, ...)
191{ 210{
192 Buffer msg; 211 Buffer msg;
193 u_int type, id; 212 u_int type, id;
@@ -201,7 +220,7 @@ get_handle(int fd, u_int expected_id, u_int *len, const char *errfmt, ...)
201 va_end(args); 220 va_end(args);
202 221
203 buffer_init(&msg); 222 buffer_init(&msg);
204 get_msg(fd, &msg); 223 get_msg(conn, &msg);
205 type = buffer_get_char(&msg); 224 type = buffer_get_char(&msg);
206 id = buffer_get_int(&msg); 225 id = buffer_get_int(&msg);
207 226
@@ -225,14 +244,14 @@ get_handle(int fd, u_int expected_id, u_int *len, const char *errfmt, ...)
225} 244}
226 245
227static Attrib * 246static Attrib *
228get_decode_stat(int fd, u_int expected_id, int quiet) 247get_decode_stat(struct sftp_conn *conn, u_int expected_id, int quiet)
229{ 248{
230 Buffer msg; 249 Buffer msg;
231 u_int type, id; 250 u_int type, id;
232 Attrib *a; 251 Attrib *a;
233 252
234 buffer_init(&msg); 253 buffer_init(&msg);
235 get_msg(fd, &msg); 254 get_msg(conn, &msg);
236 255
237 type = buffer_get_char(&msg); 256 type = buffer_get_char(&msg);
238 id = buffer_get_int(&msg); 257 id = buffer_get_int(&msg);
@@ -260,14 +279,14 @@ get_decode_stat(int fd, u_int expected_id, int quiet)
260} 279}
261 280
262static int 281static int
263get_decode_statvfs(int fd, struct sftp_statvfs *st, u_int expected_id, 282get_decode_statvfs(struct sftp_conn *conn, struct sftp_statvfs *st,
264 int quiet) 283 u_int expected_id, int quiet)
265{ 284{
266 Buffer msg; 285 Buffer msg;
267 u_int type, id, flag; 286 u_int type, id, flag;
268 287
269 buffer_init(&msg); 288 buffer_init(&msg);
270 get_msg(fd, &msg); 289 get_msg(conn, &msg);
271 290
272 type = buffer_get_char(&msg); 291 type = buffer_get_char(&msg);
273 id = buffer_get_int(&msg); 292 id = buffer_get_int(&msg);
@@ -311,21 +330,29 @@ get_decode_statvfs(int fd, struct sftp_statvfs *st, u_int expected_id,
311} 330}
312 331
313struct sftp_conn * 332struct sftp_conn *
314do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests) 333do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests,
334 u_int64_t limit_kbps)
315{ 335{
316 u_int type, exts = 0; 336 u_int type;
317 int version;
318 Buffer msg; 337 Buffer msg;
319 struct sftp_conn *ret; 338 struct sftp_conn *ret;
320 339
340 ret = xmalloc(sizeof(*ret));
341 ret->fd_in = fd_in;
342 ret->fd_out = fd_out;
343 ret->transfer_buflen = transfer_buflen;
344 ret->num_requests = num_requests;
345 ret->exts = 0;
346 ret->limit_kbps = 0;
347
321 buffer_init(&msg); 348 buffer_init(&msg);
322 buffer_put_char(&msg, SSH2_FXP_INIT); 349 buffer_put_char(&msg, SSH2_FXP_INIT);
323 buffer_put_int(&msg, SSH2_FILEXFER_VERSION); 350 buffer_put_int(&msg, SSH2_FILEXFER_VERSION);
324 send_msg(fd_out, &msg); 351 send_msg(ret, &msg);
325 352
326 buffer_clear(&msg); 353 buffer_clear(&msg);
327 354
328 get_msg(fd_in, &msg); 355 get_msg(ret, &msg);
329 356
330 /* Expecting a VERSION reply */ 357 /* Expecting a VERSION reply */
331 if ((type = buffer_get_char(&msg)) != SSH2_FXP_VERSION) { 358 if ((type = buffer_get_char(&msg)) != SSH2_FXP_VERSION) {
@@ -334,9 +361,9 @@ do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests)
334 buffer_free(&msg); 361 buffer_free(&msg);
335 return(NULL); 362 return(NULL);
336 } 363 }
337 version = buffer_get_int(&msg); 364 ret->version = buffer_get_int(&msg);
338 365
339 debug2("Remote version: %d", version); 366 debug2("Remote version: %u", ret->version);
340 367
341 /* Check for extensions */ 368 /* Check for extensions */
342 while (buffer_len(&msg) > 0) { 369 while (buffer_len(&msg) > 0) {
@@ -346,15 +373,19 @@ do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests)
346 373
347 if (strcmp(name, "posix-rename@openssh.com") == 0 && 374 if (strcmp(name, "posix-rename@openssh.com") == 0 &&
348 strcmp(value, "1") == 0) { 375 strcmp(value, "1") == 0) {
349 exts |= SFTP_EXT_POSIX_RENAME; 376 ret->exts |= SFTP_EXT_POSIX_RENAME;
350 known = 1; 377 known = 1;
351 } else if (strcmp(name, "statvfs@openssh.com") == 0 && 378 } else if (strcmp(name, "statvfs@openssh.com") == 0 &&
352 strcmp(value, "2") == 0) { 379 strcmp(value, "2") == 0) {
353 exts |= SFTP_EXT_STATVFS; 380 ret->exts |= SFTP_EXT_STATVFS;
354 known = 1; 381 known = 1;
355 } if (strcmp(name, "fstatvfs@openssh.com") == 0 && 382 } else if (strcmp(name, "fstatvfs@openssh.com") == 0 &&
356 strcmp(value, "2") == 0) { 383 strcmp(value, "2") == 0) {
357 exts |= SFTP_EXT_FSTATVFS; 384 ret->exts |= SFTP_EXT_FSTATVFS;
385 known = 1;
386 } else if (strcmp(name, "hardlink@openssh.com") == 0 &&
387 strcmp(value, "1") == 0) {
388 ret->exts |= SFTP_EXT_HARDLINK;
358 known = 1; 389 known = 1;
359 } 390 }
360 if (known) { 391 if (known) {
@@ -369,26 +400,25 @@ do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests)
369 400
370 buffer_free(&msg); 401 buffer_free(&msg);
371 402
372 ret = xmalloc(sizeof(*ret));
373 ret->fd_in = fd_in;
374 ret->fd_out = fd_out;
375 ret->transfer_buflen = transfer_buflen;
376 ret->num_requests = num_requests;
377 ret->version = version;
378 ret->msg_id = 1;
379 ret->exts = exts;
380
381 /* Some filexfer v.0 servers don't support large packets */ 403 /* Some filexfer v.0 servers don't support large packets */
382 if (version == 0) 404 if (ret->version == 0)
383 ret->transfer_buflen = MIN(ret->transfer_buflen, 20480); 405 ret->transfer_buflen = MIN(ret->transfer_buflen, 20480);
384 406
385 return(ret); 407 ret->limit_kbps = limit_kbps;
408 if (ret->limit_kbps > 0) {
409 bandwidth_limit_init(&ret->bwlimit_in, ret->limit_kbps,
410 ret->transfer_buflen);
411 bandwidth_limit_init(&ret->bwlimit_out, ret->limit_kbps,
412 ret->transfer_buflen);
413 }
414
415 return ret;
386} 416}
387 417
388u_int 418u_int
389sftp_proto_version(struct sftp_conn *conn) 419sftp_proto_version(struct sftp_conn *conn)
390{ 420{
391 return(conn->version); 421 return conn->version;
392} 422}
393 423
394int 424int
@@ -403,16 +433,16 @@ do_close(struct sftp_conn *conn, char *handle, u_int handle_len)
403 buffer_put_char(&msg, SSH2_FXP_CLOSE); 433 buffer_put_char(&msg, SSH2_FXP_CLOSE);
404 buffer_put_int(&msg, id); 434 buffer_put_int(&msg, id);
405 buffer_put_string(&msg, handle, handle_len); 435 buffer_put_string(&msg, handle, handle_len);
406 send_msg(conn->fd_out, &msg); 436 send_msg(conn, &msg);
407 debug3("Sent message SSH2_FXP_CLOSE I:%u", id); 437 debug3("Sent message SSH2_FXP_CLOSE I:%u", id);
408 438
409 status = get_status(conn->fd_in, id); 439 status = get_status(conn, id);
410 if (status != SSH2_FX_OK) 440 if (status != SSH2_FX_OK)
411 error("Couldn't close file: %s", fx2txt(status)); 441 error("Couldn't close file: %s", fx2txt(status));
412 442
413 buffer_free(&msg); 443 buffer_free(&msg);
414 444
415 return(status); 445 return status;
416} 446}
417 447
418 448
@@ -430,14 +460,14 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int printflag,
430 buffer_put_char(&msg, SSH2_FXP_OPENDIR); 460 buffer_put_char(&msg, SSH2_FXP_OPENDIR);
431 buffer_put_int(&msg, id); 461 buffer_put_int(&msg, id);
432 buffer_put_cstring(&msg, path); 462 buffer_put_cstring(&msg, path);
433 send_msg(conn->fd_out, &msg); 463 send_msg(conn, &msg);
434 464
435 buffer_clear(&msg); 465 buffer_clear(&msg);
436 466
437 handle = get_handle(conn->fd_in, id, &handle_len, 467 handle = get_handle(conn, id, &handle_len,
438 "remote readdir(\"%s\")", path); 468 "remote readdir(\"%s\")", path);
439 if (handle == NULL) 469 if (handle == NULL)
440 return(-1); 470 return -1;
441 471
442 if (dir) { 472 if (dir) {
443 ents = 0; 473 ents = 0;
@@ -454,11 +484,11 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int printflag,
454 buffer_put_char(&msg, SSH2_FXP_READDIR); 484 buffer_put_char(&msg, SSH2_FXP_READDIR);
455 buffer_put_int(&msg, id); 485 buffer_put_int(&msg, id);
456 buffer_put_string(&msg, handle, handle_len); 486 buffer_put_string(&msg, handle, handle_len);
457 send_msg(conn->fd_out, &msg); 487 send_msg(conn, &msg);
458 488
459 buffer_clear(&msg); 489 buffer_clear(&msg);
460 490
461 get_msg(conn->fd_in, &msg); 491 get_msg(conn, &msg);
462 492
463 type = buffer_get_char(&msg); 493 type = buffer_get_char(&msg);
464 id = buffer_get_int(&msg); 494 id = buffer_get_int(&msg);
@@ -537,7 +567,7 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int printflag,
537 **dir = NULL; 567 **dir = NULL;
538 } 568 }
539 569
540 return(0); 570 return 0;
541} 571}
542 572
543int 573int
@@ -566,9 +596,8 @@ do_rm(struct sftp_conn *conn, char *path)
566 debug2("Sending SSH2_FXP_REMOVE \"%s\"", path); 596 debug2("Sending SSH2_FXP_REMOVE \"%s\"", path);
567 597
568 id = conn->msg_id++; 598 id = conn->msg_id++;
569 send_string_request(conn->fd_out, id, SSH2_FXP_REMOVE, path, 599 send_string_request(conn, id, SSH2_FXP_REMOVE, path, strlen(path));
570 strlen(path)); 600 status = get_status(conn, id);
571 status = get_status(conn->fd_in, id);
572 if (status != SSH2_FX_OK) 601 if (status != SSH2_FX_OK)
573 error("Couldn't delete file: %s", fx2txt(status)); 602 error("Couldn't delete file: %s", fx2txt(status));
574 return(status); 603 return(status);
@@ -580,10 +609,10 @@ do_mkdir(struct sftp_conn *conn, char *path, Attrib *a, int printflag)
580 u_int status, id; 609 u_int status, id;
581 610
582 id = conn->msg_id++; 611 id = conn->msg_id++;
583 send_string_attrs_request(conn->fd_out, id, SSH2_FXP_MKDIR, path, 612 send_string_attrs_request(conn, id, SSH2_FXP_MKDIR, path,
584 strlen(path), a); 613 strlen(path), a);
585 614
586 status = get_status(conn->fd_in, id); 615 status = get_status(conn, id);
587 if (status != SSH2_FX_OK && printflag) 616 if (status != SSH2_FX_OK && printflag)
588 error("Couldn't create directory: %s", fx2txt(status)); 617 error("Couldn't create directory: %s", fx2txt(status));
589 618
@@ -596,10 +625,10 @@ do_rmdir(struct sftp_conn *conn, char *path)
596 u_int status, id; 625 u_int status, id;
597 626
598 id = conn->msg_id++; 627 id = conn->msg_id++;
599 send_string_request(conn->fd_out, id, SSH2_FXP_RMDIR, path, 628 send_string_request(conn, id, SSH2_FXP_RMDIR, path,
600 strlen(path)); 629 strlen(path));
601 630
602 status = get_status(conn->fd_in, id); 631 status = get_status(conn, id);
603 if (status != SSH2_FX_OK) 632 if (status != SSH2_FX_OK)
604 error("Couldn't remove directory: %s", fx2txt(status)); 633 error("Couldn't remove directory: %s", fx2txt(status));
605 634
@@ -613,11 +642,11 @@ do_stat(struct sftp_conn *conn, char *path, int quiet)
613 642
614 id = conn->msg_id++; 643 id = conn->msg_id++;
615 644
616 send_string_request(conn->fd_out, id, 645 send_string_request(conn, id,
617 conn->version == 0 ? SSH2_FXP_STAT_VERSION_0 : SSH2_FXP_STAT, 646 conn->version == 0 ? SSH2_FXP_STAT_VERSION_0 : SSH2_FXP_STAT,
618 path, strlen(path)); 647 path, strlen(path));
619 648
620 return(get_decode_stat(conn->fd_in, id, quiet)); 649 return(get_decode_stat(conn, id, quiet));
621} 650}
622 651
623Attrib * 652Attrib *
@@ -634,10 +663,10 @@ do_lstat(struct sftp_conn *conn, char *path, int quiet)
634 } 663 }
635 664
636 id = conn->msg_id++; 665 id = conn->msg_id++;
637 send_string_request(conn->fd_out, id, SSH2_FXP_LSTAT, path, 666 send_string_request(conn, id, SSH2_FXP_LSTAT, path,
638 strlen(path)); 667 strlen(path));
639 668
640 return(get_decode_stat(conn->fd_in, id, quiet)); 669 return(get_decode_stat(conn, id, quiet));
641} 670}
642 671
643#ifdef notyet 672#ifdef notyet
@@ -647,10 +676,10 @@ do_fstat(struct sftp_conn *conn, char *handle, u_int handle_len, int quiet)
647 u_int id; 676 u_int id;
648 677
649 id = conn->msg_id++; 678 id = conn->msg_id++;
650 send_string_request(conn->fd_out, id, SSH2_FXP_FSTAT, handle, 679 send_string_request(conn, id, SSH2_FXP_FSTAT, handle,
651 handle_len); 680 handle_len);
652 681
653 return(get_decode_stat(conn->fd_in, id, quiet)); 682 return(get_decode_stat(conn, id, quiet));
654} 683}
655#endif 684#endif
656 685
@@ -660,10 +689,10 @@ do_setstat(struct sftp_conn *conn, char *path, Attrib *a)
660 u_int status, id; 689 u_int status, id;
661 690
662 id = conn->msg_id++; 691 id = conn->msg_id++;
663 send_string_attrs_request(conn->fd_out, id, SSH2_FXP_SETSTAT, path, 692 send_string_attrs_request(conn, id, SSH2_FXP_SETSTAT, path,
664 strlen(path), a); 693 strlen(path), a);
665 694
666 status = get_status(conn->fd_in, id); 695 status = get_status(conn, id);
667 if (status != SSH2_FX_OK) 696 if (status != SSH2_FX_OK)
668 error("Couldn't setstat on \"%s\": %s", path, 697 error("Couldn't setstat on \"%s\": %s", path,
669 fx2txt(status)); 698 fx2txt(status));
@@ -678,10 +707,10 @@ do_fsetstat(struct sftp_conn *conn, char *handle, u_int handle_len,
678 u_int status, id; 707 u_int status, id;
679 708
680 id = conn->msg_id++; 709 id = conn->msg_id++;
681 send_string_attrs_request(conn->fd_out, id, SSH2_FXP_FSETSTAT, handle, 710 send_string_attrs_request(conn, id, SSH2_FXP_FSETSTAT, handle,
682 handle_len, a); 711 handle_len, a);
683 712
684 status = get_status(conn->fd_in, id); 713 status = get_status(conn, id);
685 if (status != SSH2_FX_OK) 714 if (status != SSH2_FX_OK)
686 error("Couldn't fsetstat: %s", fx2txt(status)); 715 error("Couldn't fsetstat: %s", fx2txt(status));
687 716
@@ -697,12 +726,12 @@ do_realpath(struct sftp_conn *conn, char *path)
697 Attrib *a; 726 Attrib *a;
698 727
699 expected_id = id = conn->msg_id++; 728 expected_id = id = conn->msg_id++;
700 send_string_request(conn->fd_out, id, SSH2_FXP_REALPATH, path, 729 send_string_request(conn, id, SSH2_FXP_REALPATH, path,
701 strlen(path)); 730 strlen(path));
702 731
703 buffer_init(&msg); 732 buffer_init(&msg);
704 733
705 get_msg(conn->fd_in, &msg); 734 get_msg(conn, &msg);
706 type = buffer_get_char(&msg); 735 type = buffer_get_char(&msg);
707 id = buffer_get_int(&msg); 736 id = buffer_get_int(&msg);
708 737
@@ -756,13 +785,13 @@ do_rename(struct sftp_conn *conn, char *oldpath, char *newpath)
756 } 785 }
757 buffer_put_cstring(&msg, oldpath); 786 buffer_put_cstring(&msg, oldpath);
758 buffer_put_cstring(&msg, newpath); 787 buffer_put_cstring(&msg, newpath);
759 send_msg(conn->fd_out, &msg); 788 send_msg(conn, &msg);
760 debug3("Sent message %s \"%s\" -> \"%s\"", 789 debug3("Sent message %s \"%s\" -> \"%s\"",
761 (conn->exts & SFTP_EXT_POSIX_RENAME) ? "posix-rename@openssh.com" : 790 (conn->exts & SFTP_EXT_POSIX_RENAME) ? "posix-rename@openssh.com" :
762 "SSH2_FXP_RENAME", oldpath, newpath); 791 "SSH2_FXP_RENAME", oldpath, newpath);
763 buffer_free(&msg); 792 buffer_free(&msg);
764 793
765 status = get_status(conn->fd_in, id); 794 status = get_status(conn, id);
766 if (status != SSH2_FX_OK) 795 if (status != SSH2_FX_OK)
767 error("Couldn't rename file \"%s\" to \"%s\": %s", oldpath, 796 error("Couldn't rename file \"%s\" to \"%s\": %s", oldpath,
768 newpath, fx2txt(status)); 797 newpath, fx2txt(status));
@@ -771,6 +800,39 @@ do_rename(struct sftp_conn *conn, char *oldpath, char *newpath)
771} 800}
772 801
773int 802int
803do_hardlink(struct sftp_conn *conn, char *oldpath, char *newpath)
804{
805 Buffer msg;
806 u_int status, id;
807
808 buffer_init(&msg);
809
810 /* Send link request */
811 id = conn->msg_id++;
812 if ((conn->exts & SFTP_EXT_HARDLINK) == 0) {
813 error("Server does not support hardlink@openssh.com extension");
814 return -1;
815 }
816
817 buffer_put_char(&msg, SSH2_FXP_EXTENDED);
818 buffer_put_int(&msg, id);
819 buffer_put_cstring(&msg, "hardlink@openssh.com");
820 buffer_put_cstring(&msg, oldpath);
821 buffer_put_cstring(&msg, newpath);
822 send_msg(conn, &msg);
823 debug3("Sent message hardlink@openssh.com \"%s\" -> \"%s\"",
824 oldpath, newpath);
825 buffer_free(&msg);
826
827 status = get_status(conn, id);
828 if (status != SSH2_FX_OK)
829 error("Couldn't link file \"%s\" to \"%s\": %s", oldpath,
830 newpath, fx2txt(status));
831
832 return(status);
833}
834
835int
774do_symlink(struct sftp_conn *conn, char *oldpath, char *newpath) 836do_symlink(struct sftp_conn *conn, char *oldpath, char *newpath)
775{ 837{
776 Buffer msg; 838 Buffer msg;
@@ -789,12 +851,12 @@ do_symlink(struct sftp_conn *conn, char *oldpath, char *newpath)
789 buffer_put_int(&msg, id); 851 buffer_put_int(&msg, id);
790 buffer_put_cstring(&msg, oldpath); 852 buffer_put_cstring(&msg, oldpath);
791 buffer_put_cstring(&msg, newpath); 853 buffer_put_cstring(&msg, newpath);
792 send_msg(conn->fd_out, &msg); 854 send_msg(conn, &msg);
793 debug3("Sent message SSH2_FXP_SYMLINK \"%s\" -> \"%s\"", oldpath, 855 debug3("Sent message SSH2_FXP_SYMLINK \"%s\" -> \"%s\"", oldpath,
794 newpath); 856 newpath);
795 buffer_free(&msg); 857 buffer_free(&msg);
796 858
797 status = get_status(conn->fd_in, id); 859 status = get_status(conn, id);
798 if (status != SSH2_FX_OK) 860 if (status != SSH2_FX_OK)
799 error("Couldn't symlink file \"%s\" to \"%s\": %s", oldpath, 861 error("Couldn't symlink file \"%s\" to \"%s\": %s", oldpath,
800 newpath, fx2txt(status)); 862 newpath, fx2txt(status));
@@ -812,12 +874,11 @@ do_readlink(struct sftp_conn *conn, char *path)
812 Attrib *a; 874 Attrib *a;
813 875
814 expected_id = id = conn->msg_id++; 876 expected_id = id = conn->msg_id++;
815 send_string_request(conn->fd_out, id, SSH2_FXP_READLINK, path, 877 send_string_request(conn, id, SSH2_FXP_READLINK, path, strlen(path));
816 strlen(path));
817 878
818 buffer_init(&msg); 879 buffer_init(&msg);
819 880
820 get_msg(conn->fd_in, &msg); 881 get_msg(conn, &msg);
821 type = buffer_get_char(&msg); 882 type = buffer_get_char(&msg);
822 id = buffer_get_int(&msg); 883 id = buffer_get_int(&msg);
823 884
@@ -871,10 +932,10 @@ do_statvfs(struct sftp_conn *conn, const char *path, struct sftp_statvfs *st,
871 buffer_put_int(&msg, id); 932 buffer_put_int(&msg, id);
872 buffer_put_cstring(&msg, "statvfs@openssh.com"); 933 buffer_put_cstring(&msg, "statvfs@openssh.com");
873 buffer_put_cstring(&msg, path); 934 buffer_put_cstring(&msg, path);
874 send_msg(conn->fd_out, &msg); 935 send_msg(conn, &msg);
875 buffer_free(&msg); 936 buffer_free(&msg);
876 937
877 return get_decode_statvfs(conn->fd_in, st, id, quiet); 938 return get_decode_statvfs(conn, st, id, quiet);
878} 939}
879 940
880#ifdef notyet 941#ifdef notyet
@@ -898,16 +959,16 @@ do_fstatvfs(struct sftp_conn *conn, const char *handle, u_int handle_len,
898 buffer_put_int(&msg, id); 959 buffer_put_int(&msg, id);
899 buffer_put_cstring(&msg, "fstatvfs@openssh.com"); 960 buffer_put_cstring(&msg, "fstatvfs@openssh.com");
900 buffer_put_string(&msg, handle, handle_len); 961 buffer_put_string(&msg, handle, handle_len);
901 send_msg(conn->fd_out, &msg); 962 send_msg(conn, &msg);
902 buffer_free(&msg); 963 buffer_free(&msg);
903 964
904 return get_decode_statvfs(conn->fd_in, st, id, quiet); 965 return get_decode_statvfs(conn, st, id, quiet);
905} 966}
906#endif 967#endif
907 968
908static void 969static void
909send_read_request(int fd_out, u_int id, u_int64_t offset, u_int len, 970send_read_request(struct sftp_conn *conn, u_int id, u_int64_t offset,
910 char *handle, u_int handle_len) 971 u_int len, char *handle, u_int handle_len)
911{ 972{
912 Buffer msg; 973 Buffer msg;
913 974
@@ -918,7 +979,7 @@ send_read_request(int fd_out, u_int id, u_int64_t offset, u_int len,
918 buffer_put_string(&msg, handle, handle_len); 979 buffer_put_string(&msg, handle, handle_len);
919 buffer_put_int64(&msg, offset); 980 buffer_put_int64(&msg, offset);
920 buffer_put_int(&msg, len); 981 buffer_put_int(&msg, len);
921 send_msg(fd_out, &msg); 982 send_msg(conn, &msg);
922 buffer_free(&msg); 983 buffer_free(&msg);
923} 984}
924 985
@@ -976,10 +1037,10 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
976 buffer_put_int(&msg, SSH2_FXF_READ); 1037 buffer_put_int(&msg, SSH2_FXF_READ);
977 attrib_clear(&junk); /* Send empty attributes */ 1038 attrib_clear(&junk); /* Send empty attributes */
978 encode_attrib(&msg, &junk); 1039 encode_attrib(&msg, &junk);
979 send_msg(conn->fd_out, &msg); 1040 send_msg(conn, &msg);
980 debug3("Sent message SSH2_FXP_OPEN I:%u P:%s", id, remote_path); 1041 debug3("Sent message SSH2_FXP_OPEN I:%u P:%s", id, remote_path);
981 1042
982 handle = get_handle(conn->fd_in, id, &handle_len, 1043 handle = get_handle(conn, id, &handle_len,
983 "remote open(\"%s\")", remote_path); 1044 "remote open(\"%s\")", remote_path);
984 if (handle == NULL) { 1045 if (handle == NULL) {
985 buffer_free(&msg); 1046 buffer_free(&msg);
@@ -1032,12 +1093,12 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
1032 offset += buflen; 1093 offset += buflen;
1033 num_req++; 1094 num_req++;
1034 TAILQ_INSERT_TAIL(&requests, req, tq); 1095 TAILQ_INSERT_TAIL(&requests, req, tq);
1035 send_read_request(conn->fd_out, req->id, req->offset, 1096 send_read_request(conn, req->id, req->offset,
1036 req->len, handle, handle_len); 1097 req->len, handle, handle_len);
1037 } 1098 }
1038 1099
1039 buffer_clear(&msg); 1100 buffer_clear(&msg);
1040 get_msg(conn->fd_in, &msg); 1101 get_msg(conn, &msg);
1041 type = buffer_get_char(&msg); 1102 type = buffer_get_char(&msg);
1042 id = buffer_get_int(&msg); 1103 id = buffer_get_int(&msg);
1043 debug3("Received reply T:%u I:%u R:%d", type, id, max_req); 1104 debug3("Received reply T:%u I:%u R:%d", type, id, max_req);
@@ -1092,7 +1153,7 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
1092 req->id = conn->msg_id++; 1153 req->id = conn->msg_id++;
1093 req->len -= len; 1154 req->len -= len;
1094 req->offset += len; 1155 req->offset += len;
1095 send_read_request(conn->fd_out, req->id, 1156 send_read_request(conn, req->id,
1096 req->offset, req->len, handle, handle_len); 1157 req->offset, req->len, handle, handle_len);
1097 /* Reduce the request size */ 1158 /* Reduce the request size */
1098 if (len < buflen) 1159 if (len < buflen)
@@ -1327,12 +1388,12 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
1327 buffer_put_cstring(&msg, remote_path); 1388 buffer_put_cstring(&msg, remote_path);
1328 buffer_put_int(&msg, SSH2_FXF_WRITE|SSH2_FXF_CREAT|SSH2_FXF_TRUNC); 1389 buffer_put_int(&msg, SSH2_FXF_WRITE|SSH2_FXF_CREAT|SSH2_FXF_TRUNC);
1329 encode_attrib(&msg, &a); 1390 encode_attrib(&msg, &a);
1330 send_msg(conn->fd_out, &msg); 1391 send_msg(conn, &msg);
1331 debug3("Sent message SSH2_FXP_OPEN I:%u P:%s", id, remote_path); 1392 debug3("Sent message SSH2_FXP_OPEN I:%u P:%s", id, remote_path);
1332 1393
1333 buffer_clear(&msg); 1394 buffer_clear(&msg);
1334 1395
1335 handle = get_handle(conn->fd_in, id, &handle_len, 1396 handle = get_handle(conn, id, &handle_len,
1336 "remote open(\"%s\")", remote_path); 1397 "remote open(\"%s\")", remote_path);
1337 if (handle == NULL) { 1398 if (handle == NULL) {
1338 close(local_fd); 1399 close(local_fd);
@@ -1381,7 +1442,7 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
1381 buffer_put_string(&msg, handle, handle_len); 1442 buffer_put_string(&msg, handle, handle_len);
1382 buffer_put_int64(&msg, offset); 1443 buffer_put_int64(&msg, offset);
1383 buffer_put_string(&msg, data, len); 1444 buffer_put_string(&msg, data, len);
1384 send_msg(conn->fd_out, &msg); 1445 send_msg(conn, &msg);
1385 debug3("Sent message SSH2_FXP_WRITE I:%u O:%llu S:%u", 1446 debug3("Sent message SSH2_FXP_WRITE I:%u O:%llu S:%u",
1386 id, (unsigned long long)offset, len); 1447 id, (unsigned long long)offset, len);
1387 } else if (TAILQ_FIRST(&acks) == NULL) 1448 } else if (TAILQ_FIRST(&acks) == NULL)
@@ -1395,7 +1456,7 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
1395 u_int r_id; 1456 u_int r_id;
1396 1457
1397 buffer_clear(&msg); 1458 buffer_clear(&msg);
1398 get_msg(conn->fd_in, &msg); 1459 get_msg(conn, &msg);
1399 type = buffer_get_char(&msg); 1460 type = buffer_get_char(&msg);
1400 r_id = buffer_get_int(&msg); 1461 r_id = buffer_get_int(&msg);
1401 1462
diff --git a/sftp-client.h b/sftp-client.h
index 1d08c4049..aef54ef49 100644
--- a/sftp-client.h
+++ b/sftp-client.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-client.h,v 1.18 2009/08/18 18:36:20 djm Exp $ */ 1/* $OpenBSD: sftp-client.h,v 1.20 2010/12/04 00:18:01 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> 4 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
@@ -51,7 +51,7 @@ struct sftp_statvfs {
51 * Initialise a SSH filexfer connection. Returns NULL on error or 51 * Initialise a SSH filexfer connection. Returns NULL on error or
52 * a pointer to a initialized sftp_conn struct on success. 52 * a pointer to a initialized sftp_conn struct on success.
53 */ 53 */
54struct sftp_conn *do_init(int, int, u_int, u_int); 54struct sftp_conn *do_init(int, int, u_int, u_int, u_int64_t);
55 55
56u_int sftp_proto_version(struct sftp_conn *); 56u_int sftp_proto_version(struct sftp_conn *);
57 57
@@ -94,6 +94,9 @@ int do_statvfs(struct sftp_conn *, const char *, struct sftp_statvfs *, int);
94/* Rename 'oldpath' to 'newpath' */ 94/* Rename 'oldpath' to 'newpath' */
95int do_rename(struct sftp_conn *, char *, char *); 95int do_rename(struct sftp_conn *, char *, char *);
96 96
97/* Link 'oldpath' to 'newpath' */
98int do_hardlink(struct sftp_conn *, char *, char *);
99
97/* Rename 'oldpath' to 'newpath' */ 100/* Rename 'oldpath' to 'newpath' */
98int do_symlink(struct sftp_conn *, char *, char *); 101int do_symlink(struct sftp_conn *, char *, char *);
99 102
diff --git a/sftp-server.0 b/sftp-server.0
index 05b9ddc9c..d8d91c5d5 100644
--- a/sftp-server.0
+++ b/sftp-server.0
@@ -51,7 +51,7 @@ DESCRIPTION
51SEE ALSO 51SEE ALSO
52 sftp(1), ssh(1), sshd_config(5), sshd(8) 52 sftp(1), ssh(1), sshd_config(5), sshd(8)
53 53
54 T. Ylonen, S. Lehtinen, SSH File Transfer Protocol, 54 T. Ylonen and S. Lehtinen, SSH File Transfer Protocol,
55 draft-ietf-secsh-filexfer-00.txt, January 2001, work in progress 55 draft-ietf-secsh-filexfer-00.txt, January 2001, work in progress
56 material. 56 material.
57 57
diff --git a/sftp-server.c b/sftp-server.c
index a98ac2b6d..b268d0883 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-server.c,v 1.91 2010/01/13 01:40:16 djm Exp $ */ 1/* $OpenBSD: sftp-server.c,v 1.93 2010/12/04 00:18:01 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000-2004 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000-2004 Markus Friedl. All rights reserved.
4 * 4 *
@@ -535,6 +535,9 @@ process_init(void)
535 /* fstatvfs extension */ 535 /* fstatvfs extension */
536 buffer_put_cstring(&msg, "fstatvfs@openssh.com"); 536 buffer_put_cstring(&msg, "fstatvfs@openssh.com");
537 buffer_put_cstring(&msg, "2"); /* version */ 537 buffer_put_cstring(&msg, "2"); /* version */
538 /* hardlink extension */
539 buffer_put_cstring(&msg, "hardlink@openssh.com");
540 buffer_put_cstring(&msg, "1"); /* version */
538 send_msg(&msg); 541 send_msg(&msg);
539 buffer_free(&msg); 542 buffer_free(&msg);
540} 543}
@@ -1223,6 +1226,27 @@ process_extended_fstatvfs(u_int32_t id)
1223} 1226}
1224 1227
1225static void 1228static void
1229process_extended_hardlink(u_int32_t id)
1230{
1231 char *oldpath, *newpath;
1232 int ret, status;
1233
1234 oldpath = get_string(NULL);
1235 newpath = get_string(NULL);
1236 debug3("request %u: hardlink", id);
1237 logit("hardlink old \"%s\" new \"%s\"", oldpath, newpath);
1238 if (readonly)
1239 status = SSH2_FX_PERMISSION_DENIED;
1240 else {
1241 ret = link(oldpath, newpath);
1242 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
1243 }
1244 send_status(id, status);
1245 xfree(oldpath);
1246 xfree(newpath);
1247}
1248
1249static void
1226process_extended(void) 1250process_extended(void)
1227{ 1251{
1228 u_int32_t id; 1252 u_int32_t id;
@@ -1236,6 +1260,8 @@ process_extended(void)
1236 process_extended_statvfs(id); 1260 process_extended_statvfs(id);
1237 else if (strcmp(request, "fstatvfs@openssh.com") == 0) 1261 else if (strcmp(request, "fstatvfs@openssh.com") == 0)
1238 process_extended_fstatvfs(id); 1262 process_extended_fstatvfs(id);
1263 else if (strcmp(request, "hardlink@openssh.com") == 0)
1264 process_extended_hardlink(id);
1239 else 1265 else
1240 send_status(id, SSH2_FX_OP_UNSUPPORTED); /* MUST */ 1266 send_status(id, SSH2_FX_OP_UNSUPPORTED); /* MUST */
1241 xfree(request); 1267 xfree(request);
@@ -1377,8 +1403,7 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
1377 ssize_t len, olen, set_size; 1403 ssize_t len, olen, set_size;
1378 SyslogFacility log_facility = SYSLOG_FACILITY_AUTH; 1404 SyslogFacility log_facility = SYSLOG_FACILITY_AUTH;
1379 char *cp, buf[4*4096]; 1405 char *cp, buf[4*4096];
1380 const char *errmsg; 1406 long mask;
1381 mode_t mask;
1382 1407
1383 extern char *optarg; 1408 extern char *optarg;
1384 extern char *__progname; 1409 extern char *__progname;
@@ -1412,11 +1437,12 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
1412 error("Invalid log facility \"%s\"", optarg); 1437 error("Invalid log facility \"%s\"", optarg);
1413 break; 1438 break;
1414 case 'u': 1439 case 'u':
1415 mask = (mode_t)strtonum(optarg, 0, 0777, &errmsg); 1440 errno = 0;
1416 if (errmsg != NULL) 1441 mask = strtol(optarg, &cp, 8);
1417 fatal("Invalid umask \"%s\": %s", 1442 if (mask < 0 || mask > 0777 || *cp != '\0' ||
1418 optarg, errmsg); 1443 cp == optarg || (mask == 0 && errno != 0))
1419 (void)umask(mask); 1444 fatal("Invalid umask \"%s\"", optarg);
1445 (void)umask((mode_t)mask);
1420 break; 1446 break;
1421 case 'h': 1447 case 'h':
1422 default: 1448 default:
diff --git a/sftp.0 b/sftp.0
index 40de1a0cd..6ceed93ab 100644
--- a/sftp.0
+++ b/sftp.0
@@ -5,7 +5,7 @@ NAME
5 5
6SYNOPSIS 6SYNOPSIS
7 sftp [-1246Cpqrv] [-B buffer_size] [-b batchfile] [-c cipher] 7 sftp [-1246Cpqrv] [-B buffer_size] [-b batchfile] [-c cipher]
8 [-D sftp_server_path] [-F ssh_config] [-i identity_file] 8 [-D sftp_server_path] [-F ssh_config] [-i identity_file] [-l limit]
9 [-o ssh_option] [-P port] [-R num_requests] [-S program] 9 [-o ssh_option] [-P port] [-R num_requests] [-S program]
10 [-s subsystem | sftp_server] host 10 [-s subsystem | sftp_server] host
11 sftp [user@]host[:file ...] 11 sftp [user@]host[:file ...]
@@ -50,9 +50,9 @@ DESCRIPTION
50 batchfile of `-' may be used to indicate standard input. sftp 50 batchfile of `-' may be used to indicate standard input. sftp
51 will abort if any of the following commands fail: get, put, 51 will abort if any of the following commands fail: get, put,
52 rename, ln, rm, mkdir, chdir, ls, lchdir, chmod, chown, chgrp, 52 rename, ln, rm, mkdir, chdir, ls, lchdir, chmod, chown, chgrp,
53 lpwd, df, and lmkdir. Termination on error can be suppressed on 53 lpwd, df, symlink, and lmkdir. Termination on error can be
54 a command by command basis by prefixing the command with a `-' 54 suppressed on a command by command basis by prefixing the command
55 character (for example, -rm /tmp/blah*). 55 with a `-' character (for example, -rm /tmp/blah*).
56 56
57 -C Enables compression (via ssh's -C flag). 57 -C Enables compression (via ssh's -C flag).
58 58
@@ -73,6 +73,9 @@ DESCRIPTION
73 key authentication is read. This option is directly passed to 73 key authentication is read. This option is directly passed to
74 ssh(1). 74 ssh(1).
75 75
76 -l limit
77 Limits the used bandwidth, specified in Kbit/s.
78
76 -o ssh_option 79 -o ssh_option
77 Can be used to pass options to ssh in the format used in 80 Can be used to pass options to ssh in the format used in
78 ssh_config(5). This is useful for specifying options for which 81 ssh_config(5). This is useful for specifying options for which
@@ -105,7 +108,9 @@ DESCRIPTION
105 HostName 108 HostName
106 IdentityFile 109 IdentityFile
107 IdentitiesOnly 110 IdentitiesOnly
111 IPQoS
108 KbdInteractiveDevices 112 KbdInteractiveDevices
113 KexAlgorithms
109 LogLevel 114 LogLevel
110 MACs 115 MACs
111 NoHostAuthenticationForLocalhost 116 NoHostAuthenticationForLocalhost
@@ -225,8 +230,10 @@ INTERACTIVE COMMANDS
225 lmkdir path 230 lmkdir path
226 Create local directory specified by path. 231 Create local directory specified by path.
227 232
228 ln oldpath newpath 233 ln [-s] oldpath newpath
229 Create a symbolic link from oldpath to newpath. 234 Create a link from oldpath to newpath. If the -s flag is
235 specified the created link is a symbolic link, otherwise it is a
236 hard link.
230 237
231 lpwd Print local working directory. 238 lpwd Print local working directory.
232 239
@@ -317,8 +324,8 @@ SEE ALSO
317 ftp(1), ls(1), scp(1), ssh(1), ssh-add(1), ssh-keygen(1), glob(3), 324 ftp(1), ls(1), scp(1), ssh(1), ssh-add(1), ssh-keygen(1), glob(3),
318 ssh_config(5), sftp-server(8), sshd(8) 325 ssh_config(5), sftp-server(8), sshd(8)
319 326
320 T. Ylonen, S. Lehtinen, SSH File Transfer Protocol, 327 T. Ylonen and S. Lehtinen, SSH File Transfer Protocol,
321 draft-ietf-secsh-filexfer-00.txt, January 2001, work in progress 328 draft-ietf-secsh-filexfer-00.txt, January 2001, work in progress
322 material. 329 material.
323 330
324OpenBSD 4.8 February 8, 2010 OpenBSD 4.8 331OpenBSD 4.8 December 4, 2010 OpenBSD 4.8
diff --git a/sftp.1 b/sftp.1
index 777b02a58..89b5d3544 100644
--- a/sftp.1
+++ b/sftp.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: sftp.1,v 1.83 2010/02/08 10:50:20 markus Exp $ 1.\" $OpenBSD: sftp.1,v 1.88 2010/12/04 00:18:01 djm Exp $
2.\" 2.\"
3.\" Copyright (c) 2001 Damien Miller. All rights reserved. 3.\" Copyright (c) 2001 Damien Miller. All rights reserved.
4.\" 4.\"
@@ -22,7 +22,7 @@
22.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24.\" 24.\"
25.Dd $Mdocdate: February 8 2010 $ 25.Dd $Mdocdate: December 4 2010 $
26.Dt SFTP 1 26.Dt SFTP 1
27.Os 27.Os
28.Sh NAME 28.Sh NAME
@@ -38,6 +38,7 @@
38.Op Fl D Ar sftp_server_path 38.Op Fl D Ar sftp_server_path
39.Op Fl F Ar ssh_config 39.Op Fl F Ar ssh_config
40.Op Fl i Ar identity_file 40.Op Fl i Ar identity_file
41.Op Fl l Ar limit
41.Op Fl o Ar ssh_option 42.Op Fl o Ar ssh_option
42.Op Fl P Ar port 43.Op Fl P Ar port
43.Op Fl R Ar num_requests 44.Op Fl R Ar num_requests
@@ -49,9 +50,11 @@
49.Oo Ar user Ns @ Oc Ns 50.Oo Ar user Ns @ Oc Ns
50.Ar host Ns Op : Ns Ar 51.Ar host Ns Op : Ns Ar
51.Nm sftp 52.Nm sftp
52.Oo Ar user Ns @ Oc Ns 53.Oo
54.Ar user Ns @ Oc Ns
53.Ar host Ns Oo : Ns Ar dir Ns 55.Ar host Ns Oo : Ns Ar dir Ns
54.Op Ar / Oc 56.Op Ar /
57.Oc
55.Nm sftp 58.Nm sftp
56.Fl b Ar batchfile 59.Fl b Ar batchfile
57.Oo Ar user Ns @ Oc Ns Ar host 60.Oo Ar user Ns @ Oc Ns Ar host
@@ -125,7 +128,7 @@ commands fail:
125.Ic get , put , rename , ln , 128.Ic get , put , rename , ln ,
126.Ic rm , mkdir , chdir , ls , 129.Ic rm , mkdir , chdir , ls ,
127.Ic lchdir , chmod , chown , 130.Ic lchdir , chmod , chown ,
128.Ic chgrp , lpwd , df , 131.Ic chgrp , lpwd , df , symlink ,
129and 132and
130.Ic lmkdir . 133.Ic lmkdir .
131Termination on error can be suppressed on a command by command basis by 134Termination on error can be suppressed on a command by command basis by
@@ -157,6 +160,8 @@ Selects the file from which the identity (private key) for public key
157authentication is read. 160authentication is read.
158This option is directly passed to 161This option is directly passed to
159.Xr ssh 1 . 162.Xr ssh 1 .
163.It Fl l Ar limit
164Limits the used bandwidth, specified in Kbit/s.
160.It Fl o Ar ssh_option 165.It Fl o Ar ssh_option
161Can be used to pass options to 166Can be used to pass options to
162.Nm ssh 167.Nm ssh
@@ -196,7 +201,9 @@ For full details of the options listed below, and their possible values, see
196.It HostName 201.It HostName
197.It IdentityFile 202.It IdentityFile
198.It IdentitiesOnly 203.It IdentitiesOnly
204.It IPQoS
199.It KbdInteractiveDevices 205.It KbdInteractiveDevices
206.It KexAlgorithms
200.It LogLevel 207.It LogLevel
201.It MACs 208.It MACs
202.It NoHostAuthenticationForLocalhost 209.It NoHostAuthenticationForLocalhost
@@ -385,11 +392,19 @@ characters and may match multiple files.
385.It Ic lmkdir Ar path 392.It Ic lmkdir Ar path
386Create local directory specified by 393Create local directory specified by
387.Ar path . 394.Ar path .
388.It Ic ln Ar oldpath Ar newpath 395.It Xo Ic ln
389Create a symbolic link from 396.Op Fl s
397.Ar oldpath
398.Ar newpath
399.Xc
400Create a link from
390.Ar oldpath 401.Ar oldpath
391to 402to
392.Ar newpath . 403.Ar newpath .
404If the
405.Fl s
406flag is specified the created link is a symbolic link, otherwise it is
407a hard link.
393.It Ic lpwd 408.It Ic lpwd
394Print local working directory. 409Print local working directory.
395.It Xo Ic ls 410.It Xo Ic ls
diff --git a/sftp.c b/sftp.c
index 229f12987..ab667f5a5 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp.c,v 1.125 2010/06/18 00:58:39 djm Exp $ */ 1/* $OpenBSD: sftp.c,v 1.132 2010/12/04 00:18:01 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -132,6 +132,7 @@ extern char *__progname;
132#define I_GET 5 132#define I_GET 5
133#define I_HELP 6 133#define I_HELP 6
134#define I_LCHDIR 7 134#define I_LCHDIR 7
135#define I_LINK 25
135#define I_LLS 8 136#define I_LLS 8
136#define I_LMKDIR 9 137#define I_LMKDIR 9
137#define I_LPWD 10 138#define I_LPWD 10
@@ -176,7 +177,7 @@ static const struct CMD cmds[] = {
176 { "lchdir", I_LCHDIR, LOCAL }, 177 { "lchdir", I_LCHDIR, LOCAL },
177 { "lls", I_LLS, LOCAL }, 178 { "lls", I_LLS, LOCAL },
178 { "lmkdir", I_LMKDIR, LOCAL }, 179 { "lmkdir", I_LMKDIR, LOCAL },
179 { "ln", I_SYMLINK, REMOTE }, 180 { "ln", I_LINK, REMOTE },
180 { "lpwd", I_LPWD, LOCAL }, 181 { "lpwd", I_LPWD, LOCAL },
181 { "ls", I_LS, REMOTE }, 182 { "ls", I_LS, REMOTE },
182 { "lumask", I_LUMASK, NOARGS }, 183 { "lumask", I_LUMASK, NOARGS },
@@ -240,7 +241,7 @@ help(void)
240 "lcd path Change local directory to 'path'\n" 241 "lcd path Change local directory to 'path'\n"
241 "lls [ls-options [path]] Display local directory listing\n" 242 "lls [ls-options [path]] Display local directory listing\n"
242 "lmkdir path Create local directory\n" 243 "lmkdir path Create local directory\n"
243 "ln oldpath newpath Symlink remote file\n" 244 "ln [-s] oldpath newpath Link remote file (-s for symlink)\n"
244 "lpwd Print local working directory\n" 245 "lpwd Print local working directory\n"
245 "ls [-1afhlnrSt] [path] Display remote directory listing\n" 246 "ls [-1afhlnrSt] [path] Display remote directory listing\n"
246 "lumask umask Set local umask to 'umask'\n" 247 "lumask umask Set local umask to 'umask'\n"
@@ -269,7 +270,7 @@ local_do_shell(const char *args)
269 if (!*args) 270 if (!*args)
270 args = NULL; 271 args = NULL;
271 272
272 if ((shell = getenv("SHELL")) == NULL) 273 if ((shell = getenv("SHELL")) == NULL || *shell == '\0')
273 shell = _PATH_BSHELL; 274 shell = _PATH_BSHELL;
274 275
275 if ((pid = fork()) == -1) 276 if ((pid = fork()) == -1)
@@ -377,6 +378,30 @@ parse_getput_flags(const char *cmd, char **argv, int argc, int *pflag,
377} 378}
378 379
379static int 380static int
381parse_link_flags(const char *cmd, char **argv, int argc, int *sflag)
382{
383 extern int opterr, optind, optopt, optreset;
384 int ch;
385
386 optind = optreset = 1;
387 opterr = 0;
388
389 *sflag = 0;
390 while ((ch = getopt(argc, argv, "s")) != -1) {
391 switch (ch) {
392 case 's':
393 *sflag = 1;
394 break;
395 default:
396 error("%s: Invalid flag -%c", cmd, optopt);
397 return -1;
398 }
399 }
400
401 return optind;
402}
403
404static int
380parse_ls_flags(char **argv, int argc, int *lflag) 405parse_ls_flags(char **argv, int argc, int *lflag)
381{ 406{
382 extern int opterr, optind, optopt, optreset; 407 extern int opterr, optind, optopt, optreset;
@@ -758,18 +783,22 @@ static int
758do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path, 783do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
759 int lflag) 784 int lflag)
760{ 785{
761 glob_t g;
762 u_int i, c = 1, colspace = 0, columns = 1;
763 Attrib *a = NULL; 786 Attrib *a = NULL;
787 char *fname, *lname;
788 glob_t g;
789 int err;
790 struct winsize ws;
791 u_int i, c = 1, colspace = 0, columns = 1, m = 0, width = 80;
764 792
765 memset(&g, 0, sizeof(g)); 793 memset(&g, 0, sizeof(g));
766 794
767 if (remote_glob(conn, path, GLOB_MARK|GLOB_NOCHECK|GLOB_BRACE, 795 if (remote_glob(conn, path,
768 NULL, &g) || (g.gl_pathc && !g.gl_matchc)) { 796 GLOB_MARK|GLOB_NOCHECK|GLOB_BRACE|GLOB_KEEPSTAT, NULL, &g) ||
797 (g.gl_pathc && !g.gl_matchc)) {
769 if (g.gl_pathc) 798 if (g.gl_pathc)
770 globfree(&g); 799 globfree(&g);
771 error("Can't ls: \"%s\" not found", path); 800 error("Can't ls: \"%s\" not found", path);
772 return (-1); 801 return -1;
773 } 802 }
774 803
775 if (interrupted) 804 if (interrupted)
@@ -779,59 +808,35 @@ do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
779 * If the glob returns a single match and it is a directory, 808 * If the glob returns a single match and it is a directory,
780 * then just list its contents. 809 * then just list its contents.
781 */ 810 */
782 if (g.gl_matchc == 1) { 811 if (g.gl_matchc == 1 && g.gl_statv[0] != NULL &&
783 if ((a = do_lstat(conn, g.gl_pathv[0], 1)) == NULL) { 812 S_ISDIR(g.gl_statv[0]->st_mode)) {
784 globfree(&g); 813 err = do_ls_dir(conn, g.gl_pathv[0], strip_path, lflag);
785 return (-1); 814 globfree(&g);
786 } 815 return err;
787 if ((a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) &&
788 S_ISDIR(a->perm)) {
789 int err;
790
791 err = do_ls_dir(conn, g.gl_pathv[0], strip_path, lflag);
792 globfree(&g);
793 return (err);
794 }
795 } 816 }
796 817
797 if (!(lflag & LS_SHORT_VIEW)) { 818 if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1)
798 u_int m = 0, width = 80; 819 width = ws.ws_col;
799 struct winsize ws;
800 820
821 if (!(lflag & LS_SHORT_VIEW)) {
801 /* Count entries for sort and find longest filename */ 822 /* Count entries for sort and find longest filename */
802 for (i = 0; g.gl_pathv[i]; i++) 823 for (i = 0; g.gl_pathv[i]; i++)
803 m = MAX(m, strlen(g.gl_pathv[i])); 824 m = MAX(m, strlen(g.gl_pathv[i]));
804 825
805 if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1)
806 width = ws.ws_col;
807
808 columns = width / (m + 2); 826 columns = width / (m + 2);
809 columns = MAX(columns, 1); 827 columns = MAX(columns, 1);
810 colspace = width / columns; 828 colspace = width / columns;
811 } 829 }
812 830
813 for (i = 0; g.gl_pathv[i] && !interrupted; i++, a = NULL) { 831 for (i = 0; g.gl_pathv[i] && !interrupted; i++, a = NULL) {
814 char *fname;
815
816 fname = path_strip(g.gl_pathv[i], strip_path); 832 fname = path_strip(g.gl_pathv[i], strip_path);
817
818 if (lflag & LS_LONG_VIEW) { 833 if (lflag & LS_LONG_VIEW) {
819 char *lname; 834 if (g.gl_statv[i] == NULL) {
820 struct stat sb; 835 error("no stat information for %s", fname);
821 836 continue;
822 /* 837 }
823 * XXX: this is slow - 1 roundtrip per path 838 lname = ls_file(fname, g.gl_statv[i], 1,
824 * A solution to this is to fork glob() and 839 (lflag & LS_SI_UNITS));
825 * build a sftp specific version which keeps the
826 * attribs (which currently get thrown away)
827 * that the server returns as well as the filenames.
828 */
829 memset(&sb, 0, sizeof(sb));
830 if (a == NULL)
831 a = do_lstat(conn, g.gl_pathv[i], 1);
832 if (a != NULL)
833 attrib_to_stat(a, &sb);
834 lname = ls_file(fname, &sb, 1, (lflag & LS_SI_UNITS));
835 printf("%s\n", lname); 840 printf("%s\n", lname);
836 xfree(lname); 841 xfree(lname);
837 } else { 842 } else {
@@ -852,7 +857,7 @@ do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
852 if (g.gl_pathc) 857 if (g.gl_pathc)
853 globfree(&g); 858 globfree(&g);
854 859
855 return (0); 860 return 0;
856} 861}
857 862
858static int 863static int
@@ -1108,7 +1113,7 @@ makeargv(const char *arg, int *argcp, int sloppy, char *lastquote,
1108 1113
1109static int 1114static int
1110parse_args(const char **cpp, int *pflag, int *rflag, int *lflag, int *iflag, 1115parse_args(const char **cpp, int *pflag, int *rflag, int *lflag, int *iflag,
1111 int *hflag, unsigned long *n_arg, char **path1, char **path2) 1116 int *hflag, int *sflag, unsigned long *n_arg, char **path1, char **path2)
1112{ 1117{
1113 const char *cmd, *cp = *cpp; 1118 const char *cmd, *cp = *cpp;
1114 char *cp2, **argv; 1119 char *cp2, **argv;
@@ -1158,7 +1163,8 @@ parse_args(const char **cpp, int *pflag, int *rflag, int *lflag, int *iflag,
1158 switch (cmdnum) { 1163 switch (cmdnum) {
1159 case I_GET: 1164 case I_GET:
1160 case I_PUT: 1165 case I_PUT:
1161 if ((optidx = parse_getput_flags(cmd, argv, argc, pflag, rflag)) == -1) 1166 if ((optidx = parse_getput_flags(cmd, argv, argc,
1167 pflag, rflag)) == -1)
1162 return -1; 1168 return -1;
1163 /* Get first pathname (mandatory) */ 1169 /* Get first pathname (mandatory) */
1164 if (argc - optidx < 1) { 1170 if (argc - optidx < 1) {
@@ -1174,8 +1180,11 @@ parse_args(const char **cpp, int *pflag, int *rflag, int *lflag, int *iflag,
1174 undo_glob_escape(*path2); 1180 undo_glob_escape(*path2);
1175 } 1181 }
1176 break; 1182 break;
1177 case I_RENAME: 1183 case I_LINK:
1184 if ((optidx = parse_link_flags(cmd, argv, argc, sflag)) == -1)
1185 return -1;
1178 case I_SYMLINK: 1186 case I_SYMLINK:
1187 case I_RENAME:
1179 if (argc - optidx < 2) { 1188 if (argc - optidx < 2) {
1180 error("You must specify two paths after a %s " 1189 error("You must specify two paths after a %s "
1181 "command.", cmd); 1190 "command.", cmd);
@@ -1278,7 +1287,8 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
1278 int err_abort) 1287 int err_abort)
1279{ 1288{
1280 char *path1, *path2, *tmp; 1289 char *path1, *path2, *tmp;
1281 int pflag = 0, rflag = 0, lflag = 0, iflag = 0, hflag = 0, cmdnum, i; 1290 int pflag = 0, rflag = 0, lflag = 0, iflag = 0, hflag = 0, sflag = 0;
1291 int cmdnum, i;
1282 unsigned long n_arg = 0; 1292 unsigned long n_arg = 0;
1283 Attrib a, *aa; 1293 Attrib a, *aa;
1284 char path_buf[MAXPATHLEN]; 1294 char path_buf[MAXPATHLEN];
@@ -1286,8 +1296,8 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
1286 glob_t g; 1296 glob_t g;
1287 1297
1288 path1 = path2 = NULL; 1298 path1 = path2 = NULL;
1289 cmdnum = parse_args(&cmd, &pflag, &rflag, &lflag, &iflag, &hflag, &n_arg, 1299 cmdnum = parse_args(&cmd, &pflag, &rflag, &lflag, &iflag, &hflag,
1290 &path1, &path2); 1300 &sflag, &n_arg, &path1, &path2);
1291 1301
1292 if (iflag != 0) 1302 if (iflag != 0)
1293 err_abort = 0; 1303 err_abort = 0;
@@ -1315,8 +1325,11 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
1315 err = do_rename(conn, path1, path2); 1325 err = do_rename(conn, path1, path2);
1316 break; 1326 break;
1317 case I_SYMLINK: 1327 case I_SYMLINK:
1328 sflag = 1;
1329 case I_LINK:
1330 path1 = make_absolute(path1, *pwd);
1318 path2 = make_absolute(path2, *pwd); 1331 path2 = make_absolute(path2, *pwd);
1319 err = do_symlink(conn, path1, path2); 1332 err = (sflag ? do_symlink : do_hardlink)(conn, path1, path2);
1320 break; 1333 break;
1321 case I_RM: 1334 case I_RM:
1322 path1 = make_absolute(path1, *pwd); 1335 path1 = make_absolute(path1, *pwd);
@@ -1745,6 +1758,7 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path,
1745 case '"': 1758 case '"':
1746 case '\\': 1759 case '\\':
1747 case '\t': 1760 case '\t':
1761 case '[':
1748 case ' ': 1762 case ' ':
1749 if (quote == '\0' || tmp2[i] == quote) { 1763 if (quote == '\0' || tmp2[i] == quote) {
1750 if (el_insertstr(el, ins) == -1) 1764 if (el_insertstr(el, ins) == -1)
@@ -1874,7 +1888,7 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
1874 1888
1875 /* Tab Completion */ 1889 /* Tab Completion */
1876 el_set(el, EL_ADDFN, "ftp-complete", 1890 el_set(el, EL_ADDFN, "ftp-complete",
1877 "Context senstive argument completion", complete); 1891 "Context sensitive argument completion", complete);
1878 complete_ctx.conn = conn; 1892 complete_ctx.conn = conn;
1879 complete_ctx.remote_pathp = &remote_path; 1893 complete_ctx.remote_pathp = &remote_path;
1880 el_set(el, EL_CLIENTDATA, (void*)&complete_ctx); 1894 el_set(el, EL_CLIENTDATA, (void*)&complete_ctx);
@@ -2054,7 +2068,7 @@ usage(void)
2054 fprintf(stderr, 2068 fprintf(stderr,
2055 "usage: %s [-1246Cpqrv] [-B buffer_size] [-b batchfile] [-c cipher]\n" 2069 "usage: %s [-1246Cpqrv] [-B buffer_size] [-b batchfile] [-c cipher]\n"
2056 " [-D sftp_server_path] [-F ssh_config] " 2070 " [-D sftp_server_path] [-F ssh_config] "
2057 "[-i identity_file]\n" 2071 "[-i identity_file] [-l limit]\n"
2058 " [-o ssh_option] [-P port] [-R num_requests] " 2072 " [-o ssh_option] [-P port] [-R num_requests] "
2059 "[-S program]\n" 2073 "[-S program]\n"
2060 " [-s subsystem | sftp_server] host\n" 2074 " [-s subsystem | sftp_server] host\n"
@@ -2073,6 +2087,7 @@ main(int argc, char **argv)
2073 int debug_level = 0, sshver = 2; 2087 int debug_level = 0, sshver = 2;
2074 char *file1 = NULL, *sftp_server = NULL; 2088 char *file1 = NULL, *sftp_server = NULL;
2075 char *ssh_program = _PATH_SSH_PROGRAM, *sftp_direct = NULL; 2089 char *ssh_program = _PATH_SSH_PROGRAM, *sftp_direct = NULL;
2090 const char *errstr;
2076 LogLevel ll = SYSLOG_LEVEL_INFO; 2091 LogLevel ll = SYSLOG_LEVEL_INFO;
2077 arglist args; 2092 arglist args;
2078 extern int optind; 2093 extern int optind;
@@ -2080,6 +2095,7 @@ main(int argc, char **argv)
2080 struct sftp_conn *conn; 2095 struct sftp_conn *conn;
2081 size_t copy_buffer_len = DEFAULT_COPY_BUFLEN; 2096 size_t copy_buffer_len = DEFAULT_COPY_BUFLEN;
2082 size_t num_requests = DEFAULT_NUM_REQUESTS; 2097 size_t num_requests = DEFAULT_NUM_REQUESTS;
2098 long long limit_kbps = 0;
2083 2099
2084 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ 2100 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
2085 sanitise_stdfd(); 2101 sanitise_stdfd();
@@ -2097,7 +2113,7 @@ main(int argc, char **argv)
2097 infile = stdin; 2113 infile = stdin;
2098 2114
2099 while ((ch = getopt(argc, argv, 2115 while ((ch = getopt(argc, argv,
2100 "1246hpqrvCc:D:i:o:s:S:b:B:F:P:R:")) != -1) { 2116 "1246hpqrvCc:D:i:l:o:s:S:b:B:F:P:R:")) != -1) {
2101 switch (ch) { 2117 switch (ch) {
2102 /* Passed through to ssh(1) */ 2118 /* Passed through to ssh(1) */
2103 case '4': 2119 case '4':
@@ -2158,6 +2174,13 @@ main(int argc, char **argv)
2158 case 'D': 2174 case 'D':
2159 sftp_direct = optarg; 2175 sftp_direct = optarg;
2160 break; 2176 break;
2177 case 'l':
2178 limit_kbps = strtonum(optarg, 1, 100 * 1024 * 1024,
2179 &errstr);
2180 if (errstr != NULL)
2181 usage();
2182 limit_kbps *= 1024; /* kbps */
2183 break;
2161 case 'r': 2184 case 'r':
2162 global_rflag = 1; 2185 global_rflag = 1;
2163 break; 2186 break;
@@ -2235,7 +2258,7 @@ main(int argc, char **argv)
2235 } 2258 }
2236 freeargs(&args); 2259 freeargs(&args);
2237 2260
2238 conn = do_init(in, out, copy_buffer_len, num_requests); 2261 conn = do_init(in, out, copy_buffer_len, num_requests, limit_kbps);
2239 if (conn == NULL) 2262 if (conn == NULL)
2240 fatal("Couldn't initialise connection to server"); 2263 fatal("Couldn't initialise connection to server");
2241 2264
diff --git a/ssh-add.0 b/ssh-add.0
index 86f3994c4..bf62ca905 100644
--- a/ssh-add.0
+++ b/ssh-add.0
@@ -1,7 +1,7 @@
1SSH-ADD(1) OpenBSD Reference Manual SSH-ADD(1) 1SSH-ADD(1) OpenBSD Reference Manual SSH-ADD(1)
2 2
3NAME 3NAME
4 ssh-add - adds RSA or DSA identities to the authentication agent 4 ssh-add - adds private key identities to the authentication agent
5 5
6SYNOPSIS 6SYNOPSIS
7 ssh-add [-cDdLlXx] [-t life] [file ...] 7 ssh-add [-cDdLlXx] [-t life] [file ...]
@@ -9,10 +9,10 @@ SYNOPSIS
9 ssh-add -e pkcs11 9 ssh-add -e pkcs11
10 10
11DESCRIPTION 11DESCRIPTION
12 ssh-add adds RSA or DSA identities to the authentication agent, 12 ssh-add adds private key identities to the authentication agent,
13 ssh-agent(1). When run without arguments, it adds the files 13 ssh-agent(1). When run without arguments, it adds the files
14 ~/.ssh/id_rsa, ~/.ssh/id_dsa and ~/.ssh/identity. After loading a 14 ~/.ssh/id_rsa, ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and ~/.ssh/identity. After
15 private key, ssh-add will try to load corresponding certificate 15 loading a private key, ssh-add will try to load corresponding certificate
16 information from the filename obtained by appending -cert.pub to the name 16 information from the filename obtained by appending -cert.pub to the name
17 of the private key file. Alternative file names can be given on the 17 of the private key file. Alternative file names can be given on the
18 command line. 18 command line.
@@ -87,6 +87,10 @@ FILES
87 Contains the protocol version 2 DSA authentication identity of 87 Contains the protocol version 2 DSA authentication identity of
88 the user. 88 the user.
89 89
90 ~/.ssh/id_ecdsa
91 Contains the protocol version 2 ECDSA authentication identity of
92 the user.
93
90 ~/.ssh/id_rsa 94 ~/.ssh/id_rsa
91 Contains the protocol version 2 RSA authentication identity of 95 Contains the protocol version 2 RSA authentication identity of
92 the user. 96 the user.
@@ -94,7 +98,7 @@ FILES
94 Identity files should not be readable by anyone but the user. Note that 98 Identity files should not be readable by anyone but the user. Note that
95 ssh-add ignores identity files if they are accessible by others. 99 ssh-add ignores identity files if they are accessible by others.
96 100
97DIAGNOSTICS 101EXIT STATUS
98 Exit status is 0 on success, 1 if the specified command fails, and 2 if 102 Exit status is 0 on success, 1 if the specified command fails, and 2 if
99 ssh-add is unable to contact the authentication agent. 103 ssh-add is unable to contact the authentication agent.
100 104
@@ -108,4 +112,4 @@ AUTHORS
108 created OpenSSH. Markus Friedl contributed the support for SSH protocol 112 created OpenSSH. Markus Friedl contributed the support for SSH protocol
109 versions 1.5 and 2.0. 113 versions 1.5 and 2.0.
110 114
111OpenBSD 4.8 March 5, 2010 OpenBSD 4.8 115OpenBSD 4.8 October 28, 2010 OpenBSD 4.8
diff --git a/ssh-add.1 b/ssh-add.1
index d7cc53101..fd48ff98f 100644
--- a/ssh-add.1
+++ b/ssh-add.1
@@ -1,6 +1,4 @@
1.\" $OpenBSD: ssh-add.1,v 1.52 2010/03/05 10:28:21 djm Exp $ 1.\" $OpenBSD: ssh-add.1,v 1.55 2010/10/28 18:33:28 jmc Exp $
2.\"
3.\" -*- nroff -*-
4.\" 2.\"
5.\" Author: Tatu Ylonen <ylo@cs.hut.fi> 3.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
6.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -37,12 +35,12 @@
37.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 35.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
38.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39.\" 37.\"
40.Dd $Mdocdate: March 5 2010 $ 38.Dd $Mdocdate: October 28 2010 $
41.Dt SSH-ADD 1 39.Dt SSH-ADD 1
42.Os 40.Os
43.Sh NAME 41.Sh NAME
44.Nm ssh-add 42.Nm ssh-add
45.Nd adds RSA or DSA identities to the authentication agent 43.Nd adds private key identities to the authentication agent
46.Sh SYNOPSIS 44.Sh SYNOPSIS
47.Nm ssh-add 45.Nm ssh-add
48.Op Fl cDdLlXx 46.Op Fl cDdLlXx
@@ -54,11 +52,12 @@
54.Fl e Ar pkcs11 52.Fl e Ar pkcs11
55.Sh DESCRIPTION 53.Sh DESCRIPTION
56.Nm 54.Nm
57adds RSA or DSA identities to the authentication agent, 55adds private key identities to the authentication agent,
58.Xr ssh-agent 1 . 56.Xr ssh-agent 1 .
59When run without arguments, it adds the files 57When run without arguments, it adds the files
60.Pa ~/.ssh/id_rsa , 58.Pa ~/.ssh/id_rsa ,
61.Pa ~/.ssh/id_dsa 59.Pa ~/.ssh/id_dsa ,
60.Pa ~/.ssh/id_ecdsa
62and 61and
63.Pa ~/.ssh/identity . 62.Pa ~/.ssh/identity .
64After loading a private key, 63After loading a private key,
@@ -165,6 +164,8 @@ socket used to communicate with the agent.
165Contains the protocol version 1 RSA authentication identity of the user. 164Contains the protocol version 1 RSA authentication identity of the user.
166.It Pa ~/.ssh/id_dsa 165.It Pa ~/.ssh/id_dsa
167Contains the protocol version 2 DSA authentication identity of the user. 166Contains the protocol version 2 DSA authentication identity of the user.
167.It Pa ~/.ssh/id_ecdsa
168Contains the protocol version 2 ECDSA authentication identity of the user.
168.It Pa ~/.ssh/id_rsa 169.It Pa ~/.ssh/id_rsa
169Contains the protocol version 2 RSA authentication identity of the user. 170Contains the protocol version 2 RSA authentication identity of the user.
170.El 171.El
@@ -173,7 +174,7 @@ Identity files should not be readable by anyone but the user.
173Note that 174Note that
174.Nm 175.Nm
175ignores identity files if they are accessible by others. 176ignores identity files if they are accessible by others.
176.Sh DIAGNOSTICS 177.Sh EXIT STATUS
177Exit status is 0 on success, 1 if the specified command fails, 178Exit status is 0 on success, 1 if the specified command fails,
178and 2 if 179and 2 if
179.Nm 180.Nm
diff --git a/ssh-add.c b/ssh-add.c
index fb641ec48..125d6645b 100644
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-add.c,v 1.96 2010/05/14 00:47:22 djm Exp $ */ 1/* $OpenBSD: ssh-add.c,v 1.100 2010/08/31 12:33:38 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -70,6 +70,9 @@ extern char *__progname;
70static char *default_files[] = { 70static char *default_files[] = {
71 _PATH_SSH_CLIENT_ID_RSA, 71 _PATH_SSH_CLIENT_ID_RSA,
72 _PATH_SSH_CLIENT_ID_DSA, 72 _PATH_SSH_CLIENT_ID_DSA,
73#ifdef OPENSSL_HAS_ECC
74 _PATH_SSH_CLIENT_ID_ECDSA,
75#endif
73 _PATH_SSH_CLIENT_IDENTITY, 76 _PATH_SSH_CLIENT_IDENTITY,
74 NULL 77 NULL
75}; 78};
@@ -372,7 +375,7 @@ main(int argc, char **argv)
372 init_rng(); 375 init_rng();
373 seed_rng(); 376 seed_rng();
374 377
375 SSLeay_add_all_algorithms(); 378 OpenSSL_add_all_algorithms();
376 379
377 /* At first, get a connection to the authentication agent. */ 380 /* At first, get a connection to the authentication agent. */
378 ac = ssh_get_authentication_connection(); 381 ac = ssh_get_authentication_connection();
diff --git a/ssh-agent.0 b/ssh-agent.0
index dfc82a966..7fe1560d3 100644
--- a/ssh-agent.0
+++ b/ssh-agent.0
@@ -9,17 +9,18 @@ SYNOPSIS
9 9
10DESCRIPTION 10DESCRIPTION
11 ssh-agent is a program to hold private keys used for public key 11 ssh-agent is a program to hold private keys used for public key
12 authentication (RSA, DSA). The idea is that ssh-agent is started in the 12 authentication (RSA, DSA, ECDSA). The idea is that ssh-agent is started
13 beginning of an X-session or a login session, and all other windows or 13 in the beginning of an X-session or a login session, and all other
14 programs are started as clients to the ssh-agent program. Through use of 14 windows or programs are started as clients to the ssh-agent program.
15 environment variables the agent can be located and automatically used for 15 Through use of environment variables the agent can be located and
16 authentication when logging in to other machines using ssh(1). 16 automatically used for authentication when logging in to other machines
17 using ssh(1).
17 18
18 The options are as follows: 19 The options are as follows:
19 20
20 -a bind_address 21 -a bind_address
21 Bind the agent to the UNIX-domain socket bind_address. The 22 Bind the agent to the UNIX-domain socket bind_address. The
22 default is /tmp/ssh-XXXXXXXXXX/agent.<ppid>. 23 default is $TMPDIR/ssh-XXXXXXXXXX/agent.<ppid>.
23 24
24 -c Generate C-shell commands on stdout. This is the default if 25 -c Generate C-shell commands on stdout. This is the default if
25 SHELL looks like it's a csh style of shell. 26 SHELL looks like it's a csh style of shell.
@@ -45,13 +46,13 @@ DESCRIPTION
45 46
46 The agent initially does not have any private keys. Keys are added using 47 The agent initially does not have any private keys. Keys are added using
47 ssh-add(1). When executed without arguments, ssh-add(1) adds the files 48 ssh-add(1). When executed without arguments, ssh-add(1) adds the files
48 ~/.ssh/id_rsa, ~/.ssh/id_dsa and ~/.ssh/identity. If the identity has a 49 ~/.ssh/id_rsa, ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and ~/.ssh/identity. If
49 passphrase, ssh-add(1) asks for the passphrase on the terminal if it has 50 the identity has a passphrase, ssh-add(1) asks for the passphrase on the
50 one or from a small X11 program if running under X11. If neither of 51 terminal if it has one or from a small X11 program if running under X11.
51 these is the case then the authentication will fail. It then sends the 52 If neither of these is the case then the authentication will fail. It
52 identity to the agent. Several identities can be stored in the agent; 53 then sends the identity to the agent. Several identities can be stored
53 the agent can automatically use any of these identities. ssh-add -l 54 in the agent; the agent can automatically use any of these identities.
54 displays the identities currently held by the agent. 55 ssh-add -l displays the identities currently held by the agent.
55 56
56 The idea is that the agent is run in the user's local PC, laptop, or 57 The idea is that the agent is run in the user's local PC, laptop, or
57 terminal. Authentication data need not be stored on any other machine, 58 terminal. Authentication data need not be stored on any other machine,
@@ -95,11 +96,15 @@ FILES
95 Contains the protocol version 2 DSA authentication identity of 96 Contains the protocol version 2 DSA authentication identity of
96 the user. 97 the user.
97 98
99 ~/.ssh/id_ecdsa
100 Contains the protocol version 2 ECDSA authentication identity of
101 the user.
102
98 ~/.ssh/id_rsa 103 ~/.ssh/id_rsa
99 Contains the protocol version 2 RSA authentication identity of 104 Contains the protocol version 2 RSA authentication identity of
100 the user. 105 the user.
101 106
102 /tmp/ssh-XXXXXXXXXX/agent.<ppid> 107 $TMPDIR/ssh-XXXXXXXXXX/agent.<ppid>
103 UNIX-domain sockets used to contain the connection to the 108 UNIX-domain sockets used to contain the connection to the
104 authentication agent. These sockets should only be readable by 109 authentication agent. These sockets should only be readable by
105 the owner. The sockets should get automatically removed when the 110 the owner. The sockets should get automatically removed when the
@@ -115,4 +120,4 @@ AUTHORS
115 created OpenSSH. Markus Friedl contributed the support for SSH protocol 120 created OpenSSH. Markus Friedl contributed the support for SSH protocol
116 versions 1.5 and 2.0. 121 versions 1.5 and 2.0.
117 122
118OpenBSD 4.8 January 17, 2010 OpenBSD 4.8 123OpenBSD 4.8 November 21, 2010 OpenBSD 4.8
diff --git a/ssh-agent.1 b/ssh-agent.1
index f65e8e625..bb801c902 100644
--- a/ssh-agent.1
+++ b/ssh-agent.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ssh-agent.1,v 1.50 2010/01/17 21:49:09 tedu Exp $ 1.\" $OpenBSD: ssh-agent.1,v 1.53 2010/11/21 01:01:13 djm Exp $
2.\" 2.\"
3.\" Author: Tatu Ylonen <ylo@cs.hut.fi> 3.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -34,7 +34,7 @@
34.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36.\" 36.\"
37.Dd $Mdocdate: January 17 2010 $ 37.Dd $Mdocdate: November 21 2010 $
38.Dt SSH-AGENT 1 38.Dt SSH-AGENT 1
39.Os 39.Os
40.Sh NAME 40.Sh NAME
@@ -42,18 +42,18 @@
42.Nd authentication agent 42.Nd authentication agent
43.Sh SYNOPSIS 43.Sh SYNOPSIS
44.Nm ssh-agent 44.Nm ssh-agent
45.Op Fl c Li | Fl s 45.Op Fl c | s
46.Op Fl d 46.Op Fl d
47.Op Fl a Ar bind_address 47.Op Fl a Ar bind_address
48.Op Fl t Ar life 48.Op Fl t Ar life
49.Op Ar command Op Ar arg ... 49.Op Ar command Op Ar arg ...
50.Nm ssh-agent 50.Nm ssh-agent
51.Op Fl c Li | Fl s 51.Op Fl c | s
52.Fl k 52.Fl k
53.Sh DESCRIPTION 53.Sh DESCRIPTION
54.Nm 54.Nm
55is a program to hold private keys used for public key authentication 55is a program to hold private keys used for public key authentication
56(RSA, DSA). 56(RSA, DSA, ECDSA).
57The idea is that 57The idea is that
58.Nm 58.Nm
59is started in the beginning of an X-session or a login session, and 59is started in the beginning of an X-session or a login session, and
@@ -72,7 +72,7 @@ Bind the agent to the
72socket 72socket
73.Ar bind_address . 73.Ar bind_address .
74The default is 74The default is
75.Pa /tmp/ssh-XXXXXXXXXX/agent.\*(Ltppid\*(Gt . 75.Pa $TMPDIR/ssh-XXXXXXXXXX/agent.\*(Ltppid\*(Gt .
76.It Fl c 76.It Fl c
77Generate C-shell commands on 77Generate C-shell commands on
78.Dv stdout . 78.Dv stdout .
@@ -114,7 +114,8 @@ When executed without arguments,
114.Xr ssh-add 1 114.Xr ssh-add 1
115adds the files 115adds the files
116.Pa ~/.ssh/id_rsa , 116.Pa ~/.ssh/id_rsa ,
117.Pa ~/.ssh/id_dsa 117.Pa ~/.ssh/id_dsa ,
118.Pa ~/.ssh/id_ecdsa
118and 119and
119.Pa ~/.ssh/identity . 120.Pa ~/.ssh/identity .
120If the identity has a passphrase, 121If the identity has a passphrase,
@@ -187,9 +188,11 @@ line terminates.
187Contains the protocol version 1 RSA authentication identity of the user. 188Contains the protocol version 1 RSA authentication identity of the user.
188.It Pa ~/.ssh/id_dsa 189.It Pa ~/.ssh/id_dsa
189Contains the protocol version 2 DSA authentication identity of the user. 190Contains the protocol version 2 DSA authentication identity of the user.
191.It Pa ~/.ssh/id_ecdsa
192Contains the protocol version 2 ECDSA authentication identity of the user.
190.It Pa ~/.ssh/id_rsa 193.It Pa ~/.ssh/id_rsa
191Contains the protocol version 2 RSA authentication identity of the user. 194Contains the protocol version 2 RSA authentication identity of the user.
192.It Pa /tmp/ssh-XXXXXXXXXX/agent.\*(Ltppid\*(Gt 195.It Pa $TMPDIR/ssh-XXXXXXXXXX/agent.\*(Ltppid\*(Gt
193.Ux Ns -domain 196.Ux Ns -domain
194sockets used to contain the connection to the authentication agent. 197sockets used to contain the connection to the authentication agent.
195These sockets should only be readable by the owner. 198These sockets should only be readable by the owner.
diff --git a/ssh-agent.c b/ssh-agent.c
index 2c0e28696..afba413d7 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-agent.c,v 1.166 2010/04/16 01:47:26 djm Exp $ */ 1/* $OpenBSD: ssh-agent.c,v 1.171 2010/11/21 01:01:13 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -468,6 +468,11 @@ process_add_identity(SocketEntry *e, int version)
468 int type, success = 0, death = 0, confirm = 0; 468 int type, success = 0, death = 0, confirm = 0;
469 char *type_name, *comment; 469 char *type_name, *comment;
470 Key *k = NULL; 470 Key *k = NULL;
471#ifdef OPENSSL_HAS_ECC
472 BIGNUM *exponent;
473 EC_POINT *q;
474 char *curve;
475#endif
471 u_char *cert; 476 u_char *cert;
472 u_int len; 477 u_int len;
473 478
@@ -490,7 +495,6 @@ process_add_identity(SocketEntry *e, int version)
490 case 2: 495 case 2:
491 type_name = buffer_get_string(&e->request, NULL); 496 type_name = buffer_get_string(&e->request, NULL);
492 type = key_type_from_name(type_name); 497 type = key_type_from_name(type_name);
493 xfree(type_name);
494 switch (type) { 498 switch (type) {
495 case KEY_DSA: 499 case KEY_DSA:
496 k = key_new_private(type); 500 k = key_new_private(type);
@@ -509,6 +513,59 @@ process_add_identity(SocketEntry *e, int version)
509 key_add_private(k); 513 key_add_private(k);
510 buffer_get_bignum2(&e->request, k->dsa->priv_key); 514 buffer_get_bignum2(&e->request, k->dsa->priv_key);
511 break; 515 break;
516#ifdef OPENSSL_HAS_ECC
517 case KEY_ECDSA:
518 k = key_new_private(type);
519 k->ecdsa_nid = key_ecdsa_nid_from_name(type_name);
520 curve = buffer_get_string(&e->request, NULL);
521 if (k->ecdsa_nid != key_curve_name_to_nid(curve))
522 fatal("%s: curve names mismatch", __func__);
523 xfree(curve);
524 k->ecdsa = EC_KEY_new_by_curve_name(k->ecdsa_nid);
525 if (k->ecdsa == NULL)
526 fatal("%s: EC_KEY_new_by_curve_name failed",
527 __func__);
528 q = EC_POINT_new(EC_KEY_get0_group(k->ecdsa));
529 if (q == NULL)
530 fatal("%s: BN_new failed", __func__);
531 if ((exponent = BN_new()) == NULL)
532 fatal("%s: BN_new failed", __func__);
533 buffer_get_ecpoint(&e->request,
534 EC_KEY_get0_group(k->ecdsa), q);
535 buffer_get_bignum2(&e->request, exponent);
536 if (EC_KEY_set_public_key(k->ecdsa, q) != 1)
537 fatal("%s: EC_KEY_set_public_key failed",
538 __func__);
539 if (EC_KEY_set_private_key(k->ecdsa, exponent) != 1)
540 fatal("%s: EC_KEY_set_private_key failed",
541 __func__);
542 if (key_ec_validate_public(EC_KEY_get0_group(k->ecdsa),
543 EC_KEY_get0_public_key(k->ecdsa)) != 0)
544 fatal("%s: bad ECDSA public key", __func__);
545 if (key_ec_validate_private(k->ecdsa) != 0)
546 fatal("%s: bad ECDSA private key", __func__);
547 BN_clear_free(exponent);
548 EC_POINT_free(q);
549 break;
550 case KEY_ECDSA_CERT:
551 cert = buffer_get_string(&e->request, &len);
552 if ((k = key_from_blob(cert, len)) == NULL)
553 fatal("Certificate parse failed");
554 xfree(cert);
555 key_add_private(k);
556 if ((exponent = BN_new()) == NULL)
557 fatal("%s: BN_new failed", __func__);
558 buffer_get_bignum2(&e->request, exponent);
559 if (EC_KEY_set_private_key(k->ecdsa, exponent) != 1)
560 fatal("%s: EC_KEY_set_private_key failed",
561 __func__);
562 if (key_ec_validate_public(EC_KEY_get0_group(k->ecdsa),
563 EC_KEY_get0_public_key(k->ecdsa)) != 0 ||
564 key_ec_validate_private(k->ecdsa) != 0)
565 fatal("%s: bad ECDSA key", __func__);
566 BN_clear_free(exponent);
567 break;
568#endif /* OPENSSL_HAS_ECC */
512 case KEY_RSA: 569 case KEY_RSA:
513 k = key_new_private(type); 570 k = key_new_private(type);
514 buffer_get_bignum2(&e->request, k->rsa->n); 571 buffer_get_bignum2(&e->request, k->rsa->n);
@@ -534,9 +591,11 @@ process_add_identity(SocketEntry *e, int version)
534 buffer_get_bignum2(&e->request, k->rsa->q); 591 buffer_get_bignum2(&e->request, k->rsa->q);
535 break; 592 break;
536 default: 593 default:
594 xfree(type_name);
537 buffer_clear(&e->request); 595 buffer_clear(&e->request);
538 goto send; 596 goto send;
539 } 597 }
598 xfree(type_name);
540 break; 599 break;
541 } 600 }
542 /* enable blinding */ 601 /* enable blinding */
@@ -1092,7 +1151,7 @@ main(int ac, char **av)
1092 prctl(PR_SET_DUMPABLE, 0); 1151 prctl(PR_SET_DUMPABLE, 0);
1093#endif 1152#endif
1094 1153
1095 SSLeay_add_all_algorithms(); 1154 OpenSSL_add_all_algorithms();
1096 1155
1097 __progname = ssh_get_progname(av[0]); 1156 __progname = ssh_get_progname(av[0]);
1098 init_rng(); 1157 init_rng();
@@ -1173,7 +1232,7 @@ main(int ac, char **av)
1173 1232
1174 if (agentsocket == NULL) { 1233 if (agentsocket == NULL) {
1175 /* Create private directory for agent socket */ 1234 /* Create private directory for agent socket */
1176 strlcpy(socket_dir, "/tmp/ssh-XXXXXXXXXX", sizeof socket_dir); 1235 mktemp_proto(socket_dir, sizeof(socket_dir));
1177 if (mkdtemp(socket_dir) == NULL) { 1236 if (mkdtemp(socket_dir) == NULL) {
1178 perror("mkdtemp: private socket dir"); 1237 perror("mkdtemp: private socket dir");
1179 exit(1); 1238 exit(1);
diff --git a/ssh-dss.c b/ssh-dss.c
index 175e4d030..ede5e21e5 100644
--- a/ssh-dss.c
+++ b/ssh-dss.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-dss.c,v 1.26 2010/04/16 01:47:26 djm Exp $ */ 1/* $OpenBSD: ssh-dss.c,v 1.27 2010/08/31 09:58:37 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -133,7 +133,7 @@ ssh_dss_verify(const Key *key, const u_char *signature, u_int signaturelen,
133 char *ktype; 133 char *ktype;
134 buffer_init(&b); 134 buffer_init(&b);
135 buffer_append(&b, signature, signaturelen); 135 buffer_append(&b, signature, signaturelen);
136 ktype = buffer_get_string(&b, NULL); 136 ktype = buffer_get_cstring(&b, NULL);
137 if (strcmp("ssh-dss", ktype) != 0) { 137 if (strcmp("ssh-dss", ktype) != 0) {
138 error("ssh_dss_verify: cannot handle type %s", ktype); 138 error("ssh_dss_verify: cannot handle type %s", ktype);
139 buffer_free(&b); 139 buffer_free(&b);
diff --git a/ssh-ecdsa.c b/ssh-ecdsa.c
new file mode 100644
index 000000000..c8276b460
--- /dev/null
+++ b/ssh-ecdsa.c
@@ -0,0 +1,168 @@
1/* $OpenBSD: ssh-ecdsa.c,v 1.4 2010/09/10 01:04:10 djm Exp $ */
2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2010 Damien Miller. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include "includes.h"
28
29#ifdef OPENSSL_HAS_ECC
30
31#include <sys/types.h>
32
33#include <openssl/bn.h>
34#include <openssl/ec.h>
35#include <openssl/ecdsa.h>
36#include <openssl/evp.h>
37
38#include <string.h>
39
40#include "xmalloc.h"
41#include "buffer.h"
42#include "compat.h"
43#include "log.h"
44#include "key.h"
45
46int
47ssh_ecdsa_sign(const Key *key, u_char **sigp, u_int *lenp,
48 const u_char *data, u_int datalen)
49{
50 ECDSA_SIG *sig;
51 const EVP_MD *evp_md;
52 EVP_MD_CTX md;
53 u_char digest[EVP_MAX_MD_SIZE];
54 u_int len, dlen;
55 Buffer b, bb;
56
57 if (key == NULL || key->ecdsa == NULL ||
58 (key->type != KEY_ECDSA && key->type != KEY_ECDSA_CERT)) {
59 error("%s: no ECDSA key", __func__);
60 return -1;
61 }
62 evp_md = key_ec_nid_to_evpmd(key->ecdsa_nid);
63 EVP_DigestInit(&md, evp_md);
64 EVP_DigestUpdate(&md, data, datalen);
65 EVP_DigestFinal(&md, digest, &dlen);
66
67 sig = ECDSA_do_sign(digest, dlen, key->ecdsa);
68 memset(digest, 'd', sizeof(digest));
69
70 if (sig == NULL) {
71 error("%s: sign failed", __func__);
72 return -1;
73 }
74
75 buffer_init(&bb);
76 buffer_put_bignum2(&bb, sig->r);
77 buffer_put_bignum2(&bb, sig->s);
78 ECDSA_SIG_free(sig);
79
80 buffer_init(&b);
81 buffer_put_cstring(&b, key_ssh_name_plain(key));
82 buffer_put_string(&b, buffer_ptr(&bb), buffer_len(&bb));
83 buffer_free(&bb);
84 len = buffer_len(&b);
85 if (lenp != NULL)
86 *lenp = len;
87 if (sigp != NULL) {
88 *sigp = xmalloc(len);
89 memcpy(*sigp, buffer_ptr(&b), len);
90 }
91 buffer_free(&b);
92
93 return 0;
94}
95int
96ssh_ecdsa_verify(const Key *key, const u_char *signature, u_int signaturelen,
97 const u_char *data, u_int datalen)
98{
99 ECDSA_SIG *sig;
100 const EVP_MD *evp_md;
101 EVP_MD_CTX md;
102 u_char digest[EVP_MAX_MD_SIZE], *sigblob;
103 u_int len, dlen;
104 int rlen, ret;
105 Buffer b, bb;
106 char *ktype;
107
108 if (key == NULL || key->ecdsa == NULL ||
109 (key->type != KEY_ECDSA && key->type != KEY_ECDSA_CERT)) {
110 error("%s: no ECDSA key", __func__);
111 return -1;
112 }
113 evp_md = key_ec_nid_to_evpmd(key->ecdsa_nid);
114
115 /* fetch signature */
116 buffer_init(&b);
117 buffer_append(&b, signature, signaturelen);
118 ktype = buffer_get_string(&b, NULL);
119 if (strcmp(key_ssh_name_plain(key), ktype) != 0) {
120 error("%s: cannot handle type %s", __func__, ktype);
121 buffer_free(&b);
122 xfree(ktype);
123 return -1;
124 }
125 xfree(ktype);
126 sigblob = buffer_get_string(&b, &len);
127 rlen = buffer_len(&b);
128 buffer_free(&b);
129 if (rlen != 0) {
130 error("%s: remaining bytes in signature %d", __func__, rlen);
131 xfree(sigblob);
132 return -1;
133 }
134
135 /* parse signature */
136 if ((sig = ECDSA_SIG_new()) == NULL)
137 fatal("%s: ECDSA_SIG_new failed", __func__);
138 if ((sig->r = BN_new()) == NULL ||
139 (sig->s = BN_new()) == NULL)
140 fatal("%s: BN_new failed", __func__);
141
142 buffer_init(&bb);
143 buffer_append(&bb, sigblob, len);
144 buffer_get_bignum2(&bb, sig->r);
145 buffer_get_bignum2(&bb, sig->s);
146 if (buffer_len(&bb) != 0)
147 fatal("%s: remaining bytes in inner sigblob", __func__);
148
149 /* clean up */
150 memset(sigblob, 0, len);
151 xfree(sigblob);
152
153 /* hash the data */
154 EVP_DigestInit(&md, evp_md);
155 EVP_DigestUpdate(&md, data, datalen);
156 EVP_DigestFinal(&md, digest, &dlen);
157
158 ret = ECDSA_do_verify(digest, dlen, sig, key->ecdsa);
159 memset(digest, 'd', sizeof(digest));
160
161 ECDSA_SIG_free(sig);
162
163 debug("%s: signature %s", __func__,
164 ret == 1 ? "correct" : ret == 0 ? "incorrect" : "error");
165 return ret;
166}
167
168#endif /* OPENSSL_HAS_ECC */
diff --git a/ssh-keygen.0 b/ssh-keygen.0
index fb7838724..e01ad16d9 100644
--- a/ssh-keygen.0
+++ b/ssh-keygen.0
@@ -28,18 +28,19 @@ SYNOPSIS
28DESCRIPTION 28DESCRIPTION
29 ssh-keygen generates, manages and converts authentication keys for 29 ssh-keygen generates, manages and converts authentication keys for
30 ssh(1). ssh-keygen can create RSA keys for use by SSH protocol version 1 30 ssh(1). ssh-keygen can create RSA keys for use by SSH protocol version 1
31 and RSA or DSA keys for use by SSH protocol version 2. The type of key 31 and DSA, ECDSA or RSA keys for use by SSH protocol version 2. The type
32 to be generated is specified with the -t option. If invoked without any 32 of key to be generated is specified with the -t option. If invoked
33 arguments, ssh-keygen will generate an RSA key for use in SSH protocol 2 33 without any arguments, ssh-keygen will generate an RSA key for use in SSH
34 connections. 34 protocol 2 connections.
35 35
36 ssh-keygen is also used to generate groups for use in Diffie-Hellman 36 ssh-keygen is also used to generate groups for use in Diffie-Hellman
37 group exchange (DH-GEX). See the MODULI GENERATION section for details. 37 group exchange (DH-GEX). See the MODULI GENERATION section for details.
38 38
39 Normally each user wishing to use SSH with RSA or DSA authentication runs 39 Normally each user wishing to use SSH with public key authentication runs
40 this once to create the authentication key in ~/.ssh/identity, 40 this once to create the authentication key in ~/.ssh/identity,
41 ~/.ssh/id_dsa or ~/.ssh/id_rsa. Additionally, the system administrator 41 ~/.ssh/id_ecdsa, ~/.ssh/id_dsa or ~/.ssh/id_rsa. Additionally, the
42 may use this to generate host keys, as seen in /etc/rc. 42 system administrator may use this to generate host keys, as seen in
43 /etc/rc.
43 44
44 Normally this program generates the key and asks for a file in which to 45 Normally this program generates the key and asks for a file in which to
45 store the private key. The public key is stored in a file with the same 46 store the private key. The public key is stored in a file with the same
@@ -255,8 +256,8 @@ DESCRIPTION
255 256
256 -t type 257 -t type
257 Specifies the type of key to create. The possible values are 258 Specifies the type of key to create. The possible values are
258 ``rsa1'' for protocol version 1 and ``rsa'' or ``dsa'' for 259 ``rsa1'' for protocol version 1 and ``dsa'', ``ecdsa'' or ``rsa''
259 protocol version 2. 260 for protocol version 2.
260 261
261 -V validity_interval 262 -V validity_interval
262 Specify a validity interval when signing a certificate. A 263 Specify a validity interval when signing a certificate. A
@@ -391,10 +392,9 @@ FILES
391 the user. This file should not be readable by anyone but the 392 the user. This file should not be readable by anyone but the
392 user. It is possible to specify a passphrase when generating the 393 user. It is possible to specify a passphrase when generating the
393 key; that passphrase will be used to encrypt the private part of 394 key; that passphrase will be used to encrypt the private part of
394 this file using 128-bit AES. This file is not automatically 395 this file using 3DES. This file is not automatically accessed by
395 accessed by ssh-keygen but it is offered as the default file for 396 ssh-keygen but it is offered as the default file for the private
396 the private key. ssh(1) will read this file when a login attempt 397 key. ssh(1) will read this file when a login attempt is made.
397 is made.
398 398
399 ~/.ssh/identity.pub 399 ~/.ssh/identity.pub
400 Contains the protocol version 1 RSA public key for 400 Contains the protocol version 1 RSA public key for
@@ -404,34 +404,21 @@ FILES
404 contents of this file secret. 404 contents of this file secret.
405 405
406 ~/.ssh/id_dsa 406 ~/.ssh/id_dsa
407 Contains the protocol version 2 DSA authentication identity of 407 ~/.ssh/id_ecdsa
408 the user. This file should not be readable by anyone but the
409 user. It is possible to specify a passphrase when generating the
410 key; that passphrase will be used to encrypt the private part of
411 this file using 128-bit AES. This file is not automatically
412 accessed by ssh-keygen but it is offered as the default file for
413 the private key. ssh(1) will read this file when a login attempt
414 is made.
415
416 ~/.ssh/id_dsa.pub
417 Contains the protocol version 2 DSA public key for
418 authentication. The contents of this file should be added to
419 ~/.ssh/authorized_keys on all machines where the user wishes to
420 log in using public key authentication. There is no need to keep
421 the contents of this file secret.
422
423 ~/.ssh/id_rsa 408 ~/.ssh/id_rsa
424 Contains the protocol version 2 RSA authentication identity of 409 Contains the protocol version 2 DSA, ECDSA or RSA authentication
425 the user. This file should not be readable by anyone but the 410 identity of the user. This file should not be readable by anyone
426 user. It is possible to specify a passphrase when generating the 411 but the user. It is possible to specify a passphrase when
427 key; that passphrase will be used to encrypt the private part of 412 generating the key; that passphrase will be used to encrypt the
428 this file using 128-bit AES. This file is not automatically 413 private part of this file using 128-bit AES. This file is not
429 accessed by ssh-keygen but it is offered as the default file for 414 automatically accessed by ssh-keygen but it is offered as the
430 the private key. ssh(1) will read this file when a login attempt 415 default file for the private key. ssh(1) will read this file
431 is made. 416 when a login attempt is made.
432 417
418 ~/.ssh/id_dsa.pub
419 ~/.ssh/id_ecdsa.pub
433 ~/.ssh/id_rsa.pub 420 ~/.ssh/id_rsa.pub
434 Contains the protocol version 2 RSA public key for 421 Contains the protocol version 2 DSA, ECDSA or RSA public key for
435 authentication. The contents of this file should be added to 422 authentication. The contents of this file should be added to
436 ~/.ssh/authorized_keys on all machines where the user wishes to 423 ~/.ssh/authorized_keys on all machines where the user wishes to
437 log in using public key authentication. There is no need to keep 424 log in using public key authentication. There is no need to keep
@@ -453,4 +440,4 @@ AUTHORS
453 created OpenSSH. Markus Friedl contributed the support for SSH protocol 440 created OpenSSH. Markus Friedl contributed the support for SSH protocol
454 versions 1.5 and 2.0. 441 versions 1.5 and 2.0.
455 442
456OpenBSD 4.8 August 4, 2010 OpenBSD 4.8 443OpenBSD 4.8 October 28, 2010 OpenBSD 4.8
diff --git a/ssh-keygen.1 b/ssh-keygen.1
index 9acd8f8c9..205f741b8 100644
--- a/ssh-keygen.1
+++ b/ssh-keygen.1
@@ -1,6 +1,4 @@
1.\" $OpenBSD: ssh-keygen.1,v 1.98 2010/08/04 06:07:11 djm Exp $ 1.\" $OpenBSD: ssh-keygen.1,v 1.101 2010/10/28 18:33:28 jmc Exp $
2.\"
3.\" -*- nroff -*-
4.\" 2.\"
5.\" Author: Tatu Ylonen <ylo@cs.hut.fi> 3.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
6.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -37,7 +35,7 @@
37.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 35.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
38.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39.\" 37.\"
40.Dd $Mdocdate: August 4 2010 $ 38.Dd $Mdocdate: October 28 2010 $
41.Dt SSH-KEYGEN 1 39.Dt SSH-KEYGEN 1
42.Os 40.Os
43.Sh NAME 41.Sh NAME
@@ -125,7 +123,7 @@
125generates, manages and converts authentication keys for 123generates, manages and converts authentication keys for
126.Xr ssh 1 . 124.Xr ssh 1 .
127.Nm 125.Nm
128can create RSA keys for use by SSH protocol version 1 and RSA or DSA 126can create RSA keys for use by SSH protocol version 1 and DSA, ECDSA or RSA
129keys for use by SSH protocol version 2. 127keys for use by SSH protocol version 2.
130The type of key to be generated is specified with the 128The type of key to be generated is specified with the
131.Fl t 129.Fl t
@@ -142,9 +140,10 @@ See the
142section for details. 140section for details.
143.Pp 141.Pp
144Normally each user wishing to use SSH 142Normally each user wishing to use SSH
145with RSA or DSA authentication runs this once to create the authentication 143with public key authentication runs this once to create the authentication
146key in 144key in
147.Pa ~/.ssh/identity , 145.Pa ~/.ssh/identity ,
146.Pa ~/.ssh/id_ecdsa ,
148.Pa ~/.ssh/id_dsa 147.Pa ~/.ssh/id_dsa
149or 148or
150.Pa ~/.ssh/id_rsa . 149.Pa ~/.ssh/id_rsa .
@@ -426,9 +425,10 @@ Specifies the type of key to create.
426The possible values are 425The possible values are
427.Dq rsa1 426.Dq rsa1
428for protocol version 1 and 427for protocol version 1 and
429.Dq rsa 428.Dq dsa ,
429.Dq ecdsa
430or 430or
431.Dq dsa 431.Dq rsa
432for protocol version 2. 432for protocol version 2.
433.It Fl V Ar validity_interval 433.It Fl V Ar validity_interval
434Specify a validity interval when signing a certificate. 434Specify a validity interval when signing a certificate.
@@ -605,18 +605,19 @@ or
605.Xr ssh 1 . 605.Xr ssh 1 .
606Please refer to those manual pages for details. 606Please refer to those manual pages for details.
607.Sh FILES 607.Sh FILES
608.Bl -tag -width Ds 608.Bl -tag -width Ds -compact
609.It Pa ~/.ssh/identity 609.It Pa ~/.ssh/identity
610Contains the protocol version 1 RSA authentication identity of the user. 610Contains the protocol version 1 RSA authentication identity of the user.
611This file should not be readable by anyone but the user. 611This file should not be readable by anyone but the user.
612It is possible to 612It is possible to
613specify a passphrase when generating the key; that passphrase will be 613specify a passphrase when generating the key; that passphrase will be
614used to encrypt the private part of this file using 128-bit AES. 614used to encrypt the private part of this file using 3DES.
615This file is not automatically accessed by 615This file is not automatically accessed by
616.Nm 616.Nm
617but it is offered as the default file for the private key. 617but it is offered as the default file for the private key.
618.Xr ssh 1 618.Xr ssh 1
619will read this file when a login attempt is made. 619will read this file when a login attempt is made.
620.Pp
620.It Pa ~/.ssh/identity.pub 621.It Pa ~/.ssh/identity.pub
621Contains the protocol version 1 RSA public key for authentication. 622Contains the protocol version 1 RSA public key for authentication.
622The contents of this file should be added to 623The contents of this file should be added to
@@ -624,26 +625,11 @@ The contents of this file should be added to
624on all machines 625on all machines
625where the user wishes to log in using RSA authentication. 626where the user wishes to log in using RSA authentication.
626There is no need to keep the contents of this file secret. 627There is no need to keep the contents of this file secret.
628.Pp
627.It Pa ~/.ssh/id_dsa 629.It Pa ~/.ssh/id_dsa
628Contains the protocol version 2 DSA authentication identity of the user. 630.It Pa ~/.ssh/id_ecdsa
629This file should not be readable by anyone but the user.
630It is possible to
631specify a passphrase when generating the key; that passphrase will be
632used to encrypt the private part of this file using 128-bit AES.
633This file is not automatically accessed by
634.Nm
635but it is offered as the default file for the private key.
636.Xr ssh 1
637will read this file when a login attempt is made.
638.It Pa ~/.ssh/id_dsa.pub
639Contains the protocol version 2 DSA public key for authentication.
640The contents of this file should be added to
641.Pa ~/.ssh/authorized_keys
642on all machines
643where the user wishes to log in using public key authentication.
644There is no need to keep the contents of this file secret.
645.It Pa ~/.ssh/id_rsa 631.It Pa ~/.ssh/id_rsa
646Contains the protocol version 2 RSA authentication identity of the user. 632Contains the protocol version 2 DSA, ECDSA or RSA authentication identity of the user.
647This file should not be readable by anyone but the user. 633This file should not be readable by anyone but the user.
648It is possible to 634It is possible to
649specify a passphrase when generating the key; that passphrase will be 635specify a passphrase when generating the key; that passphrase will be
@@ -653,13 +639,17 @@ This file is not automatically accessed by
653but it is offered as the default file for the private key. 639but it is offered as the default file for the private key.
654.Xr ssh 1 640.Xr ssh 1
655will read this file when a login attempt is made. 641will read this file when a login attempt is made.
642.Pp
643.It Pa ~/.ssh/id_dsa.pub
644.It Pa ~/.ssh/id_ecdsa.pub
656.It Pa ~/.ssh/id_rsa.pub 645.It Pa ~/.ssh/id_rsa.pub
657Contains the protocol version 2 RSA public key for authentication. 646Contains the protocol version 2 DSA, ECDSA or RSA public key for authentication.
658The contents of this file should be added to 647The contents of this file should be added to
659.Pa ~/.ssh/authorized_keys 648.Pa ~/.ssh/authorized_keys
660on all machines 649on all machines
661where the user wishes to log in using public key authentication. 650where the user wishes to log in using public key authentication.
662There is no need to keep the contents of this file secret. 651There is no need to keep the contents of this file secret.
652.Pp
663.It Pa /etc/moduli 653.It Pa /etc/moduli
664Contains Diffie-Hellman groups used for DH-GEX. 654Contains Diffie-Hellman groups used for DH-GEX.
665The file format is described in 655The file format is described in
diff --git a/ssh-keygen.c b/ssh-keygen.c
index d90b1dfdd..c95e4ab29 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keygen.c,v 1.197 2010/08/04 06:07:11 djm Exp $ */ 1/* $OpenBSD: ssh-keygen.c,v 1.205 2011/01/11 06:13:10 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -57,6 +57,7 @@
57/* Number of bits in the RSA/DSA key. This value can be set on the command line. */ 57/* Number of bits in the RSA/DSA key. This value can be set on the command line. */
58#define DEFAULT_BITS 2048 58#define DEFAULT_BITS 2048
59#define DEFAULT_BITS_DSA 1024 59#define DEFAULT_BITS_DSA 1024
60#define DEFAULT_BITS_ECDSA 256
60u_int32_t bits = 0; 61u_int32_t bits = 0;
61 62
62/* 63/*
@@ -176,6 +177,12 @@ ask_filename(struct passwd *pw, const char *prompt)
176 case KEY_DSA: 177 case KEY_DSA:
177 name = _PATH_SSH_CLIENT_ID_DSA; 178 name = _PATH_SSH_CLIENT_ID_DSA;
178 break; 179 break;
180#ifdef OPENSSL_HAS_ECC
181 case KEY_ECDSA_CERT:
182 case KEY_ECDSA:
183 name = _PATH_SSH_CLIENT_ID_ECDSA;
184 break;
185#endif
179 case KEY_RSA_CERT: 186 case KEY_RSA_CERT:
180 case KEY_RSA_CERT_V00: 187 case KEY_RSA_CERT_V00:
181 case KEY_RSA: 188 case KEY_RSA:
@@ -260,6 +267,12 @@ do_convert_to_pkcs8(Key *k)
260 if (!PEM_write_DSA_PUBKEY(stdout, k->dsa)) 267 if (!PEM_write_DSA_PUBKEY(stdout, k->dsa))
261 fatal("PEM_write_DSA_PUBKEY failed"); 268 fatal("PEM_write_DSA_PUBKEY failed");
262 break; 269 break;
270#ifdef OPENSSL_HAS_ECC
271 case KEY_ECDSA:
272 if (!PEM_write_EC_PUBKEY(stdout, k->ecdsa))
273 fatal("PEM_write_EC_PUBKEY failed");
274 break;
275#endif
263 default: 276 default:
264 fatal("%s: unsupported key type %s", __func__, key_type(k)); 277 fatal("%s: unsupported key type %s", __func__, key_type(k));
265 } 278 }
@@ -280,6 +293,7 @@ do_convert_to_pem(Key *k)
280 fatal("PEM_write_DSAPublicKey failed"); 293 fatal("PEM_write_DSAPublicKey failed");
281 break; 294 break;
282#endif 295#endif
296 /* XXX ECDSA? */
283 default: 297 default:
284 fatal("%s: unsupported key type %s", __func__, key_type(k)); 298 fatal("%s: unsupported key type %s", __func__, key_type(k));
285 } 299 }
@@ -539,6 +553,14 @@ do_convert_from_pkcs8(Key **k, int *private)
539 (*k)->type = KEY_DSA; 553 (*k)->type = KEY_DSA;
540 (*k)->dsa = EVP_PKEY_get1_DSA(pubkey); 554 (*k)->dsa = EVP_PKEY_get1_DSA(pubkey);
541 break; 555 break;
556#ifdef OPENSSL_HAS_ECC
557 case EVP_PKEY_EC:
558 *k = key_new(KEY_UNSPEC);
559 (*k)->type = KEY_ECDSA;
560 (*k)->ecdsa = EVP_PKEY_get1_EC_KEY(pubkey);
561 (*k)->ecdsa_nid = key_ecdsa_key_to_nid((*k)->ecdsa);
562 break;
563#endif
542 default: 564 default:
543 fatal("%s: unsupported pubkey type %d", __func__, 565 fatal("%s: unsupported pubkey type %d", __func__,
544 EVP_PKEY_type(pubkey->type)); 566 EVP_PKEY_type(pubkey->type));
@@ -574,6 +596,7 @@ do_convert_from_pem(Key **k, int *private)
574 fclose(fp); 596 fclose(fp);
575 return; 597 return;
576 } 598 }
599 /* XXX ECDSA */
577#endif 600#endif
578 fatal("%s: unrecognised raw private key format", __func__); 601 fatal("%s: unrecognised raw private key format", __func__);
579} 602}
@@ -614,6 +637,12 @@ do_convert_from(struct passwd *pw)
614 ok = PEM_write_DSAPrivateKey(stdout, k->dsa, NULL, 637 ok = PEM_write_DSAPrivateKey(stdout, k->dsa, NULL,
615 NULL, 0, NULL, NULL); 638 NULL, 0, NULL, NULL);
616 break; 639 break;
640#ifdef OPENSSL_HAS_ECC
641 case KEY_ECDSA:
642 ok = PEM_write_ECPrivateKey(stdout, k->ecdsa, NULL,
643 NULL, 0, NULL, NULL);
644 break;
645#endif
617 case KEY_RSA: 646 case KEY_RSA:
618 ok = PEM_write_RSAPrivateKey(stdout, k->rsa, NULL, 647 ok = PEM_write_RSAPrivateKey(stdout, k->rsa, NULL,
619 NULL, 0, NULL, NULL); 648 NULL, 0, NULL, NULL);
@@ -1404,7 +1433,8 @@ do_ca_sign(struct passwd *pw, int argc, char **argv)
1404 tmp = tilde_expand_filename(argv[i], pw->pw_uid); 1433 tmp = tilde_expand_filename(argv[i], pw->pw_uid);
1405 if ((public = key_load_public(tmp, &comment)) == NULL) 1434 if ((public = key_load_public(tmp, &comment)) == NULL)
1406 fatal("%s: unable to open \"%s\"", __func__, tmp); 1435 fatal("%s: unable to open \"%s\"", __func__, tmp);
1407 if (public->type != KEY_RSA && public->type != KEY_DSA) 1436 if (public->type != KEY_RSA && public->type != KEY_DSA &&
1437 public->type != KEY_ECDSA)
1408 fatal("%s: key \"%s\" type %s cannot be certified", 1438 fatal("%s: key \"%s\" type %s cannot be certified",
1409 __func__, tmp, key_type(public)); 1439 __func__, tmp, key_type(public));
1410 1440
@@ -1450,7 +1480,8 @@ do_ca_sign(struct passwd *pw, int argc, char **argv)
1450 if (!quiet) { 1480 if (!quiet) {
1451 logit("Signed %s key %s: id \"%s\" serial %llu%s%s " 1481 logit("Signed %s key %s: id \"%s\" serial %llu%s%s "
1452 "valid %s", key_cert_type(public), 1482 "valid %s", key_cert_type(public),
1453 out, public->cert->key_id, public->cert->serial, 1483 out, public->cert->key_id,
1484 (unsigned long long)public->cert->serial,
1454 cert_principals != NULL ? " for " : "", 1485 cert_principals != NULL ? " for " : "",
1455 cert_principals != NULL ? cert_principals : "", 1486 cert_principals != NULL ? cert_principals : "",
1456 fmt_validity(cert_valid_from, cert_valid_to)); 1487 fmt_validity(cert_valid_from, cert_valid_to));
@@ -1675,8 +1706,10 @@ do_show_cert(struct passwd *pw)
1675 printf(" Signing CA: %s %s\n", 1706 printf(" Signing CA: %s %s\n",
1676 key_type(key->cert->signature_key), ca_fp); 1707 key_type(key->cert->signature_key), ca_fp);
1677 printf(" Key ID: \"%s\"\n", key->cert->key_id); 1708 printf(" Key ID: \"%s\"\n", key->cert->key_id);
1678 if (!v00) 1709 if (!v00) {
1679 printf(" Serial: %llu\n", key->cert->serial); 1710 printf(" Serial: %llu\n",
1711 (unsigned long long)key->cert->serial);
1712 }
1680 printf(" Valid: %s\n", 1713 printf(" Valid: %s\n",
1681 fmt_validity(key->cert->valid_after, key->cert->valid_before)); 1714 fmt_validity(key->cert->valid_after, key->cert->valid_before));
1682 printf(" Principals: "); 1715 printf(" Principals: ");
@@ -1781,7 +1814,7 @@ main(int argc, char **argv)
1781 1814
1782 __progname = ssh_get_progname(argv[0]); 1815 __progname = ssh_get_progname(argv[0]);
1783 1816
1784 SSLeay_add_all_algorithms(); 1817 OpenSSL_add_all_algorithms();
1785 log_init(argv[0], SYSLOG_LEVEL_INFO, SYSLOG_FACILITY_USER, 1); 1818 log_init(argv[0], SYSLOG_LEVEL_INFO, SYSLOG_FACILITY_USER, 1);
1786 1819
1787 init_rng(); 1820 init_rng();
@@ -1802,7 +1835,7 @@ main(int argc, char **argv)
1802 "O:C:r:g:R:T:G:M:S:s:a:V:W:z:")) != -1) { 1835 "O:C:r:g:R:T:G:M:S:s:a:V:W:z:")) != -1) {
1803 switch (opt) { 1836 switch (opt) {
1804 case 'b': 1837 case 'b':
1805 bits = (u_int32_t)strtonum(optarg, 768, 32768, &errstr); 1838 bits = (u_int32_t)strtonum(optarg, 256, 32768, &errstr);
1806 if (errstr) 1839 if (errstr)
1807 fatal("Bits has bad value %s (%s)", 1840 fatal("Bits has bad value %s (%s)",
1808 optarg, errstr); 1841 optarg, errstr);
@@ -2086,8 +2119,14 @@ main(int argc, char **argv)
2086 fprintf(stderr, "unknown key type %s\n", key_type_name); 2119 fprintf(stderr, "unknown key type %s\n", key_type_name);
2087 exit(1); 2120 exit(1);
2088 } 2121 }
2089 if (bits == 0) 2122 if (bits == 0) {
2090 bits = (type == KEY_DSA) ? DEFAULT_BITS_DSA : DEFAULT_BITS; 2123 if (type == KEY_DSA)
2124 bits = DEFAULT_BITS_DSA;
2125 else if (type == KEY_ECDSA)
2126 bits = DEFAULT_BITS_ECDSA;
2127 else
2128 bits = DEFAULT_BITS;
2129 }
2091 maxbits = (type == KEY_DSA) ? 2130 maxbits = (type == KEY_DSA) ?
2092 OPENSSL_DSA_MAX_MODULUS_BITS : OPENSSL_RSA_MAX_MODULUS_BITS; 2131 OPENSSL_DSA_MAX_MODULUS_BITS : OPENSSL_RSA_MAX_MODULUS_BITS;
2093 if (bits > maxbits) { 2132 if (bits > maxbits) {
@@ -2096,6 +2135,11 @@ main(int argc, char **argv)
2096 } 2135 }
2097 if (type == KEY_DSA && bits != 1024) 2136 if (type == KEY_DSA && bits != 1024)
2098 fatal("DSA keys must be 1024 bits"); 2137 fatal("DSA keys must be 1024 bits");
2138 else if (type != KEY_ECDSA && bits < 768)
2139 fatal("Key must at least be 768 bits");
2140 else if (type == KEY_ECDSA && key_ecdsa_bits_to_nid(bits) == -1)
2141 fatal("Invalid ECDSA key length - valid lengths are "
2142 "256, 384 or 521 bits");
2099 if (!quiet) 2143 if (!quiet)
2100 printf("Generating public/private %s key pair.\n", key_type_name); 2144 printf("Generating public/private %s key pair.\n", key_type_name);
2101 private = key_generate(type, bits); 2145 private = key_generate(type, bits);
diff --git a/ssh-keyscan.0 b/ssh-keyscan.0
index 9bf4cc252..ba53bce81 100644
--- a/ssh-keyscan.0
+++ b/ssh-keyscan.0
@@ -48,9 +48,9 @@ DESCRIPTION
48 -t type 48 -t type
49 Specifies the type of the key to fetch from the scanned hosts. 49 Specifies the type of the key to fetch from the scanned hosts.
50 The possible values are ``rsa1'' for protocol version 1 and 50 The possible values are ``rsa1'' for protocol version 1 and
51 ``rsa'' or ``dsa'' for protocol version 2. Multiple values may 51 ``dsa'', ``ecdsa'' or ``rsa'' for protocol version 2. Multiple
52 be specified by separating them with commas. The default is 52 values may be specified by separating them with commas. The
53 ``rsa''. 53 default is ``rsa''.
54 54
55 -v Verbose mode. Causes ssh-keyscan to print debugging messages 55 -v Verbose mode. Causes ssh-keyscan to print debugging messages
56 about its progress. 56 about its progress.
@@ -72,11 +72,12 @@ FILES
72 72
73 host-or-namelist bits exponent modulus 73 host-or-namelist bits exponent modulus
74 74
75 Output format for rsa and dsa keys: 75 Output format for rsa, dsa and ecdsa keys:
76 76
77 host-or-namelist keytype base64-encoded-key 77 host-or-namelist keytype base64-encoded-key
78 78
79 Where keytype is either ``ssh-rsa'' or ``ssh-dss''. 79 Where keytype is either ``ecdsa-sha2-nistp256'', ``ecdsa-sha2-nistp384'',
80 ``ecdsa-sha2-nistp521'', ``ssh-dss'' or ``ssh-rsa''.
80 81
81 /etc/ssh/ssh_known_hosts 82 /etc/ssh/ssh_known_hosts
82 83
@@ -88,7 +89,7 @@ EXAMPLES
88 Find all hosts from the file ssh_hosts which have new or different keys 89 Find all hosts from the file ssh_hosts which have new or different keys
89 from those in the sorted file ssh_known_hosts: 90 from those in the sorted file ssh_known_hosts:
90 91
91 $ ssh-keyscan -t rsa,dsa -f ssh_hosts | \ 92 $ ssh-keyscan -t rsa,dsa,ecdsa -f ssh_hosts | \
92 sort -u - ssh_known_hosts | diff ssh_known_hosts - 93 sort -u - ssh_known_hosts | diff ssh_known_hosts -
93 94
94SEE ALSO 95SEE ALSO
@@ -105,4 +106,4 @@ BUGS
105 This is because it opens a connection to the ssh port, reads the public 106 This is because it opens a connection to the ssh port, reads the public
106 key, and drops the connection as soon as it gets the key. 107 key, and drops the connection as soon as it gets the key.
107 108
108OpenBSD 4.8 January 9, 2010 OpenBSD 4.8 109OpenBSD 4.8 August 31, 2010 OpenBSD 4.8
diff --git a/ssh-keyscan.1 b/ssh-keyscan.1
index 78255ff79..fe9bb6e07 100644
--- a/ssh-keyscan.1
+++ b/ssh-keyscan.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ssh-keyscan.1,v 1.28 2010/01/09 23:04:13 dtucker Exp $ 1.\" $OpenBSD: ssh-keyscan.1,v 1.29 2010/08/31 11:54:45 djm Exp $
2.\" 2.\"
3.\" Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. 3.\" Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
4.\" 4.\"
@@ -6,7 +6,7 @@
6.\" permitted provided that due credit is given to the author and the 6.\" permitted provided that due credit is given to the author and the
7.\" OpenBSD project by leaving this copyright notice intact. 7.\" OpenBSD project by leaving this copyright notice intact.
8.\" 8.\"
9.Dd $Mdocdate: January 9 2010 $ 9.Dd $Mdocdate: August 31 2010 $
10.Dt SSH-KEYSCAN 1 10.Dt SSH-KEYSCAN 1
11.Os 11.Os
12.Sh NAME 12.Sh NAME
@@ -88,9 +88,10 @@ Specifies the type of the key to fetch from the scanned hosts.
88The possible values are 88The possible values are
89.Dq rsa1 89.Dq rsa1
90for protocol version 1 and 90for protocol version 1 and
91.Dq rsa 91.Dq dsa ,
92.Dq ecdsa
92or 93or
93.Dq dsa 94.Dq rsa
94for protocol version 2. 95for protocol version 2.
95Multiple values may be specified by separating them with commas. 96Multiple values may be specified by separating them with commas.
96The default is 97The default is
@@ -122,7 +123,7 @@ attacks which have begun after the ssh_known_hosts file was created.
122host-or-namelist bits exponent modulus 123host-or-namelist bits exponent modulus
123.Ed 124.Ed
124.Pp 125.Pp
125.Pa Output format for rsa and dsa keys: 126.Pa Output format for rsa, dsa and ecdsa keys:
126.Bd -literal 127.Bd -literal
127host-or-namelist keytype base64-encoded-key 128host-or-namelist keytype base64-encoded-key
128.Ed 129.Ed
@@ -130,9 +131,12 @@ host-or-namelist keytype base64-encoded-key
130Where 131Where
131.Pa keytype 132.Pa keytype
132is either 133is either
133.Dq ssh-rsa 134.Dq ecdsa-sha2-nistp256 ,
135.Dq ecdsa-sha2-nistp384 ,
136.Dq ecdsa-sha2-nistp521 ,
137.Dq ssh-dss
134or 138or
135.Dq ssh-dss . 139.Dq ssh-rsa .
136.Pp 140.Pp
137.Pa /etc/ssh/ssh_known_hosts 141.Pa /etc/ssh/ssh_known_hosts
138.Sh EXAMPLES 142.Sh EXAMPLES
@@ -149,7 +153,7 @@ Find all hosts from the file
149which have new or different keys from those in the sorted file 153which have new or different keys from those in the sorted file
150.Pa ssh_known_hosts : 154.Pa ssh_known_hosts :
151.Bd -literal 155.Bd -literal
152$ ssh-keyscan -t rsa,dsa -f ssh_hosts | \e 156$ ssh-keyscan -t rsa,dsa,ecdsa -f ssh_hosts | \e
153 sort -u - ssh_known_hosts | diff ssh_known_hosts - 157 sort -u - ssh_known_hosts | diff ssh_known_hosts -
154.Ed 158.Ed
155.Sh SEE ALSO 159.Sh SEE ALSO
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index b6cf427cd..25d7ac66f 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keyscan.c,v 1.82 2010/06/22 04:54:30 djm Exp $ */ 1/* $OpenBSD: ssh-keyscan.c,v 1.84 2011/01/04 20:44:13 otto Exp $ */
2/* 2/*
3 * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. 3 * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
4 * 4 *
@@ -52,9 +52,10 @@ int IPv4or6 = AF_UNSPEC;
52 52
53int ssh_port = SSH_DEFAULT_PORT; 53int ssh_port = SSH_DEFAULT_PORT;
54 54
55#define KT_RSA1 1 55#define KT_RSA1 1
56#define KT_DSA 2 56#define KT_DSA 2
57#define KT_RSA 4 57#define KT_RSA 4
58#define KT_ECDSA 8
58 59
59int get_keytypes = KT_RSA; /* Get only RSA keys by default */ 60int get_keytypes = KT_RSA; /* Get only RSA keys by default */
60 61
@@ -245,12 +246,14 @@ keygrab_ssh2(con *c)
245 packet_set_connection(c->c_fd, c->c_fd); 246 packet_set_connection(c->c_fd, c->c_fd);
246 enable_compat20(); 247 enable_compat20();
247 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = c->c_keytype == KT_DSA? 248 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = c->c_keytype == KT_DSA?
248 "ssh-dss": "ssh-rsa"; 249 "ssh-dss" : (c->c_keytype == KT_RSA ? "ssh-rsa" :
250 "ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521");
249 c->c_kex = kex_setup(myproposal); 251 c->c_kex = kex_setup(myproposal);
250 c->c_kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client; 252 c->c_kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client;
251 c->c_kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client; 253 c->c_kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client;
252 c->c_kex->kex[KEX_DH_GEX_SHA1] = kexgex_client; 254 c->c_kex->kex[KEX_DH_GEX_SHA1] = kexgex_client;
253 c->c_kex->kex[KEX_DH_GEX_SHA256] = kexgex_client; 255 c->c_kex->kex[KEX_DH_GEX_SHA256] = kexgex_client;
256 c->c_kex->kex[KEX_ECDH_SHA2] = kexecdh_client;
254 c->c_kex->verify_host_key = hostjump; 257 c->c_kex->verify_host_key = hostjump;
255 258
256 if (!(j = setjmp(kexjmp))) { 259 if (!(j = setjmp(kexjmp))) {
@@ -571,7 +574,7 @@ do_host(char *host)
571 574
572 if (name == NULL) 575 if (name == NULL)
573 return; 576 return;
574 for (j = KT_RSA1; j <= KT_RSA; j *= 2) { 577 for (j = KT_RSA1; j <= KT_ECDSA; j *= 2) {
575 if (get_keytypes & j) { 578 if (get_keytypes & j) {
576 while (ncon >= MAXCON) 579 while (ncon >= MAXCON)
577 conloop(); 580 conloop();
@@ -673,6 +676,9 @@ main(int argc, char **argv)
673 case KEY_DSA: 676 case KEY_DSA:
674 get_keytypes |= KT_DSA; 677 get_keytypes |= KT_DSA;
675 break; 678 break;
679 case KEY_ECDSA:
680 get_keytypes |= KT_ECDSA;
681 break;
676 case KEY_RSA: 682 case KEY_RSA:
677 get_keytypes |= KT_RSA; 683 get_keytypes |= KT_RSA;
678 break; 684 break;
diff --git a/ssh-keysign.0 b/ssh-keysign.0
index cd119139f..9da4b2446 100644
--- a/ssh-keysign.0
+++ b/ssh-keysign.0
@@ -23,14 +23,18 @@ FILES
23 /etc/ssh/ssh_config 23 /etc/ssh/ssh_config
24 Controls whether ssh-keysign is enabled. 24 Controls whether ssh-keysign is enabled.
25 25
26 /etc/ssh/ssh_host_dsa_key, /etc/ssh/ssh_host_rsa_key 26 /etc/ssh/ssh_host_dsa_key
27 /etc/ssh/ssh_host_ecdsa_key
28 /etc/ssh/ssh_host_rsa_key
27 These files contain the private parts of the host keys used to 29 These files contain the private parts of the host keys used to
28 generate the digital signature. They should be owned by root, 30 generate the digital signature. They should be owned by root,
29 readable only by root, and not accessible to others. Since they 31 readable only by root, and not accessible to others. Since they
30 are readable only by root, ssh-keysign must be set-uid root if 32 are readable only by root, ssh-keysign must be set-uid root if
31 host-based authentication is used. 33 host-based authentication is used.
32 34
33 /etc/ssh/ssh_host_dsa_key-cert.pub, /etc/ssh/ssh_host_rsa_key-cert.pub 35 /etc/ssh/ssh_host_dsa_key-cert.pub
36 /etc/ssh/ssh_host_ecdsa_key-cert.pub
37 /etc/ssh/ssh_host_rsa_key-cert.pub
34 If these files exist they are assumed to contain public 38 If these files exist they are assumed to contain public
35 certificate information corresponding with the private keys 39 certificate information corresponding with the private keys
36 above. 40 above.
@@ -44,4 +48,4 @@ HISTORY
44AUTHORS 48AUTHORS
45 Markus Friedl <markus@openbsd.org> 49 Markus Friedl <markus@openbsd.org>
46 50
47OpenBSD 4.8 August 4, 2010 OpenBSD 4.8 51OpenBSD 4.8 August 31, 2010 OpenBSD 4.8
diff --git a/ssh-keysign.8 b/ssh-keysign.8
index 46c0ee9cd..5e09e0271 100644
--- a/ssh-keysign.8
+++ b/ssh-keysign.8
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ssh-keysign.8,v 1.10 2010/08/04 05:42:47 djm Exp $ 1.\" $OpenBSD: ssh-keysign.8,v 1.12 2010/08/31 11:54:45 djm Exp $
2.\" 2.\"
3.\" Copyright (c) 2002 Markus Friedl. All rights reserved. 3.\" Copyright (c) 2002 Markus Friedl. All rights reserved.
4.\" 4.\"
@@ -22,7 +22,7 @@
22.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24.\" 24.\"
25.Dd $Mdocdate: August 4 2010 $ 25.Dd $Mdocdate: August 31 2010 $
26.Dt SSH-KEYSIGN 8 26.Dt SSH-KEYSIGN 8
27.Os 27.Os
28.Sh NAME 28.Sh NAME
@@ -55,12 +55,15 @@ and
55.Xr sshd 8 55.Xr sshd 8
56for more information about host-based authentication. 56for more information about host-based authentication.
57.Sh FILES 57.Sh FILES
58.Bl -tag -width Ds 58.Bl -tag -width Ds -compact
59.It Pa /etc/ssh/ssh_config 59.It Pa /etc/ssh/ssh_config
60Controls whether 60Controls whether
61.Nm 61.Nm
62is enabled. 62is enabled.
63.It Pa /etc/ssh/ssh_host_dsa_key, /etc/ssh/ssh_host_rsa_key 63.Pp
64.It Pa /etc/ssh/ssh_host_dsa_key
65.It Pa /etc/ssh/ssh_host_ecdsa_key
66.It Pa /etc/ssh/ssh_host_rsa_key
64These files contain the private parts of the host keys used to 67These files contain the private parts of the host keys used to
65generate the digital signature. 68generate the digital signature.
66They should be owned by root, readable only by root, and not 69They should be owned by root, readable only by root, and not
@@ -68,7 +71,10 @@ accessible to others.
68Since they are readable only by root, 71Since they are readable only by root,
69.Nm 72.Nm
70must be set-uid root if host-based authentication is used. 73must be set-uid root if host-based authentication is used.
71.It Pa /etc/ssh/ssh_host_dsa_key-cert.pub, /etc/ssh/ssh_host_rsa_key-cert.pub 74.Pp
75.It Pa /etc/ssh/ssh_host_dsa_key-cert.pub
76.It Pa /etc/ssh/ssh_host_ecdsa_key-cert.pub
77.It Pa /etc/ssh/ssh_host_rsa_key-cert.pub
72If these files exist they are assumed to contain public certificate 78If these files exist they are assumed to contain public certificate
73information corresponding with the private keys above. 79information corresponding with the private keys above.
74.El 80.El
diff --git a/ssh-keysign.c b/ssh-keysign.c
index 0c7077050..d05156005 100644
--- a/ssh-keysign.c
+++ b/ssh-keysign.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keysign.c,v 1.32 2010/08/04 06:08:40 djm Exp $ */ 1/* $OpenBSD: ssh-keysign.c,v 1.35 2010/08/31 12:33:38 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2002 Markus Friedl. All rights reserved. 3 * Copyright (c) 2002 Markus Friedl. All rights reserved.
4 * 4 *
@@ -194,7 +194,7 @@ main(int argc, char **argv)
194 if (key_fd[0] == -1 && key_fd[1] == -1) 194 if (key_fd[0] == -1 && key_fd[1] == -1)
195 fatal("could not open any host key"); 195 fatal("could not open any host key");
196 196
197 SSLeay_add_all_algorithms(); 197 OpenSSL_add_all_algorithms();
198 for (i = 0; i < 256; i++) 198 for (i = 0; i < 256; i++)
199 rnd[i] = arc4random(); 199 rnd[i] = arc4random();
200 RAND_seed(rnd, sizeof(rnd)); 200 RAND_seed(rnd, sizeof(rnd));
diff --git a/ssh-rsa.c b/ssh-rsa.c
index c471ff323..c6355fa09 100644
--- a/ssh-rsa.c
+++ b/ssh-rsa.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-rsa.c,v 1.44 2010/07/16 14:07:35 djm Exp $ */ 1/* $OpenBSD: ssh-rsa.c,v 1.45 2010/08/31 09:58:37 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000, 2003 Markus Friedl <markus@openbsd.org> 3 * Copyright (c) 2000, 2003 Markus Friedl <markus@openbsd.org>
4 * 4 *
@@ -127,7 +127,7 @@ ssh_rsa_verify(const Key *key, const u_char *signature, u_int signaturelen,
127 } 127 }
128 buffer_init(&b); 128 buffer_init(&b);
129 buffer_append(&b, signature, signaturelen); 129 buffer_append(&b, signature, signaturelen);
130 ktype = buffer_get_string(&b, NULL); 130 ktype = buffer_get_cstring(&b, NULL);
131 if (strcmp("ssh-rsa", ktype) != 0) { 131 if (strcmp("ssh-rsa", ktype) != 0) {
132 error("ssh_rsa_verify: cannot handle type %s", ktype); 132 error("ssh_rsa_verify: cannot handle type %s", ktype);
133 buffer_free(&b); 133 buffer_free(&b);
diff --git a/ssh.0 b/ssh.0
index 8d53ad289..3d2036253 100644
--- a/ssh.0
+++ b/ssh.0
@@ -135,15 +135,15 @@ DESCRIPTION
135 with a PKCS#11 token providing the user's private RSA key. 135 with a PKCS#11 token providing the user's private RSA key.
136 136
137 -i identity_file 137 -i identity_file
138 Selects a file from which the identity (private key) for RSA or 138 Selects a file from which the identity (private key) for public
139 DSA authentication is read. The default is ~/.ssh/identity for 139 key authentication is read. The default is ~/.ssh/identity for
140 protocol version 1, and ~/.ssh/id_rsa and ~/.ssh/id_dsa for 140 protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and
141 protocol version 2. Identity files may also be specified on a 141 ~/.ssh/id_rsa for protocol version 2. Identity files may also be
142 per-host basis in the configuration file. It is possible to have 142 specified on a per-host basis in the configuration file. It is
143 multiple -i options (and multiple identities specified in 143 possible to have multiple -i options (and multiple identities
144 configuration files). ssh will also try to load certificate 144 specified in configuration files). ssh will also try to load
145 information from the filename obtained by appending -cert.pub to 145 certificate information from the filename obtained by appending
146 identity filenames. 146 -cert.pub to identity filenames.
147 147
148 -K Enables GSSAPI-based authentication and forwarding (delegation) 148 -K Enables GSSAPI-based authentication and forwarding (delegation)
149 of GSSAPI credentials to the server. 149 of GSSAPI credentials to the server.
@@ -244,7 +244,9 @@ DESCRIPTION
244 HostName 244 HostName
245 IdentityFile 245 IdentityFile
246 IdentitiesOnly 246 IdentitiesOnly
247 IPQoS
247 KbdInteractiveDevices 248 KbdInteractiveDevices
249 KexAlgorithms
248 LocalCommand 250 LocalCommand
249 LocalForward 251 LocalForward
250 LogLevel 252 LogLevel
@@ -380,9 +382,6 @@ DESCRIPTION
380 configuration file and a system-wide configuration file. The file format 382 configuration file and a system-wide configuration file. The file format
381 and configuration options are described in ssh_config(5). 383 and configuration options are described in ssh_config(5).
382 384
383 ssh exits with the exit status of the remote command or with 255 if an
384 error occurred.
385
386AUTHENTICATION 385AUTHENTICATION
387 The OpenSSH SSH client supports SSH protocols 1 and 2. The default is to 386 The OpenSSH SSH client supports SSH protocols 1 and 2. The default is to
388 use protocol 2 only, though this can be changed via the Protocol option 387 use protocol 2 only, though this can be changed via the Protocol option
@@ -421,9 +420,9 @@ AUTHENTICATION
421 creates a public/private key pair for authentication purposes. The 420 creates a public/private key pair for authentication purposes. The
422 server knows the public key, and only the user knows the private key. 421 server knows the public key, and only the user knows the private key.
423 ssh implements public key authentication protocol automatically, using 422 ssh implements public key authentication protocol automatically, using
424 either the RSA or DSA algorithms. Protocol 1 is restricted to using only 423 one of the DSA, ECDSA or RSA algorithms. Protocol 1 is restricted to
425 RSA keys, but protocol 2 may use either. The HISTORY section of ssl(8) 424 using only RSA keys, but protocol 2 may use any. The HISTORY section of
426 contains a brief discussion of the two algorithms. 425 ssl(8) contains a brief discussion of the DSA and RSA algorithms.
427 426
428 The file ~/.ssh/authorized_keys lists the public keys that are permitted 427 The file ~/.ssh/authorized_keys lists the public keys that are permitted
429 for logging in. When the user logs in, the ssh program tells the server 428 for logging in. When the user logs in, the ssh program tells the server
@@ -433,14 +432,15 @@ AUTHENTICATION
433 432
434 The user creates his/her key pair by running ssh-keygen(1). This stores 433 The user creates his/her key pair by running ssh-keygen(1). This stores
435 the private key in ~/.ssh/identity (protocol 1), ~/.ssh/id_dsa (protocol 434 the private key in ~/.ssh/identity (protocol 1), ~/.ssh/id_dsa (protocol
436 2 DSA), or ~/.ssh/id_rsa (protocol 2 RSA) and stores the public key in 435 2 DSA), ~/.ssh/id_ecdsa (protocol 2 ECDSA), or ~/.ssh/id_rsa (protocol 2
437 ~/.ssh/identity.pub (protocol 1), ~/.ssh/id_dsa.pub (protocol 2 DSA), or 436 RSA) and stores the public key in ~/.ssh/identity.pub (protocol 1),
438 ~/.ssh/id_rsa.pub (protocol 2 RSA) in the user's home directory. The 437 ~/.ssh/id_dsa.pub (protocol 2 DSA), ~/.ssh/id_ecdsa.pub (protocol 2
439 user should then copy the public key to ~/.ssh/authorized_keys in his/her 438 ECDSA), or ~/.ssh/id_rsa.pub (protocol 2 RSA) in the user's home
440 home directory on the remote machine. The authorized_keys file 439 directory. The user should then copy the public key to
441 corresponds to the conventional ~/.rhosts file, and has one key per line, 440 ~/.ssh/authorized_keys in his/her home directory on the remote machine.
442 though the lines can be very long. After this, the user can log in 441 The authorized_keys file corresponds to the conventional ~/.rhosts file,
443 without giving the password. 442 and has one key per line, though the lines can be very long. After this,
443 the user can log in without giving the password.
444 444
445 A variation on public key authentication is available in the form of 445 A variation on public key authentication is available in the form of
446 certificate authentication: instead of a set of public/private keys, 446 certificate authentication: instead of a set of public/private keys,
@@ -763,10 +763,10 @@ FILES
763 for the user, and not accessible by others. 763 for the user, and not accessible by others.
764 764
765 ~/.ssh/authorized_keys 765 ~/.ssh/authorized_keys
766 Lists the public keys (RSA/DSA) that can be used for logging in 766 Lists the public keys (DSA/ECDSA/RSA) that can be used for
767 as this user. The format of this file is described in the 767 logging in as this user. The format of this file is described in
768 sshd(8) manual page. This file is not highly sensitive, but the 768 the sshd(8) manual page. This file is not highly sensitive, but
769 recommended permissions are read/write for the user, and not 769 the recommended permissions are read/write for the user, and not
770 accessible by others. 770 accessible by others.
771 771
772 ~/.ssh/config 772 ~/.ssh/config
@@ -781,6 +781,7 @@ FILES
781 781
782 ~/.ssh/identity 782 ~/.ssh/identity
783 ~/.ssh/id_dsa 783 ~/.ssh/id_dsa
784 ~/.ssh/id_ecdsa
784 ~/.ssh/id_rsa 785 ~/.ssh/id_rsa
785 Contains the private key for authentication. These files contain 786 Contains the private key for authentication. These files contain
786 sensitive data and should be readable by the user but not 787 sensitive data and should be readable by the user but not
@@ -792,6 +793,7 @@ FILES
792 793
793 ~/.ssh/identity.pub 794 ~/.ssh/identity.pub
794 ~/.ssh/id_dsa.pub 795 ~/.ssh/id_dsa.pub
796 ~/.ssh/id_ecdsa.pub
795 ~/.ssh/id_rsa.pub 797 ~/.ssh/id_rsa.pub
796 Contains the public key for authentication. These files are not 798 Contains the public key for authentication. These files are not
797 sensitive and can (but need not) be readable by anyone. 799 sensitive and can (but need not) be readable by anyone.
@@ -822,6 +824,7 @@ FILES
822 824
823 /etc/ssh/ssh_host_key 825 /etc/ssh/ssh_host_key
824 /etc/ssh/ssh_host_dsa_key 826 /etc/ssh/ssh_host_dsa_key
827 /etc/ssh/ssh_host_ecdsa_key
825 /etc/ssh/ssh_host_rsa_key 828 /etc/ssh/ssh_host_rsa_key
826 These three files contain the private parts of the host keys and 829 These three files contain the private parts of the host keys and
827 are used for host-based authentication. If protocol version 1 is 830 are used for host-based authentication. If protocol version 1 is
@@ -842,6 +845,10 @@ FILES
842 just before the user's shell (or command) is started. See the 845 just before the user's shell (or command) is started. See the
843 sshd(8) manual page for more information. 846 sshd(8) manual page for more information.
844 847
848EXIT STATUS
849 ssh exits with the exit status of the remote command or with 255 if an
850 error occurred.
851
845SEE ALSO 852SEE ALSO
846 scp(1), sftp(1), ssh-add(1), ssh-agent(1), ssh-keygen(1), ssh-keyscan(1), 853 scp(1), sftp(1), ssh-add(1), ssh-agent(1), ssh-keygen(1), ssh-keyscan(1),
847 tun(4), hosts.equiv(5), ssh_config(5), ssh-keysign(8), sshd(8) 854 tun(4), hosts.equiv(5), ssh_config(5), ssh-keysign(8), sshd(8)
@@ -874,7 +881,10 @@ SEE ALSO
874 881
875 The Secure Shell (SSH) Public Key File Format, RFC 4716, 2006. 882 The Secure Shell (SSH) Public Key File Format, RFC 4716, 2006.
876 883
877 A. Perrig, D. Song, Hash Visualization: a New Technique to improve 884 Elliptic Curve Algorithm Integration in the Secure Shell Transport Layer,
885 RFC 5656, 2009.
886
887 A. Perrig and D. Song, Hash Visualization: a New Technique to improve
878 Real-World Security, 1999, International Workshop on Cryptographic 888 Real-World Security, 1999, International Workshop on Cryptographic
879 Techniques and E-Commerce (CrypTEC '99). 889 Techniques and E-Commerce (CrypTEC '99).
880 890
@@ -885,4 +895,4 @@ AUTHORS
885 created OpenSSH. Markus Friedl contributed the support for SSH protocol 895 created OpenSSH. Markus Friedl contributed the support for SSH protocol
886 versions 1.5 and 2.0. 896 versions 1.5 and 2.0.
887 897
888OpenBSD 4.8 August 4, 2010 OpenBSD 4.8 898OpenBSD 4.8 November 18, 2010 OpenBSD 4.8
diff --git a/ssh.1 b/ssh.1
index 02d28a00b..e3a42b5ad 100644
--- a/ssh.1
+++ b/ssh.1
@@ -1,4 +1,3 @@
1.\" -*- nroff -*-
2.\" 1.\"
3.\" Author: Tatu Ylonen <ylo@cs.hut.fi> 2.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 3.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -34,8 +33,8 @@
34.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 33.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36.\" 35.\"
37.\" $OpenBSD: ssh.1,v 1.308 2010/08/04 05:37:01 djm Exp $ 36.\" $OpenBSD: ssh.1,v 1.316 2010/11/18 15:01:00 jmc Exp $
38.Dd $Mdocdate: August 4 2010 $ 37.Dd $Mdocdate: November 18 2010 $
39.Dt SSH 1 38.Dt SSH 1
40.Os 39.Os
41.Sh NAME 40.Sh NAME
@@ -269,13 +268,14 @@ should use to communicate with a PKCS#11 token providing the user's
269private RSA key. 268private RSA key.
270.It Fl i Ar identity_file 269.It Fl i Ar identity_file
271Selects a file from which the identity (private key) for 270Selects a file from which the identity (private key) for
272RSA or DSA authentication is read. 271public key authentication is read.
273The default is 272The default is
274.Pa ~/.ssh/identity 273.Pa ~/.ssh/identity
275for protocol version 1, and 274for protocol version 1, and
276.Pa ~/.ssh/id_rsa 275.Pa ~/.ssh/id_dsa ,
276.Pa ~/.ssh/id_ecdsa
277and 277and
278.Pa ~/.ssh/id_dsa 278.Pa ~/.ssh/id_rsa
279for protocol version 2. 279for protocol version 2.
280Identity files may also be specified on 280Identity files may also be specified on
281a per-host basis in the configuration file. 281a per-host basis in the configuration file.
@@ -435,7 +435,9 @@ For full details of the options listed below, and their possible values, see
435.It HostName 435.It HostName
436.It IdentityFile 436.It IdentityFile
437.It IdentitiesOnly 437.It IdentitiesOnly
438.It IPQoS
438.It KbdInteractiveDevices 439.It KbdInteractiveDevices
440.It KexAlgorithms
439.It LocalCommand 441.It LocalCommand
440.It LocalForward 442.It LocalForward
441.It LogLevel 443.It LogLevel
@@ -646,10 +648,6 @@ may additionally obtain configuration data from
646a per-user configuration file and a system-wide configuration file. 648a per-user configuration file and a system-wide configuration file.
647The file format and configuration options are described in 649The file format and configuration options are described in
648.Xr ssh_config 5 . 650.Xr ssh_config 5 .
649.Pp
650.Nm
651exits with the exit status of the remote command or with 255
652if an error occurred.
653.Sh AUTHENTICATION 651.Sh AUTHENTICATION
654The OpenSSH SSH client supports SSH protocols 1 and 2. 652The OpenSSH SSH client supports SSH protocols 1 and 2.
655The default is to use protocol 2 only, 653The default is to use protocol 2 only,
@@ -721,14 +719,14 @@ key pair for authentication purposes.
721The server knows the public key, and only the user knows the private key. 719The server knows the public key, and only the user knows the private key.
722.Nm 720.Nm
723implements public key authentication protocol automatically, 721implements public key authentication protocol automatically,
724using either the RSA or DSA algorithms. 722using one of the DSA, ECDSA or RSA algorithms.
725Protocol 1 is restricted to using only RSA keys, 723Protocol 1 is restricted to using only RSA keys,
726but protocol 2 may use either. 724but protocol 2 may use any.
727The 725The
728.Sx HISTORY 726.Sx HISTORY
729section of 727section of
730.Xr ssl 8 728.Xr ssl 8
731contains a brief discussion of the two algorithms. 729contains a brief discussion of the DSA and RSA algorithms.
732.Pp 730.Pp
733The file 731The file
734.Pa ~/.ssh/authorized_keys 732.Pa ~/.ssh/authorized_keys
@@ -748,6 +746,8 @@ This stores the private key in
748(protocol 1), 746(protocol 1),
749.Pa ~/.ssh/id_dsa 747.Pa ~/.ssh/id_dsa
750(protocol 2 DSA), 748(protocol 2 DSA),
749.Pa ~/.ssh/id_ecdsa
750(protocol 2 ECDSA),
751or 751or
752.Pa ~/.ssh/id_rsa 752.Pa ~/.ssh/id_rsa
753(protocol 2 RSA) 753(protocol 2 RSA)
@@ -756,6 +756,8 @@ and stores the public key in
756(protocol 1), 756(protocol 1),
757.Pa ~/.ssh/id_dsa.pub 757.Pa ~/.ssh/id_dsa.pub
758(protocol 2 DSA), 758(protocol 2 DSA),
759.Pa ~/.ssh/id_ecdsa.pub
760(protocol 2 ECDSA),
759or 761or
760.Pa ~/.ssh/id_rsa.pub 762.Pa ~/.ssh/id_rsa.pub
761(protocol 2 RSA) 763(protocol 2 RSA)
@@ -1250,7 +1252,7 @@ option in
1250.Xr sshd_config 5 . 1252.Xr sshd_config 5 .
1251.Sh FILES 1253.Sh FILES
1252.Bl -tag -width Ds -compact 1254.Bl -tag -width Ds -compact
1253.It ~/.rhosts 1255.It Pa ~/.rhosts
1254This file is used for host-based authentication (see above). 1256This file is used for host-based authentication (see above).
1255On some machines this file may need to be 1257On some machines this file may need to be
1256world-readable if the user's home directory is on an NFS partition, 1258world-readable if the user's home directory is on an NFS partition,
@@ -1263,42 +1265,44 @@ The recommended
1263permission for most machines is read/write for the user, and not 1265permission for most machines is read/write for the user, and not
1264accessible by others. 1266accessible by others.
1265.Pp 1267.Pp
1266.It ~/.shosts 1268.It Pa ~/.shosts
1267This file is used in exactly the same way as 1269This file is used in exactly the same way as
1268.Pa .rhosts , 1270.Pa .rhosts ,
1269but allows host-based authentication without permitting login with 1271but allows host-based authentication without permitting login with
1270rlogin/rsh. 1272rlogin/rsh.
1271.Pp 1273.Pp
1272.It ~/.ssh/ 1274.It Pa ~/.ssh/
1273This directory is the default location for all user-specific configuration 1275This directory is the default location for all user-specific configuration
1274and authentication information. 1276and authentication information.
1275There is no general requirement to keep the entire contents of this directory 1277There is no general requirement to keep the entire contents of this directory
1276secret, but the recommended permissions are read/write/execute for the user, 1278secret, but the recommended permissions are read/write/execute for the user,
1277and not accessible by others. 1279and not accessible by others.
1278.Pp 1280.Pp
1279.It ~/.ssh/authorized_keys 1281.It Pa ~/.ssh/authorized_keys
1280Lists the public keys (RSA/DSA) that can be used for logging in as this user. 1282Lists the public keys (DSA/ECDSA/RSA) that can be used for logging in as
1283this user.
1281The format of this file is described in the 1284The format of this file is described in the
1282.Xr sshd 8 1285.Xr sshd 8
1283manual page. 1286manual page.
1284This file is not highly sensitive, but the recommended 1287This file is not highly sensitive, but the recommended
1285permissions are read/write for the user, and not accessible by others. 1288permissions are read/write for the user, and not accessible by others.
1286.Pp 1289.Pp
1287.It ~/.ssh/config 1290.It Pa ~/.ssh/config
1288This is the per-user configuration file. 1291This is the per-user configuration file.
1289The file format and configuration options are described in 1292The file format and configuration options are described in
1290.Xr ssh_config 5 . 1293.Xr ssh_config 5 .
1291Because of the potential for abuse, this file must have strict permissions: 1294Because of the potential for abuse, this file must have strict permissions:
1292read/write for the user, and not accessible by others. 1295read/write for the user, and not accessible by others.
1293.Pp 1296.Pp
1294.It ~/.ssh/environment 1297.It Pa ~/.ssh/environment
1295Contains additional definitions for environment variables; see 1298Contains additional definitions for environment variables; see
1296.Sx ENVIRONMENT , 1299.Sx ENVIRONMENT ,
1297above. 1300above.
1298.Pp 1301.Pp
1299.It ~/.ssh/identity 1302.It Pa ~/.ssh/identity
1300.It ~/.ssh/id_dsa 1303.It Pa ~/.ssh/id_dsa
1301.It ~/.ssh/id_rsa 1304.It Pa ~/.ssh/id_ecdsa
1305.It Pa ~/.ssh/id_rsa
1302Contains the private key for authentication. 1306Contains the private key for authentication.
1303These files 1307These files
1304contain sensitive data and should be readable by the user but not 1308contain sensitive data and should be readable by the user but not
@@ -1309,21 +1313,22 @@ It is possible to specify a passphrase when
1309generating the key which will be used to encrypt the 1313generating the key which will be used to encrypt the
1310sensitive part of this file using 3DES. 1314sensitive part of this file using 3DES.
1311.Pp 1315.Pp
1312.It ~/.ssh/identity.pub 1316.It Pa ~/.ssh/identity.pub
1313.It ~/.ssh/id_dsa.pub 1317.It Pa ~/.ssh/id_dsa.pub
1314.It ~/.ssh/id_rsa.pub 1318.It Pa ~/.ssh/id_ecdsa.pub
1319.It Pa ~/.ssh/id_rsa.pub
1315Contains the public key for authentication. 1320Contains the public key for authentication.
1316These files are not 1321These files are not
1317sensitive and can (but need not) be readable by anyone. 1322sensitive and can (but need not) be readable by anyone.
1318.Pp 1323.Pp
1319.It ~/.ssh/known_hosts 1324.It Pa ~/.ssh/known_hosts
1320Contains a list of host keys for all hosts the user has logged into 1325Contains a list of host keys for all hosts the user has logged into
1321that are not already in the systemwide list of known host keys. 1326that are not already in the systemwide list of known host keys.
1322See 1327See
1323.Xr sshd 8 1328.Xr sshd 8
1324for further details of the format of this file. 1329for further details of the format of this file.
1325.Pp 1330.Pp
1326.It ~/.ssh/rc 1331.It Pa ~/.ssh/rc
1327Commands in this file are executed by 1332Commands in this file are executed by
1328.Nm 1333.Nm
1329when the user logs in, just before the user's shell (or command) is 1334when the user logs in, just before the user's shell (or command) is
@@ -1332,11 +1337,11 @@ See the
1332.Xr sshd 8 1337.Xr sshd 8
1333manual page for more information. 1338manual page for more information.
1334.Pp 1339.Pp
1335.It /etc/hosts.equiv 1340.It Pa /etc/hosts.equiv
1336This file is for host-based authentication (see above). 1341This file is for host-based authentication (see above).
1337It should only be writable by root. 1342It should only be writable by root.
1338.Pp 1343.Pp
1339.It /etc/shosts.equiv 1344.It Pa /etc/shosts.equiv
1340This file is used in exactly the same way as 1345This file is used in exactly the same way as
1341.Pa hosts.equiv , 1346.Pa hosts.equiv ,
1342but allows host-based authentication without permitting login with 1347but allows host-based authentication without permitting login with
@@ -1347,9 +1352,10 @@ Systemwide configuration file.
1347The file format and configuration options are described in 1352The file format and configuration options are described in
1348.Xr ssh_config 5 . 1353.Xr ssh_config 5 .
1349.Pp 1354.Pp
1350.It /etc/ssh/ssh_host_key 1355.It Pa /etc/ssh/ssh_host_key
1351.It /etc/ssh/ssh_host_dsa_key 1356.It Pa /etc/ssh/ssh_host_dsa_key
1352.It /etc/ssh/ssh_host_rsa_key 1357.It Pa /etc/ssh/ssh_host_ecdsa_key
1358.It Pa /etc/ssh/ssh_host_rsa_key
1353These three files contain the private parts of the host keys 1359These three files contain the private parts of the host keys
1354and are used for host-based authentication. 1360and are used for host-based authentication.
1355If protocol version 1 is used, 1361If protocol version 1 is used,
@@ -1367,7 +1373,7 @@ By default
1367.Nm 1373.Nm
1368is not setuid root. 1374is not setuid root.
1369.Pp 1375.Pp
1370.It /etc/ssh/ssh_known_hosts 1376.It Pa /etc/ssh/ssh_known_hosts
1371Systemwide list of known host keys. 1377Systemwide list of known host keys.
1372This file should be prepared by the 1378This file should be prepared by the
1373system administrator to contain the public host keys of all machines in the 1379system administrator to contain the public host keys of all machines in the
@@ -1377,7 +1383,7 @@ See
1377.Xr sshd 8 1383.Xr sshd 8
1378for further details of the format of this file. 1384for further details of the format of this file.
1379.Pp 1385.Pp
1380.It /etc/ssh/sshrc 1386.It Pa /etc/ssh/sshrc
1381Commands in this file are executed by 1387Commands in this file are executed by
1382.Nm 1388.Nm
1383when the user logs in, just before the user's shell (or command) is started. 1389when the user logs in, just before the user's shell (or command) is started.
@@ -1385,6 +1391,10 @@ See the
1385.Xr sshd 8 1391.Xr sshd 8
1386manual page for more information. 1392manual page for more information.
1387.El 1393.El
1394.Sh EXIT STATUS
1395.Nm
1396exits with the exit status of the remote command or with 255
1397if an error occurred.
1388.Sh SEE ALSO 1398.Sh SEE ALSO
1389.Xr scp 1 , 1399.Xr scp 1 ,
1390.Xr sftp 1 , 1400.Xr sftp 1 ,
@@ -1458,6 +1468,11 @@ manual page for more information.
1458.%D 2006 1468.%D 2006
1459.Re 1469.Re
1460.Rs 1470.Rs
1471.%R RFC 5656
1472.%T "Elliptic Curve Algorithm Integration in the Secure Shell Transport Layer"
1473.%D 2009
1474.Re
1475.Rs
1461.%T "Hash Visualization: a New Technique to improve Real-World Security" 1476.%T "Hash Visualization: a New Technique to improve Real-World Security"
1462.%A A. Perrig 1477.%A A. Perrig
1463.%A D. Song 1478.%A D. Song
diff --git a/ssh.c b/ssh.c
index 4419f7642..9409fa713 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.346 2010/08/12 21:49:44 djm Exp $ */ 1/* $OpenBSD: ssh.c,v 1.356 2011/01/06 22:23:53 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -50,6 +50,7 @@
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/param.h> 51#include <sys/param.h>
52#include <sys/socket.h> 52#include <sys/socket.h>
53#include <sys/wait.h>
53 54
54#include <ctype.h> 55#include <ctype.h>
55#include <errno.h> 56#include <errno.h>
@@ -182,9 +183,6 @@ int subsystem_flag = 0;
182/* # of replies received for global requests */ 183/* # of replies received for global requests */
183static int remote_forward_confirms_received = 0; 184static int remote_forward_confirms_received = 0;
184 185
185/* pid of proxycommand child process */
186pid_t proxy_command_pid = 0;
187
188/* mux.c */ 186/* mux.c */
189extern int muxserver_sock; 187extern int muxserver_sock;
190extern u_int muxclient_command; 188extern u_int muxclient_command;
@@ -210,6 +208,7 @@ usage(void)
210static int ssh_session(void); 208static int ssh_session(void);
211static int ssh_session2(void); 209static int ssh_session2(void);
212static void load_public_identity_files(void); 210static void load_public_identity_files(void);
211static void main_sigchld_handler(int);
213 212
214/* from muxclient.c */ 213/* from muxclient.c */
215void muxclient(const char *); 214void muxclient(const char *);
@@ -222,7 +221,7 @@ int
222main(int ac, char **av) 221main(int ac, char **av)
223{ 222{
224 int i, r, opt, exit_status, use_syslog; 223 int i, r, opt, exit_status, use_syslog;
225 char *p, *cp, *line, *argv0, buf[MAXPATHLEN]; 224 char *p, *cp, *line, *argv0, buf[MAXPATHLEN], *host_arg;
226 struct stat st; 225 struct stat st;
227 struct passwd *pw; 226 struct passwd *pw;
228 int dummy, timeout_ms; 227 int dummy, timeout_ms;
@@ -599,7 +598,7 @@ main(int ac, char **av)
599 if (!host) 598 if (!host)
600 usage(); 599 usage();
601 600
602 SSLeay_add_all_algorithms(); 601 OpenSSL_add_all_algorithms();
603 ERR_load_crypto_strings(); 602 ERR_load_crypto_strings();
604 603
605 /* Initialize the command to execute on remote host. */ 604 /* Initialize the command to execute on remote host. */
@@ -694,6 +693,8 @@ main(int ac, char **av)
694 options.port = sp ? ntohs(sp->s_port) : SSH_DEFAULT_PORT; 693 options.port = sp ? ntohs(sp->s_port) : SSH_DEFAULT_PORT;
695 } 694 }
696 695
696 /* preserve host name given on command line for %n expansion */
697 host_arg = host;
697 if (options.hostname != NULL) { 698 if (options.hostname != NULL) {
698 host = percent_expand(options.hostname, 699 host = percent_expand(options.hostname,
699 "h", host, (char *)NULL); 700 "h", host, (char *)NULL);
@@ -708,7 +709,7 @@ main(int ac, char **av)
708 debug3("expanding LocalCommand: %s", options.local_command); 709 debug3("expanding LocalCommand: %s", options.local_command);
709 cp = options.local_command; 710 cp = options.local_command;
710 options.local_command = percent_expand(cp, "d", pw->pw_dir, 711 options.local_command = percent_expand(cp, "d", pw->pw_dir,
711 "h", host, "l", thishost, "n", host, "r", options.user, 712 "h", host, "l", thishost, "n", host_arg, "r", options.user,
712 "p", buf, "u", pw->pw_name, (char *)NULL); 713 "p", buf, "u", pw->pw_name, (char *)NULL);
713 debug3("expanded LocalCommand: %s", options.local_command); 714 debug3("expanded LocalCommand: %s", options.local_command);
714 xfree(cp); 715 xfree(cp);
@@ -780,34 +781,53 @@ main(int ac, char **av)
780 sensitive_data.external_keysign = 0; 781 sensitive_data.external_keysign = 0;
781 if (options.rhosts_rsa_authentication || 782 if (options.rhosts_rsa_authentication ||
782 options.hostbased_authentication) { 783 options.hostbased_authentication) {
783 sensitive_data.nkeys = 5; 784 sensitive_data.nkeys = 7;
784 sensitive_data.keys = xcalloc(sensitive_data.nkeys, 785 sensitive_data.keys = xcalloc(sensitive_data.nkeys,
785 sizeof(Key)); 786 sizeof(Key));
787 for (i = 0; i < sensitive_data.nkeys; i++)
788 sensitive_data.keys[i] = NULL;
786 789
787 PRIV_START; 790 PRIV_START;
788 sensitive_data.keys[0] = key_load_private_type(KEY_RSA1, 791 sensitive_data.keys[0] = key_load_private_type(KEY_RSA1,
789 _PATH_HOST_KEY_FILE, "", NULL, NULL); 792 _PATH_HOST_KEY_FILE, "", NULL, NULL);
790 sensitive_data.keys[1] = key_load_private_cert(KEY_DSA, 793 sensitive_data.keys[1] = key_load_private_cert(KEY_DSA,
791 _PATH_HOST_DSA_KEY_FILE, "", NULL); 794 _PATH_HOST_DSA_KEY_FILE, "", NULL);
792 sensitive_data.keys[2] = key_load_private_cert(KEY_RSA, 795#ifdef OPENSSL_HAS_ECC
796 sensitive_data.keys[2] = key_load_private_cert(KEY_ECDSA,
797 _PATH_HOST_ECDSA_KEY_FILE, "", NULL);
798#endif
799 sensitive_data.keys[3] = key_load_private_cert(KEY_RSA,
793 _PATH_HOST_RSA_KEY_FILE, "", NULL); 800 _PATH_HOST_RSA_KEY_FILE, "", NULL);
794 sensitive_data.keys[3] = key_load_private_type(KEY_DSA, 801 sensitive_data.keys[4] = key_load_private_type(KEY_DSA,
795 _PATH_HOST_DSA_KEY_FILE, "", NULL, NULL); 802 _PATH_HOST_DSA_KEY_FILE, "", NULL, NULL);
796 sensitive_data.keys[4] = key_load_private_type(KEY_RSA, 803#ifdef OPENSSL_HAS_ECC
804 sensitive_data.keys[5] = key_load_private_type(KEY_ECDSA,
805 _PATH_HOST_ECDSA_KEY_FILE, "", NULL, NULL);
806#endif
807 sensitive_data.keys[6] = key_load_private_type(KEY_RSA,
797 _PATH_HOST_RSA_KEY_FILE, "", NULL, NULL); 808 _PATH_HOST_RSA_KEY_FILE, "", NULL, NULL);
798 PRIV_END; 809 PRIV_END;
799 810
800 if (options.hostbased_authentication == 1 && 811 if (options.hostbased_authentication == 1 &&
801 sensitive_data.keys[0] == NULL && 812 sensitive_data.keys[0] == NULL &&
802 sensitive_data.keys[3] == NULL && 813 sensitive_data.keys[4] == NULL &&
803 sensitive_data.keys[4] == NULL) { 814 sensitive_data.keys[5] == NULL &&
815 sensitive_data.keys[6] == NULL) {
804 sensitive_data.keys[1] = key_load_cert( 816 sensitive_data.keys[1] = key_load_cert(
805 _PATH_HOST_DSA_KEY_FILE); 817 _PATH_HOST_DSA_KEY_FILE);
818#ifdef OPENSSL_HAS_ECC
806 sensitive_data.keys[2] = key_load_cert( 819 sensitive_data.keys[2] = key_load_cert(
820 _PATH_HOST_ECDSA_KEY_FILE);
821#endif
822 sensitive_data.keys[3] = key_load_cert(
807 _PATH_HOST_RSA_KEY_FILE); 823 _PATH_HOST_RSA_KEY_FILE);
808 sensitive_data.keys[3] = key_load_public(
809 _PATH_HOST_DSA_KEY_FILE, NULL);
810 sensitive_data.keys[4] = key_load_public( 824 sensitive_data.keys[4] = key_load_public(
825 _PATH_HOST_DSA_KEY_FILE, NULL);
826#ifdef OPENSSL_HAS_ECC
827 sensitive_data.keys[5] = key_load_public(
828 _PATH_HOST_ECDSA_KEY_FILE, NULL);
829#endif
830 sensitive_data.keys[6] = key_load_public(
811 _PATH_HOST_RSA_KEY_FILE, NULL); 831 _PATH_HOST_RSA_KEY_FILE, NULL);
812 sensitive_data.external_keysign = 1; 832 sensitive_data.external_keysign = 1;
813 } 833 }
@@ -830,10 +850,19 @@ main(int ac, char **av)
830 */ 850 */
831 r = snprintf(buf, sizeof buf, "%s%s%s", pw->pw_dir, 851 r = snprintf(buf, sizeof buf, "%s%s%s", pw->pw_dir,
832 strcmp(pw->pw_dir, "/") ? "/" : "", _PATH_SSH_USER_DIR); 852 strcmp(pw->pw_dir, "/") ? "/" : "", _PATH_SSH_USER_DIR);
833 if (r > 0 && (size_t)r < sizeof(buf) && stat(buf, &st) < 0) 853 if (r > 0 && (size_t)r < sizeof(buf) && stat(buf, &st) < 0) {
854#ifdef WITH_SELINUX
855 char *scon;
856
857 matchpathcon(buf, 0700, &scon);
858 setfscreatecon(scon);
859#endif
834 if (mkdir(buf, 0700) < 0) 860 if (mkdir(buf, 0700) < 0)
835 error("Could not create directory '%.200s'.", buf); 861 error("Could not create directory '%.200s'.", buf);
836 862#ifdef WITH_SELINUX
863 setfscreatecon(NULL);
864#endif
865 }
837 /* load options.identity_files */ 866 /* load options.identity_files */
838 load_public_identity_files(); 867 load_public_identity_files();
839 868
@@ -849,10 +878,11 @@ main(int ac, char **av)
849 tilde_expand_filename(options.user_hostfile2, original_real_uid); 878 tilde_expand_filename(options.user_hostfile2, original_real_uid);
850 879
851 signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE early */ 880 signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE early */
881 signal(SIGCHLD, main_sigchld_handler);
852 882
853 /* Log into the remote system. Never returns if the login fails. */ 883 /* Log into the remote system. Never returns if the login fails. */
854 ssh_login(&sensitive_data, host, (struct sockaddr *)&hostaddr, 884 ssh_login(&sensitive_data, host, (struct sockaddr *)&hostaddr,
855 pw, timeout_ms); 885 options.port, pw, timeout_ms);
856 886
857 if (packet_connection_is_on_socket()) { 887 if (packet_connection_is_on_socket()) {
858 verbose("Authenticated to %s ([%s]:%d).", host, 888 verbose("Authenticated to %s ([%s]:%d).", host,
@@ -890,12 +920,8 @@ main(int ac, char **av)
890 if (options.control_path != NULL && muxserver_sock != -1) 920 if (options.control_path != NULL && muxserver_sock != -1)
891 unlink(options.control_path); 921 unlink(options.control_path);
892 922
893 /* 923 /* Kill ProxyCommand if it is running. */
894 * Send SIGHUP to proxy command if used. We don't wait() in 924 ssh_kill_proxy_command();
895 * case it hangs and instead rely on init to reap the child
896 */
897 if (proxy_command_pid > 1)
898 kill(proxy_command_pid, SIGHUP);
899 925
900 return exit_status; 926 return exit_status;
901} 927}
@@ -927,6 +953,7 @@ control_persist_detach(void)
927 tty_flag = otty_flag; 953 tty_flag = otty_flag;
928 close(muxserver_sock); 954 close(muxserver_sock);
929 muxserver_sock = -1; 955 muxserver_sock = -1;
956 options.control_master = SSHCTL_MASTER_NO;
930 muxclient(options.control_path); 957 muxclient(options.control_path);
931 /* muxclient() doesn't return on success. */ 958 /* muxclient() doesn't return on success. */
932 fatal("Failed to connect to new control master"); 959 fatal("Failed to connect to new control master");
@@ -1199,7 +1226,8 @@ ssh_session(void)
1199 } 1226 }
1200 } 1227 }
1201 /* Tell the packet module whether this is an interactive session. */ 1228 /* Tell the packet module whether this is an interactive session. */
1202 packet_set_interactive(interactive); 1229 packet_set_interactive(interactive,
1230 options.ip_qos_interactive, options.ip_qos_bulk);
1203 1231
1204 /* Request authentication agent forwarding if appropriate. */ 1232 /* Request authentication agent forwarding if appropriate. */
1205 check_agent_present(); 1233 check_agent_present();
@@ -1297,8 +1325,6 @@ ssh_session2_setup(int id, int success, void *arg)
1297 1325
1298 client_session2_setup(id, tty_flag, subsystem_flag, getenv("TERM"), 1326 client_session2_setup(id, tty_flag, subsystem_flag, getenv("TERM"),
1299 NULL, fileno(stdin), &command, environ); 1327 NULL, fileno(stdin), &command, environ);
1300
1301 packet_set_interactive(interactive);
1302} 1328}
1303 1329
1304/* open new channel for a session */ 1330/* open new channel for a session */
@@ -1516,3 +1542,19 @@ load_public_identity_files(void)
1516 bzero(pwdir, strlen(pwdir)); 1542 bzero(pwdir, strlen(pwdir));
1517 xfree(pwdir); 1543 xfree(pwdir);
1518} 1544}
1545
1546static void
1547main_sigchld_handler(int sig)
1548{
1549 int save_errno = errno;
1550 pid_t pid;
1551 int status;
1552
1553 while ((pid = waitpid(-1, &status, WNOHANG)) > 0 ||
1554 (pid < 0 && errno == EINTR))
1555 ;
1556
1557 signal(sig, main_sigchld_handler);
1558 errno = save_errno;
1559}
1560
diff --git a/ssh2.h b/ssh2.h
index 3ffaf686b..51a963cae 100644
--- a/ssh2.h
+++ b/ssh2.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh2.h,v 1.13 2010/02/26 20:29:54 djm Exp $ */ 1/* $OpenBSD: ssh2.h,v 1.14 2010/08/31 11:54:45 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -98,6 +98,10 @@
98#define SSH2_MSG_KEX_DH_GEX_REPLY 33 98#define SSH2_MSG_KEX_DH_GEX_REPLY 33
99#define SSH2_MSG_KEX_DH_GEX_REQUEST 34 99#define SSH2_MSG_KEX_DH_GEX_REQUEST 34
100 100
101/* ecdh */
102#define SSH2_MSG_KEX_ECDH_INIT 30
103#define SSH2_MSG_KEX_ECDH_REPLY 31
104
101/* user authentication: generic */ 105/* user authentication: generic */
102 106
103#define SSH2_MSG_USERAUTH_REQUEST 50 107#define SSH2_MSG_USERAUTH_REQUEST 50
diff --git a/ssh_config.0 b/ssh_config.0
index 6c19de765..71233b49b 100644
--- a/ssh_config.0
+++ b/ssh_config.0
@@ -313,7 +313,18 @@ DESCRIPTION
313 HostKeyAlgorithms 313 HostKeyAlgorithms
314 Specifies the protocol version 2 host key algorithms that the 314 Specifies the protocol version 2 host key algorithms that the
315 client wants to use in order of preference. The default for this 315 client wants to use in order of preference. The default for this
316 option is: ``ssh-rsa,ssh-dss''. 316 option is:
317
318 ecdsa-sha2-nistp256-cert-v01@openssh.com,
319 ecdsa-sha2-nistp384-cert-v01@openssh.com,
320 ecdsa-sha2-nistp521-cert-v01@openssh.com,
321 ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,
322 ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com,
323 ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
324 ssh-rsa,ssh-dss
325
326 If hostkeys are known for the destination host then this default
327 is modified to prefer their algorithms.
317 328
318 HostKeyAlias 329 HostKeyAlias
319 Specifies an alias that should be used instead of the real host 330 Specifies an alias that should be used instead of the real host
@@ -340,14 +351,14 @@ DESCRIPTION
340 ``no''. 351 ``no''.
341 352
342 IdentityFile 353 IdentityFile
343 Specifies a file from which the user's RSA or DSA authentication 354 Specifies a file from which the user's DSA, ECDSA or DSA
344 identity is read. The default is ~/.ssh/identity for protocol 355 authentication identity is read. The default is ~/.ssh/identity
345 version 1, and ~/.ssh/id_rsa and ~/.ssh/id_dsa for protocol 356 for protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and
346 version 2. Additionally, any identities represented by the 357 ~/.ssh/id_rsa for protocol version 2. Additionally, any
347 authentication agent will be used for authentication. ssh(1) 358 identities represented by the authentication agent will be used
348 will try to load certificate information from the filename 359 for authentication. ssh(1) will try to load certificate
349 obtained by appending -cert.pub to the path of a specified 360 information from the filename obtained by appending -cert.pub to
350 IdentityFile. 361 the path of a specified IdentityFile.
351 362
352 The file name may use the tilde syntax to refer to a user's home 363 The file name may use the tilde syntax to refer to a user's home
353 directory or one of the following escape characters: `%d' (local 364 directory or one of the following escape characters: `%d' (local
@@ -358,6 +369,19 @@ DESCRIPTION
358 configuration files; all these identities will be tried in 369 configuration files; all these identities will be tried in
359 sequence. 370 sequence.
360 371
372 IPQoS Specifies the IPv4 type-of-service or DSCP class for connections.
373 Accepted values are ``af11'', ``af12'', ``af13'', ``af14'',
374 ``af22'', ``af23'', ``af31'', ``af32'', ``af33'', ``af41'',
375 ``af42'', ``af43'', ``cs0'', ``cs1'', ``cs2'', ``cs3'', ``cs4'',
376 ``cs5'', ``cs6'', ``cs7'', ``ef'', ``lowdelay'', ``throughput'',
377 ``reliability'', or a numeric value. This option may take one or
378 two arguments, separated by whitespace. If one argument is
379 specified, it is used as the packet class unconditionally. If
380 two values are specified, the first is automatically selected for
381 interactive sessions and the second for non-interactive sessions.
382 The default is ``lowdelay'' for interactive sessions and
383 ``throughput'' for non-interactive sessions.
384
361 KbdInteractiveAuthentication 385 KbdInteractiveAuthentication
362 Specifies whether to use keyboard-interactive authentication. 386 Specifies whether to use keyboard-interactive authentication.
363 The argument to this keyword must be ``yes'' or ``no''. The 387 The argument to this keyword must be ``yes'' or ``no''. The
@@ -371,6 +395,16 @@ DESCRIPTION
371 OpenSSH server, it may be zero or more of: ``bsdauth'', ``pam'', 395 OpenSSH server, it may be zero or more of: ``bsdauth'', ``pam'',
372 and ``skey''. 396 and ``skey''.
373 397
398 KexAlgorithms
399 Specifies the available KEX (Key Exchange) algorithms. Multiple
400 algorithms must be comma-separated. The default is:
401
402 ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,
403 diffie-hellman-group-exchange-sha256,
404 diffie-hellman-group-exchange-sha1,
405 diffie-hellman-group14-sha1,
406 diffie-hellman-group1-sha1
407
374 LocalCommand 408 LocalCommand
375 Specifies a command to execute on the local machine after 409 Specifies a command to execute on the local machine after
376 successfully connecting to the server. The command string 410 successfully connecting to the server. The command string
@@ -444,7 +478,7 @@ DESCRIPTION
444 478
445 PKCS11Provider 479 PKCS11Provider
446 Specifies which PKCS#11 provider to use. The argument to this 480 Specifies which PKCS#11 provider to use. The argument to this
447 keyword is the PKCS#11 shared libary ssh(1) should use to 481 keyword is the PKCS#11 shared library ssh(1) should use to
448 communicate with a PKCS#11 token providing the user's private RSA 482 communicate with a PKCS#11 token providing the user's private RSA
449 key. 483 key.
450 484
@@ -614,7 +648,7 @@ DESCRIPTION
614 Specifies the tun(4) devices to open on the client (local_tun) 648 Specifies the tun(4) devices to open on the client (local_tun)
615 and the server (remote_tun). 649 and the server (remote_tun).
616 650
617 The argument must be local_tun [:remote_tun]. The devices may be 651 The argument must be local_tun[:remote_tun]. The devices may be
618 specified by numerical ID or the keyword ``any'', which uses the 652 specified by numerical ID or the keyword ``any'', which uses the
619 next available tunnel device. If remote_tun is not specified, it 653 next available tunnel device. If remote_tun is not specified, it
620 defaults to ``any''. The default is ``any:any''. 654 defaults to ``any''. The default is ``any:any''.
@@ -707,4 +741,4 @@ AUTHORS
707 created OpenSSH. Markus Friedl contributed the support for SSH protocol 741 created OpenSSH. Markus Friedl contributed the support for SSH protocol
708 versions 1.5 and 2.0. 742 versions 1.5 and 2.0.
709 743
710OpenBSD 4.8 August 4, 2010 OpenBSD 4.8 744OpenBSD 4.8 December 8, 2010 OpenBSD 4.8
diff --git a/ssh_config.5 b/ssh_config.5
index 321a94db6..269d3941b 100644
--- a/ssh_config.5
+++ b/ssh_config.5
@@ -1,4 +1,3 @@
1.\" -*- nroff -*-
2.\" 1.\"
3.\" Author: Tatu Ylonen <ylo@cs.hut.fi> 2.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 3.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -34,8 +33,8 @@
34.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 33.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36.\" 35.\"
37.\" $OpenBSD: ssh_config.5,v 1.138 2010/08/04 05:37:01 djm Exp $ 36.\" $OpenBSD: ssh_config.5,v 1.146 2010/12/08 04:02:47 djm Exp $
38.Dd $Mdocdate: August 4 2010 $ 37.Dd $Mdocdate: December 8 2010 $
39.Dt SSH_CONFIG 5 38.Dt SSH_CONFIG 5
40.Os 39.Os
41.Sh NAME 40.Sh NAME
@@ -579,7 +578,18 @@ is similar to
579Specifies the protocol version 2 host key algorithms 578Specifies the protocol version 2 host key algorithms
580that the client wants to use in order of preference. 579that the client wants to use in order of preference.
581The default for this option is: 580The default for this option is:
582.Dq ssh-rsa,ssh-dss . 581.Bd -literal -offset 3n
582ecdsa-sha2-nistp256-cert-v01@openssh.com,
583ecdsa-sha2-nistp384-cert-v01@openssh.com,
584ecdsa-sha2-nistp521-cert-v01@openssh.com,
585ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,
586ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com,
587ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
588ssh-rsa,ssh-dss
589.Ed
590.Pp
591If hostkeys are known for the destination host then this default is modified
592to prefer their algorithms.
583.It Cm HostKeyAlias 593.It Cm HostKeyAlias
584Specifies an alias that should be used instead of the 594Specifies an alias that should be used instead of the
585real host name when looking up or saving the host key 595real host name when looking up or saving the host key
@@ -615,14 +625,15 @@ offers many different identities.
615The default is 625The default is
616.Dq no . 626.Dq no .
617.It Cm IdentityFile 627.It Cm IdentityFile
618Specifies a file from which the user's RSA or DSA authentication identity 628Specifies a file from which the user's DSA, ECDSA or DSA authentication
619is read. 629identity is read.
620The default is 630The default is
621.Pa ~/.ssh/identity 631.Pa ~/.ssh/identity
622for protocol version 1, and 632for protocol version 1, and
623.Pa ~/.ssh/id_rsa 633.Pa ~/.ssh/id_dsa ,
634.Pa ~/.ssh/id_ecdsa
624and 635and
625.Pa ~/.ssh/id_dsa 636.Pa ~/.ssh/id_rsa
626for protocol version 2. 637for protocol version 2.
627Additionally, any identities represented by the authentication agent 638Additionally, any identities represented by the authentication agent
628will be used for authentication. 639will be used for authentication.
@@ -650,6 +661,43 @@ escape characters:
650It is possible to have 661It is possible to have
651multiple identity files specified in configuration files; all these 662multiple identity files specified in configuration files; all these
652identities will be tried in sequence. 663identities will be tried in sequence.
664.It Cm IPQoS
665Specifies the IPv4 type-of-service or DSCP class for connections.
666Accepted values are
667.Dq af11 ,
668.Dq af12 ,
669.Dq af13 ,
670.Dq af14 ,
671.Dq af22 ,
672.Dq af23 ,
673.Dq af31 ,
674.Dq af32 ,
675.Dq af33 ,
676.Dq af41 ,
677.Dq af42 ,
678.Dq af43 ,
679.Dq cs0 ,
680.Dq cs1 ,
681.Dq cs2 ,
682.Dq cs3 ,
683.Dq cs4 ,
684.Dq cs5 ,
685.Dq cs6 ,
686.Dq cs7 ,
687.Dq ef ,
688.Dq lowdelay ,
689.Dq throughput ,
690.Dq reliability ,
691or a numeric value.
692This option may take one or two arguments, separated by whitespace.
693If one argument is specified, it is used as the packet class unconditionally.
694If two values are specified, the first is automatically selected for
695interactive sessions and the second for non-interactive sessions.
696The default is
697.Dq lowdelay
698for interactive sessions and
699.Dq throughput
700for non-interactive sessions.
653.It Cm KbdInteractiveAuthentication 701.It Cm KbdInteractiveAuthentication
654Specifies whether to use keyboard-interactive authentication. 702Specifies whether to use keyboard-interactive authentication.
655The argument to this keyword must be 703The argument to this keyword must be
@@ -669,6 +717,17 @@ it may be zero or more of:
669.Dq pam , 717.Dq pam ,
670and 718and
671.Dq skey . 719.Dq skey .
720.It Cm KexAlgorithms
721Specifies the available KEX (Key Exchange) algorithms.
722Multiple algorithms must be comma-separated.
723The default is:
724.Bd -literal -offset indent
725ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,
726diffie-hellman-group-exchange-sha256,
727diffie-hellman-group-exchange-sha1,
728diffie-hellman-group14-sha1,
729diffie-hellman-group1-sha1
730.Ed
672.It Cm LocalCommand 731.It Cm LocalCommand
673Specifies a command to execute on the local machine after successfully 732Specifies a command to execute on the local machine after successfully
674connecting to the server. 733connecting to the server.
@@ -782,7 +841,7 @@ The default is
782.Dq no . 841.Dq no .
783.It Cm PKCS11Provider 842.It Cm PKCS11Provider
784Specifies which PKCS#11 provider to use. 843Specifies which PKCS#11 provider to use.
785The argument to this keyword is the PKCS#11 shared libary 844The argument to this keyword is the PKCS#11 shared library
786.Xr ssh 1 845.Xr ssh 1
787should use to communicate with a PKCS#11 token providing the user's 846should use to communicate with a PKCS#11 token providing the user's
788private RSA key. 847private RSA key.
diff --git a/sshconnect.c b/sshconnect.c
index f55beffe4..74643a8c4 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect.c,v 1.224 2010/04/16 21:14:27 djm Exp $ */ 1/* $OpenBSD: sshconnect.c,v 1.232 2011/01/16 11:50:36 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -34,6 +34,7 @@
34#include <paths.h> 34#include <paths.h>
35#endif 35#endif
36#include <pwd.h> 36#include <pwd.h>
37#include <signal.h>
37#include <stdarg.h> 38#include <stdarg.h>
38#include <stdio.h> 39#include <stdio.h>
39#include <stdlib.h> 40#include <stdlib.h>
@@ -66,14 +67,15 @@ char *server_version_string = NULL;
66 67
67static int matching_host_key_dns = 0; 68static int matching_host_key_dns = 0;
68 69
70static pid_t proxy_command_pid = 0;
71
69/* import */ 72/* import */
70extern Options options; 73extern Options options;
71extern char *__progname; 74extern char *__progname;
72extern uid_t original_real_uid; 75extern uid_t original_real_uid;
73extern uid_t original_effective_uid; 76extern uid_t original_effective_uid;
74extern pid_t proxy_command_pid;
75 77
76static int show_other_keys(const char *, Key *); 78static int show_other_keys(struct hostkeys *, Key *);
77static void warn_changed_key(Key *); 79static void warn_changed_key(Key *);
78 80
79/* 81/*
@@ -87,7 +89,7 @@ ssh_proxy_connect(const char *host, u_short port, const char *proxy_command)
87 pid_t pid; 89 pid_t pid;
88 char *shell, strport[NI_MAXSERV]; 90 char *shell, strport[NI_MAXSERV];
89 91
90 if ((shell = getenv("SHELL")) == NULL) 92 if ((shell = getenv("SHELL")) == NULL || *shell == '\0')
91 shell = _PATH_BSHELL; 93 shell = _PATH_BSHELL;
92 94
93 /* Convert the port number into a string. */ 95 /* Convert the port number into a string. */
@@ -141,6 +143,7 @@ ssh_proxy_connect(const char *host, u_short port, const char *proxy_command)
141 143
142 /* Execute the proxy command. Note that we gave up any 144 /* Execute the proxy command. Note that we gave up any
143 extra privileges above. */ 145 extra privileges above. */
146 signal(SIGPIPE, SIG_DFL);
144 execv(argv[0], argv); 147 execv(argv[0], argv);
145 perror(argv[0]); 148 perror(argv[0]);
146 exit(1); 149 exit(1);
@@ -167,6 +170,17 @@ ssh_proxy_connect(const char *host, u_short port, const char *proxy_command)
167 return 0; 170 return 0;
168} 171}
169 172
173void
174ssh_kill_proxy_command(void)
175{
176 /*
177 * Send SIGHUP to proxy command if used. We don't wait() in
178 * case it hangs and instead rely on init to reap the child
179 */
180 if (proxy_command_pid > 1)
181 kill(proxy_command_pid, SIGHUP);
182}
183
170/* 184/*
171 * Creates a (possibly privileged) socket for use as the ssh connection. 185 * Creates a (possibly privileged) socket for use as the ssh connection.
172 */ 186 */
@@ -594,6 +608,79 @@ check_host_cert(const char *host, const Key *host_key)
594 return 1; 608 return 1;
595} 609}
596 610
611static int
612sockaddr_is_local(struct sockaddr *hostaddr)
613{
614 switch (hostaddr->sa_family) {
615 case AF_INET:
616 return (ntohl(((struct sockaddr_in *)hostaddr)->
617 sin_addr.s_addr) >> 24) == IN_LOOPBACKNET;
618 case AF_INET6:
619 return IN6_IS_ADDR_LOOPBACK(
620 &(((struct sockaddr_in6 *)hostaddr)->sin6_addr));
621 default:
622 return 0;
623 }
624}
625
626/*
627 * Prepare the hostname and ip address strings that are used to lookup
628 * host keys in known_hosts files. These may have a port number appended.
629 */
630void
631get_hostfile_hostname_ipaddr(char *hostname, struct sockaddr *hostaddr,
632 u_short port, char **hostfile_hostname, char **hostfile_ipaddr)
633{
634 char ntop[NI_MAXHOST];
635 socklen_t addrlen;
636
637 switch (hostaddr == NULL ? -1 : hostaddr->sa_family) {
638 case -1:
639 addrlen = 0;
640 break;
641 case AF_INET:
642 addrlen = sizeof(struct sockaddr_in);
643 break;
644 case AF_INET6:
645 addrlen = sizeof(struct sockaddr_in6);
646 break;
647 default:
648 addrlen = sizeof(struct sockaddr);
649 break;
650 }
651
652 /*
653 * We don't have the remote ip-address for connections
654 * using a proxy command
655 */
656 if (hostfile_ipaddr != NULL) {
657 if (options.proxy_command == NULL) {
658 if (getnameinfo(hostaddr, addrlen,
659 ntop, sizeof(ntop), NULL, 0, NI_NUMERICHOST) != 0)
660 fatal("check_host_key: getnameinfo failed");
661 *hostfile_ipaddr = put_host_port(ntop, port);
662 } else {
663 *hostfile_ipaddr = xstrdup("<no hostip for proxy "
664 "command>");
665 }
666 }
667
668 /*
669 * Allow the user to record the key under a different name or
670 * differentiate a non-standard port. This is useful for ssh
671 * tunneling over forwarded connections or if you run multiple
672 * sshd's on different ports on the same machine.
673 */
674 if (hostfile_hostname != NULL) {
675 if (options.host_key_alias != NULL) {
676 *hostfile_hostname = xstrdup(options.host_key_alias);
677 debug("using hostkeyalias: %s", *hostfile_hostname);
678 } else {
679 *hostfile_hostname = put_host_port(hostname, port);
680 }
681 }
682}
683
597/* 684/*
598 * check whether the supplied host key is valid, return -1 if the key 685 * check whether the supplied host key is valid, return -1 if the key
599 * is not valid. the user_hostfile will not be updated if 'readonly' is true. 686 * is not valid. the user_hostfile will not be updated if 'readonly' is true.
@@ -603,21 +690,21 @@ check_host_cert(const char *host, const Key *host_key)
603#define ROQUIET 2 690#define ROQUIET 2
604static int 691static int
605check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port, 692check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port,
606 Key *host_key, int readonly, const char *user_hostfile, 693 Key *host_key, int readonly, char *user_hostfile,
607 const char *system_hostfile) 694 char *system_hostfile)
608{ 695{
609 Key *file_key, *raw_key = NULL; 696 Key *raw_key = NULL;
610 const char *type; 697 const char *type;
611 char *ip = NULL, *host = NULL; 698 char *ip = NULL, *host = NULL;
612 char hostline[1000], *hostp, *fp, *ra; 699 char hostline[1000], *hostp, *fp, *ra;
613 HostStatus host_status; 700 HostStatus host_status;
614 HostStatus ip_status; 701 HostStatus ip_status;
615 int r, want_cert, local = 0, host_ip_differ = 0; 702 int r, want_cert = key_is_cert(host_key), host_ip_differ = 0;
616 int salen; 703 int local = sockaddr_is_local(hostaddr);
617 char ntop[NI_MAXHOST];
618 char msg[1024]; 704 char msg[1024];
619 int len, host_line, ip_line, cancelled_forwarding = 0; 705 int len, cancelled_forwarding = 0;
620 const char *host_file = NULL, *ip_file = NULL; 706 struct hostkeys *host_hostkeys, *ip_hostkeys;
707 const struct hostkey_entry *host_found, *ip_found;
621 708
622 /* 709 /*
623 * Force accepting of the host key for loopback/localhost. The 710 * Force accepting of the host key for loopback/localhost. The
@@ -627,23 +714,6 @@ check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port,
627 * essentially disables host authentication for localhost; however, 714 * essentially disables host authentication for localhost; however,
628 * this is probably not a real problem. 715 * this is probably not a real problem.
629 */ 716 */
630 /** hostaddr == 0! */
631 switch (hostaddr->sa_family) {
632 case AF_INET:
633 local = (ntohl(((struct sockaddr_in *)hostaddr)->
634 sin_addr.s_addr) >> 24) == IN_LOOPBACKNET;
635 salen = sizeof(struct sockaddr_in);
636 break;
637 case AF_INET6:
638 local = IN6_IS_ADDR_LOOPBACK(
639 &(((struct sockaddr_in6 *)hostaddr)->sin6_addr));
640 salen = sizeof(struct sockaddr_in6);
641 break;
642 default:
643 local = 0;
644 salen = sizeof(struct sockaddr_storage);
645 break;
646 }
647 if (options.no_host_authentication_for_localhost == 1 && local && 717 if (options.no_host_authentication_for_localhost == 1 && local &&
648 options.host_key_alias == NULL) { 718 options.host_key_alias == NULL) {
649 debug("Forcing accepting of host key for " 719 debug("Forcing accepting of host key for "
@@ -652,17 +722,10 @@ check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port,
652 } 722 }
653 723
654 /* 724 /*
655 * We don't have the remote ip-address for connections 725 * Prepare the hostname and address strings used for hostkey lookup.
656 * using a proxy command 726 * In some cases, these will have a port number appended.
657 */ 727 */
658 if (options.proxy_command == NULL) { 728 get_hostfile_hostname_ipaddr(hostname, hostaddr, port, &host, &ip);
659 if (getnameinfo(hostaddr, salen, ntop, sizeof(ntop),
660 NULL, 0, NI_NUMERICHOST) != 0)
661 fatal("check_host_key: getnameinfo failed");
662 ip = put_host_port(ntop, port);
663 } else {
664 ip = xstrdup("<no hostip for proxy command>");
665 }
666 729
667 /* 730 /*
668 * Turn off check_host_ip if the connection is to localhost, via proxy 731 * Turn off check_host_ip if the connection is to localhost, via proxy
@@ -672,74 +735,52 @@ check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port,
672 strcmp(hostname, ip) == 0 || options.proxy_command != NULL)) 735 strcmp(hostname, ip) == 0 || options.proxy_command != NULL))
673 options.check_host_ip = 0; 736 options.check_host_ip = 0;
674 737
675 /* 738 host_hostkeys = init_hostkeys();
676 * Allow the user to record the key under a different name or 739 load_hostkeys(host_hostkeys, host, user_hostfile);
677 * differentiate a non-standard port. This is useful for ssh 740 load_hostkeys(host_hostkeys, host, system_hostfile);
678 * tunneling over forwarded connections or if you run multiple 741
679 * sshd's on different ports on the same machine. 742 ip_hostkeys = NULL;
680 */ 743 if (!want_cert && options.check_host_ip) {
681 if (options.host_key_alias != NULL) { 744 ip_hostkeys = init_hostkeys();
682 host = xstrdup(options.host_key_alias); 745 load_hostkeys(ip_hostkeys, ip, user_hostfile);
683 debug("using hostkeyalias: %s", host); 746 load_hostkeys(ip_hostkeys, ip, system_hostfile);
684 } else {
685 host = put_host_port(hostname, port);
686 } 747 }
687 748
688 retry: 749 retry:
750 /* Reload these as they may have changed on cert->key downgrade */
689 want_cert = key_is_cert(host_key); 751 want_cert = key_is_cert(host_key);
690 type = key_type(host_key); 752 type = key_type(host_key);
691 753
692 /* 754 /*
693 * Store the host key from the known host file in here so that we can
694 * compare it with the key for the IP address.
695 */
696 file_key = key_new(key_is_cert(host_key) ? KEY_UNSPEC : host_key->type);
697
698 /*
699 * Check if the host key is present in the user's list of known 755 * Check if the host key is present in the user's list of known
700 * hosts or in the systemwide list. 756 * hosts or in the systemwide list.
701 */ 757 */
702 host_file = user_hostfile; 758 host_status = check_key_in_hostkeys(host_hostkeys, host_key,
703 host_status = check_host_in_hostfile(host_file, host, host_key, 759 &host_found);
704 file_key, &host_line); 760
705 if (host_status == HOST_NEW) {
706 host_file = system_hostfile;
707 host_status = check_host_in_hostfile(host_file, host, host_key,
708 file_key, &host_line);
709 }
710 /* 761 /*
711 * Also perform check for the ip address, skip the check if we are 762 * Also perform check for the ip address, skip the check if we are
712 * localhost, looking for a certificate, or the hostname was an ip 763 * localhost, looking for a certificate, or the hostname was an ip
713 * address to begin with. 764 * address to begin with.
714 */ 765 */
715 if (!want_cert && options.check_host_ip) { 766 if (!want_cert && ip_hostkeys != NULL) {
716 Key *ip_key = key_new(host_key->type); 767 ip_status = check_key_in_hostkeys(ip_hostkeys, host_key,
717 768 &ip_found);
718 ip_file = user_hostfile;
719 ip_status = check_host_in_hostfile(ip_file, ip, host_key,
720 ip_key, &ip_line);
721 if (ip_status == HOST_NEW) {
722 ip_file = system_hostfile;
723 ip_status = check_host_in_hostfile(ip_file, ip,
724 host_key, ip_key, &ip_line);
725 }
726 if (host_status == HOST_CHANGED && 769 if (host_status == HOST_CHANGED &&
727 (ip_status != HOST_CHANGED || !key_equal(ip_key, file_key))) 770 (ip_status != HOST_CHANGED ||
771 (ip_found != NULL &&
772 !key_equal(ip_found->key, host_found->key))))
728 host_ip_differ = 1; 773 host_ip_differ = 1;
729
730 key_free(ip_key);
731 } else 774 } else
732 ip_status = host_status; 775 ip_status = host_status;
733 776
734 key_free(file_key);
735
736 switch (host_status) { 777 switch (host_status) {
737 case HOST_OK: 778 case HOST_OK:
738 /* The host is known and the key matches. */ 779 /* The host is known and the key matches. */
739 debug("Host '%.200s' is known and matches the %s host %s.", 780 debug("Host '%.200s' is known and matches the %s host %s.",
740 host, type, want_cert ? "certificate" : "key"); 781 host, type, want_cert ? "certificate" : "key");
741 debug("Found %s in %s:%d", 782 debug("Found %s in %s:%lu", want_cert ? "CA key" : "key",
742 want_cert ? "CA key" : "key", host_file, host_line); 783 host_found->file, host_found->line);
743 if (want_cert && !check_host_cert(hostname, host_key)) 784 if (want_cert && !check_host_cert(hostname, host_key))
744 goto fail; 785 goto fail;
745 if (options.check_host_ip && ip_status == HOST_NEW) { 786 if (options.check_host_ip && ip_status == HOST_NEW) {
@@ -790,7 +831,7 @@ check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port,
790 } else if (options.strict_host_key_checking == 2) { 831 } else if (options.strict_host_key_checking == 2) {
791 char msg1[1024], msg2[1024]; 832 char msg1[1024], msg2[1024];
792 833
793 if (show_other_keys(host, host_key)) 834 if (show_other_keys(host_hostkeys, host_key))
794 snprintf(msg1, sizeof(msg1), 835 snprintf(msg1, sizeof(msg1),
795 "\nbut keys of different type are already" 836 "\nbut keys of different type are already"
796 " known for this host."); 837 " known for this host.");
@@ -831,8 +872,7 @@ check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port,
831 * local known_hosts file. 872 * local known_hosts file.
832 */ 873 */
833 if (options.check_host_ip && ip_status == HOST_NEW) { 874 if (options.check_host_ip && ip_status == HOST_NEW) {
834 snprintf(hostline, sizeof(hostline), "%s,%s", 875 snprintf(hostline, sizeof(hostline), "%s,%s", host, ip);
835 host, ip);
836 hostp = hostline; 876 hostp = hostline;
837 if (options.hash_known_hosts) { 877 if (options.hash_known_hosts) {
838 /* Add hash of host and IP separately */ 878 /* Add hash of host and IP separately */
@@ -886,8 +926,8 @@ check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port,
886 * all hosts that one might visit. 926 * all hosts that one might visit.
887 */ 927 */
888 debug("Host certificate authority does not " 928 debug("Host certificate authority does not "
889 "match %s in %s:%d", CA_MARKER, 929 "match %s in %s:%lu", CA_MARKER,
890 host_file, host_line); 930 host_found->file, host_found->line);
891 goto fail; 931 goto fail;
892 } 932 }
893 if (readonly == ROQUIET) 933 if (readonly == ROQUIET)
@@ -909,13 +949,15 @@ check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port,
909 error("DNS SPOOFING is happening or the IP address for the host"); 949 error("DNS SPOOFING is happening or the IP address for the host");
910 error("and its host key have changed at the same time."); 950 error("and its host key have changed at the same time.");
911 if (ip_status != HOST_NEW) 951 if (ip_status != HOST_NEW)
912 error("Offending key for IP in %s:%d", ip_file, ip_line); 952 error("Offending key for IP in %s:%lu",
953 ip_found->file, ip_found->line);
913 } 954 }
914 /* The host key has changed. */ 955 /* The host key has changed. */
915 warn_changed_key(host_key); 956 warn_changed_key(host_key);
916 error("Add correct host key in %.100s to get rid of this message.", 957 error("Add correct host key in %.100s to get rid of this message.",
917 user_hostfile); 958 user_hostfile);
918 error("Offending key in %s:%d", host_file, host_line); 959 error("Offending %s key in %s:%lu", key_type(host_found->key),
960 host_found->file, host_found->line);
919 961
920 /* 962 /*
921 * If strict host key checking is in use, the user will have 963 * If strict host key checking is in use, the user will have
@@ -1000,13 +1042,13 @@ check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port,
1000 snprintf(msg, sizeof(msg), 1042 snprintf(msg, sizeof(msg),
1001 "Warning: the %s host key for '%.200s' " 1043 "Warning: the %s host key for '%.200s' "
1002 "differs from the key for the IP address '%.128s'" 1044 "differs from the key for the IP address '%.128s'"
1003 "\nOffending key for IP in %s:%d", 1045 "\nOffending key for IP in %s:%lu",
1004 type, host, ip, ip_file, ip_line); 1046 type, host, ip, ip_found->file, ip_found->line);
1005 if (host_status == HOST_OK) { 1047 if (host_status == HOST_OK) {
1006 len = strlen(msg); 1048 len = strlen(msg);
1007 snprintf(msg + len, sizeof(msg) - len, 1049 snprintf(msg + len, sizeof(msg) - len,
1008 "\nMatching host key in %s:%d", 1050 "\nMatching host key in %s:%lu",
1009 host_file, host_line); 1051 host_found->file, host_found->line);
1010 } 1052 }
1011 if (options.strict_host_key_checking == 1) { 1053 if (options.strict_host_key_checking == 1) {
1012 logit("%s", msg); 1054 logit("%s", msg);
@@ -1024,6 +1066,10 @@ check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port,
1024 1066
1025 xfree(ip); 1067 xfree(ip);
1026 xfree(host); 1068 xfree(host);
1069 if (host_hostkeys != NULL)
1070 free_hostkeys(host_hostkeys);
1071 if (ip_hostkeys != NULL)
1072 free_hostkeys(ip_hostkeys);
1027 return 0; 1073 return 0;
1028 1074
1029fail: 1075fail:
@@ -1043,6 +1089,10 @@ fail:
1043 key_free(raw_key); 1089 key_free(raw_key);
1044 xfree(ip); 1090 xfree(ip);
1045 xfree(host); 1091 xfree(host);
1092 if (host_hostkeys != NULL)
1093 free_hostkeys(host_hostkeys);
1094 if (ip_hostkeys != NULL)
1095 free_hostkeys(ip_hostkeys);
1046 return -1; 1096 return -1;
1047} 1097}
1048 1098
@@ -1052,6 +1102,11 @@ verify_host_key(char *host, struct sockaddr *hostaddr, Key *host_key)
1052{ 1102{
1053 struct stat st; 1103 struct stat st;
1054 int flags = 0; 1104 int flags = 0;
1105 char *fp;
1106
1107 fp = key_fingerprint(host_key, SSH_FP_MD5, SSH_FP_HEX);
1108 debug("Server host key: %s %s", key_type(host_key), fp);
1109 xfree(fp);
1055 1110
1056 /* XXX certs are not yet supported for DNS */ 1111 /* XXX certs are not yet supported for DNS */
1057 if (!key_is_cert(host_key) && options.verify_host_key_dns && 1112 if (!key_is_cert(host_key) && options.verify_host_key_dns &&
@@ -1095,7 +1150,7 @@ verify_host_key(char *host, struct sockaddr *hostaddr, Key *host_key)
1095 */ 1150 */
1096void 1151void
1097ssh_login(Sensitive *sensitive, const char *orighost, 1152ssh_login(Sensitive *sensitive, const char *orighost,
1098 struct sockaddr *hostaddr, struct passwd *pw, int timeout_ms) 1153 struct sockaddr *hostaddr, u_short port, struct passwd *pw, int timeout_ms)
1099{ 1154{
1100 char *host, *cp; 1155 char *host, *cp;
1101 char *server_user, *local_user; 1156 char *server_user, *local_user;
@@ -1118,7 +1173,7 @@ ssh_login(Sensitive *sensitive, const char *orighost,
1118 /* key exchange */ 1173 /* key exchange */
1119 /* authenticate user */ 1174 /* authenticate user */
1120 if (compat20) { 1175 if (compat20) {
1121 ssh_kex2(host, hostaddr); 1176 ssh_kex2(host, hostaddr, port);
1122 ssh_userauth2(local_user, server_user, host, sensitive); 1177 ssh_userauth2(local_user, server_user, host, sensitive);
1123 } else { 1178 } else {
1124 ssh_kex(host, hostaddr); 1179 ssh_kex(host, hostaddr);
@@ -1145,68 +1200,41 @@ ssh_put_password(char *password)
1145 xfree(padded); 1200 xfree(padded);
1146} 1201}
1147 1202
1148static int
1149show_key_from_file(const char *file, const char *host, int keytype)
1150{
1151 Key *found;
1152 char *fp, *ra;
1153 int line, ret;
1154
1155 found = key_new(keytype);
1156 if ((ret = lookup_key_in_hostfile_by_type(file, host,
1157 keytype, found, &line))) {
1158 fp = key_fingerprint(found, SSH_FP_MD5, SSH_FP_HEX);
1159 ra = key_fingerprint(found, SSH_FP_MD5, SSH_FP_RANDOMART);
1160 logit("WARNING: %s key found for host %s\n"
1161 "in %s:%d\n"
1162 "%s key fingerprint %s.\n%s\n",
1163 key_type(found), host, file, line,
1164 key_type(found), fp, ra);
1165 xfree(ra);
1166 xfree(fp);
1167 }
1168 key_free(found);
1169 return (ret);
1170}
1171
1172/* print all known host keys for a given host, but skip keys of given type */ 1203/* print all known host keys for a given host, but skip keys of given type */
1173static int 1204static int
1174show_other_keys(const char *host, Key *key) 1205show_other_keys(struct hostkeys *hostkeys, Key *key)
1175{ 1206{
1176 int type[] = { KEY_RSA1, KEY_RSA, KEY_DSA, -1}; 1207 int type[] = { KEY_RSA1, KEY_RSA, KEY_DSA, KEY_ECDSA, -1};
1177 int i, found = 0; 1208 int i, ret = 0;
1209 char *fp, *ra;
1210 const struct hostkey_entry *found;
1178 1211
1179 for (i = 0; type[i] != -1; i++) { 1212 for (i = 0; type[i] != -1; i++) {
1180 if (type[i] == key->type) 1213 if (type[i] == key->type)
1181 continue; 1214 continue;
1182 if (type[i] != KEY_RSA1 && 1215 if (!lookup_key_in_hostkeys_by_type(hostkeys, type[i], &found))
1183 show_key_from_file(options.user_hostfile2, host, type[i])) {
1184 found = 1;
1185 continue;
1186 }
1187 if (type[i] != KEY_RSA1 &&
1188 show_key_from_file(options.system_hostfile2, host, type[i])) {
1189 found = 1;
1190 continue;
1191 }
1192 if (show_key_from_file(options.user_hostfile, host, type[i])) {
1193 found = 1;
1194 continue;
1195 }
1196 if (show_key_from_file(options.system_hostfile, host, type[i])) {
1197 found = 1;
1198 continue; 1216 continue;
1199 } 1217 fp = key_fingerprint(found->key, SSH_FP_MD5, SSH_FP_HEX);
1200 debug2("no key of type %d for host %s", type[i], host); 1218 ra = key_fingerprint(found->key, SSH_FP_MD5, SSH_FP_RANDOMART);
1219 logit("WARNING: %s key found for host %s\n"
1220 "in %s:%lu\n"
1221 "%s key fingerprint %s.",
1222 key_type(found->key),
1223 found->host, found->file, found->line,
1224 key_type(found->key), fp);
1225 if (options.visual_host_key)
1226 logit("%s", ra);
1227 xfree(ra);
1228 xfree(fp);
1229 ret = 1;
1201 } 1230 }
1202 return (found); 1231 return ret;
1203} 1232}
1204 1233
1205static void 1234static void
1206warn_changed_key(Key *host_key) 1235warn_changed_key(Key *host_key)
1207{ 1236{
1208 char *fp; 1237 char *fp;
1209 const char *type = key_type(host_key);
1210 1238
1211 fp = key_fingerprint(host_key, SSH_FP_MD5, SSH_FP_HEX); 1239 fp = key_fingerprint(host_key, SSH_FP_MD5, SSH_FP_HEX);
1212 1240
@@ -1215,9 +1243,9 @@ warn_changed_key(Key *host_key)
1215 error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); 1243 error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
1216 error("IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!"); 1244 error("IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!");
1217 error("Someone could be eavesdropping on you right now (man-in-the-middle attack)!"); 1245 error("Someone could be eavesdropping on you right now (man-in-the-middle attack)!");
1218 error("It is also possible that the %s host key has just been changed.", type); 1246 error("It is also possible that a host key has just been changed.");
1219 error("The fingerprint for the %s key sent by the remote host is\n%s.", 1247 error("The fingerprint for the %s key sent by the remote host is\n%s.",
1220 type, fp); 1248 key_type(host_key), fp);
1221 error("Please contact your system administrator."); 1249 error("Please contact your system administrator.");
1222 1250
1223 xfree(fp); 1251 xfree(fp);
@@ -1232,16 +1260,19 @@ ssh_local_cmd(const char *args)
1232 char *shell; 1260 char *shell;
1233 pid_t pid; 1261 pid_t pid;
1234 int status; 1262 int status;
1263 void (*osighand)(int);
1235 1264
1236 if (!options.permit_local_command || 1265 if (!options.permit_local_command ||
1237 args == NULL || !*args) 1266 args == NULL || !*args)
1238 return (1); 1267 return (1);
1239 1268
1240 if ((shell = getenv("SHELL")) == NULL) 1269 if ((shell = getenv("SHELL")) == NULL || *shell == '\0')
1241 shell = _PATH_BSHELL; 1270 shell = _PATH_BSHELL;
1242 1271
1272 osighand = signal(SIGCHLD, SIG_DFL);
1243 pid = fork(); 1273 pid = fork();
1244 if (pid == 0) { 1274 if (pid == 0) {
1275 signal(SIGPIPE, SIG_DFL);
1245 debug3("Executing %s -c \"%s\"", shell, args); 1276 debug3("Executing %s -c \"%s\"", shell, args);
1246 execl(shell, shell, "-c", args, (char *)NULL); 1277 execl(shell, shell, "-c", args, (char *)NULL);
1247 error("Couldn't execute %s -c \"%s\": %s", 1278 error("Couldn't execute %s -c \"%s\": %s",
@@ -1252,6 +1283,7 @@ ssh_local_cmd(const char *args)
1252 while (waitpid(pid, &status, 0) == -1) 1283 while (waitpid(pid, &status, 0) == -1)
1253 if (errno != EINTR) 1284 if (errno != EINTR)
1254 fatal("Couldn't wait for child: %s", strerror(errno)); 1285 fatal("Couldn't wait for child: %s", strerror(errno));
1286 signal(SIGCHLD, osighand);
1255 1287
1256 if (!WIFEXITED(status)) 1288 if (!WIFEXITED(status))
1257 return (1); 1289 return (1);
diff --git a/sshconnect.h b/sshconnect.h
index c59a097f4..fd7f7f7c6 100644
--- a/sshconnect.h
+++ b/sshconnect.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect.h,v 1.25 2009/05/27 06:38:16 andreas Exp $ */ 1/* $OpenBSD: sshconnect.h,v 1.27 2010/11/29 23:45:51 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -34,16 +34,20 @@ struct Sensitive {
34int 34int
35ssh_connect(const char *, struct sockaddr_storage *, u_short, int, int, 35ssh_connect(const char *, struct sockaddr_storage *, u_short, int, int,
36 int *, int, int, const char *); 36 int *, int, int, const char *);
37void ssh_kill_proxy_command(void);
37 38
38void 39void ssh_login(Sensitive *, const char *, struct sockaddr *, u_short,
39ssh_login(Sensitive *, const char *, struct sockaddr *, struct passwd *, int); 40 struct passwd *, int);
40 41
41void ssh_exchange_identification(int); 42void ssh_exchange_identification(int);
42 43
43int verify_host_key(char *, struct sockaddr *, Key *); 44int verify_host_key(char *, struct sockaddr *, Key *);
44 45
46void get_hostfile_hostname_ipaddr(char *, struct sockaddr *, u_short,
47 char **, char **);
48
45void ssh_kex(char *, struct sockaddr *); 49void ssh_kex(char *, struct sockaddr *);
46void ssh_kex2(char *, struct sockaddr *); 50void ssh_kex2(char *, struct sockaddr *, u_short);
47 51
48void ssh_userauth1(const char *, const char *, char *, Sensitive *); 52void ssh_userauth1(const char *, const char *, char *, Sensitive *);
49void ssh_userauth2(const char *, const char *, char *, Sensitive *); 53void ssh_userauth2(const char *, const char *, char *, Sensitive *);
diff --git a/sshconnect2.c b/sshconnect2.c
index 1a03c6bf3..aaf02ece4 100644
--- a/sshconnect2.c
+++ b/sshconnect2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect2.c,v 1.183 2010/04/26 22:28:24 djm Exp $ */ 1/* $OpenBSD: sshconnect2.c,v 1.186 2010/11/29 23:45:51 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2008 Damien Miller. All rights reserved. 4 * Copyright (c) 2008 Damien Miller. All rights reserved.
@@ -69,6 +69,7 @@
69#include "msg.h" 69#include "msg.h"
70#include "pathnames.h" 70#include "pathnames.h"
71#include "uidswap.h" 71#include "uidswap.h"
72#include "hostfile.h"
72#include "schnorr.h" 73#include "schnorr.h"
73#include "jpake.h" 74#include "jpake.h"
74 75
@@ -101,8 +102,60 @@ verify_host_key_callback(Key *hostkey)
101 return 0; 102 return 0;
102} 103}
103 104
105static char *
106order_hostkeyalgs(char *host, struct sockaddr *hostaddr, u_short port)
107{
108 char *oavail, *avail, *first, *last, *alg, *hostname, *ret;
109 size_t maxlen;
110 struct hostkeys *hostkeys;
111 int ktype;
112
113 /* Find all hostkeys for this hostname */
114 get_hostfile_hostname_ipaddr(host, hostaddr, port, &hostname, NULL);
115 hostkeys = init_hostkeys();
116 load_hostkeys(hostkeys, hostname, options.user_hostfile2);
117 load_hostkeys(hostkeys, hostname, options.system_hostfile2);
118 load_hostkeys(hostkeys, hostname, options.user_hostfile);
119 load_hostkeys(hostkeys, hostname, options.system_hostfile);
120
121 oavail = avail = xstrdup(KEX_DEFAULT_PK_ALG);
122 maxlen = strlen(avail) + 1;
123 first = xmalloc(maxlen);
124 last = xmalloc(maxlen);
125 *first = *last = '\0';
126
127#define ALG_APPEND(to, from) \
128 do { \
129 if (*to != '\0') \
130 strlcat(to, ",", maxlen); \
131 strlcat(to, from, maxlen); \
132 } while (0)
133
134 while ((alg = strsep(&avail, ",")) && *alg != '\0') {
135 if ((ktype = key_type_from_name(alg)) == KEY_UNSPEC)
136 fatal("%s: unknown alg %s", __func__, alg);
137 if (lookup_key_in_hostkeys_by_type(hostkeys,
138 key_type_plain(ktype), NULL))
139 ALG_APPEND(first, alg);
140 else
141 ALG_APPEND(last, alg);
142 }
143#undef ALG_APPEND
144 xasprintf(&ret, "%s%s%s", first, *first == '\0' ? "" : ",", last);
145 if (*first != '\0')
146 debug3("%s: prefer hostkeyalgs: %s", __func__, first);
147
148 xfree(first);
149 xfree(last);
150 xfree(hostname);
151 xfree(oavail);
152 free_hostkeys(hostkeys);
153
154 return ret;
155}
156
104void 157void
105ssh_kex2(char *host, struct sockaddr *hostaddr) 158ssh_kex2(char *host, struct sockaddr *hostaddr, u_short port)
106{ 159{
107 Kex *kex; 160 Kex *kex;
108 161
@@ -160,6 +213,13 @@ ssh_kex2(char *host, struct sockaddr *hostaddr)
160 if (options.hostkeyalgorithms != NULL) 213 if (options.hostkeyalgorithms != NULL)
161 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = 214 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] =
162 options.hostkeyalgorithms; 215 options.hostkeyalgorithms;
216 else {
217 /* Prefer algorithms that we already have keys for */
218 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] =
219 order_hostkeyalgs(host, hostaddr, port);
220 }
221 if (options.kex_algorithms != NULL)
222 myproposal[PROPOSAL_KEX_ALGS] = options.kex_algorithms;
163 223
164#ifdef GSSAPI 224#ifdef GSSAPI
165 /* If we've got GSSAPI algorithms, then we also support the 225 /* If we've got GSSAPI algorithms, then we also support the
@@ -181,6 +241,7 @@ ssh_kex2(char *host, struct sockaddr *hostaddr)
181 kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client; 241 kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client;
182 kex->kex[KEX_DH_GEX_SHA1] = kexgex_client; 242 kex->kex[KEX_DH_GEX_SHA1] = kexgex_client;
183 kex->kex[KEX_DH_GEX_SHA256] = kexgex_client; 243 kex->kex[KEX_DH_GEX_SHA256] = kexgex_client;
244 kex->kex[KEX_ECDH_SHA2] = kexecdh_client;
184#ifdef GSSAPI 245#ifdef GSSAPI
185 if (options.gss_keyex) { 246 if (options.gss_keyex) {
186 kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_client; 247 kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_client;
diff --git a/sshd.0 b/sshd.0
index a5d40c4d8..bb01b7164 100644
--- a/sshd.0
+++ b/sshd.0
@@ -78,10 +78,10 @@ DESCRIPTION
78 be given if sshd is not run as root (as the normal host key files 78 be given if sshd is not run as root (as the normal host key files
79 are normally not readable by anyone but root). The default is 79 are normally not readable by anyone but root). The default is
80 /etc/ssh/ssh_host_key for protocol version 1, and 80 /etc/ssh/ssh_host_key for protocol version 1, and
81 /etc/ssh/ssh_host_rsa_key and /etc/ssh/ssh_host_dsa_key for 81 /etc/ssh/ssh_host_dsa_key, /etc/ssh/ssh_host_ecdsa_key and
82 protocol version 2. It is possible to have multiple host key 82 /etc/ssh/ssh_host_rsa_key for protocol version 2. It is possible
83 files for the different protocol versions and host key 83 to have multiple host key files for the different protocol
84 algorithms. 84 versions and host key algorithms.
85 85
86 -i Specifies that sshd is being run from inetd(8). sshd is normally 86 -i Specifies that sshd is being run from inetd(8). sshd is normally
87 not run from inetd because it needs to generate the server key 87 not run from inetd because it needs to generate the server key
@@ -143,8 +143,8 @@ DESCRIPTION
143AUTHENTICATION 143AUTHENTICATION
144 The OpenSSH SSH daemon supports SSH protocols 1 and 2. The default is to 144 The OpenSSH SSH daemon supports SSH protocols 1 and 2. The default is to
145 use protocol 2 only, though this can be changed via the Protocol option 145 use protocol 2 only, though this can be changed via the Protocol option
146 in sshd_config(5). Protocol 2 supports both RSA and DSA keys; protocol 1 146 in sshd_config(5). Protocol 2 supports DSA, ECDSA and RSA keys; protocol
147 only supports RSA keys. For both protocols, each host has a host- 147 1 only supports RSA keys. For both protocols, each host has a host-
148 specific key, normally 2048 bits, used to identify the host. 148 specific key, normally 2048 bits, used to identify the host.
149 149
150 Forward security for protocol 1 is provided through an additional server 150 Forward security for protocol 1 is provided through an additional server
@@ -273,13 +273,15 @@ AUTHORIZED_KEYS FILE FORMAT
273 exponent, modulus, and comment fields give the RSA key for protocol 273 exponent, modulus, and comment fields give the RSA key for protocol
274 version 1; the comment field is not used for anything (but may be 274 version 1; the comment field is not used for anything (but may be
275 convenient for the user to identify the key). For protocol version 2 the 275 convenient for the user to identify the key). For protocol version 2 the
276 keytype is ``ssh-dss'' or ``ssh-rsa''. 276 keytype is ``ecdsa-sha2-nistp256'', ``ecdsa-sha2-nistp384'',
277 ``ecdsa-sha2-nistp521'', ``ssh-dss'' or ``ssh-rsa''.
277 278
278 Note that lines in this file are usually several hundred bytes long 279 Note that lines in this file are usually several hundred bytes long
279 (because of the size of the public key encoding) up to a limit of 8 280 (because of the size of the public key encoding) up to a limit of 8
280 kilobytes, which permits DSA keys up to 8 kilobits and RSA keys up to 16 281 kilobytes, which permits DSA keys up to 8 kilobits and RSA keys up to 16
281 kilobits. You don't want to type them in; instead, copy the 282 kilobits. You don't want to type them in; instead, copy the
282 identity.pub, id_dsa.pub, or the id_rsa.pub file and edit it. 283 identity.pub, id_dsa.pub, id_ecdsa.pub, or the id_rsa.pub file and edit
284 it.
283 285
284 sshd enforces a minimum RSA key modulus size for protocol 1 and protocol 286 sshd enforces a minimum RSA key modulus size for protocol 1 and protocol
285 2 keys of 768 bits. 287 2 keys of 768 bits.
@@ -504,11 +506,11 @@ FILES
504 for the user, and not accessible by others. 506 for the user, and not accessible by others.
505 507
506 ~/.ssh/authorized_keys 508 ~/.ssh/authorized_keys
507 Lists the public keys (RSA/DSA) that can be used for logging in 509 Lists the public keys (DSA/ECDSA/RSA) that can be used for
508 as this user. The format of this file is described above. The 510 logging in as this user. The format of this file is described
509 content of the file is not highly sensitive, but the recommended 511 above. The content of the file is not highly sensitive, but the
510 permissions are read/write for the user, and not accessible by 512 recommended permissions are read/write for the user, and not
511 others. 513 accessible by others.
512 514
513 If this file, the ~/.ssh directory, or the user's home directory 515 If this file, the ~/.ssh directory, or the user's home directory
514 are writable by other users, then the file could be modified or 516 are writable by other users, then the file could be modified or
@@ -565,6 +567,7 @@ FILES
565 567
566 /etc/ssh/ssh_host_key 568 /etc/ssh/ssh_host_key
567 /etc/ssh/ssh_host_dsa_key 569 /etc/ssh/ssh_host_dsa_key
570 /etc/ssh/ssh_host_ecdsa_key
568 /etc/ssh/ssh_host_rsa_key 571 /etc/ssh/ssh_host_rsa_key
569 These three files contain the private parts of the host keys. 572 These three files contain the private parts of the host keys.
570 These files should only be owned by root, readable only by root, 573 These files should only be owned by root, readable only by root,
@@ -573,6 +576,7 @@ FILES
573 576
574 /etc/ssh/ssh_host_key.pub 577 /etc/ssh/ssh_host_key.pub
575 /etc/ssh/ssh_host_dsa_key.pub 578 /etc/ssh/ssh_host_dsa_key.pub
579 /etc/ssh/ssh_host_ecdsa_key.pub
576 /etc/ssh/ssh_host_rsa_key.pub 580 /etc/ssh/ssh_host_rsa_key.pub
577 These three files contain the public parts of the host keys. 581 These three files contain the public parts of the host keys.
578 These files should be world-readable but writable only by root. 582 These files should be world-readable but writable only by root.
@@ -627,4 +631,4 @@ CAVEATS
627 System security is not improved unless rshd, rlogind, and rexecd are 631 System security is not improved unless rshd, rlogind, and rexecd are
628 disabled (thus completely disabling rlogin and rsh into the machine). 632 disabled (thus completely disabling rlogin and rsh into the machine).
629 633
630OpenBSD 4.8 August 4, 2010 OpenBSD 4.8 634OpenBSD 4.8 October 28, 2010 OpenBSD 4.8
diff --git a/sshd.8 b/sshd.8
index d3685b92b..5503b1331 100644
--- a/sshd.8
+++ b/sshd.8
@@ -1,4 +1,3 @@
1.\" -*- nroff -*-
2.\" 1.\"
3.\" Author: Tatu Ylonen <ylo@cs.hut.fi> 2.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 3.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -34,8 +33,8 @@
34.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 33.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36.\" 35.\"
37.\" $OpenBSD: sshd.8,v 1.257 2010/08/04 05:37:01 djm Exp $ 36.\" $OpenBSD: sshd.8,v 1.260 2010/10/28 18:33:28 jmc Exp $
38.Dd $Mdocdate: August 4 2010 $ 37.Dd $Mdocdate: October 28 2010 $
39.Dt SSHD 8 38.Dt SSHD 8
40.Os 39.Os
41.Sh NAME 40.Sh NAME
@@ -170,9 +169,10 @@ host key files are normally not readable by anyone but root).
170The default is 169The default is
171.Pa /etc/ssh/ssh_host_key 170.Pa /etc/ssh/ssh_host_key
172for protocol version 1, and 171for protocol version 1, and
173.Pa /etc/ssh/ssh_host_rsa_key 172.Pa /etc/ssh/ssh_host_dsa_key ,
173.Pa /etc/ssh/ssh_host_ecdsa_key
174and 174and
175.Pa /etc/ssh/ssh_host_dsa_key 175.Pa /etc/ssh/ssh_host_rsa_key
176for protocol version 2. 176for protocol version 2.
177It is possible to have multiple host key files for 177It is possible to have multiple host key files for
178the different protocol versions and host key algorithms. 178the different protocol versions and host key algorithms.
@@ -275,7 +275,7 @@ though this can be changed via the
275.Cm Protocol 275.Cm Protocol
276option in 276option in
277.Xr sshd_config 5 . 277.Xr sshd_config 5 .
278Protocol 2 supports both RSA and DSA keys; 278Protocol 2 supports DSA, ECDSA and RSA keys;
279protocol 1 only supports RSA keys. 279protocol 1 only supports RSA keys.
280For both protocols, 280For both protocols,
281each host has a host-specific key, 281each host has a host-specific key,
@@ -483,6 +483,9 @@ protocol version 1; the
483comment field is not used for anything (but may be convenient for the 483comment field is not used for anything (but may be convenient for the
484user to identify the key). 484user to identify the key).
485For protocol version 2 the keytype is 485For protocol version 2 the keytype is
486.Dq ecdsa-sha2-nistp256 ,
487.Dq ecdsa-sha2-nistp384 ,
488.Dq ecdsa-sha2-nistp521 ,
486.Dq ssh-dss 489.Dq ssh-dss
487or 490or
488.Dq ssh-rsa . 491.Dq ssh-rsa .
@@ -494,6 +497,7 @@ keys up to 16 kilobits.
494You don't want to type them in; instead, copy the 497You don't want to type them in; instead, copy the
495.Pa identity.pub , 498.Pa identity.pub ,
496.Pa id_dsa.pub , 499.Pa id_dsa.pub ,
500.Pa id_ecdsa.pub ,
497or the 501or the
498.Pa id_rsa.pub 502.Pa id_rsa.pub
499file and edit it. 503file and edit it.
@@ -751,7 +755,7 @@ AAAA1234.....=
751.Ed 755.Ed
752.Sh FILES 756.Sh FILES
753.Bl -tag -width Ds -compact 757.Bl -tag -width Ds -compact
754.It ~/.hushlogin 758.It Pa ~/.hushlogin
755This file is used to suppress printing the last login time and 759This file is used to suppress printing the last login time and
756.Pa /etc/motd , 760.Pa /etc/motd ,
757if 761if
@@ -763,7 +767,7 @@ are enabled.
763It does not suppress printing of the banner specified by 767It does not suppress printing of the banner specified by
764.Cm Banner . 768.Cm Banner .
765.Pp 769.Pp
766.It ~/.rhosts 770.It Pa ~/.rhosts
767This file is used for host-based authentication (see 771This file is used for host-based authentication (see
768.Xr ssh 1 772.Xr ssh 1
769for more information). 773for more information).
@@ -778,21 +782,22 @@ The recommended
778permission for most machines is read/write for the user, and not 782permission for most machines is read/write for the user, and not
779accessible by others. 783accessible by others.
780.Pp 784.Pp
781.It ~/.shosts 785.It Pa ~/.shosts
782This file is used in exactly the same way as 786This file is used in exactly the same way as
783.Pa .rhosts , 787.Pa .rhosts ,
784but allows host-based authentication without permitting login with 788but allows host-based authentication without permitting login with
785rlogin/rsh. 789rlogin/rsh.
786.Pp 790.Pp
787.It ~/.ssh/ 791.It Pa ~/.ssh/
788This directory is the default location for all user-specific configuration 792This directory is the default location for all user-specific configuration
789and authentication information. 793and authentication information.
790There is no general requirement to keep the entire contents of this directory 794There is no general requirement to keep the entire contents of this directory
791secret, but the recommended permissions are read/write/execute for the user, 795secret, but the recommended permissions are read/write/execute for the user,
792and not accessible by others. 796and not accessible by others.
793.Pp 797.Pp
794.It ~/.ssh/authorized_keys 798.It Pa ~/.ssh/authorized_keys
795Lists the public keys (RSA/DSA) that can be used for logging in as this user. 799Lists the public keys (DSA/ECDSA/RSA) that can be used for logging in
800as this user.
796The format of this file is described above. 801The format of this file is described above.
797The content of the file is not highly sensitive, but the recommended 802The content of the file is not highly sensitive, but the recommended
798permissions are read/write for the user, and not accessible by others. 803permissions are read/write for the user, and not accessible by others.
@@ -809,7 +814,7 @@ will not allow it to be used unless the
809option has been set to 814option has been set to
810.Dq no . 815.Dq no .
811.Pp 816.Pp
812.It ~/.ssh/environment 817.It Pa ~/.ssh/environment
813This file is read into the environment at login (if it exists). 818This file is read into the environment at login (if it exists).
814It can only contain empty lines, comment lines (that start with 819It can only contain empty lines, comment lines (that start with
815.Ql # ) , 820.Ql # ) ,
@@ -821,40 +826,40 @@ controlled via the
821.Cm PermitUserEnvironment 826.Cm PermitUserEnvironment
822option. 827option.
823.Pp 828.Pp
824.It ~/.ssh/known_hosts 829.It Pa ~/.ssh/known_hosts
825Contains a list of host keys for all hosts the user has logged into 830Contains a list of host keys for all hosts the user has logged into
826that are not already in the systemwide list of known host keys. 831that are not already in the systemwide list of known host keys.
827The format of this file is described above. 832The format of this file is described above.
828This file should be writable only by root/the owner and 833This file should be writable only by root/the owner and
829can, but need not be, world-readable. 834can, but need not be, world-readable.
830.Pp 835.Pp
831.It ~/.ssh/rc 836.It Pa ~/.ssh/rc
832Contains initialization routines to be run before 837Contains initialization routines to be run before
833the user's home directory becomes accessible. 838the user's home directory becomes accessible.
834This file should be writable only by the user, and need not be 839This file should be writable only by the user, and need not be
835readable by anyone else. 840readable by anyone else.
836.Pp 841.Pp
837.It /etc/hosts.allow 842.It Pa /etc/hosts.allow
838.It /etc/hosts.deny 843.It Pa /etc/hosts.deny
839Access controls that should be enforced by tcp-wrappers are defined here. 844Access controls that should be enforced by tcp-wrappers are defined here.
840Further details are described in 845Further details are described in
841.Xr hosts_access 5 . 846.Xr hosts_access 5 .
842.Pp 847.Pp
843.It /etc/hosts.equiv 848.It Pa /etc/hosts.equiv
844This file is for host-based authentication (see 849This file is for host-based authentication (see
845.Xr ssh 1 ) . 850.Xr ssh 1 ) .
846It should only be writable by root. 851It should only be writable by root.
847.Pp 852.Pp
848.It /etc/moduli 853.It Pa /etc/moduli
849Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange". 854Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange".
850The file format is described in 855The file format is described in
851.Xr moduli 5 . 856.Xr moduli 5 .
852.Pp 857.Pp
853.It /etc/motd 858.It Pa /etc/motd
854See 859See
855.Xr motd 5 . 860.Xr motd 5 .
856.Pp 861.Pp
857.It /etc/nologin 862.It Pa /etc/nologin
858If this file exists, 863If this file exists,
859.Nm 864.Nm
860refuses to let anyone except root log in. 865refuses to let anyone except root log in.
@@ -863,15 +868,16 @@ are displayed to anyone trying to log in, and non-root connections are
863refused. 868refused.
864The file should be world-readable. 869The file should be world-readable.
865.Pp 870.Pp
866.It /etc/shosts.equiv 871.It Pa /etc/shosts.equiv
867This file is used in exactly the same way as 872This file is used in exactly the same way as
868.Pa hosts.equiv , 873.Pa hosts.equiv ,
869but allows host-based authentication without permitting login with 874but allows host-based authentication without permitting login with
870rlogin/rsh. 875rlogin/rsh.
871.Pp 876.Pp
872.It /etc/ssh/ssh_host_key 877.It Pa /etc/ssh/ssh_host_key
873.It /etc/ssh/ssh_host_dsa_key 878.It Pa /etc/ssh/ssh_host_dsa_key
874.It /etc/ssh/ssh_host_rsa_key 879.It Pa /etc/ssh/ssh_host_ecdsa_key
880.It Pa /etc/ssh/ssh_host_rsa_key
875These three files contain the private parts of the host keys. 881These three files contain the private parts of the host keys.
876These files should only be owned by root, readable only by root, and not 882These files should only be owned by root, readable only by root, and not
877accessible to others. 883accessible to others.
@@ -879,9 +885,10 @@ Note that
879.Nm 885.Nm
880does not start if these files are group/world-accessible. 886does not start if these files are group/world-accessible.
881.Pp 887.Pp
882.It /etc/ssh/ssh_host_key.pub 888.It Pa /etc/ssh/ssh_host_key.pub
883.It /etc/ssh/ssh_host_dsa_key.pub 889.It Pa /etc/ssh/ssh_host_dsa_key.pub
884.It /etc/ssh/ssh_host_rsa_key.pub 890.It Pa /etc/ssh/ssh_host_ecdsa_key.pub
891.It Pa /etc/ssh/ssh_host_rsa_key.pub
885These three files contain the public parts of the host keys. 892These three files contain the public parts of the host keys.
886These files should be world-readable but writable only by 893These files should be world-readable but writable only by
887root. 894root.
@@ -892,7 +899,7 @@ the user so their contents can be copied to known hosts files.
892These files are created using 899These files are created using
893.Xr ssh-keygen 1 . 900.Xr ssh-keygen 1 .
894.Pp 901.Pp
895.It /etc/ssh/ssh_known_hosts 902.It Pa /etc/ssh/ssh_known_hosts
896Systemwide list of known host keys. 903Systemwide list of known host keys.
897This file should be prepared by the 904This file should be prepared by the
898system administrator to contain the public host keys of all machines in the 905system administrator to contain the public host keys of all machines in the
@@ -901,20 +908,20 @@ The format of this file is described above.
901This file should be writable only by root/the owner and 908This file should be writable only by root/the owner and
902should be world-readable. 909should be world-readable.
903.Pp 910.Pp
904.It /etc/ssh/sshd_config 911.It Pa /etc/ssh/sshd_config
905Contains configuration data for 912Contains configuration data for
906.Nm sshd . 913.Nm sshd .
907The file format and configuration options are described in 914The file format and configuration options are described in
908.Xr sshd_config 5 . 915.Xr sshd_config 5 .
909.Pp 916.Pp
910.It /etc/ssh/sshrc 917.It Pa /etc/ssh/sshrc
911Similar to 918Similar to
912.Pa ~/.ssh/rc , 919.Pa ~/.ssh/rc ,
913it can be used to specify 920it can be used to specify
914machine-specific login-time initializations globally. 921machine-specific login-time initializations globally.
915This file should be writable only by root, and should be world-readable. 922This file should be writable only by root, and should be world-readable.
916.Pp 923.Pp
917.It /var/empty 924.It Pa /var/empty
918.Xr chroot 2 925.Xr chroot 2
919directory used by 926directory used by
920.Nm 927.Nm
@@ -922,7 +929,7 @@ during privilege separation in the pre-authentication phase.
922The directory should not contain any files and must be owned by root 929The directory should not contain any files and must be owned by root
923and not group or world-writable. 930and not group or world-writable.
924.Pp 931.Pp
925.It /var/run/sshd.pid 932.It Pa /var/run/sshd.pid
926Contains the process ID of the 933Contains the process ID of the
927.Nm 934.Nm
928listening for connections (if there are several daemons running 935listening for connections (if there are several daemons running
diff --git a/sshd.c b/sshd.c
index 06a2e1e5c..1136c63e4 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshd.c,v 1.375 2010/04/16 01:47:26 djm Exp $ */ 1/* $OpenBSD: sshd.c,v 1.381 2011/01/11 06:13:10 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -737,6 +737,7 @@ list_hostkey_types(void)
737 switch (key->type) { 737 switch (key->type) {
738 case KEY_RSA: 738 case KEY_RSA:
739 case KEY_DSA: 739 case KEY_DSA:
740 case KEY_ECDSA:
740 if (buffer_len(&b) > 0) 741 if (buffer_len(&b) > 0)
741 buffer_append(&b, ",", 1); 742 buffer_append(&b, ",", 1);
742 p = key_ssh_name(key); 743 p = key_ssh_name(key);
@@ -752,6 +753,7 @@ list_hostkey_types(void)
752 case KEY_DSA_CERT_V00: 753 case KEY_DSA_CERT_V00:
753 case KEY_RSA_CERT: 754 case KEY_RSA_CERT:
754 case KEY_DSA_CERT: 755 case KEY_DSA_CERT:
756 case KEY_ECDSA_CERT:
755 if (buffer_len(&b) > 0) 757 if (buffer_len(&b) > 0)
756 buffer_append(&b, ",", 1); 758 buffer_append(&b, ",", 1);
757 p = key_ssh_name(key); 759 p = key_ssh_name(key);
@@ -778,6 +780,7 @@ get_hostkey_by_type(int type, int need_private)
778 case KEY_DSA_CERT_V00: 780 case KEY_DSA_CERT_V00:
779 case KEY_RSA_CERT: 781 case KEY_RSA_CERT:
780 case KEY_DSA_CERT: 782 case KEY_DSA_CERT:
783 case KEY_ECDSA_CERT:
781 key = sensitive_data.host_certificates[i]; 784 key = sensitive_data.host_certificates[i];
782 break; 785 break;
783 default: 786 default:
@@ -1468,7 +1471,7 @@ main(int ac, char **av)
1468 else 1471 else
1469 closefrom(REEXEC_DEVCRYPTO_RESERVED_FD); 1472 closefrom(REEXEC_DEVCRYPTO_RESERVED_FD);
1470 1473
1471 SSLeay_add_all_algorithms(); 1474 OpenSSL_add_all_algorithms();
1472 1475
1473 /* 1476 /*
1474 * Force logging to stderr until we have loaded the private host 1477 * Force logging to stderr until we have loaded the private host
@@ -1580,6 +1583,7 @@ main(int ac, char **av)
1580 break; 1583 break;
1581 case KEY_RSA: 1584 case KEY_RSA:
1582 case KEY_DSA: 1585 case KEY_DSA:
1586 case KEY_ECDSA:
1583 sensitive_data.have_ssh2_key = 1; 1587 sensitive_data.have_ssh2_key = 1;
1584 break; 1588 break;
1585 } 1589 }
@@ -2084,7 +2088,8 @@ main(int ac, char **av)
2084 /* The connection has been terminated. */ 2088 /* The connection has been terminated. */
2085 packet_get_state(MODE_IN, NULL, NULL, NULL, &ibytes); 2089 packet_get_state(MODE_IN, NULL, NULL, NULL, &ibytes);
2086 packet_get_state(MODE_OUT, NULL, NULL, NULL, &obytes); 2090 packet_get_state(MODE_OUT, NULL, NULL, NULL, &obytes);
2087 verbose("Transferred: sent %llu, received %llu bytes", obytes, ibytes); 2091 verbose("Transferred: sent %llu, received %llu bytes",
2092 (unsigned long long)obytes, (unsigned long long)ibytes);
2088 2093
2089 verbose("Closing connection to %.500s port %d", remote_ip, remote_port); 2094 verbose("Closing connection to %.500s port %d", remote_ip, remote_port);
2090 2095
@@ -2354,6 +2359,8 @@ do_ssh2_kex(void)
2354 myproposal[PROPOSAL_COMP_ALGS_CTOS] = 2359 myproposal[PROPOSAL_COMP_ALGS_CTOS] =
2355 myproposal[PROPOSAL_COMP_ALGS_STOC] = "none,zlib@openssh.com"; 2360 myproposal[PROPOSAL_COMP_ALGS_STOC] = "none,zlib@openssh.com";
2356 } 2361 }
2362 if (options.kex_algorithms != NULL)
2363 myproposal[PROPOSAL_KEX_ALGS] = options.kex_algorithms;
2357 2364
2358 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = list_hostkey_types(); 2365 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = list_hostkey_types();
2359 2366
@@ -2405,6 +2412,7 @@ do_ssh2_kex(void)
2405 kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server; 2412 kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server;
2406 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; 2413 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
2407 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; 2414 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
2415 kex->kex[KEX_ECDH_SHA2] = kexecdh_server;
2408#ifdef GSSAPI 2416#ifdef GSSAPI
2409 if (options.gss_keyex) { 2417 if (options.gss_keyex) {
2410 kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server; 2418 kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
diff --git a/sshd_config b/sshd_config
index 69ff6b600..3576260a2 100644
--- a/sshd_config
+++ b/sshd_config
@@ -1,4 +1,4 @@
1# $OpenBSD: sshd_config,v 1.81 2009/10/08 14:03:41 markus Exp $ 1# $OpenBSD: sshd_config,v 1.82 2010/09/06 17:10:19 naddy Exp $
2 2
3# This is the sshd server system-wide configuration file. See 3# This is the sshd server system-wide configuration file. See
4# sshd_config(5) for more information. 4# sshd_config(5) for more information.
@@ -23,6 +23,7 @@
23# HostKeys for protocol version 2 23# HostKeys for protocol version 2
24#HostKey /etc/ssh/ssh_host_rsa_key 24#HostKey /etc/ssh/ssh_host_rsa_key
25#HostKey /etc/ssh/ssh_host_dsa_key 25#HostKey /etc/ssh/ssh_host_dsa_key
26#HostKey /etc/ssh/ssh_host_ecdsa_key
26 27
27# Lifetime and size of ephemeral version 1 server key 28# Lifetime and size of ephemeral version 1 server key
28#KeyRegenerationInterval 1h 29#KeyRegenerationInterval 1h
diff --git a/sshd_config.0 b/sshd_config.0
index a49953851..669d29a06 100644
--- a/sshd_config.0
+++ b/sshd_config.0
@@ -272,11 +272,12 @@ DESCRIPTION
272 HostKey 272 HostKey
273 Specifies a file containing a private host key used by SSH. The 273 Specifies a file containing a private host key used by SSH. The
274 default is /etc/ssh/ssh_host_key for protocol version 1, and 274 default is /etc/ssh/ssh_host_key for protocol version 1, and
275 /etc/ssh/ssh_host_rsa_key and /etc/ssh/ssh_host_dsa_key for 275 /etc/ssh/ssh_host_dsa_key, /etc/ssh/ssh_host_ecdsa_key and
276 protocol version 2. Note that sshd(8) will refuse to use a file 276 /etc/ssh/ssh_host_rsa_key for protocol version 2. Note that
277 if it is group/world-accessible. It is possible to have multiple 277 sshd(8) will refuse to use a file if it is group/world-
278 host key files. ``rsa1'' keys are used for version 1 and ``dsa'' 278 accessible. It is possible to have multiple host key files.
279 or ``rsa'' are used for version 2 of the SSH protocol. 279 ``rsa1'' keys are used for version 1 and ``dsa'', ``ecdsa'' or
280 ``rsa'' are used for version 2 of the SSH protocol.
280 281
281 IgnoreRhosts 282 IgnoreRhosts
282 Specifies that .rhosts and .shosts files will not be used in 283 Specifies that .rhosts and .shosts files will not be used in
@@ -290,6 +291,20 @@ DESCRIPTION
290 ~/.ssh/known_hosts during RhostsRSAAuthentication or 291 ~/.ssh/known_hosts during RhostsRSAAuthentication or
291 HostbasedAuthentication. The default is ``no''. 292 HostbasedAuthentication. The default is ``no''.
292 293
294 IPQoS Specifies the IPv4 type-of-service or DSCP class for the
295 connection. Accepted values are ``af11'', ``af12'', ``af13'',
296 ``af14'', ``af22'', ``af23'', ``af31'', ``af32'', ``af33'',
297 ``af41'', ``af42'', ``af43'', ``cs0'', ``cs1'', ``cs2'', ``cs3'',
298 ``cs4'', ``cs5'', ``cs6'', ``cs7'', ``ef'', ``lowdelay'',
299 ``throughput'', ``reliability'', or a numeric value. This option
300 may take one or two arguments, separated by whitespace. If one
301 argument is specified, it is used as the packet class
302 unconditionally. If two values are specified, the first is
303 automatically selected for interactive sessions and the second
304 for non-interactive sessions. The default is ``lowdelay'' for
305 interactive sessions and ``throughput'' for non-interactive
306 sessions.
307
293 KerberosAuthentication 308 KerberosAuthentication
294 Specifies whether the password provided by the user for 309 Specifies whether the password provided by the user for
295 PasswordAuthentication will be validated through the Kerberos 310 PasswordAuthentication will be validated through the Kerberos
@@ -311,6 +326,14 @@ DESCRIPTION
311 Specifies whether to automatically destroy the user's ticket 326 Specifies whether to automatically destroy the user's ticket
312 cache file on logout. The default is ``yes''. 327 cache file on logout. The default is ``yes''.
313 328
329 KexAlgorithms
330 Specifies the available KEX (Key Exchange) algorithms. Multiple
331 algorithms must be comma-separated. The default is
332 ``ecdh-sha2-nistp256'', ``ecdh-sha2-nistp384'',
333 ``ecdh-sha2-nistp521'', ``diffie-hellman-group-exchange-sha256'',
334 ``diffie-hellman-group-exchange-sha1'',
335 ``diffie-hellman-group14-sha1'', ``diffie-hellman-group1-sha1''.
336
314 KeyRegenerationInterval 337 KeyRegenerationInterval
315 In protocol version 1, the ephemeral server key is automatically 338 In protocol version 1, the ephemeral server key is automatically
316 regenerated after this many seconds (if it has been used). The 339 regenerated after this many seconds (if it has been used). The
@@ -323,8 +346,8 @@ DESCRIPTION
323 Specifies the local addresses sshd(8) should listen on. The 346 Specifies the local addresses sshd(8) should listen on. The
324 following forms may be used: 347 following forms may be used:
325 348
326 ListenAddress host | IPv4_addr | IPv6_addr 349 ListenAddress host|IPv4_addr|IPv6_addr
327 ListenAddress host | IPv4_addr:port 350 ListenAddress host|IPv4_addr:port
328 ListenAddress [host|IPv6_addr]:port 351 ListenAddress [host|IPv6_addr]:port
329 352
330 If port is not specified, sshd will listen on the address and all 353 If port is not specified, sshd will listen on the address and all
@@ -424,7 +447,7 @@ DESCRIPTION
424 447
425 PermitOpen host:port 448 PermitOpen host:port
426 PermitOpen IPv4_addr:port 449 PermitOpen IPv4_addr:port
427 PermitOpen [ IPv6_addr ]:port 450 PermitOpen [IPv6_addr]:port
428 451
429 Multiple forwards may be specified by separating them with 452 Multiple forwards may be specified by separating them with
430 whitespace. An argument of ``any'' can be used to remove all 453 whitespace. An argument of ``any'' can be used to remove all
@@ -650,9 +673,9 @@ DESCRIPTION
650 673
651TIME FORMATS 674TIME FORMATS
652 sshd(8) command-line arguments and configuration file options that 675 sshd(8) command-line arguments and configuration file options that
653 specify time may be expressed using a sequence of the form: time 676 specify time may be expressed using a sequence of the form:
654 [qualifier], where time is a positive integer value and qualifier is one 677 time[qualifier], where time is a positive integer value and qualifier is
655 of the following: 678 one of the following:
656 679
657 <none> seconds 680 <none> seconds
658 s | S seconds 681 s | S seconds
@@ -687,4 +710,4 @@ AUTHORS
687 versions 1.5 and 2.0. Niels Provos and Markus Friedl contributed support 710 versions 1.5 and 2.0. Niels Provos and Markus Friedl contributed support
688 for privilege separation. 711 for privilege separation.
689 712
690OpenBSD 4.8 June 30, 2010 OpenBSD 4.8 713OpenBSD 4.8 December 8, 2010 OpenBSD 4.8
diff --git a/sshd_config.5 b/sshd_config.5
index 55e8d8503..449afb302 100644
--- a/sshd_config.5
+++ b/sshd_config.5
@@ -1,4 +1,3 @@
1.\" -*- nroff -*-
2.\" 1.\"
3.\" Author: Tatu Ylonen <ylo@cs.hut.fi> 2.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 3.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -34,8 +33,8 @@
34.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 33.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36.\" 35.\"
37.\" $OpenBSD: sshd_config.5,v 1.125 2010/06/30 07:28:34 jmc Exp $ 36.\" $OpenBSD: sshd_config.5,v 1.131 2010/12/08 04:02:47 djm Exp $
38.Dd $Mdocdate: June 30 2010 $ 37.Dd $Mdocdate: December 8 2010 $
39.Dt SSHD_CONFIG 5 38.Dt SSHD_CONFIG 5
40.Os 39.Os
41.Sh NAME 40.Sh NAME
@@ -498,9 +497,10 @@ used by SSH.
498The default is 497The default is
499.Pa /etc/ssh/ssh_host_key 498.Pa /etc/ssh/ssh_host_key
500for protocol version 1, and 499for protocol version 1, and
501.Pa /etc/ssh/ssh_host_rsa_key 500.Pa /etc/ssh/ssh_host_dsa_key ,
501.Pa /etc/ssh/ssh_host_ecdsa_key
502and 502and
503.Pa /etc/ssh/ssh_host_dsa_key 503.Pa /etc/ssh/ssh_host_rsa_key
504for protocol version 2. 504for protocol version 2.
505Note that 505Note that
506.Xr sshd 8 506.Xr sshd 8
@@ -508,7 +508,8 @@ will refuse to use a file if it is group/world-accessible.
508It is possible to have multiple host key files. 508It is possible to have multiple host key files.
509.Dq rsa1 509.Dq rsa1
510keys are used for version 1 and 510keys are used for version 1 and
511.Dq dsa 511.Dq dsa ,
512.Dq ecdsa
512or 513or
513.Dq rsa 514.Dq rsa
514are used for version 2 of the SSH protocol. 515are used for version 2 of the SSH protocol.
@@ -539,6 +540,43 @@ or
539.Cm HostbasedAuthentication . 540.Cm HostbasedAuthentication .
540The default is 541The default is
541.Dq no . 542.Dq no .
543.It Cm IPQoS
544Specifies the IPv4 type-of-service or DSCP class for the connection.
545Accepted values are
546.Dq af11 ,
547.Dq af12 ,
548.Dq af13 ,
549.Dq af14 ,
550.Dq af22 ,
551.Dq af23 ,
552.Dq af31 ,
553.Dq af32 ,
554.Dq af33 ,
555.Dq af41 ,
556.Dq af42 ,
557.Dq af43 ,
558.Dq cs0 ,
559.Dq cs1 ,
560.Dq cs2 ,
561.Dq cs3 ,
562.Dq cs4 ,
563.Dq cs5 ,
564.Dq cs6 ,
565.Dq cs7 ,
566.Dq ef ,
567.Dq lowdelay ,
568.Dq throughput ,
569.Dq reliability ,
570or a numeric value.
571This option may take one or two arguments, separated by whitespace.
572If one argument is specified, it is used as the packet class unconditionally.
573If two values are specified, the first is automatically selected for
574interactive sessions and the second for non-interactive sessions.
575The default is
576.Dq lowdelay
577for interactive sessions and
578.Dq throughput
579for non-interactive sessions.
542.It Cm KerberosAuthentication 580.It Cm KerberosAuthentication
543Specifies whether the password provided by the user for 581Specifies whether the password provided by the user for
544.Cm PasswordAuthentication 582.Cm PasswordAuthentication
@@ -564,6 +602,17 @@ Specifies whether to automatically destroy the user's ticket cache
564file on logout. 602file on logout.
565The default is 603The default is
566.Dq yes . 604.Dq yes .
605.It Cm KexAlgorithms
606Specifies the available KEX (Key Exchange) algorithms.
607Multiple algorithms must be comma-separated.
608The default is
609.Dq ecdh-sha2-nistp256 ,
610.Dq ecdh-sha2-nistp384 ,
611.Dq ecdh-sha2-nistp521 ,
612.Dq diffie-hellman-group-exchange-sha256 ,
613.Dq diffie-hellman-group-exchange-sha1 ,
614.Dq diffie-hellman-group14-sha1 ,
615.Dq diffie-hellman-group1-sha1 .
567.It Cm KeyRegenerationInterval 616.It Cm KeyRegenerationInterval
568In protocol version 1, the ephemeral server key is automatically regenerated 617In protocol version 1, the ephemeral server key is automatically regenerated
569after this many seconds (if it has been used). 618after this many seconds (if it has been used).
diff --git a/sshlogin.c b/sshlogin.c
index 33bd652fb..54629f747 100644
--- a/sshlogin.c
+++ b/sshlogin.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshlogin.c,v 1.26 2007/09/11 15:47:17 gilles Exp $ */ 1/* $OpenBSD: sshlogin.c,v 1.27 2011/01/11 06:06:09 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
diff --git a/uuencode.c b/uuencode.c
index b9e57e993..09d80d2fc 100644
--- a/uuencode.c
+++ b/uuencode.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: uuencode.c,v 1.25 2009/03/05 11:30:50 djm Exp $ */ 1/* $OpenBSD: uuencode.c,v 1.26 2010/08/31 11:54:45 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -72,7 +72,7 @@ uudecode(const char *src, u_char *target, size_t targsize)
72} 72}
73 73
74void 74void
75dump_base64(FILE *fp, u_char *data, u_int len) 75dump_base64(FILE *fp, const u_char *data, u_int len)
76{ 76{
77 char *buf; 77 char *buf;
78 int i, n; 78 int i, n;
diff --git a/uuencode.h b/uuencode.h
index fec55b491..4d9888126 100644
--- a/uuencode.h
+++ b/uuencode.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: uuencode.h,v 1.13 2006/08/03 03:34:42 deraadt Exp $ */ 1/* $OpenBSD: uuencode.h,v 1.14 2010/08/31 11:54:45 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -26,4 +26,4 @@
26 26
27int uuencode(const u_char *, u_int, char *, size_t); 27int uuencode(const u_char *, u_int, char *, size_t);
28int uudecode(const char *, u_char *, size_t); 28int uudecode(const char *, u_char *, size_t);
29void dump_base64(FILE *, u_char *, u_int); 29void dump_base64(FILE *, const u_char *, u_int);
diff --git a/version.h b/version.h
index 67d78dcc3..202e0dec2 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
1/* $OpenBSD: version.h,v 1.59 2010/08/08 16:26:42 djm Exp $ */ 1/* $OpenBSD: version.h,v 1.60 2011/01/22 09:18:53 djm Exp $ */
2 2
3#define SSH_VERSION "OpenSSH_5.6" 3#define SSH_VERSION "OpenSSH_5.7"
4 4
5#define SSH_PORTABLE "p1" 5#define SSH_PORTABLE "p1"
6#define SSH_RELEASE SSH_VERSION SSH_PORTABLE 6#define SSH_RELEASE SSH_VERSION SSH_PORTABLE