summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3101
-rw-r--r--Makefile.in31
-rw-r--r--PROTOCOL27
-rw-r--r--PROTOCOL.chacha20poly1305105
-rw-r--r--PROTOCOL.key68
-rw-r--r--README4
-rw-r--r--aclocal.m486
-rw-r--r--addrmatch.c6
-rw-r--r--atomicio.c4
-rw-r--r--auth-krb5.c3
-rw-r--r--auth-options.c18
-rw-r--r--auth-pam.c4
-rw-r--r--auth2-hostbased.c8
-rw-r--r--auth2-pubkey.c8
-rw-r--r--authfd.c63
-rw-r--r--authfile.c382
-rw-r--r--authfile.h5
-rw-r--r--blocks.c248
-rw-r--r--bufaux.c76
-rw-r--r--bufbn.c3
-rw-r--r--buffer.c3
-rw-r--r--buffer.h6
-rw-r--r--canohost.c17
-rw-r--r--chacha.c219
-rw-r--r--chacha.h35
-rw-r--r--channels.c25
-rw-r--r--cipher-chachapoly.c114
-rw-r--r--cipher-chachapoly.h41
-rw-r--r--cipher.c81
-rw-r--r--cipher.h12
-rw-r--r--clientloop.c10
-rw-r--r--compat.c61
-rw-r--r--compat.h3
-rw-r--r--config.h.in74
-rwxr-xr-xconfigure1006
-rw-r--r--configure.ac308
-rw-r--r--contrib/caldera/openssh.spec4
-rw-r--r--contrib/cygwin/ssh-host-config52
-rw-r--r--contrib/redhat/openssh.spec2
-rw-r--r--contrib/suse/openssh.spec2
-rw-r--r--crypto_api.h44
-rw-r--r--defines.h26
-rw-r--r--dh.c53
-rw-r--r--dh.h3
-rw-r--r--digest.c149
-rw-r--r--digest.h55
-rw-r--r--ed25519.c144
-rw-r--r--fe25519.c337
-rw-r--r--fe25519.h70
-rw-r--r--ge25519.c321
-rw-r--r--ge25519.h43
-rw-r--r--ge25519_base.data858
-rw-r--r--gss-serv-krb5.c6
-rw-r--r--hash.c76
-rw-r--r--hostfile.c3
-rw-r--r--kex.c143
-rw-r--r--kex.h31
-rw-r--r--kexc25519.c122
-rw-r--r--kexc25519c.c129
-rw-r--r--kexc25519s.c126
-rw-r--r--kexdh.c17
-rw-r--r--kexdhc.c4
-rw-r--r--kexdhs.c8
-rw-r--r--kexecdh.c18
-rw-r--r--kexecdhc.c6
-rw-r--r--kexecdhs.c11
-rw-r--r--kexgex.c24
-rw-r--r--kexgexc.c8
-rw-r--r--kexgexs.c6
-rw-r--r--key.c510
-rw-r--r--key.h19
-rw-r--r--loginrec.c11
-rw-r--r--mac.c12
-rw-r--r--mac.h4
-rw-r--r--match.c6
-rw-r--r--misc.c10
-rw-r--r--misc.h4
-rw-r--r--moduli.c106
-rw-r--r--monitor.c3
-rw-r--r--monitor_mm.c29
-rw-r--r--monitor_mm.h4
-rw-r--r--myproposal.h21
-rw-r--r--openbsd-compat/Makefile.in6
-rw-r--r--openbsd-compat/arc4random.c294
-rw-r--r--openbsd-compat/bcrypt_pbkdf.c170
-rw-r--r--openbsd-compat/blf.h88
-rw-r--r--openbsd-compat/blowfish.c694
-rw-r--r--openbsd-compat/bsd-arc4random.c150
-rw-r--r--openbsd-compat/bsd-cygwin_util.h8
-rw-r--r--openbsd-compat/bsd-misc.c1
-rw-r--r--openbsd-compat/bsd-poll.c7
-rw-r--r--openbsd-compat/bsd-setres_id.c3
-rw-r--r--openbsd-compat/bsd-snprintf.c46
-rw-r--r--openbsd-compat/bsd-statvfs.c55
-rw-r--r--openbsd-compat/bsd-statvfs.h11
-rw-r--r--openbsd-compat/chacha_private.h222
-rw-r--r--openbsd-compat/openbsd-compat.h16
-rw-r--r--openbsd-compat/openssl-compat.c30
-rw-r--r--openbsd-compat/openssl-compat.h18
-rw-r--r--openbsd-compat/setproctitle.c9
-rw-r--r--packet.c39
-rw-r--r--pathnames.h4
-rw-r--r--pkcs11.h18
-rw-r--r--platform.c16
-rw-r--r--platform.h3
-rw-r--r--poly1305.c160
-rw-r--r--poly1305.h22
-rw-r--r--progressmeter.c8
-rw-r--r--readconf.c578
-rw-r--r--readconf.h34
-rw-r--r--regress/Makefile20
-rw-r--r--regress/agent-ptrace.sh12
-rw-r--r--regress/agent.sh34
-rw-r--r--regress/cert-hostkey.sh60
-rw-r--r--regress/cert-userkey.sh31
-rw-r--r--regress/cipher-speed.sh23
-rw-r--r--regress/forward-control.sh2
-rw-r--r--regress/integrity.sh24
-rw-r--r--regress/kextype.sh14
-rw-r--r--regress/keytype.sh16
-rw-r--r--regress/krl.sh5
-rwxr-xr-xregress/modpipe.c6
-rw-r--r--regress/rekey.sh63
-rw-r--r--regress/scp-ssh-wrapper.sh6
-rw-r--r--regress/scp.sh1
-rw-r--r--regress/setuid-allowed.c56
-rw-r--r--regress/sftp-perm.sh269
-rw-r--r--regress/test-exec.sh21
-rw-r--r--regress/try-ciphers.sh31
-rw-r--r--roaming_client.c20
-rw-r--r--roaming_common.c18
-rw-r--r--sandbox-capsicum.c120
-rw-r--r--sandbox-darwin.c2
-rw-r--r--sandbox-null.c2
-rw-r--r--sandbox-rlimit.c4
-rw-r--r--sandbox-seccomp-filter.c2
-rw-r--r--sandbox-systrace.c2
-rw-r--r--sc25519.c308
-rw-r--r--sc25519.h80
-rw-r--r--schnorr.c57
-rw-r--r--schnorr.h8
-rw-r--r--scp.07
-rw-r--r--scp.114
-rw-r--r--scp.c6
-rw-r--r--servconf.c84
-rw-r--r--servconf.h6
-rw-r--r--serverloop.c5
-rw-r--r--session.c61
-rw-r--r--session.h3
-rw-r--r--sftp-client.c193
-rw-r--r--sftp-client.h16
-rw-r--r--sftp-common.c8
-rw-r--r--sftp-glob.c3
-rw-r--r--sftp-server.024
-rw-r--r--sftp-server.838
-rw-r--r--sftp-server.c458
-rw-r--r--sftp.034
-rw-r--r--sftp.143
-rw-r--r--sftp.c242
-rw-r--r--smult_curve25519_ref.c265
-rw-r--r--ssh-add.016
-rw-r--r--ssh-add.19
-rw-r--r--ssh-add.c16
-rw-r--r--ssh-agent.033
-rw-r--r--ssh-agent.111
-rw-r--r--ssh-agent.c136
-rw-r--r--ssh-dss.c58
-rw-r--r--ssh-ecdsa.c50
-rw-r--r--ssh-ed25519.c143
-rw-r--r--ssh-keygen.086
-rw-r--r--ssh-keygen.157
-rw-r--r--ssh-keygen.c93
-rw-r--r--ssh-keyscan.010
-rw-r--r--ssh-keyscan.18
-rw-r--r--ssh-keyscan.c17
-rw-r--r--ssh-keysign.04
-rw-r--r--ssh-keysign.86
-rw-r--r--ssh-keysign.c8
-rw-r--r--ssh-pkcs11-helper.c5
-rw-r--r--ssh-pkcs11.c136
-rw-r--r--ssh-rsa.c106
-rw-r--r--ssh-sandbox.h3
-rw-r--r--ssh.065
-rw-r--r--ssh.155
-rw-r--r--ssh.c301
-rw-r--r--ssh_config2
-rw-r--r--ssh_config.0131
-rw-r--r--ssh_config.5176
-rw-r--r--sshconnect.c248
-rw-r--r--sshconnect.h8
-rw-r--r--sshconnect1.c5
-rw-r--r--sshconnect2.c36
-rw-r--r--sshd.037
-rw-r--r--sshd.817
-rw-r--r--sshd.c56
-rw-r--r--sshd_config9
-rw-r--r--sshd_config.066
-rw-r--r--sshd_config.549
-rw-r--r--uidswap.c7
-rw-r--r--verify.c49
-rw-r--r--version.h4
-rw-r--r--xmalloc.c12
202 files changed, 13381 insertions, 4405 deletions
diff --git a/ChangeLog b/ChangeLog
index 6175764f5..c0dab651b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,25 +1,1042 @@
120140130
2 - (djm) [configure.ac] Only check for width-specified integer types
3 in headers that actually exist. patch from Tom G. Christensen;
4 ok dtucker@
5 - (djm) [configure.ac atomicio.c] Kludge around NetBSD offering
6 different symbols for 'read' when various compiler flags are
7 in use, causing atomicio.c comparisons against it to break and
8 read/write operations to hang; ok dtucker
9 - (djm) Release openssh-6.5p1
10
1120140129
12 - (djm) [configure.ac] Fix broken shell test '==' vs '='; patch from
13 Tom G. Christensen
14
1520140128
16 - (djm) [configure.ac] Search for inet_ntop in libnsl and libresovl;
17 ok dtucker
18 - (djm) [sshd.c] Use kill(0, ...) instead of killpg(0, ...); the
19 latter being specified to have undefined behaviour in SUSv3;
20 ok dtucker
21 - (tim) [regress/agent.sh regress/agent-ptrace.sh] Assign $? to a variable
22 when used as an error message inside an if statement so we display the
23 correct into. agent.sh patch from Petr Lautrbach.
24
2520140127
26 - (dtucker) [Makefile.in] Remove trailing backslash which some make
27 implementations (eg older Solaris) do not cope with.
28
2920140126
30 - OpenBSD CVS Sync
31 - dtucker@cvs.openbsd.org 2014/01/25 10:12:50
32 [cipher.c cipher.h kex.c kex.h kexgexc.c]
33 Add a special case for the DH group size for 3des-cbc, which has an
34 effective strength much lower than the key size. This causes problems
35 with some cryptlib implementations, which don't support group sizes larger
36 than 4k but also don't use the largest group size it does support as
37 specified in the RFC. Based on a patch from Petr Lautrbach at Redhat,
38 reduced by me with input from Markus. ok djm@ markus@
39 - markus@cvs.openbsd.org 2014/01/25 20:35:37
40 [kex.c]
41 dh_need needs to be set to max(seclen, blocksize, ivlen, mac_len)
42 ok dtucker@, noted by mancha
43 - (djm) [configure.ac sandbox-capsicum.c sandbox-rlimit.c] Disable
44 RLIMIT_NOFILE pseudo-sandbox on FreeBSD. In some configurations,
45 libc will attempt to open additional file descriptors for crypto
46 offload and crash if they cannot be opened.
47 - (djm) [configure.ac] correct AC_DEFINE for previous.
48
4920140125
50 - (djm) [configure.ac] Fix detection of capsicum sandbox on FreeBSD
51 - (djm) [configure.ac] Do not attempt to use capsicum sandbox unless
52 sys/capability.h exists and cap_rights_limit is in libc. Fixes
53 build on FreeBSD9x which provides the header but not the libc
54 support.
55 - (djm) [configure.ac] autoconf sets finds to 'yes' not '1', so test
56 against the correct thing.
57
5820140124
59 - (djm) [Makefile.in regress/scp-ssh-wrapper.sh regress/scp.sh] Make
60 the scp regress test actually test the built scp rather than the one
61 in $PATH. ok dtucker@
62
6320140123
64 - (tim) [session.c] Improve error reporting on set_id().
65 - (dtucker) [configure.ac] NetBSD's (and FreeBSD's) strnvis is gratuitously
66 incompatible with OpenBSD's despite post-dating it by more than a decade.
67 Declare it as broken, and document FreeBSD's as the same. ok djm@
68
6920140122
70 - (djm) [openbsd-compat/setproctitle.c] Don't fail to compile if a
71 platform that is expected to use the reuse-argv style setproctitle
72 hack surprises us by providing a setproctitle in libc; ok dtucker
73 - (djm) [configure.ac] Unless specifically requested, only attempt
74 to build Position Independent Executables on gcc >= 4.x; ok dtucker
75 - (djm) [configure.ac aclocal.m4] More tests to detect fallout from
76 platform hardening options: include some long long int arithmatic
77 to detect missing support functions for -ftrapv in libgcc and
78 equivalents, actually test linking when -ftrapv is supplied and
79 set either both -pie/-fPIE or neither. feedback and ok dtucker@
80
8120140121
82 - (dtucker) [configure.ac] Make PIE a configure-time option which defaults
83 to on platforms where it's known to be reliably detected and off elsewhere.
84 Works around platforms such as FreeBSD 9.1 where it does not interop with
85 -ftrapv (it seems to work but fails when trying to link ssh). ok djm@
86 - (dtucker) [aclocal.m4] Differentiate between compile-time and link-time
87 tests in the configure output. ok djm.
88 - (tim) [platform.c session.c] Fix bug affecting SVR5 platforms introduced
89 with sftp chroot support. Move set_id call after chroot.
90 - (djm) [aclocal.m4] Flesh out the code run in the OSSH_CHECK_CFLAG_COMPILE
91 and OSSH_CHECK_LDFLAG_LINK tests to give them a better chance of
92 detecting toolchain-related problems; ok dtucker
93
9420140120
95 - (dtucker) [gss-serv-krb5.c] Fall back to krb5_cc_gen_new if the Kerberos
96 implementation does not have krb5_cc_new_unique, similar to what we do
97 in auth-krb5.c.
98 - (djm) [regress/cert-hostkey.sh] Fix regress failure on platforms that
99 skip one or more key types (e.g. RHEL/CentOS 6.5); ok dtucker@
100 - (djm) OpenBSD CVS Sync
101 - djm@cvs.openbsd.org 2014/01/20 00:08:48
102 [digest.c]
103 memleak; found by Loganaden Velvindron @ AfriNIC; ok markus@
104
10520140119
106 - (dtucker) OpenBSD CVS Sync
107 - dtucker@cvs.openbsd.org 2014/01/17 06:23:24
108 [sftp-server.c]
109 fix log message statvfs. ok djm
110 - dtucker@cvs.openbsd.org 2014/01/18 09:36:26
111 [session.c]
112 explicitly define USE_PIPES to 1 to prevent redefinition warnings in
113 portable on platforms that use pipes for everything. From vinschen at
114 redhat.
115 - dtucker@cvs.openbsd.org 2014/01/19 04:17:29
116 [canohost.c addrmatch.c]
117 Cast socklen_t when comparing to size_t and use socklen_t to iterate over
118 the ip options, both to prevent signed/unsigned comparison warnings.
119 Patch from vinschen at redhat via portable openssh, begrudging ok deraadt.
120 - djm@cvs.openbsd.org 2014/01/19 04:48:08
121 [ssh_config.5]
122 fix inverted meaning of 'no' and 'yes' for CanonicalizeFallbackLocal
123 - dtucker@cvs.openbsd.org 2014/01/19 11:21:51
124 [addrmatch.c]
125 Cast the sizeof to socklen_t so it'll work even if the supplied len is
126 negative. Suggested by and ok djm, ok deraadt.
127
12820140118
129 - (dtucker) [uidswap.c] Prevent unused variable warnings on Cygwin. Patch
130 from vinschen at redhat.com
131 - (dtucker) [openbsd-compat/bsd-cygwin_util.h] Add missing function
132 declarations that stopped being included when we stopped including
133 <windows.h> from openbsd-compat/bsd-cygwin_util.h. Patch from vinschen at
134 redhat.com.
135 - (dtucker) [configure.ac] On Cygwin the getopt variables (like optargs,
136 optind) are defined in getopt.h already. Unfortunately they are defined as
137 "declspec(dllimport)" for historical reasons, because the GNU linker didn't
138 allow auto-import on PE/COFF targets way back when. The problem is the
139 dllexport attributes collide with the definitions in the various source
140 files in OpenSSH, which obviousy define the variables without
141 declspec(dllimport). The least intrusive way to get rid of these warnings
142 is to disable warnings for GCC compiler attributes when building on Cygwin.
143 Patch from vinschen at redhat.com.
144 - (dtucker) [sandbox-capsicum.c] Correct some error messages and make the
145 return value check for cap_enter() consistent with the other uses in
146 FreeBSD. From by Loganaden Velvindron @ AfriNIC via bz#2140.
147
14820140117
149 - (dtucker) [aclocal.m4 configure.ac] Add some additional compiler/toolchain
150 hardening flags including -fstack-protector-strong. These default to on
151 if the toolchain supports them, but there is a configure-time knob
152 (--without-hardening) to disable them if necessary. ok djm@
153 - (djm) [sftp-client.c] signed/unsigned comparison fix
154 - (dtucker) [loginrec.c] Cast to the types specfied in the format
155 specification to prevent warnings.
156 - (dtucker) [crypto_api.h] Wrap stdlib.h include inside #ifdef HAVE_STDINT_H.
157 - (dtucker) [poly1305.c] Wrap stdlib.h include inside #ifdef HAVE_STDINT_H.
158 - (dtucker) [blocks.c fe25519.c ge25519.c hash.c sc25519.c verify.c] Include
159 includes.h to pull in all of the compatibility stuff.
160 - (dtucker) [openbsd-compat/bcrypt_pbkdf.c] Wrap stdlib.h include inside
161 #ifdef HAVE_STDINT_H.
162 - (dtucker) [defines.h] Add typedefs for uintXX_t types for platforms that
163 don't have them.
164 - (dtucker) [configure.ac] Split AC_CHECK_FUNCS for OpenSSL functions into
165 separate lines and alphabetize for easier diffing of changes.
166 - (dtucker) OpenBSD CVS Sync
167 - djm@cvs.openbsd.org 2014/01/17 00:21:06
168 [sftp-client.c]
169 signed/unsigned comparison warning fix; from portable (Id sync only)
170 - dtucker@cvs.openbsd.org 2014/01/17 05:26:41
171 [digest.c]
172 remove unused includes. ok djm@
173 - (djm) [Makefile.in configure.ac sandbox-capsicum.c sandbox-darwin.c]
174 [sandbox-null.c sandbox-rlimit.c sandbox-seccomp-filter.c]
175 [sandbox-systrace.c ssh-sandbox.h sshd.c] Support preauth sandboxing
176 using the Capsicum API introduced in FreeBSD 10. Patch by Dag-Erling
177 Smorgrav, updated by Loganaden Velvindron @ AfriNIC; ok dtucker@
178 - (dtucker) [configure.ac digest.c openbsd-compat/openssl-compat.c
179 openbsd-compat/openssl-compat.h] Add compatibility layer for older
180 openssl versions. ok djm@
181 - (dtucker) Fix typo in #ifndef.
182 - (dtucker) [configure.ac openbsd-compat/bsd-statvfs.c
183 openbsd-compat/bsd-statvfs.h] Implement enough of statvfs on top of statfs
184 to be useful (and for the regression tests to pass) on platforms that
185 have statfs and fstatfs. ok djm@
186 - (dtucker) [openbsd-compat/bsd-statvfs.h] Only start including headers if we
187 need them to cut down on the name collisions.
188 - (dtucker) [configure.ac] Also look in inttypes.h for uintXX_t types.
189 - (dtucker) [configure.ac] Have --without-hardening not turn off
190 stack-protector since that has a separate flag that's been around a while.
191 - (dtucker) [readconf.c] Wrap paths.h inside an ifdef. Allows building on
192 Solaris.
193 - (dtucker) [defines.h] Move our definitions of uintXX_t types down to after
194 they're defined if we have to define them ourselves. Fixes builds on old
195 AIX.
196
19720140118
198 - (djm) OpenBSD CVS Sync
199 - djm@cvs.openbsd.org 2014/01/16 07:31:09
200 [sftp-client.c]
201 needless and incorrect cast to size_t can break resumption of
202 large download; patch from tobias@
203 - djm@cvs.openbsd.org 2014/01/16 07:32:00
204 [version.h]
205 openssh-6.5
206 - (djm) [contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
207 [contrib/suse/openssh.spec] Crank RPM spec version numbers.
208 - (djm) [README] update release notes URL.
209
21020140112
211 - (djm) OpenBSD CVS Sync
212 - djm@cvs.openbsd.org 2014/01/10 05:59:19
213 [sshd_config]
214 the /etc/ssh/ssh_host_ed25519_key is loaded by default too
215 - djm@cvs.openbsd.org 2014/01/12 08:13:13
216 [bufaux.c buffer.h kex.c kex.h kexc25519.c kexc25519c.c kexc25519s.c]
217 [kexdhc.c kexdhs.c kexecdhc.c kexecdhs.c kexgexc.c kexgexs.c]
218 avoid use of OpenSSL BIGNUM type and functions for KEX with
219 Curve25519 by adding a buffer_put_bignum2_from_string() that stores
220 a string using the bignum encoding rules. Will make it easier to
221 build a reduced-feature OpenSSH without OpenSSL in the future;
222 ok markus@
223
22420140110
225 - (djm) OpenBSD CVS Sync
226 - tedu@cvs.openbsd.org 2014/01/04 17:50:55
227 [mac.c monitor_mm.c monitor_mm.h xmalloc.c]
228 use standard types and formats for size_t like variables. ok dtucker
229 - guenther@cvs.openbsd.org 2014/01/09 03:26:00
230 [sftp-common.c]
231 When formating the time for "ls -l"-style output, show dates in the future
232 with the year, and rearrange a comparison to avoid a potentional signed
233 arithmetic overflow that would give the wrong result.
234 ok djm@
235 - djm@cvs.openbsd.org 2014/01/09 23:20:00
236 [digest.c digest.h hostfile.c kex.c kex.h kexc25519.c kexc25519c.c]
237 [kexc25519s.c kexdh.c kexecdh.c kexecdhc.c kexecdhs.c kexgex.c kexgexc.c]
238 [kexgexs.c key.c key.h roaming_client.c roaming_common.c schnorr.c]
239 [schnorr.h ssh-dss.c ssh-ecdsa.c ssh-rsa.c sshconnect2.c]
240 Introduce digest API and use it to perform all hashing operations
241 rather than calling OpenSSL EVP_Digest* directly. Will make it easier
242 to build a reduced-feature OpenSSH without OpenSSL in future;
243 feedback, ok markus@
244 - djm@cvs.openbsd.org 2014/01/09 23:26:48
245 [sshconnect.c sshd.c]
246 ban clients/servers that suffer from SSH_BUG_DERIVEKEY, they are ancient,
247 deranged and might make some attacks on KEX easier; ok markus@
248
24920140108
250 - (djm) [regress/.cvsignore] Ignore regress test droppings; ok dtucker@
251
25220131231
253 - (djm) OpenBSD CVS Sync
254 - djm@cvs.openbsd.org 2013/12/30 23:52:28
255 [auth2-hostbased.c auth2-pubkey.c compat.c compat.h ssh-rsa.c]
256 [sshconnect.c sshconnect2.c sshd.c]
257 refuse RSA keys from old proprietary clients/servers that use the
258 obsolete RSA+MD5 signature scheme. it will still be possible to connect
259 with these clients/servers but only DSA keys will be accepted, and we'll
260 deprecate them entirely in a future release. ok markus@
261
26220131229
263 - (djm) [loginrec.c] Check for username truncation when looking up lastlog
264 entries
265 - (djm) [regress/Makefile] Add some generated files for cleaning
266 - (djm) OpenBSD CVS Sync
267 - djm@cvs.openbsd.org 2013/12/19 00:10:30
268 [ssh-add.c]
269 skip requesting smartcard PIN when removing keys from agent; bz#2187
270 patch from jay AT slushpupie.com; ok dtucker
271 - dtucker@cvs.openbsd.org 2013/12/19 00:19:12
272 [serverloop.c]
273 Cast client_alive_interval to u_int64_t before assinging to
274 max_time_milliseconds to avoid potential integer overflow in the timeout.
275 bz#2170, patch from Loganaden Velvindron, ok djm@
276 - djm@cvs.openbsd.org 2013/12/19 00:27:57
277 [auth-options.c]
278 simplify freeing of source-address certificate restriction
279 - djm@cvs.openbsd.org 2013/12/19 01:04:36
280 [channels.c]
281 bz#2147: fix multiple remote forwardings with dynamically assigned
282 listen ports. In the s->c message to open the channel we were sending
283 zero (the magic number to request a dynamic port) instead of the actual
284 listen port. The client therefore had no way of discriminating between
285 them.
286
287 Diagnosis and fix by ronf AT timeheart.net
288 - djm@cvs.openbsd.org 2013/12/19 01:19:41
289 [ssh-agent.c]
290 bz#2186: don't crash (NULL deref) when deleting PKCS#11 keys from an agent
291 that has a mix of normal and PKCS#11 keys; fix from jay AT slushpupie.com;
292 ok dtucker
293 - djm@cvs.openbsd.org 2013/12/19 22:57:13
294 [poly1305.c poly1305.h]
295 use full name for author, with his permission
296 - tedu@cvs.openbsd.org 2013/12/21 07:10:47
297 [ssh-keygen.1]
298 small typo
299 - djm@cvs.openbsd.org 2013/12/27 22:30:17
300 [ssh-dss.c ssh-ecdsa.c ssh-rsa.c]
301 make the original RSA and DSA signing/verification code look more like
302 the ECDSA/Ed25519 ones: use key_type_plain() when checking the key type
303 rather than tediously listing all variants, use __func__ for debug/
304 error messages
305 - djm@cvs.openbsd.org 2013/12/27 22:37:18
306 [ssh-rsa.c]
307 correct comment
308 - djm@cvs.openbsd.org 2013/12/29 02:28:10
309 [key.c]
310 allow ed25519 keys to appear as certificate authorities
311 - djm@cvs.openbsd.org 2013/12/29 02:37:04
312 [key.c]
313 correct comment for key_to_certified()
314 - djm@cvs.openbsd.org 2013/12/29 02:49:52
315 [key.c]
316 correct comment for key_drop_cert()
317 - djm@cvs.openbsd.org 2013/12/29 04:20:04
318 [key.c]
319 to make sure we don't omit any key types as valid CA keys again,
320 factor the valid key type check into a key_type_is_valid_ca()
321 function
322 - djm@cvs.openbsd.org 2013/12/29 04:29:25
323 [authfd.c]
324 allow deletion of ed25519 keys from the agent
325 - djm@cvs.openbsd.org 2013/12/29 04:35:50
326 [authfile.c]
327 don't refuse to load Ed25519 certificates
328 - djm@cvs.openbsd.org 2013/12/29 05:42:16
329 [ssh.c]
330 don't forget to load Ed25519 certs too
331 - djm@cvs.openbsd.org 2013/12/29 05:57:02
332 [sshconnect.c]
333 when showing other hostkeys, don't forget Ed25519 keys
334
33520131221
336 - (dtucker) [regress/keytype.sh] Actually test ecdsa key types.
337
33820131219
339 - (dtucker) [configure.ac] bz#2178: Don't try to use BSM on Solaris versions
340 greater than 11 either rather than just 11. Patch from Tomas Kuthan.
341 - (dtucker) [auth-pam.c] bz#2163: check return value from pam_get_item().
342 Patch from Loganaden Velvindron.
343
34420131218
345 - (djm) OpenBSD CVS Sync
346 - djm@cvs.openbsd.org 2013/12/07 08:08:26
347 [ssh-keygen.1]
348 document -a and -o wrt new key format
349 - naddy@cvs.openbsd.org 2013/12/07 11:58:46
350 [ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh-keysign.8 ssh.1]
351 [ssh_config.5 sshd.8 sshd_config.5]
352 add missing mentions of ed25519; ok djm@
353 - dtucker@cvs.openbsd.org 2013/12/08 09:53:27
354 [sshd_config.5]
355 Use a literal for the default value of KEXAlgorithms. ok deraadt jmc
356 - markus@cvs.openbsd.org 2013/12/09 11:03:45
357 [blocks.c ed25519.c fe25519.c fe25519.h ge25519.c ge25519.h]
358 [ge25519_base.data hash.c sc25519.c sc25519.h verify.c]
359 Add Authors for the public domain ed25519/nacl code.
360 see also http://nacl.cr.yp.to/features.html
361 All of the NaCl software is in the public domain.
362 and http://ed25519.cr.yp.to/software.html
363 The Ed25519 software is in the public domain.
364 - markus@cvs.openbsd.org 2013/12/09 11:08:17
365 [crypto_api.h]
366 remove unused defines
367 - pascal@cvs.openbsd.org 2013/12/15 18:17:26
368 [ssh-add.c]
369 Make ssh-add also add .ssh/id_ed25519; fixes lie in manual page.
370 ok markus@
371 - djm@cvs.openbsd.org 2013/12/15 21:42:35
372 [cipher-chachapoly.c]
373 add some comments and constify a constant
374 - markus@cvs.openbsd.org 2013/12/17 10:36:38
375 [crypto_api.h]
376 I've assempled the header file by cut&pasting from generated headers
377 and the source files.
378
37920131208
380 - (djm) [openbsd-compat/bsd-setres_id.c] Missing header; from Corinna
381 Vinschen
382 - (djm) [Makefile.in regress/Makefile regress/agent-ptrace.sh]
383 [regress/setuid-allowed.c] Check that ssh-agent is not on a no-setuid
384 filesystem before running agent-ptrace.sh; ok dtucker
385
38620131207
387 - (djm) OpenBSD CVS Sync
388 - djm@cvs.openbsd.org 2013/12/05 22:59:45
389 [sftp-client.c]
390 fix memory leak in error path in do_readdir(); pointed out by
391 Loganaden Velvindron @ AfriNIC in bz#2163
392 - djm@cvs.openbsd.org 2013/12/06 03:40:51
393 [ssh-keygen.c]
394 remove duplicated character ('g') in getopt() string;
395 document the (few) remaining option characters so we don't have to
396 rummage next time.
397 - markus@cvs.openbsd.org 2013/12/06 13:30:08
398 [authfd.c key.c key.h ssh-agent.c]
399 move private key (de)serialization to key.c; ok djm
400 - markus@cvs.openbsd.org 2013/12/06 13:34:54
401 [authfile.c authfile.h cipher.c cipher.h key.c packet.c ssh-agent.c]
402 [ssh-keygen.c PROTOCOL.key] new private key format, bcrypt as KDF by
403 default; details in PROTOCOL.key; feedback and lots help from djm;
404 ok djm@
405 - markus@cvs.openbsd.org 2013/12/06 13:39:49
406 [authfd.c authfile.c key.c key.h myproposal.h pathnames.h readconf.c]
407 [servconf.c ssh-agent.c ssh-keygen.c ssh-keyscan.1 ssh-keyscan.c]
408 [ssh-keysign.c ssh.c ssh_config.5 sshd.8 sshd.c verify.c ssh-ed25519.c]
409 [sc25519.h sc25519.c hash.c ge25519_base.data ge25519.h ge25519.c]
410 [fe25519.h fe25519.c ed25519.c crypto_api.h blocks.c]
411 support ed25519 keys (hostkeys and user identities) using the public
412 domain ed25519 reference code from SUPERCOP, see
413 http://ed25519.cr.yp.to/software.html
414 feedback, help & ok djm@
415 - jmc@cvs.openbsd.org 2013/12/06 15:29:07
416 [sshd.8]
417 missing comma;
418 - djm@cvs.openbsd.org 2013/12/07 00:19:15
419 [key.c]
420 set k->cert = NULL after freeing it
421 - markus@cvs.openbsd.org 2013/12/06 13:52:46
422 [regress/Makefile regress/agent.sh regress/cert-hostkey.sh]
423 [regress/cert-userkey.sh regress/keytype.sh]
424 test ed25519 support; from djm@
425 - (djm) [blocks.c ed25519.c fe25519.c fe25519.h ge25519.c ge25519.h]
426 [ge25519_base.data hash.c sc25519.c sc25519.h verify.c] Fix RCS idents
427 - (djm) [Makefile.in] Add ed25519 sources
428 - (djm) [authfile.c] Conditionalise inclusion of util.h
429 - (djm) [configure.ac openbsd-compat/Makefile.in openbsd-compat/bcrypt_pbkdf.c]
430 [openbsd-compat/blf.h openbsd-compat/blowfish.c]
431 [openbsd-compat/openbsd-compat.h] Start at supporting bcrypt_pbkdf in
432 portable.
433 - (djm) [ed25519.c ssh-ed25519.c openbsd-compat/Makefile.in]
434 [openbsd-compat/bcrypt_pbkdf.c] Make ed25519/new key format compile on
435 Linux
436 - (djm) [regress/cert-hostkey.sh] Fix merge botch
437 - (djm) [Makefile.in] PATHSUBS and keygen bits for Ed25519; from
438 Loganaden Velvindron @ AfriNIC in bz#2179
439
44020131205
441 - (djm) OpenBSD CVS Sync
442 - jmc@cvs.openbsd.org 2013/11/21 08:05:09
443 [ssh_config.5 sshd_config.5]
444 no need for .Pp before displays;
445 - deraadt@cvs.openbsd.org 2013/11/25 18:04:21
446 [ssh.1 ssh.c]
447 improve -Q usage and such. One usage change is that the option is now
448 case-sensitive
449 ok dtucker markus djm
450 - jmc@cvs.openbsd.org 2013/11/26 12:14:54
451 [ssh.1 ssh.c]
452 - put -Q in the right place
453 - Ar was a poor choice for the arguments to -Q. i've chosen an
454 admittedly equally poor Cm, at least consistent with the rest
455 of the docs. also no need for multiple instances
456 - zap a now redundant Nm
457 - usage() sync
458 - deraadt@cvs.openbsd.org 2013/11/26 19:15:09
459 [pkcs11.h]
460 cleanup 1 << 31 idioms. Resurrection of this issue pointed out by
461 Eitan Adler ok markus for ssh, implies same change in kerberosV
462 - djm@cvs.openbsd.org 2013/12/01 23:19:05
463 [PROTOCOL]
464 mention curve25519-sha256@libssh.org key exchange algorithm
465 - djm@cvs.openbsd.org 2013/12/02 02:50:27
466 [PROTOCOL.chacha20poly1305]
467 typo; from Jon Cave
468 - djm@cvs.openbsd.org 2013/12/02 02:56:17
469 [ssh-pkcs11-helper.c]
470 use-after-free; bz#2175 patch from Loganaden Velvindron @ AfriNIC
471 - djm@cvs.openbsd.org 2013/12/02 03:09:22
472 [key.c]
473 make key_to_blob() return a NULL blob on failure; part of
474 bz#2175 from Loganaden Velvindron @ AfriNIC
475 - djm@cvs.openbsd.org 2013/12/02 03:13:14
476 [cipher.c]
477 correct bzero of chacha20+poly1305 key context. bz#2177 from
478 Loganaden Velvindron @ AfriNIC
479
480 Also make it a memset for consistency with the rest of cipher.c
481 - djm@cvs.openbsd.org 2013/12/04 04:20:01
482 [sftp-client.c]
483 bz#2171: don't leak local_fd on error; from Loganaden Velvindron @
484 AfriNIC
485 - djm@cvs.openbsd.org 2013/12/05 01:16:41
486 [servconf.c servconf.h]
487 bz#2161 - fix AuthorizedKeysCommand inside a Match block and
488 rearrange things so the same error is harder to make next time;
489 with and ok dtucker@
490 - (dtucker) [configure.ac] bz#2173: use pkg-config --libs to include correct
491 -L location for libedit. Patch from Serge van den Boom.
492
49320131121
494 - (djm) OpenBSD CVS Sync
495 - dtucker@cvs.openbsd.org 2013/11/08 11:15:19
496 [bufaux.c bufbn.c buffer.c sftp-client.c sftp-common.c sftp-glob.c]
497 [uidswap.c] Include stdlib.h for free() as per the man page.
498 - markus@cvs.openbsd.org 2013/11/13 13:48:20
499 [ssh-pkcs11.c]
500 add missing braces found by pedro
501 - djm@cvs.openbsd.org 2013/11/20 02:19:01
502 [sshd.c]
503 delay closure of in/out fds until after "Bad protocol version
504 identification..." message, as get_remote_ipaddr/get_remote_port
505 require them open.
506 - deraadt@cvs.openbsd.org 2013/11/20 20:53:10
507 [scp.c]
508 unsigned casts for ctype macros where neccessary
509 ok guenther millert markus
510 - deraadt@cvs.openbsd.org 2013/11/20 20:54:10
511 [canohost.c clientloop.c match.c readconf.c sftp.c]
512 unsigned casts for ctype macros where neccessary
513 ok guenther millert markus
514 - djm@cvs.openbsd.org 2013/11/21 00:45:44
515 [Makefile.in PROTOCOL PROTOCOL.chacha20poly1305 authfile.c chacha.c]
516 [chacha.h cipher-chachapoly.c cipher-chachapoly.h cipher.c cipher.h]
517 [dh.c myproposal.h packet.c poly1305.c poly1305.h servconf.c ssh.1]
518 [ssh.c ssh_config.5 sshd_config.5] Add a new protocol 2 transport
519 cipher "chacha20-poly1305@openssh.com" that combines Daniel
520 Bernstein's ChaCha20 stream cipher and Poly1305 MAC to build an
521 authenticated encryption mode.
522
523 Inspired by and similar to Adam Langley's proposal for TLS:
524 http://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-03
525 but differs in layout used for the MAC calculation and the use of a
526 second ChaCha20 instance to separately encrypt packet lengths.
527 Details are in the PROTOCOL.chacha20poly1305 file.
528
529 Feedback markus@, naddy@; manpage bits Loganden Velvindron @ AfriNIC
530 ok markus@ naddy@
531 - naddy@cvs.openbsd.org 2013/11/18 05:09:32
532 [regress/forward-control.sh]
533 bump timeout to 10 seconds to allow slow machines (e.g. Alpha PC164)
534 to successfully run this; ok djm@
535 - djm@cvs.openbsd.org 2013/11/21 03:15:46
536 [regress/krl.sh]
537 add some reminders for additional tests that I'd like to implement
538 - djm@cvs.openbsd.org 2013/11/21 03:16:47
539 [regress/modpipe.c]
540 use unsigned long long instead of u_int64_t here to avoid warnings
541 on some systems portable OpenSSH is built on.
542 - djm@cvs.openbsd.org 2013/11/21 03:18:51
543 [regress/cipher-speed.sh regress/integrity.sh regress/rekey.sh]
544 [regress/try-ciphers.sh]
545 use new "ssh -Q cipher-auth" query to obtain lists of authenticated
546 encryption ciphers instead of specifying them manually; ensures that
547 the new chacha20poly1305@openssh.com mode is tested;
548
549 ok markus@ and naddy@ as part of the diff to add
550 chacha20poly1305@openssh.com
551
55220131110
553 - (dtucker) [regress/keytype.sh] Populate ECDSA key types to be tested by
554 querying the ones that are compiled in.
555
55620131109
557 - (dtucker) OpenBSD CVS Sync
558 - dtucker@cvs.openbsd.org 2013/11/09 05:41:34
559 [regress/test-exec.sh regress/rekey.sh]
560 Use smaller test data files to speed up tests. Grow test datafiles
561 where necessary for a specific test.
562 - (dtucker) [configure.ac kex.c key.c myproposal.h] Test for the presence of
563 NID_X9_62_prime256v1, NID_secp384r1 and NID_secp521r1 and test that the
564 latter actually works before using it. Fedora (at least) has NID_secp521r1
565 that doesn't work (see https://bugzilla.redhat.com/show_bug.cgi?id=1021897).
566 - (dtucker) [configure.ac] Fix brackets in NID_secp521r1 test.
567 - (dtucker) [configure.ac] Add missing "test".
568 - (dtucker) [key.c] Check for the correct defines for NID_secp521r1.
569
120131108 57020131108
571 - (dtucker) OpenBSD CVS Sync
572 - dtucker@cvs.openbsd.org 2013/11/08 01:06:14
573 [regress/rekey.sh]
574 Rekey less frequently during tests to speed them up
2 - (djm) OpenBSD CVS Sync 575 - (djm) OpenBSD CVS Sync
3 - markus@cvs.openbsd.org 2013/11/06 16:52:11 576 - dtucker@cvs.openbsd.org 2013/11/07 11:58:27
4 [monitor_wrap.c] 577 [cipher.c cipher.h kex.c kex.h mac.c mac.h servconf.c ssh.c]
5 fix rekeying for AES-GCM modes; ok deraadt 578 Output the effective values of Ciphers, MACs and KexAlgorithms when
579 the default has not been overridden. ok markus@
6 - djm@cvs.openbsd.org 2013/11/08 00:39:15 580 - djm@cvs.openbsd.org 2013/11/08 00:39:15
7 [auth-options.c auth2-chall.c authfd.c channels.c cipher-3des1.c] 581 [auth-options.c auth2-chall.c authfd.c channels.c cipher-3des1.c]
8 [clientloop.c gss-genr.c monitor_mm.c packet.c schnorr.c umac.c] 582 [clientloop.c gss-genr.c monitor_mm.c packet.c schnorr.c umac.c]
9 [sftp-client.c sftp-glob.c] 583 [sftp-client.c sftp-glob.c]
10 use calloc for all structure allocations; from markus@ 584 use calloc for all structure allocations; from markus@
11 - (djm) [README contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
12 [contrib/suse/openssh.spec] update version numbers
13 - djm@cvs.openbsd.org 2013/11/08 01:38:11 585 - djm@cvs.openbsd.org 2013/11/08 01:38:11
14 [version.h] 586 [version.h]
15 openssh-6.4 587 openssh-6.4
16 - (djm) Release 6.4p1 588 - (djm) [README contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
589 [contrib/suse/openssh.spec] Update version numbers following release.
590 - (dtucker) [openbsd-compat/openbsd-compat.h] Add null implementation of
591 arc4random_stir for platforms that have arc4random but don't have
592 arc4random_stir (right now this is only OpenBSD -current).
593 - (dtucker) [kex.c] Only enable CURVE25519_SHA256 if we actually have
594 EVP_sha256.
595 - (dtucker) [myproposal.h] Conditionally enable CURVE25519_SHA256.
596 - (dtucker) [openbsd-compat/bsd-poll.c] Add headers to prevent compile
597 warnings.
598 - (dtucker) [Makefile.in configure.ac] Set MALLOC_OPTIONS per platform
599 and pass in TEST_ENV. use stderr to get polluted
600 and the stderr-data test to fail.
601 - (dtucker) [contrib/cygwin/ssh-host-config] Simplify host key generation:
602 rather than testing and generating each key, call ssh-keygen -A.
603 Patch from vinschen at redhat.com.
604 - (dtucker) OpenBSD CVS Sync
605 - dtucker@cvs.openbsd.org 2013/11/09 05:41:34
606 [regress/test-exec.sh regress/rekey.sh]
607 Use smaller test data files to speed up tests. Grow test datafiles
608 where necessary for a specific test.
609
61020131107
611 - (djm) [ssh-pkcs11.c] Bring back "non-constant initialiser" fix (rev 1.5)
612 that got lost in recent merge.
613 - (djm) [Makefile.in monitor.c] Missed chunks of curve25519 KEX diff
614 - (djm) [regress/modpipe.c regress/rekey.sh] Never intended to commit these
615 - (djm) [configure.ac defines.h] Skip arc4random_stir() calls on platforms
616 that lack it but have arc4random_uniform()
617 - (djm) OpenBSD CVS Sync
618 - markus@cvs.openbsd.org 2013/11/04 11:51:16
619 [monitor.c]
620 fix rekeying for KEX_C25519_SHA256; noted by dtucker@
621 RCSID sync only; I thought this was a merge botch and fixed it already
622 - markus@cvs.openbsd.org 2013/11/06 16:52:11
623 [monitor_wrap.c]
624 fix rekeying for AES-GCM modes; ok deraadt
625 - djm@cvs.openbsd.org 2013/11/06 23:05:59
626 [ssh-pkcs11.c]
627 from portable: s/true/true_val/ to avoid name collisions on dump platforms
628 RCSID sync only
629 - (dtucker) OpenBSD CVS Sync
630 - djm@cvs.openbsd.org 2013/10/09 23:44:14
631 [regress/Makefile] (ID sync only)
632 regression test for sftp request white/blacklisting and readonly mode.
633 - markus@cvs.openbsd.org 2013/11/02 22:39:53
634 [regress/kextype.sh]
635 add curve25519-sha256@libssh.org
636 - dtucker@cvs.openbsd.org 2013/11/04 12:27:42
637 [regress/rekey.sh]
638 Test rekeying with all KexAlgorithms.
639 - dtucker@cvs.openbsd.org 2013/11/07 00:12:05
640 [regress/rekey.sh]
641 Test rekeying for every Cipher, MAC and KEX, plus test every KEX with
642 the GCM ciphers.
643 - dtucker@cvs.openbsd.org 2013/11/07 01:12:51
644 [regress/rekey.sh]
645 Factor out the data transfer rekey tests
646 - dtucker@cvs.openbsd.org 2013/11/07 02:48:38
647 [regress/integrity.sh regress/cipher-speed.sh regress/try-ciphers.sh]
648 Use ssh -Q instead of hardcoding lists of ciphers or MACs.
649 - dtucker@cvs.openbsd.org 2013/11/07 03:55:41
650 [regress/kextype.sh]
651 Use ssh -Q to get kex types instead of a static list.
652 - dtucker@cvs.openbsd.org 2013/11/07 04:26:56
653 [regress/kextype.sh]
654 trailing space
655 - (dtucker) [Makefile.in configure.ac] Remove TEST_SSH_SHA256 environment
656 variable. It's no longer used now that we get the supported MACs from
657 ssh -Q.
658
65920131104
660 - (djm) OpenBSD CVS Sync
661 - markus@cvs.openbsd.org 2013/11/02 20:03:54
662 [ssh-pkcs11.c]
663 support pkcs#11 tokes that only provide x509 zerts instead of raw pubkeys;
664 fixes bz#1908; based on patch from Laurent Barbe; ok djm
665 - markus@cvs.openbsd.org 2013/11/02 21:59:15
666 [kex.c kex.h myproposal.h ssh-keyscan.c sshconnect2.c sshd.c]
667 use curve25519 for default key exchange (curve25519-sha256@libssh.org);
668 initial patch from Aris Adamantiadis; ok djm@
669 - markus@cvs.openbsd.org 2013/11/02 22:10:15
670 [kexdhs.c kexecdhs.c]
671 no need to include monitor_wrap.h
672 - markus@cvs.openbsd.org 2013/11/02 22:24:24
673 [kexdhs.c kexecdhs.c]
674 no need to include ssh-gss.h
675 - markus@cvs.openbsd.org 2013/11/02 22:34:01
676 [auth-options.c]
677 no need to include monitor_wrap.h and ssh-gss.h
678 - markus@cvs.openbsd.org 2013/11/02 22:39:19
679 [ssh_config.5 sshd_config.5]
680 the default kex is now curve25519-sha256@libssh.org
681 - djm@cvs.openbsd.org 2013/11/03 10:37:19
682 [roaming_common.c]
683 fix a couple of function definitions foo() -> foo(void)
684 (-Wold-style-definition)
685 - (djm) [kexc25519.c kexc25519c.c kexc25519s.c] Import missed files from
686 KEX/curve25519 change
687
68820131103
689 - (dtucker) [openbsd-compat/bsd-misc.c] Include time.h for nanosleep.
690 From OpenSMTPD where it prevents "implicit declaration" warnings (it's
691 a no-op in OpenSSH). From chl at openbsd.
692 - (dtucker) [openbsd-compat/setproctitle.c] Handle error case form the 2nd
693 vsnprintf. From eric at openbsd via chl@.
694 - (dtucker) [configure.ac defines.h] Add typedefs for intmax_t and uintmax_t
695 for platforms that don't have them.
696
69720131030
698 - (djm) OpenBSD CVS Sync
699 - djm@cvs.openbsd.org 2013/10/29 09:42:11
700 [key.c key.h]
701 fix potential stack exhaustion caused by nested certificates;
702 report by Mateusz Kocielski; ok dtucker@ markus@
703 - djm@cvs.openbsd.org 2013/10/29 09:48:02
704 [servconf.c servconf.h session.c sshd_config sshd_config.5]
705 shd_config PermitTTY to disallow TTY allocation, mirroring the
706 longstanding no-pty authorized_keys option;
707 bz#2070, patch from Teran McKinney; ok markus@
708 - jmc@cvs.openbsd.org 2013/10/29 18:49:32
709 [sshd_config.5]
710 pty(4), not pty(7);
17 711
1820130913 71220131026
19 - (djm) [channels.c] Fix unaligned access on sparc machines in SOCKS5 code; 713 - (djm) OpenBSD CVS Sync
20 ok dtucker@ 714 - djm@cvs.openbsd.org 2013/10/25 23:04:51
21 - (djm) [channels.c] sigh, typo s/buffet_/buffer_/ 715 [ssh.c]
22 - (djm) Release 6.3p1 716 fix crash when using ProxyCommand caused by previous commit - was calling
717 freeaddrinfo(NULL); spotted by sthen@ and Tim Ruehsen, patch by sthen@
718
71920131025
720 - (djm) [ssh-keygen.c ssh-keysign.c sshconnect1.c sshd.c] Remove
721 unnecessary arc4random_stir() calls. The only ones left are to ensure
722 that the PRNG gets a different state after fork() for platforms that
723 have broken the API.
724
72520131024
726 - (djm) [auth-krb5.c] bz#2032 - use local username in krb5_kuserok check
727 rather than full client name which may be of form user@REALM;
728 patch from Miguel Sanders; ok dtucker@
729 - (djm) OpenBSD CVS Sync
730 - dtucker@cvs.openbsd.org 2013/10/23 05:40:58
731 [servconf.c]
732 fix comment
733 - djm@cvs.openbsd.org 2013/10/23 23:35:32
734 [sshd.c]
735 include local address and port in "Connection from ..." message (only
736 shown at loglevel>=verbose)
737 - dtucker@cvs.openbsd.org 2013/10/24 00:49:49
738 [moduli.c]
739 Periodically print progress and, if possible, expected time to completion
740 when screening moduli for DH groups. ok deraadt djm
741 - dtucker@cvs.openbsd.org 2013/10/24 00:51:48
742 [readconf.c servconf.c ssh_config.5 sshd_config.5]
743 Disallow empty Match statements and add "Match all" which matches
744 everything. ok djm, man page help jmc@
745 - djm@cvs.openbsd.org 2013/10/24 08:19:36
746 [ssh.c]
747 fix bug introduced in hostname canonicalisation commit: don't try to
748 resolve hostnames when a ProxyCommand is set unless the user has forced
749 canonicalisation; spotted by Iain Morgan
750 - (tim) [regress/sftp-perm.sh] We need a shell that understands "! somecmd"
751
75220131023
753 - (djm) OpenBSD CVS Sync
754 - djm@cvs.openbsd.org 2013/10/20 04:39:28
755 [ssh_config.5]
756 document % expansions performed by "Match command ..."
757 - djm@cvs.openbsd.org 2013/10/20 06:19:28
758 [readconf.c ssh_config.5]
759 rename "command" subclause of the recently-added "Match" keyword to
760 "exec"; it's shorter, clearer in intent and we might want to add the
761 ability to match against the command being executed at the remote end in
762 the future.
763 - djm@cvs.openbsd.org 2013/10/20 09:51:26
764 [scp.1 sftp.1]
765 add canonicalisation options to -o lists
766 - jmc@cvs.openbsd.org 2013/10/20 18:00:13
767 [ssh_config.5]
768 tweak the "exec" description, as worded by djm;
769 - djm@cvs.openbsd.org 2013/10/23 03:03:07
770 [readconf.c]
771 Hostname may have %h sequences that should be expanded prior to Match
772 evaluation; spotted by Iain Morgan
773 - djm@cvs.openbsd.org 2013/10/23 03:05:19
774 [readconf.c ssh.c]
775 comment
776 - djm@cvs.openbsd.org 2013/10/23 04:16:22
777 [ssh-keygen.c]
778 Make code match documentation: relative-specified certificate expiry time
779 should be relative to current time and not the validity start time.
780 Reported by Petr Lautrbach; ok deraadt@
781
78220131018
783 - (djm) OpenBSD CVS Sync
784 - djm@cvs.openbsd.org 2013/10/09 23:44:14
785 [regress/Makefile regress/sftp-perm.sh]
786 regression test for sftp request white/blacklisting and readonly mode.
787 - jmc@cvs.openbsd.org 2013/10/17 07:35:48
788 [sftp.1 sftp.c]
789 tweak previous;
790 - djm@cvs.openbsd.org 2013/10/17 22:08:04
791 [sshd.c]
792 include remote port in bad banner message; bz#2162
793
79420131017
795 - (djm) OpenBSD CVS Sync
796 - jmc@cvs.openbsd.org 2013/10/15 14:10:25
797 [ssh.1 ssh_config.5]
798 tweak previous;
799 - djm@cvs.openbsd.org 2013/10/16 02:31:47
800 [readconf.c readconf.h roaming_client.c ssh.1 ssh.c ssh_config.5]
801 [sshconnect.c sshconnect.h]
802 Implement client-side hostname canonicalisation to allow an explicit
803 search path of domain suffixes to use to convert unqualified host names
804 to fully-qualified ones for host key matching.
805 This is particularly useful for host certificates, which would otherwise
806 need to list unqualified names alongside fully-qualified ones (and this
807 causes a number of problems).
808 "looks fine" markus@
809 - jmc@cvs.openbsd.org 2013/10/16 06:42:25
810 [ssh_config.5]
811 tweak previous;
812 - djm@cvs.openbsd.org 2013/10/16 22:49:39
813 [readconf.c readconf.h ssh.1 ssh.c ssh_config.5]
814 s/canonicalise/canonicalize/ for consistency with existing spelling,
815 e.g. authorized_keys; pointed out by naddy@
816 - djm@cvs.openbsd.org 2013/10/16 22:58:01
817 [ssh.c ssh_config.5]
818 one I missed in previous: s/isation/ization/
819 - djm@cvs.openbsd.org 2013/10/17 00:30:13
820 [PROTOCOL sftp-client.c sftp-client.h sftp-server.c sftp.1 sftp.c]
821 fsync@openssh.com protocol extension for sftp-server
822 client support to allow calling fsync() faster successful transfer
823 patch mostly by imorgan AT nas.nasa.gov; bz#1798
824 "fine" markus@ "grumble OK" deraadt@ "doesn't sound bad to me" millert@
825 - djm@cvs.openbsd.org 2013/10/17 00:46:49
826 [ssh.c]
827 rearrange check to reduce diff against -portable
828 (Id sync only)
829
83020131015
831 - (djm) OpenBSD CVS Sync
832 - djm@cvs.openbsd.org 2013/10/09 23:42:17
833 [sftp-server.8 sftp-server.c]
834 Add ability to whitelist and/or blacklist sftp protocol requests by name.
835 Refactor dispatch loop and consolidate read-only mode checks.
836 Make global variables static, since sftp-server is linked into sshd(8).
837 ok dtucker@
838 - djm@cvs.openbsd.org 2013/10/10 00:53:25
839 [sftp-server.c]
840 add -Q, -P and -p to usage() before jmc@ catches me
841 - djm@cvs.openbsd.org 2013/10/10 01:43:03
842 [sshd.c]
843 bz#2139: fix re-exec fallback by ensuring that startup_pipe is correctly
844 updated; ok dtucker@
845 - djm@cvs.openbsd.org 2013/10/11 02:45:36
846 [sftp-client.c]
847 rename flag arguments to be more clear and consistent.
848 reorder some internal function arguments to make adding additional flags
849 easier.
850 no functional change
851 - djm@cvs.openbsd.org 2013/10/11 02:52:23
852 [sftp-client.c]
853 missed one arg reorder
854 - djm@cvs.openbsd.org 2013/10/11 02:53:45
855 [sftp-client.h]
856 obsolete comment
857 - jmc@cvs.openbsd.org 2013/10/14 14:18:56
858 [sftp-server.8 sftp-server.c]
859 tweak previous;
860 ok djm
861 - djm@cvs.openbsd.org 2013/10/14 21:20:52
862 [session.c session.h]
863 Add logging of session starts in a useful format; ok markus@ feedback and
864 ok dtucker@
865 - djm@cvs.openbsd.org 2013/10/14 22:22:05
866 [readconf.c readconf.h ssh-keysign.c ssh.c ssh_config.5]
867 add a "Match" keyword to ssh_config that allows matching on hostname,
868 user and result of arbitrary commands. "nice work" markus@
869 - djm@cvs.openbsd.org 2013/10/14 23:28:23
870 [canohost.c misc.c misc.h readconf.c sftp-server.c ssh.c]
871 refactor client config code a little:
872 add multistate option partsing to readconf.c, similar to servconf.c's
873 existing code.
874 move checking of options that accept "none" as an argument to readconf.c
875 add a lowercase() function and use it instead of explicit tolower() in
876 loops
877 part of a larger diff that was ok markus@
878 - djm@cvs.openbsd.org 2013/10/14 23:31:01
879 [ssh.c]
880 whitespace at EOL; pointed out by markus@
881 - [ssh.c] g/c unused variable.
882
88320131010
884 - (dtucker) OpenBSD CVS Sync
885 - sthen@cvs.openbsd.org 2013/09/16 11:35:43
886 [ssh_config]
887 Remove gssapi config parts from ssh_config, as was already done for
888 sshd_config. Req by/ok ajacoutot@
889 ID SYNC ONLY for portable; kerberos/gssapi is still pretty popular
890 - djm@cvs.openbsd.org 2013/09/19 00:24:52
891 [progressmeter.c]
892 store the initial file offset so the progress meter doesn't freak out
893 when resuming sftp transfers. bz#2137; patch from Iain Morgan; ok dtucker@`
894 - djm@cvs.openbsd.org 2013/09/19 00:49:12
895 [sftp-client.c]
896 fix swapped pflag and printflag in sftp upload_dir; from Iain Morgan
897 - djm@cvs.openbsd.org 2013/09/19 01:24:46
898 [channels.c]
899 bz#1297 - tell the client (via packet_send_debug) when their preferred
900 listen address has been overridden by the server's GatewayPorts;
901 ok dtucker@
902 - djm@cvs.openbsd.org 2013/09/19 01:26:29
903 [sshconnect.c]
904 bz#1211: make BindAddress work with UsePrivilegedPort=yes; patch from
905 swp AT swp.pp.ru; ok dtucker@
906 - dtucker@cvs.openbsd.org 2013/10/08 11:42:13
907 [dh.c dh.h]
908 Increase the size of the Diffie-Hellman groups requested for a each
909 symmetric key size. New values from NIST Special Publication 800-57 with
910 the upper limit specified by RFC4419. Pointed out by Peter Backes, ok
911 djm@.
912
91320131009
914 - (djm) [openbsd-compat/arc4random.c openbsd-compat/chacha_private.h] Pull
915 in OpenBSD implementation of arc4random, shortly to replace the existing
916 bsd-arc4random.c
917 - (djm) [openbsd-compat/Makefile.in openbsd-compat/arc4random.c]
918 [openbsd-compat/bsd-arc4random.c] Replace old RC4-based arc4random
919 implementation with recent OpenBSD's ChaCha-based PRNG. ok dtucker@,
920 tested tim@
921
92220130922
923 - (dtucker) [platform.c platform.h sshd.c] bz#2156: restore Linux oom_adj
924 setting when handling SIGHUP to maintain behaviour over retart. Patch
925 from Matthew Ife.
926
92720130918
928 - (dtucker) [sshd_config] Trailing whitespace; from jstjohn at purdue edu.
929
93020130914
931 - (djm) OpenBSD CVS Sync
932 - djm@cvs.openbsd.org 2013/08/22 19:02:21
933 [sshd.c]
934 Stir PRNG after post-accept fork. The child gets a different PRNG state
935 anyway via rexec and explicit privsep reseeds, but it's good to be sure.
936 ok markus@
937 - mikeb@cvs.openbsd.org 2013/08/28 12:34:27
938 [ssh-keygen.c]
939 improve batch processing a bit by making use of the quite flag a bit
940 more often and exit with a non zero code if asked to find a hostname
941 in a known_hosts file and it wasn't there;
942 originally from reyk@, ok djm
943 - djm@cvs.openbsd.org 2013/08/31 00:13:54
944 [sftp.c]
945 make ^w match ksh behaviour (delete previous word instead of entire line)
946 - deraadt@cvs.openbsd.org 2013/09/02 22:00:34
947 [ssh-keygen.c sshconnect1.c sshd.c]
948 All the instances of arc4random_stir() are bogus, since arc4random()
949 does this itself, inside itself, and has for a very long time.. Actually,
950 this was probably reducing the entropy available.
951 ok djm
952 ID SYNC ONLY for portable; we don't trust other arc4random implementations
953 to do this right.
954 - sthen@cvs.openbsd.org 2013/09/07 13:53:11
955 [sshd_config]
956 Remove commented-out kerberos/gssapi config options from sample config,
957 kerberos support is currently not enabled in ssh in OpenBSD. Discussed with
958 various people; ok deraadt@
959 ID SYNC ONLY for portable; kerberos/gssapi is still pretty popular
960 - djm@cvs.openbsd.org 2013/09/12 01:41:12
961 [clientloop.c]
962 fix connection crash when sending break (~B) on ControlPersist'd session;
963 ok dtucker@
964 - djm@cvs.openbsd.org 2013/09/13 06:54:34
965 [channels.c]
966 avoid unaligned access in code that reused a buffer to send a
967 struct in_addr in a reply; simpler just use use buffer_put_int();
968 from portable; spotted by and ok dtucker@
969
97020130828
971 - (djm) [openbsd-compat/bsd-snprintf.c] teach our local snprintf code the
972 'j' (intmax_t/uintmax_t) and 'z' (size_t/ssize_t) conversions in case we
973 start to use them in the future.
974 - (djm) [openbsd-compat/bsd-snprintf.c] #ifdef noytet for intmax_t bits
975 until we have configure support.
976
97720130821
978 - (djm) OpenBSD CVS Sync
979 - djm@cvs.openbsd.org 2013/08/06 23:03:49
980 [sftp.c]
981 fix some whitespace at EOL
982 make list of commands an enum rather than a long list of defines
983 add -a to usage()
984 - djm@cvs.openbsd.org 2013/08/06 23:05:01
985 [sftp.1]
986 document top-level -a option (the -a option to 'get' was already
987 documented)
988 - djm@cvs.openbsd.org 2013/08/06 23:06:01
989 [servconf.c]
990 add cast to avoid format warning; from portable
991 - jmc@cvs.openbsd.org 2013/08/07 06:24:51
992 [sftp.1 sftp.c]
993 sort -a;
994 - djm@cvs.openbsd.org 2013/08/08 04:52:04
995 [sftp.c]
996 fix two year old regression: symlinking a file would incorrectly
997 canonicalise the target path. bz#2129 report from delphij AT freebsd.org
998 - djm@cvs.openbsd.org 2013/08/08 05:04:03
999 [sftp-client.c sftp-client.h sftp.c]
1000 add a "-l" flag for the rename command to force it to use the silly
1001 standard SSH_FXP_RENAME command instead of the POSIX-rename- like
1002 posix-rename@openssh.com extension.
1003
1004 intended for use in regress tests, so no documentation.
1005 - djm@cvs.openbsd.org 2013/08/09 03:37:25
1006 [sftp.c]
1007 do getopt parsing for all sftp commands (with an empty optstring for
1008 commands without arguments) to ensure consistent behaviour
1009 - djm@cvs.openbsd.org 2013/08/09 03:39:13
1010 [sftp-client.c]
1011 two problems found by a to-be-committed regress test: 1) msg_id was not
1012 being initialised so was starting at a random value from the heap
1013 (harmless, but confusing). 2) some error conditions were not being
1014 propagated back to the caller
1015 - djm@cvs.openbsd.org 2013/08/09 03:56:42
1016 [sftp.c]
1017 enable ctrl-left-arrow and ctrl-right-arrow to move forward/back a word;
1018 matching ksh's relatively recent change.
1019 - djm@cvs.openbsd.org 2013/08/13 18:32:08
1020 [ssh-keygen.c]
1021 typo in error message; from Stephan Rickauer
1022 - djm@cvs.openbsd.org 2013/08/13 18:33:08
1023 [ssh-keygen.c]
1024 another of the same typo
1025 - jmc@cvs.openbsd.org 2013/08/14 08:39:27
1026 [scp.1 ssh.1]
1027 some Bx/Ox conversion;
1028 From: Jan Stary
1029 - djm@cvs.openbsd.org 2013/08/20 00:11:38
1030 [readconf.c readconf.h ssh_config.5 sshconnect.c]
1031 Add a ssh_config ProxyUseFDPass option that supports the use of
1032 ProxyCommands that establish a connection and then pass a connected
1033 file descriptor back to ssh(1). This allows the ProxyCommand to exit
1034 rather than have to shuffle data back and forth and enables ssh to use
1035 getpeername, etc. to obtain address information just like it does with
1036 regular directly-connected sockets. ok markus@
1037 - jmc@cvs.openbsd.org 2013/08/20 06:56:07
1038 [ssh.1 ssh_config.5]
1039 some proxyusefdpass tweaks;
23 1040
2420130808 104120130808
25 - (dtucker) [regress/Makefile regress/test-exec.sh] Don't try to use test -nt 1042 - (dtucker) [regress/Makefile regress/test-exec.sh] Don't try to use test -nt
@@ -34,6 +1051,7 @@
34 - (dtucker) [regress/Makefile regress/test-exec.sh] Roll back the -nt 1051 - (dtucker) [regress/Makefile regress/test-exec.sh] Roll back the -nt
35 removal. The "make clean" removes modpipe which is built by the top-level 1052 removal. The "make clean" removes modpipe which is built by the top-level
36 directory before running the tests. Spotted by tim@ 1053 directory before running the tests. Spotted by tim@
1054 - (djm) Release 6.3p1
37 1055
3820130804 105620130804
39 - (dtucker) [auth-krb5.c configure.ac openbsd-compat/bsd-misc.h] Add support 1057 - (dtucker) [auth-krb5.c configure.ac openbsd-compat/bsd-misc.h] Add support
@@ -668,10 +1686,10 @@
668 to avoid conflicting definitions of __int64, adding the required bits. 1686 to avoid conflicting definitions of __int64, adding the required bits.
669 Patch from Corinna Vinschen. 1687 Patch from Corinna Vinschen.
670 1688
67120120323 168920130323
672 - (tim) [Makefile.in] remove some duplication introduced in 20130220 commit. 1690 - (tim) [Makefile.in] remove some duplication introduced in 20130220 commit.
673 1691
67420120322 169220130322
675 - (djm) [contrib/ssh-copy-id contrib/ssh-copy-id.1] Updated to Phil 1693 - (djm) [contrib/ssh-copy-id contrib/ssh-copy-id.1] Updated to Phil
676 Hands' greatly revised version. 1694 Hands' greatly revised version.
677 - (djm) Release 6.2p1 1695 - (djm) Release 6.2p1
@@ -679,16 +1697,16 @@
679 - (dtucker) [includes.h] Check if _GNU_SOURCE is already defined before 1697 - (dtucker) [includes.h] Check if _GNU_SOURCE is already defined before
680 defining it again. Prevents warnings if someone, eg, sets it in CFLAGS. 1698 defining it again. Prevents warnings if someone, eg, sets it in CFLAGS.
681 1699
68220120318 170020130318
683 - (djm) [configure.ac log.c scp.c sshconnect2.c openbsd-compat/vis.c] 1701 - (djm) [configure.ac log.c scp.c sshconnect2.c openbsd-compat/vis.c]
684 [openbsd-compat/vis.h] FreeBSD's strnvis isn't compatible with OpenBSD's 1702 [openbsd-compat/vis.h] FreeBSD's strnvis isn't compatible with OpenBSD's
685 so mark it as broken. Patch from des AT des.no 1703 so mark it as broken. Patch from des AT des.no
686 1704
68720120317 170520130317
688 - (tim) [configure.ac] OpenServer 5 wants lastlog even though it has none 1706 - (tim) [configure.ac] OpenServer 5 wants lastlog even though it has none
689 of the bits the configure test looks for. 1707 of the bits the configure test looks for.
690 1708
69120120316 170920130316
692 - (djm) [configure.ac] Disable utmp, wtmp and/or lastlog if the platform 1710 - (djm) [configure.ac] Disable utmp, wtmp and/or lastlog if the platform
693 is unable to successfully compile them. Based on patch from des AT 1711 is unable to successfully compile them. Based on patch from des AT
694 des.no 1712 des.no
@@ -698,7 +1716,7 @@
698 occur after UID switch; patch from John Marshall via des AT des.no; 1716 occur after UID switch; patch from John Marshall via des AT des.no;
699 ok dtucker@ 1717 ok dtucker@
700 1718
70120120312 171920130312
702 - (dtucker) [regress/Makefile regress/cipher-speed.sh regress/test-exec.sh] 1720 - (dtucker) [regress/Makefile regress/cipher-speed.sh regress/test-exec.sh]
703 Improve portability of cipher-speed test, based mostly on a patch from 1721 Improve portability of cipher-speed test, based mostly on a patch from
704 Iain Morgan. 1722 Iain Morgan.
@@ -1645,2052 +2663,3 @@
1645 [contrib/suse/openssh.spec] Update for release 6.0 2663 [contrib/suse/openssh.spec] Update for release 6.0
1646 - (djm) [README] Update URL to release notes. 2664 - (djm) [README] Update URL to release notes.
1647 - (djm) Release openssh-6.0 2665 - (djm) Release openssh-6.0
1648
164920120419
1650 - (djm) [configure.ac] Fix compilation error on FreeBSD, whose libutil
1651 contains openpty() but not login()
1652
165320120404
1654 - (djm) [Makefile.in configure.ac sandbox-seccomp-filter.c] Add sandbox
1655 mode for Linux's new seccomp filter; patch from Will Drewry; feedback
1656 and ok dtucker@
1657
165820120330
1659 - (dtucker) [contrib/redhat/openssh.spec] Bug #1992: remove now-gone WARNING
1660 file from spec file. From crighter at nuclioss com.
1661 - (djm) [entropy.c] bz#1991: relax OpenSSL version test to allow running
1662 openssh binaries on a newer fix release than they were compiled on.
1663 with and ok dtucker@
1664 - (djm) [openbsd-compat/bsd-cygwin_util.h] #undef _WIN32 to avoid incorrect
1665 assumptions when building on Cygwin; patch from Corinna Vinschen
1666
166720120309
1668 - (djm) [openbsd-compat/port-linux.c] bz#1960: fix crash on SELinux
1669 systems where sshd is run in te wrong context. Patch from Sven
1670 Vermeulen; ok dtucker@
1671 - (djm) [packet.c] bz#1963: Fix IPQoS not being set on non-mapped v4-in-v6
1672 addressed connections. ok dtucker@
1673
167420120224
1675 - (dtucker) [audit-bsm.c configure.ac] bug #1968: enable workarounds for BSM
1676 audit breakage in Solaris 11. Patch from Magnus Johansson.
1677
167820120215
1679 - (tim) [openbsd-compat/bsd-misc.h sshd.c] Fix conflicting return type for
1680 unsetenv due to rev 1.14 change to setenv.c. Cast unsetenv to void in sshd.c
1681 ok dtucker@
1682 - (tim) [defines.h] move chunk introduced in 1.125 before MAXPATHLEN so
1683 it actually works.
1684 - (tim) [regress/keytype.sh] stderr redirection needs to be inside back quote
1685 to work. Spotted by Angel Gonzalez
1686
168720120214
1688 - (djm) [openbsd-compat/bsd-cygwin_util.c] Add PROGRAMFILES to list of
1689 preserved Cygwin environment variables; from Corinna Vinschen
1690
169120120211
1692 - (djm) OpenBSD CVS Sync
1693 - djm@cvs.openbsd.org 2012/01/05 00:16:56
1694 [monitor.c]
1695 memleak on error path
1696 - djm@cvs.openbsd.org 2012/01/07 21:11:36
1697 [mux.c]
1698 fix double-free in new session handler
1699 - miod@cvs.openbsd.org 2012/01/08 13:17:11
1700 [ssh-ecdsa.c]
1701 Fix memory leak in ssh_ecdsa_verify(); from Loganaden Velvindron,
1702 ok markus@
1703 - miod@cvs.openbsd.org 2012/01/16 20:34:09
1704 [ssh-pkcs11-client.c]
1705 Fix a memory leak in pkcs11_rsa_private_encrypt(), reported by Jan Klemkow.
1706 While there, be sure to buffer_clear() between send_msg() and recv_msg().
1707 ok markus@
1708 - dtucker@cvs.openbsd.org 2012/01/18 21:46:43
1709 [clientloop.c]
1710 Ensure that $DISPLAY contains only valid characters before using it to
1711 extract xauth data so that it can't be used to play local shell
1712 metacharacter games. Report from r00t_ati at ihteam.net, ok markus.
1713 - markus@cvs.openbsd.org 2012/01/25 19:26:43
1714 [packet.c]
1715 do not permit SSH2_MSG_SERVICE_REQUEST/ACCEPT during rekeying;
1716 ok dtucker@, djm@
1717 - markus@cvs.openbsd.org 2012/01/25 19:36:31
1718 [authfile.c]
1719 memleak in key_load_file(); from Jan Klemkow
1720 - markus@cvs.openbsd.org 2012/01/25 19:40:09
1721 [packet.c packet.h]
1722 packet_read_poll() is not used anymore.
1723 - markus@cvs.openbsd.org 2012/02/09 20:00:18
1724 [version.h]
1725 move from 6.0-beta to 6.0
1726
172720120206
1728 - (djm) [ssh-keygen.c] Don't fail in do_gen_all_hostkeys on platforms
1729 that don't support ECC. Patch from Phil Oleson
1730
173120111219
1732 - OpenBSD CVS Sync
1733 - djm@cvs.openbsd.org 2011/12/02 00:41:56
1734 [mux.c]
1735 fix bz#1948: ssh -f doesn't fork for multiplexed connection.
1736 ok dtucker@
1737 - djm@cvs.openbsd.org 2011/12/02 00:43:57
1738 [mac.c]
1739 fix bz#1934: newer OpenSSL versions will require HMAC_CTX_Init before
1740 HMAC_init (this change in policy seems insane to me)
1741 ok dtucker@
1742 - djm@cvs.openbsd.org 2011/12/04 23:16:12
1743 [mux.c]
1744 revert:
1745 > revision 1.32
1746 > date: 2011/12/02 00:41:56; author: djm; state: Exp; lines: +4 -1
1747 > fix bz#1948: ssh -f doesn't fork for multiplexed connection.
1748 > ok dtucker@
1749 it interacts badly with ControlPersist
1750 - djm@cvs.openbsd.org 2011/12/07 05:44:38
1751 [auth2.c dh.c packet.c roaming.h roaming_client.c roaming_common.c]
1752 fix some harmless and/or unreachable int overflows;
1753 reported Xi Wang, ok markus@
1754
175520111125
1756 - OpenBSD CVS Sync
1757 - oga@cvs.openbsd.org 2011/11/16 12:24:28
1758 [sftp.c]
1759 Don't leak list in complete_cmd_parse if there are no commands found.
1760 Discovered when I was ``borrowing'' this code for something else.
1761 ok djm@
1762
176320111121
1764 - (dtucker) [configure.ac] Set _FORTIFY_SOURCE. ok djm@
1765
176620111104
1767 - (dtucker) OpenBSD CVS Sync
1768 - djm@cvs.openbsd.org 2011/10/18 05:15:28
1769 [ssh.c]
1770 ssh(1): skip attempting to create ~/.ssh when -F is passed; ok markus@
1771 - djm@cvs.openbsd.org 2011/10/18 23:37:42
1772 [ssh-add.c]
1773 add -k to usage(); reminded by jmc@
1774 - djm@cvs.openbsd.org 2011/10/19 00:06:10
1775 [moduli.c]
1776 s/tmpfile/tmp/ to make this -Wshadow clean
1777 - djm@cvs.openbsd.org 2011/10/19 10:39:48
1778 [umac.c]
1779 typo in comment; patch from Michael W. Bombardieri
1780 - djm@cvs.openbsd.org 2011/10/24 02:10:46
1781 [ssh.c]
1782 bz#1943: unbreak stdio forwarding when ControlPersist is in user - ssh
1783 was incorrectly requesting the forward in both the control master and
1784 slave. skip requesting it in the master to fix. ok markus@
1785 - djm@cvs.openbsd.org 2011/10/24 02:13:13
1786 [session.c]
1787 bz#1859: send tty break to pty master instead of (probably already
1788 closed) slave side; "looks good" markus@
1789 - dtucker@cvs.openbsd.org 011/11/04 00:09:39
1790 [moduli]
1791 regenerated moduli file; ok deraadt
1792 - (dtucker) [INSTALL LICENCE configure.ac openbsd-compat/Makefile.in
1793 openbsd-compat/getrrsetbyname-ldns.c openbsd-compat/getrrsetbyname.c]
1794 bz 1320: Add optional support for LDNS, a BSD licensed DNS resolver library
1795 which supports DNSSEC. Patch from Simon Vallet (svallet at genoscope cns fr)
1796 with some rework from myself and djm. ok djm.
1797
179820111025
1799 - (dtucker) [contrib/cygwin/Makefile] Continue if installing a doc file
1800 fails. Patch from Corinna Vinschen.
1801
180220111018
1803 - (djm) OpenBSD CVS Sync
1804 - djm@cvs.openbsd.org 2011/10/04 14:17:32
1805 [sftp-glob.c]
1806 silence error spam for "ls */foo" in directory with files; bz#1683
1807 - dtucker@cvs.openbsd.org 2011/10/16 11:02:46
1808 [moduli.c ssh-keygen.1 ssh-keygen.c]
1809 Add optional checkpoints for moduli screening. feedback & ok deraadt
1810 - jmc@cvs.openbsd.org 2011/10/16 15:02:41
1811 [ssh-keygen.c]
1812 put -K in the right place (usage());
1813 - stsp@cvs.openbsd.org 2011/10/16 15:51:39
1814 [moduli.c]
1815 add missing includes to unbreak tree; fix from rpointel
1816 - djm@cvs.openbsd.org 2011/10/18 04:58:26
1817 [auth-options.c key.c]
1818 remove explict search for \0 in packet strings, this job is now done
1819 implicitly by buffer_get_cstring; ok markus
1820 - djm@cvs.openbsd.org 2011/10/18 05:00:48
1821 [ssh-add.1 ssh-add.c]
1822 new "ssh-add -k" option to load plain keys (skipping certificates);
1823 "looks ok" markus@
1824
182520111001
1826 - (dtucker) [openbsd-compat/mktemp.c] Fix compiler warning. ok djm
1827 - (dtucker) OpenBSD CVS Sync
1828 - dtucker@cvs.openbsd.org 2011/09/23 00:22:04
1829 [channels.c auth-options.c servconf.c channels.h sshd.8]
1830 Add wildcard support to PermitOpen, allowing things like "PermitOpen
1831 localhost:*". bz #1857, ok djm markus.
1832 - markus@cvs.openbsd.org 2011/09/23 07:45:05
1833 [mux.c readconf.h channels.h compat.h compat.c ssh.c readconf.c channels.c
1834 version.h]
1835 unbreak remote portforwarding with dynamic allocated listen ports:
1836 1) send the actual listen port in the open message (instead of 0).
1837 this allows multiple forwardings with a dynamic listen port
1838 2) update the matching permit-open entry, so we can identify where
1839 to connect to
1840 report: den at skbkontur.ru and P. Szczygielski
1841 feedback and ok djm@
1842 - djm@cvs.openbsd.org 2011/09/25 05:44:47
1843 [auth2-pubkey.c]
1844 improve the AuthorizedPrincipalsFile debug log message to include
1845 file and line number
1846 - dtucker@cvs.openbsd.org 2011/09/30 00:47:37
1847 [sshd.c]
1848 don't attempt privsep cleanup when not using privsep; ok markus@
1849 - djm@cvs.openbsd.org 2011/09/30 21:22:49
1850 [sshd.c]
1851 fix inverted test that caused logspam; spotted by henning@
1852
185320110929
1854 - (djm) [configure.ac defines.h] No need to detect sizeof(char); patch
1855 from des AT des.no
1856 - (dtucker) [configure.ac openbsd-compat/Makefile.in
1857 openbsd-compat/strnlen.c] Add strnlen to the compat library.
1858
185920110923
1860 - (djm) [openbsd-compat/getcwd.c] Remove OpenBSD rcsid marker since we no
1861 longer want to sync this file (OpenBSD uses a __getcwd syscall now, we
1862 want this longhand version)
1863 - (djm) [openbsd-compat/getgrouplist.c] Remove OpenBSD rcsid marker: the
1864 upstream version is YPified and we don't want this
1865 - (djm) [openbsd-compat/mktemp.c] forklift upgrade to -current version.
1866 The file was totally rewritten between what we had in tree and -current.
1867 - (djm) [openbsd-compat/sha2.c openbsd-compat/sha2.h] Remove OpenBSD rcsid
1868 marker. The upstream API has changed (function and structure names)
1869 enough to put it out of sync with other providers of this interface.
1870 - (djm) [openbsd-compat/setenv.c] Forklift upgrade, including inclusion
1871 of static __findenv() function from upstream setenv.c
1872 - OpenBSD CVS Sync
1873 - millert@cvs.openbsd.org 2006/05/05 15:27:38
1874 [openbsd-compat/strlcpy.c]
1875 Convert do {} while loop -> while {} for clarity. No binary change
1876 on most architectures. From Oliver Smith. OK deraadt@ and henning@
1877 - tobias@cvs.openbsd.org 2007/10/21 11:09:30
1878 [openbsd-compat/mktemp.c]
1879 Comment fix about time consumption of _gettemp.
1880 FreeBSD did this in revision 1.20.
1881 OK deraadt@, krw@
1882 - deraadt@cvs.openbsd.org 2008/07/22 21:47:45
1883 [openbsd-compat/mktemp.c]
1884 use arc4random_uniform(); ok djm millert
1885 - millert@cvs.openbsd.org 2008/08/21 16:54:44
1886 [openbsd-compat/mktemp.c]
1887 Remove useless code, the kernel will set errno appropriately if an
1888 element in the path does not exist. OK deraadt@ pvalchev@
1889 - otto@cvs.openbsd.org 2008/12/09 19:38:38
1890 [openbsd-compat/inet_ntop.c]
1891 fix inet_ntop(3) prototype; ok millert@ libc to be bumbed very soon
1892
189320110922
1894 - OpenBSD CVS Sync
1895 - pyr@cvs.openbsd.org 2011/05/12 07:15:10
1896 [openbsd-compat/glob.c]
1897 When the max number of items for a directory has reached GLOB_LIMIT_READDIR
1898 an error is returned but closedir() is not called.
1899 spotted and fix provided by Frank Denis obsd-tech@pureftpd.org
1900 ok otto@, millert@
1901 - stsp@cvs.openbsd.org 2011/09/20 10:18:46
1902 [glob.c]
1903 In glob(3), limit recursion during matching attempts. Similar to
1904 fnmatch fix. Also collapse consecutive '*' (from NetBSD).
1905 ok miod deraadt
1906 - djm@cvs.openbsd.org 2011/09/22 06:27:29
1907 [glob.c]
1908 fix GLOB_KEEPSTAT without GLOB_NOSORT; the implicit sort was being
1909 applied only to the gl_pathv vector and not the corresponding gl_statv
1910 array. reported in OpenSSH bz#1935; feedback and okay matthew@
1911 - djm@cvs.openbsd.org 2011/08/26 01:45:15
1912 [ssh.1]
1913 Add some missing ssh_config(5) options that can be used in ssh(1)'s
1914 -o argument. Patch from duclare AT guu.fi
1915 - djm@cvs.openbsd.org 2011/09/05 05:56:13
1916 [scp.1 sftp.1]
1917 mention ControlPersist and KbdInteractiveAuthentication in the -o
1918 verbiage in these pages too (prompted by jmc@)
1919 - djm@cvs.openbsd.org 2011/09/05 05:59:08
1920 [misc.c]
1921 fix typo in IPQoS parsing: there is no "AF14" class, but there is
1922 an "AF21" class. Spotted by giesen AT snickers.org; ok markus stevesk
1923 - jmc@cvs.openbsd.org 2011/09/05 07:01:44
1924 [scp.1]
1925 knock out a useless Ns;
1926 - deraadt@cvs.openbsd.org 2011/09/07 02:18:31
1927 [ssh-keygen.1]
1928 typo (they vs the) found by Lawrence Teo
1929 - djm@cvs.openbsd.org 2011/09/09 00:43:00
1930 [ssh_config.5 sshd_config.5]
1931 fix typo in IPQoS parsing: there is no "AF14" class, but there is
1932 an "AF21" class. Spotted by giesen AT snickers.org; ok markus stevesk
1933 - djm@cvs.openbsd.org 2011/09/09 00:44:07
1934 [PROTOCOL.mux]
1935 MUX_C_CLOSE_FWD includes forward type in message (though it isn't
1936 implemented anyway)
1937 - djm@cvs.openbsd.org 2011/09/09 22:37:01
1938 [scp.c]
1939 suppress adding '--' to remote commandlines when the first argument
1940 does not start with '-'. saves breakage on some difficult-to-upgrade
1941 embedded/router platforms; feedback & ok dtucker ok markus
1942 - djm@cvs.openbsd.org 2011/09/09 22:38:21
1943 [sshd.c]
1944 kill the preauth privsep child on fatal errors in the monitor;
1945 ok markus@
1946 - djm@cvs.openbsd.org 2011/09/09 22:46:44
1947 [channels.c channels.h clientloop.h mux.c ssh.c]
1948 support for cancelling local and remote port forwards via the multiplex
1949 socket. Use ssh -O cancel -L xx:xx:xx -R yy:yy:yy user@host" to request
1950 the cancellation of the specified forwardings; ok markus@
1951 - markus@cvs.openbsd.org 2011/09/10 22:26:34
1952 [channels.c channels.h clientloop.c ssh.1]
1953 support cancellation of local/dynamic forwardings from ~C commandline;
1954 ok & feedback djm@
1955 - okan@cvs.openbsd.org 2011/09/11 06:59:05
1956 [ssh.1]
1957 document new -O cancel command; ok djm@
1958 - markus@cvs.openbsd.org 2011/09/11 16:07:26
1959 [sftp-client.c]
1960 fix leaks in do_hardlink() and do_readlink(); bz#1921
1961 from Loganaden Velvindron
1962 - markus@cvs.openbsd.org 2011/09/12 08:46:15
1963 [sftp-client.c]
1964 fix leak in do_lsreaddir(); ok djm
1965 - djm@cvs.openbsd.org 2011/09/22 06:29:03
1966 [sftp.c]
1967 don't let remote_glob() implicitly sort its results in do_globbed_ls() -
1968 in all likelihood, they will be resorted anyway
1969
197020110909
1971 - (dtucker) [entropy.h] Bug #1932: remove old definition of init_rng. From
1972 Colin Watson.
1973
197420110906
1975 - (djm) [README version.h] Correct version
1976 - (djm) [contrib/redhat/openssh.spec] Correct restorcon => restorecon
1977 - (djm) Respin OpenSSH-5.9p1 release
1978
197920110905
1980 - (djm) [README contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
1981 [contrib/suse/openssh.spec] Update version numbers.
1982
198320110904
1984 - (djm) [regress/connect-privsep.sh regress/test-exec.sh] demote fatal
1985 regress errors for the sandbox to warnings. ok tim dtucker
1986 - (dtucker) [ssh-keygen.c ssh-pkcs11.c] Bug #1929: add null implementations
1987 ofsh-pkcs11.cpkcs_init and pkcs_terminate for building without dlopen
1988 support.
1989
199020110829
1991 - (djm) [openbsd-compat/port-linux.c] Suppress logging when attempting
1992 to switch SELinux context away from unconfined_t, based on patch from
1993 Jan Chadima; bz#1919 ok dtucker@
1994
199520110827
1996 - (dtucker) [auth-skey.c] Add log.h to fix build --with-skey.
1997
199820110818
1999 - (tim) [configure.ac] Typo in error message spotted by Andy Tsouladze
2000
200120110817
2002 - (tim) [mac.c myproposal.h] Wrap SHA256 and SHA512 in ifdefs for
2003 OpenSSL 0.9.7. ok djm
2004 - (djm) [ openbsd-compat/bsd-cygwin_util.c openbsd-compat/bsd-cygwin_util.h]
2005 binary_pipe is no longer required on Cygwin; patch from Corinna Vinschen
2006 - (djm) [configure.ac] error out if the host lacks the necessary bits for
2007 an explicitly requested sandbox type
2008 - (djm) [contrib/ssh-copy-id] Missing backlslash; spotted by
2009 bisson AT archlinux.org
2010 - (djm) OpenBSD CVS Sync
2011 - dtucker@cvs.openbsd.org 2011/06/03 05:35:10
2012 [regress/cfgmatch.sh]
2013 use OBJ to find test configs, patch from Tim Rice
2014 - markus@cvs.openbsd.org 2011/06/30 22:44:43
2015 [regress/connect-privsep.sh]
2016 test with sandbox enabled; ok djm@
2017 - djm@cvs.openbsd.org 2011/08/02 01:23:41
2018 [regress/cipher-speed.sh regress/try-ciphers.sh]
2019 add SHA256/SHA512 based HMAC modes
2020 - (djm) [regress/cipher-speed.sh regress/try-ciphers.sh] disable HMAC-SHA2
2021 MAC tests for platforms that hack EVP_SHA2 support
2022
202320110812
2024 - (dtucker) [openbsd-compat/port-linux.c] Bug 1924: Improve selinux context
2025 change error by reporting old and new context names Patch from
2026 jchadima at redhat.
2027 - (djm) [contrib/redhat/openssh.spec contrib/redhat/sshd.init]
2028 [contrib/suse/openssh.spec contrib/suse/rc.sshd] Updated RHEL and SLES
2029 init scrips from imorgan AT nas.nasa.gov; bz#1920
2030 - (djm) [contrib/ssh-copy-id] Fix failure for cases where the path to the
2031 identify file contained whitespace. bz#1828 patch from gwenael.lambrouin
2032 AT gmail.com; ok dtucker@
2033
203420110807
2035 - (dtucker) OpenBSD CVS Sync
2036 - jmc@cvs.openbsd.org 2008/06/26 06:59:39
2037 [moduli.5]
2038 tweak previous;
2039 - sobrado@cvs.openbsd.org 2009/10/28 08:56:54
2040 [moduli.5]
2041 "Diffie-Hellman" is the usual spelling for the cryptographic protocol
2042 first published by Whitfield Diffie and Martin Hellman in 1976.
2043 ok jmc@
2044 - jmc@cvs.openbsd.org 2010/10/14 20:41:28
2045 [moduli.5]
2046 probabalistic -> probabilistic; from naddy
2047 - dtucker@cvs.openbsd.org 2011/08/07 12:55:30
2048 [sftp.1]
2049 typo, fix from Laurent Gautrot
2050
205120110805
2052 - OpenBSD CVS Sync
2053 - djm@cvs.openbsd.org 2011/06/23 23:35:42
2054 [monitor.c]
2055 ignore EINTR errors from poll()
2056 - tedu@cvs.openbsd.org 2011/07/06 18:09:21
2057 [authfd.c]
2058 bzero the agent address. the kernel was for a while very cranky about
2059 these things. evne though that's fixed, always good to initialize
2060 memory. ok deraadt djm
2061 - djm@cvs.openbsd.org 2011/07/29 14:42:45
2062 [sandbox-systrace.c]
2063 fail open(2) with EPERM rather than SIGKILLing the whole process. libc
2064 will call open() to do strerror() when NLS is enabled;
2065 feedback and ok markus@
2066 - markus@cvs.openbsd.org 2011/08/01 19:18:15
2067 [gss-serv.c]
2068 prevent post-auth resource exhaustion (int overflow leading to 4GB malloc);
2069 report Adam Zabrock; ok djm@, deraadt@
2070 - djm@cvs.openbsd.org 2011/08/02 01:22:11
2071 [mac.c myproposal.h ssh.1 ssh_config.5 sshd.8 sshd_config.5]
2072 Add new SHA256 and SHA512 based HMAC modes from
2073 http://www.ietf.org/id/draft-dbider-sha2-mac-for-ssh-02.txt
2074 Patch from mdb AT juniper.net; feedback and ok markus@
2075 - djm@cvs.openbsd.org 2011/08/02 23:13:01
2076 [version.h]
2077 crank now, release later
2078 - djm@cvs.openbsd.org 2011/08/02 23:15:03
2079 [ssh.c]
2080 typo in comment
2081
208220110624
2083 - (djm) [configure.ac Makefile.in sandbox-darwin.c] Add a sandbox for
2084 Darwin/OS X using sandbox_init() + setrlimit(); feedback and testing
2085 markus@
2086
208720110623
2088 - OpenBSD CVS Sync
2089 - djm@cvs.openbsd.org 2011/06/22 21:47:28
2090 [servconf.c]
2091 reuse the multistate option arrays to pretty-print options for "sshd -T"
2092 - djm@cvs.openbsd.org 2011/06/22 21:57:01
2093 [servconf.c servconf.h sshd.c sshd_config.5]
2094 [configure.ac Makefile.in]
2095 introduce sandboxing of the pre-auth privsep child using systrace(4).
2096
2097 This introduces a new "UsePrivilegeSeparation=sandbox" option for
2098 sshd_config that applies mandatory restrictions on the syscalls the
2099 privsep child can perform. This prevents a compromised privsep child
2100 from being used to attack other hosts (by opening sockets and proxying)
2101 or probing local kernel attack surface.
2102
2103 The sandbox is implemented using systrace(4) in unsupervised "fast-path"
2104 mode, where a list of permitted syscalls is supplied. Any syscall not
2105 on the list results in SIGKILL being sent to the privsep child. Note
2106 that this requires a kernel with the new SYSTR_POLICY_KILL option.
2107
2108 UsePrivilegeSeparation=sandbox will become the default in the future
2109 so please start testing it now.
2110
2111 feedback dtucker@; ok markus@
2112 - djm@cvs.openbsd.org 2011/06/22 22:08:42
2113 [channels.c channels.h clientloop.c clientloop.h mux.c ssh.c]
2114 hook up a channel confirm callback to warn the user then requested X11
2115 forwarding was refused by the server; ok markus@
2116 - djm@cvs.openbsd.org 2011/06/23 09:34:13
2117 [sshd.c ssh-sandbox.h sandbox.h sandbox-rlimit.c sandbox-systrace.c]
2118 [sandbox-null.c]
2119 rename sandbox.h => ssh-sandbox.h to make things easier for portable
2120 - (djm) [sandbox-null.c] Dummy sandbox for platforms that don't support
2121 setrlimit(2)
2122
212320110620
2124 - OpenBSD CVS Sync
2125 - djm@cvs.openbsd.org 2011/06/04 00:10:26
2126 [ssh_config.5]
2127 explain IdentifyFile's semantics a little better, prompted by bz#1898
2128 ok dtucker jmc
2129 - markus@cvs.openbsd.org 2011/06/14 22:49:18
2130 [authfile.c]
2131 make sure key_parse_public/private_rsa1() no longer consumes its input
2132 buffer. fixes ssh-add for passphrase-protected ssh1-keys;
2133 noted by naddy@; ok djm@
2134 - djm@cvs.openbsd.org 2011/06/17 21:44:31
2135 [log.c log.h monitor.c monitor.h monitor_wrap.c monitor_wrap.h sshd.c]
2136 make the pre-auth privsep slave log via a socketpair shared with the
2137 monitor rather than /var/empty/dev/log; ok dtucker@ deraadt@ markus@
2138 - djm@cvs.openbsd.org 2011/06/17 21:46:16
2139 [sftp-server.c]
2140 the protocol version should be unsigned; bz#1913 reported by mb AT
2141 smartftp.com
2142 - djm@cvs.openbsd.org 2011/06/17 21:47:35
2143 [servconf.c]
2144 factor out multi-choice option parsing into a parse_multistate label
2145 and some support structures; ok dtucker@
2146 - djm@cvs.openbsd.org 2011/06/17 21:57:25
2147 [clientloop.c]
2148 setproctitle for a mux master that has been gracefully stopped;
2149 bz#1911 from Bert.Wesarg AT googlemail.com
2150
215120110603
2152 - (dtucker) [README version.h contrib/caldera/openssh.spec
2153 contrib/redhat/openssh.spec contrib/suse/openssh.spec] Pull the version
2154 bumps from the 5.8p2 branch into HEAD. ok djm.
2155 - (tim) [configure.ac defines.h] Run test program to detect system mail
2156 directory. Add --with-maildir option to override. Fixed OpenServer 6
2157 getting it wrong. Fixed many systems having MAIL=/var/mail//username
2158 ok dtucker
2159 - (dtucker) [monitor.c] Remove the !HAVE_SOCKETPAIR case. We use socketpair
2160 unconditionally in other places and the survey data we have does not show
2161 any systems that use it. "nuke it" djm@
2162 - (djm) [configure.ac] enable setproctitle emulation for OS X
2163 - (djm) OpenBSD CVS Sync
2164 - djm@cvs.openbsd.org 2011/06/03 00:54:38
2165 [ssh.c]
2166 bz#1883 - setproctitle() to identify mux master; patch from Bert.Wesarg
2167 AT googlemail.com; ok dtucker@
2168 NB. includes additional portability code to enable setproctitle emulation
2169 on platforms that don't support it.
2170 - dtucker@cvs.openbsd.org 2011/06/03 01:37:40
2171 [ssh-agent.c]
2172 Check current parent process ID against saved one to determine if the parent
2173 has exited, rather than attempting to send a zero signal, since the latter
2174 won't work if the parent has changed privs. bz#1905, patch from Daniel Kahn
2175 Gillmor, ok djm@
2176 - dtucker@cvs.openbsd.org 2011/05/31 02:01:58
2177 [regress/dynamic-forward.sh]
2178 back out revs 1.6 and 1.5 since it's not reliable
2179 - dtucker@cvs.openbsd.org 2011/05/31 02:03:34
2180 [regress/dynamic-forward.sh]
2181 work around startup and teardown races; caught by deraadt
2182 - dtucker@cvs.openbsd.org 2011/06/03 00:29:52
2183 [regress/dynamic-forward.sh]
2184 Retry establishing the port forwarding after a small delay, should make
2185 the tests less flaky when the previous test is slow to shut down and free
2186 up the port.
2187 - (tim) [regress/cfgmatch.sh] Build/test out of tree fix.
2188
218920110529
2190 - (djm) OpenBSD CVS Sync
2191 - djm@cvs.openbsd.org 2011/05/23 03:30:07
2192 [auth-rsa.c auth.c auth.h auth2-pubkey.c monitor.c monitor_wrap.c]
2193 [pathnames.h servconf.c servconf.h sshd.8 sshd_config sshd_config.5]
2194 allow AuthorizedKeysFile to specify multiple files, separated by spaces.
2195 Bring back authorized_keys2 as a default search path (to avoid breaking
2196 existing users of this file), but override this in sshd_config so it will
2197 be no longer used on fresh installs. Maybe in 2015 we can remove it
2198 entierly :)
2199
2200 feedback and ok markus@ dtucker@
2201 - djm@cvs.openbsd.org 2011/05/23 03:33:38
2202 [auth.c]
2203 make secure_filename() spam debug logs less
2204 - djm@cvs.openbsd.org 2011/05/23 03:52:55
2205 [sshconnect.c]
2206 remove extra newline
2207 - jmc@cvs.openbsd.org 2011/05/23 07:10:21
2208 [sshd.8 sshd_config.5]
2209 tweak previous; ok djm
2210 - djm@cvs.openbsd.org 2011/05/23 07:24:57
2211 [authfile.c]
2212 read in key comments for v.2 keys (though note that these are not
2213 passed over the agent protocol); bz#439, based on patch from binder
2214 AT arago.de; ok markus@
2215 - djm@cvs.openbsd.org 2011/05/24 07:15:47
2216 [readconf.c readconf.h ssh.c ssh_config.5 sshconnect.c sshconnect2.c]
2217 Remove undocumented legacy options UserKnownHostsFile2 and
2218 GlobalKnownHostsFile2 by making UserKnownHostsFile/GlobalKnownHostsFile
2219 accept multiple paths per line and making their defaults include
2220 known_hosts2; ok markus
2221 - djm@cvs.openbsd.org 2011/05/23 03:31:31
2222 [regress/cfgmatch.sh]
2223 include testing of multiple/overridden AuthorizedKeysFiles
2224 refactor to simply daemon start/stop and get rid of racy constructs
2225
222620110520
2227 - (djm) [session.c] call setexeccon() before executing passwd for pw
2228 changes; bz#1891 reported by jchadima AT redhat.com; ok dtucker@
2229 - (djm) [aclocal.m4 configure.ac] since gcc-4.x ignores all -Wno-options
2230 options, we should corresponding -W-option when trying to determine
2231 whether it is accepted. Also includes a warning fix on the program
2232 fragment uses (bad main() return type).
2233 bz#1900 and bz#1901 reported by g.esp AT free.fr; ok dtucker@
2234 - (djm) [servconf.c] remove leftover droppings of AuthorizedKeysFile2
2235 - OpenBSD CVS Sync
2236 - djm@cvs.openbsd.org 2011/05/15 08:09:01
2237 [authfd.c monitor.c serverloop.c]
2238 use FD_CLOEXEC consistently; patch from zion AT x96.org
2239 - djm@cvs.openbsd.org 2011/05/17 07:13:31
2240 [key.c]
2241 fatal() if asked to generate a legacy ECDSA cert (these don't exist)
2242 and fix the regress test that was trying to generate them :)
2243 - djm@cvs.openbsd.org 2011/05/20 00:55:02
2244 [servconf.c]
2245 the options TrustedUserCAKeys, RevokedKeysFile, AuthorizedKeysFile
2246 and AuthorizedPrincipalsFile were not being correctly applied in
2247 Match blocks, despite being overridable there; ok dtucker@
2248 - dtucker@cvs.openbsd.org 2011/05/20 02:00:19
2249 [servconf.c]
2250 Add comment documenting what should be after the preauth check. ok djm
2251 - djm@cvs.openbsd.org 2011/05/20 03:25:45
2252 [monitor.c monitor_wrap.c servconf.c servconf.h]
2253 use a macro to define which string options to copy between configs
2254 for Match. This avoids problems caused by forgetting to keep three
2255 code locations in perfect sync and ordering
2256
2257 "this is at once beautiful and horrible" + ok dtucker@
2258 - djm@cvs.openbsd.org 2011/05/17 07:13:31
2259 [regress/cert-userkey.sh]
2260 fatal() if asked to generate a legacy ECDSA cert (these don't exist)
2261 and fix the regress test that was trying to generate them :)
2262 - djm@cvs.openbsd.org 2011/05/20 02:43:36
2263 [cert-hostkey.sh]
2264 another attempt to generate a v00 ECDSA key that broke the test
2265 ID sync only - portable already had this somehow
2266 - dtucker@cvs.openbsd.org 2011/05/20 05:19:50
2267 [dynamic-forward.sh]
2268 Prevent races in dynamic forwarding test; ok djm
2269 - dtucker@cvs.openbsd.org 2011/05/20 06:32:30
2270 [dynamic-forward.sh]
2271 fix dumb error in dynamic-forward test
2272
227320110515
2274 - (djm) OpenBSD CVS Sync
2275 - djm@cvs.openbsd.org 2011/05/05 05:12:08
2276 [mux.c]
2277 gracefully fall back when ControlPath is too large for a
2278 sockaddr_un. ok markus@ as part of a larger diff
2279 - dtucker@cvs.openbsd.org 2011/05/06 01:03:35
2280 [sshd_config]
2281 clarify language about overriding defaults. bz#1892, from Petr Cerny
2282 - djm@cvs.openbsd.org 2011/05/06 01:09:53
2283 [sftp.1]
2284 mention that IPv6 addresses must be enclosed in square brackets;
2285 bz#1845
2286 - djm@cvs.openbsd.org 2011/05/06 02:05:41
2287 [sshconnect2.c]
2288 fix memory leak; bz#1849 ok dtucker@
2289 - djm@cvs.openbsd.org 2011/05/06 21:14:05
2290 [packet.c packet.h]
2291 set traffic class for IPv6 traffic as we do for IPv4 TOS;
2292 patch from lionel AT mamane.lu via Colin Watson in bz#1855;
2293 ok markus@
2294 - djm@cvs.openbsd.org 2011/05/06 21:18:02
2295 [ssh.c ssh_config.5]
2296 add a %L expansion (short-form of the local host name) for ControlPath;
2297 sync some more expansions with LocalCommand; ok markus@
2298 - djm@cvs.openbsd.org 2011/05/06 21:31:38
2299 [readconf.c ssh_config.5]
2300 support negated Host matching, e.g.
2301
2302 Host *.example.org !c.example.org
2303 User mekmitasdigoat
2304
2305 Will match "a.example.org", "b.example.org", but not "c.example.org"
2306 ok markus@
2307 - djm@cvs.openbsd.org 2011/05/06 21:34:32
2308 [clientloop.c mux.c readconf.c readconf.h ssh.c ssh_config.5]
2309 Add a RequestTTY ssh_config option to allow configuration-based
2310 control over tty allocation (like -t/-T); ok markus@
2311 - djm@cvs.openbsd.org 2011/05/06 21:38:58
2312 [ssh.c]
2313 fix dropping from previous diff
2314 - djm@cvs.openbsd.org 2011/05/06 22:20:10
2315 [PROTOCOL.mux]
2316 fix numbering; from bert.wesarg AT googlemail.com
2317 - jmc@cvs.openbsd.org 2011/05/07 23:19:39
2318 [ssh_config.5]
2319 - tweak previous
2320 - come consistency fixes
2321 ok djm
2322 - jmc@cvs.openbsd.org 2011/05/07 23:20:25
2323 [ssh.1]
2324 +.It RequestTTY
2325 - djm@cvs.openbsd.org 2011/05/08 12:52:01
2326 [PROTOCOL.mux clientloop.c clientloop.h mux.c]
2327 improve our behaviour when TTY allocation fails: if we are in
2328 RequestTTY=auto mode (the default), then do not treat at TTY
2329 allocation error as fatal but rather just restore the local TTY
2330 to cooked mode and continue. This is more graceful on devices that
2331 never allocate TTYs.
2332
2333 If RequestTTY is set to "yes" or "force", then failure to allocate
2334 a TTY is fatal.
2335
2336 ok markus@
2337 - djm@cvs.openbsd.org 2011/05/10 05:46:46
2338 [authfile.c]
2339 despam debug() logs by detecting that we are trying to load a private key
2340 in key_try_load_public() and returning early; ok markus@
2341 - djm@cvs.openbsd.org 2011/05/11 04:47:06
2342 [auth.c auth.h auth2-pubkey.c pathnames.h servconf.c servconf.h]
2343 remove support for authorized_keys2; it is a relic from the early days
2344 of protocol v.2 support and has been undocumented for many years;
2345 ok markus@
2346 - djm@cvs.openbsd.org 2011/05/13 00:05:36
2347 [authfile.c]
2348 warn on unexpected key type in key_parse_private_type()
2349 - (djm) [packet.c] unbreak portability #endif
2350
235120110510
2352 - (dtucker) [openbsd-compat/openssl-compat.{c,h}] Bug #1882: fix
2353 --with-ssl-engine which was broken with the change from deprecated
2354 SSLeay_add_all_algorithms(). ok djm
2355
235620110506
2357 - (dtucker) [openbsd-compat/regress/closefromtest.c] Bug #1875: add prototype
2358 for closefrom() in test code. Report from Dan Wallis via Gentoo.
2359
236020110505
2361 - (djm) [defines.h] Move up include of netinet/ip.h for IPTOS
2362 definitions. From des AT des.no
2363 - (djm) [Makefile.in WARNING.RNG aclocal.m4 buildpkg.sh.in configure.ac]
2364 [entropy.c ssh-add.c ssh-agent.c ssh-keygen.c ssh-keyscan.c]
2365 [ssh-keysign.c ssh-pkcs11-helper.c ssh-rand-helper.8 ssh-rand-helper.c]
2366 [ssh.c ssh_prng_cmds.in sshd.c contrib/aix/buildbff.sh]
2367 [regress/README.regress] Remove ssh-rand-helper and all its
2368 tentacles. PRNGd seeding has been rolled into entropy.c directly.
2369 Thanks to tim@ for testing on affected platforms.
2370 - OpenBSD CVS Sync
2371 - djm@cvs.openbsd.org 2011/03/10 02:52:57
2372 [auth2-gss.c auth2.c auth.h]
2373 allow GSSAPI authentication to detect when a server-side failure causes
2374 authentication failure and don't count such failures against MaxAuthTries;
2375 bz#1244 from simon AT sxw.org.uk; ok markus@ before lock
2376 - okan@cvs.openbsd.org 2011/03/15 10:36:02
2377 [ssh-keyscan.c]
2378 use timerclear macro
2379 ok djm@
2380 - stevesk@cvs.openbsd.org 2011/03/23 15:16:22
2381 [ssh-keygen.1 ssh-keygen.c]
2382 Add -A option. For each of the key types (rsa1, rsa, dsa and ecdsa)
2383 for which host keys do not exist, generate the host keys with the
2384 default key file path, an empty passphrase, default bits for the key
2385 type, and default comment. This will be used by /etc/rc to generate
2386 new host keys. Idea from deraadt.
2387 ok deraadt
2388 - stevesk@cvs.openbsd.org 2011/03/23 16:24:56
2389 [ssh-keygen.1]
2390 -q not used in /etc/rc now so remove statement.
2391 - stevesk@cvs.openbsd.org 2011/03/23 16:50:04
2392 [ssh-keygen.c]
2393 remove -d, documentation removed >10 years ago; ok markus
2394 - jmc@cvs.openbsd.org 2011/03/24 15:29:30
2395 [ssh-keygen.1]
2396 zap trailing whitespace;
2397 - stevesk@cvs.openbsd.org 2011/03/24 22:14:54
2398 [ssh-keygen.c]
2399 use strcasecmp() for "clear" cert permission option also; ok djm
2400 - stevesk@cvs.openbsd.org 2011/03/29 18:54:17
2401 [misc.c misc.h servconf.c]
2402 print ipqos friendly string for sshd -T; ok markus
2403 # sshd -Tf sshd_config|grep ipqos
2404 ipqos lowdelay throughput
2405 - djm@cvs.openbsd.org 2011/04/12 04:23:50
2406 [ssh-keygen.c]
2407 fix -Wshadow
2408 - djm@cvs.openbsd.org 2011/04/12 05:32:49
2409 [sshd.c]
2410 exit with 0 status on SIGTERM; bz#1879
2411 - djm@cvs.openbsd.org 2011/04/13 04:02:48
2412 [ssh-keygen.1]
2413 improve wording; bz#1861
2414 - djm@cvs.openbsd.org 2011/04/13 04:09:37
2415 [ssh-keygen.1]
2416 mention valid -b sizes for ECDSA keys; bz#1862
2417 - djm@cvs.openbsd.org 2011/04/17 22:42:42
2418 [PROTOCOL.mux clientloop.c clientloop.h mux.c ssh.1 ssh.c]
2419 allow graceful shutdown of multiplexing: request that a mux server
2420 removes its listener socket and refuse future multiplexing requests;
2421 ok markus@
2422 - djm@cvs.openbsd.org 2011/04/18 00:46:05
2423 [ssh-keygen.c]
2424 certificate options are supposed to be packed in lexical order of
2425 option name (though we don't actually enforce this at present).
2426 Move one up that was out of sequence
2427 - djm@cvs.openbsd.org 2011/05/04 21:15:29
2428 [authfile.c authfile.h ssh-add.c]
2429 allow "ssh-add - < key"; feedback and ok markus@
2430 - (tim) [configure.ac] Add AC_LANG_SOURCE to OPENSSH_CHECK_CFLAG_COMPILE
2431 so autoreconf 2.68 is happy.
2432 - (tim) [defines.h] Deal with platforms that do not have S_IFSOCK ok djm@
2433
243420110221
2435 - (dtucker) [contrib/cygwin/ssh-host-config] From Corinna: revamp of the
2436 Cygwin-specific service installer script ssh-host-config. The actual
2437 functionality is the same, the revisited version is just more
2438 exact when it comes to check for problems which disallow to run
2439 certain aspects of the script. So, part of this script and the also
2440 rearranged service helper script library "csih" is to check if all
2441 the tools required to run the script are available on the system.
2442 The new script also is more thorough to inform the user why the
2443 script failed. Patch from vinschen at redhat com.
2444
244520110218
2446 - OpenBSD CVS Sync
2447 - djm@cvs.openbsd.org 2011/02/16 00:31:14
2448 [ssh-keysign.c]
2449 make hostbased auth with ECDSA keys work correctly. Based on patch
2450 by harvey.eneman AT oracle.com in bz#1858; ok markus@ (pre-lock)
2451
245220110206
2453 - (dtucker) [openbsd-compat/port-linux.c] Bug #1851: fix syntax error in
2454 selinux code. Patch from Leonardo Chiquitto
2455 - (dtucker) [contrib/cygwin/ssh-{host,user}-config] Add ECDSA key
2456 generation and simplify. Patch from Corinna Vinschen.
2457
245820110204
2459 - OpenBSD CVS Sync
2460 - djm@cvs.openbsd.org 2011/01/31 21:42:15
2461 [PROTOCOL.mux]
2462 cut'n'pasto; from bert.wesarg AT googlemail.com
2463 - djm@cvs.openbsd.org 2011/02/04 00:44:21
2464 [key.c]
2465 fix uninitialised nonce variable; reported by Mateusz Kocielski
2466 - djm@cvs.openbsd.org 2011/02/04 00:44:43
2467 [version.h]
2468 openssh-5.8
2469 - (djm) [README contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
2470 [contrib/suse/openssh.spec] update versions in docs and spec files.
2471 - Release OpenSSH 5.8p1
2472
247320110128
2474 - (djm) [openbsd-compat/port-linux.c] Check whether SELinux is enabled
2475 before attempting setfscreatecon(). Check whether matchpathcon()
2476 succeeded before using its result. Patch from cjwatson AT debian.org;
2477 bz#1851
2478
247920110127
2480 - (tim) [config.guess config.sub] Sync with upstream.
2481 - (tim) [configure.ac] Consistent M4 quoting throughout, updated obsolete
2482 AC_TRY_COMPILE with AC_COMPILE_IFELSE, updated obsolete AC_TRY_LINK with
2483 AC_LINK_IFELSE, updated obsolete AC_TRY_RUN with AC_RUN_IFELSE, misc white
2484 space changes for consistency/readability. Makes autoconf 2.68 happy.
2485 "Nice work" djm
2486
248720110125
2488 - (djm) [configure.ac Makefile.in ssh.c openbsd-compat/port-linux.c
2489 openbsd-compat/port-linux.h] Move SELinux-specific code from ssh.c to
2490 port-linux.c to avoid compilation errors. Add -lselinux to ssh when
2491 building with SELinux support to avoid linking failure; report from
2492 amk AT spamfence.net; ok dtucker
2493
249420110122
2495 - (dtucker) [configure.ac openbsd-compat/openssl-compat.{c,h}] Add
2496 RSA_get_default_method() for the benefit of openssl versions that don't
2497 have it (at least openssl-engine-0.9.6b). Found and tested by Kevin Brott,
2498 ok djm@.
2499 - OpenBSD CVS Sync
2500 - djm@cvs.openbsd.org 2011/01/22 09:18:53
2501 [version.h]
2502 crank to OpenSSH-5.7
2503 - (djm) [README contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
2504 [contrib/suse/openssh.spec] update versions in docs and spec files.
2505 - (djm) Release 5.7p1
2506
250720110119
2508 - (tim) [contrib/caldera/openssh.spec] Use CFLAGS from Makefile instead
2509 of RPM so build completes. Signatures were changed to .asc since 4.1p1.
2510 - (djm) [configure.ac] Disable ECC on OpenSSL <0.9.8g. Releases prior to
2511 0.9.8 lacked it, and 0.9.8a through 0.9.8d have proven buggy in pre-
2512 release testing (random crashes and failure to load ECC keys).
2513 ok dtucker@
2514
251520110117
2516 - (djm) [regress/Makefile] use $TEST_SSH_KEYGEN instead of the one in
2517 $PATH, fix cleanup of droppings; reported by openssh AT
2518 roumenpetrov.info; ok dtucker@
2519 - (djm) [regress/agent-ptrace.sh] Fix false failure on OS X by adding
2520 its unique snowflake of a gdb error to the ones we look for.
2521 - (djm) [regress/agent-getpeereid.sh] leave stdout attached when running
2522 ssh-add to avoid $SUDO failures on Linux
2523 - (dtucker) [openbsd-compat/port-linux.c] Bug #1838: Add support for the new
2524 Linux OOM-killer magic values that changed in 2.6.36 kernels, with fallback
2525 to the old values. Feedback from vapier at gentoo org and djm, ok djm.
2526 - (djm) [configure.ac regress/agent-getpeereid.sh regress/multiplex.sh]
2527 [regress/sftp-glob.sh regress/test-exec.sh] Rework how feature tests are
2528 disabled on platforms that do not support them; add a "config_defined()"
2529 shell function that greps for defines in config.h and use them to decide
2530 on feature tests.
2531 Convert a couple of existing grep's over config.h to use the new function
2532 Add a define "FILESYSTEM_NO_BACKSLASH" for filesystem that can't represent
2533 backslash characters in filenames, enable it for Cygwin and use it to turn
2534 of tests for quotes backslashes in sftp-glob.sh.
2535 based on discussion with vinschen AT redhat.com and dtucker@; ok dtucker@
2536 - (tim) [regress/agent-getpeereid.sh] shell portability fix.
2537 - (dtucker) [openbsd-compat/port-linux.c] Fix minor bug caught by -Werror on
2538 the tinderbox.
2539 - (dtucker) [LICENCE Makefile.in audit-bsm.c audit-linux.c audit.c audit.h
2540 configure.ac defines.h loginrec.c] Bug #1402: add linux audit subsystem
2541 support, based on patches from Tomas Mraz and jchadima at redhat.
2542
254320110116
2544 - (dtucker) [Makefile.in configure.ac regress/kextype.sh] Skip sha256-based
2545 on configurations that don't have it.
2546 - OpenBSD CVS Sync
2547 - djm@cvs.openbsd.org 2011/01/16 11:50:05
2548 [clientloop.c]
2549 Use atomicio when flushing protocol 1 std{out,err} buffers at
2550 session close. This was a latent bug exposed by setting a SIGCHLD
2551 handler and spotted by kevin.brott AT gmail.com; ok dtucker@
2552 - djm@cvs.openbsd.org 2011/01/16 11:50:36
2553 [sshconnect.c]
2554 reset the SIGPIPE handler when forking to execute child processes;
2555 ok dtucker@
2556 - djm@cvs.openbsd.org 2011/01/16 12:05:59
2557 [clientloop.c]
2558 a couple more tweaks to the post-close protocol 1 stderr/stdout flush:
2559 now that we use atomicio(), convert them from while loops to if statements
2560 add test and cast to compile cleanly with -Wsigned
2561
256220110114
2563 - OpenBSD CVS Sync
2564 - djm@cvs.openbsd.org 2011/01/13 21:54:53
2565 [mux.c]
2566 correct error messages; patch from bert.wesarg AT googlemail.com
2567 - djm@cvs.openbsd.org 2011/01/13 21:55:25
2568 [PROTOCOL.mux]
2569 correct protocol names and add a couple of missing protocol number
2570 defines; patch from bert.wesarg AT googlemail.com
2571 - (djm) [Makefile.in] Use shell test to disable ecdsa key generating in
2572 host-key-force target rather than a substitution that is replaced with a
2573 comment so that the Makefile.in is still a syntactically valid Makefile
2574 (useful to run the distprep target)
2575 - (tim) [regress/cert-hostkey.sh] Typo. Missing $ on variable name.
2576 - (tim) [regress/cert-hostkey.sh] Add missing TEST_SSH_ECC guard around some
2577 ecdsa bits.
2578
257920110113
2580 - (djm) [misc.c] include time.h for nanosleep() prototype
2581 - (tim) [Makefile.in] test the ECC bits if we have the capability. ok djm
2582 - (tim) [Makefile.in configure.ac opensshd.init.in] Add support for generating
2583 ecdsa keys. ok djm.
2584 - (djm) [entropy.c] cast OPENSSL_VERSION_NUMBER to u_long to avoid
2585 gcc warning on platforms where it defaults to int
2586 - (djm) [regress/Makefile] add a few more generated files to the clean
2587 target
2588 - (djm) [myproposal.h] Fix reversed OPENSSL_VERSION_NUMBER test and bad
2589 #define that was causing diffie-hellman-group-exchange-sha256 to be
2590 incorrectly disabled
2591 - (djm) [regress/kextype.sh] Testing diffie-hellman-group-exchange-sha256
2592 should not depend on ECC support
2593
259420110112
2595 - OpenBSD CVS Sync
2596 - nicm@cvs.openbsd.org 2010/10/08 21:48:42
2597 [openbsd-compat/glob.c]
2598 Extend GLOB_LIMIT to cover readdir and stat and bump the malloc limit
2599 from ARG_MAX to 64K.
2600 Fixes glob-using programs (notably ftp) able to be triggered to hit
2601 resource limits.
2602 Idea from a similar NetBSD change, original problem reported by jasper@.
2603 ok millert tedu jasper
2604 - djm@cvs.openbsd.org 2011/01/12 01:53:14
2605 avoid some integer overflows mostly with GLOB_APPEND and GLOB_DOOFFS
2606 and sanity check arguments (these will be unnecessary when we switch
2607 struct glob members from being type into to size_t in the future);
2608 "looks ok" tedu@ feedback guenther@
2609 - (djm) [configure.ac] Turn on -Wno-unused-result for gcc >= 4.4 to avoid
2610 silly warnings on write() calls we don't care succeed or not.
2611 - (djm) [configure.ac] Fix broken test for gcc >= 4.4 with per-compiler
2612 flag tests that don't depend on gcc version at all; suggested by and
2613 ok dtucker@
2614
261520110111
2616 - (tim) [regress/host-expand.sh] Fix for building outside of read only
2617 source tree.
2618 - (djm) [platform.c] Some missing includes that show up under -Werror
2619 - OpenBSD CVS Sync
2620 - djm@cvs.openbsd.org 2011/01/08 10:51:51
2621 [clientloop.c]
2622 use host and not options.hostname, as the latter may have unescaped
2623 substitution characters
2624 - djm@cvs.openbsd.org 2011/01/11 06:06:09
2625 [sshlogin.c]
2626 fd leak on error paths; from zinovik@
2627 NB. Id sync only; we use loginrec.c that was also audited and fixed
2628 recently
2629 - djm@cvs.openbsd.org 2011/01/11 06:13:10
2630 [clientloop.c ssh-keygen.c sshd.c]
2631 some unsigned long long casts that make things a bit easier for
2632 portable without resorting to dropping PRIu64 formats everywhere
2633
263420110109
2635 - (djm) [Makefile.in] list ssh_host_ecdsa key in PATHSUBS; spotted by
2636 openssh AT roumenpetrov.info
2637
263820110108
2639 - (djm) [regress/keytype.sh] s/echo -n/echon/ to repair failing regress
2640 test on OSX and others. Reported by imorgan AT nas.nasa.gov
2641
264220110107
2643 - (djm) [regress/cert-hostkey.sh regress/cert-userkey.sh] fix shell test
2644 for no-ECC case. Patch from cristian.ionescu-idbohrn AT axis.com
2645 - djm@cvs.openbsd.org 2011/01/06 22:23:53
2646 [ssh.c]
2647 unbreak %n expansion in LocalCommand; patch from bert.wesarg AT
2648 googlemail.com; ok markus@
2649 - djm@cvs.openbsd.org 2011/01/06 22:23:02
2650 [clientloop.c]
2651 when exiting due to ServerAliveTimeout, mention the hostname that caused
2652 it (useful with backgrounded controlmaster)
2653 - djm@cvs.openbsd.org 2011/01/06 22:46:21
2654 [regress/Makefile regress/host-expand.sh]
2655 regress test for LocalCommand %n expansion from bert.wesarg AT
2656 googlemail.com; ok markus@
2657 - djm@cvs.openbsd.org 2011/01/06 23:01:35
2658 [sshconnect.c]
2659 reset SIGCHLD handler to SIG_DFL when execuring LocalCommand;
2660 ok markus@
2661
266220110106
2663 - (djm) OpenBSD CVS Sync
2664 - markus@cvs.openbsd.org 2010/12/08 22:46:03
2665 [scp.1 scp.c]
2666 add a new -3 option to scp: Copies between two remote hosts are
2667 transferred through the local host. Without this option the data
2668 is copied directly between the two remote hosts. ok djm@ (bugzilla #1837)
2669 - jmc@cvs.openbsd.org 2010/12/09 14:13:33
2670 [scp.1 scp.c]
2671 scp.1: grammer fix
2672 scp.c: add -3 to usage()
2673 - markus@cvs.openbsd.org 2010/12/14 11:59:06
2674 [sshconnect.c]
2675 don't mention key type in key-changed-warning, since we also print
2676 this warning if a new key type appears. ok djm@
2677 - djm@cvs.openbsd.org 2010/12/15 00:49:27
2678 [readpass.c]
2679 fix ControlMaster=ask regression
2680 reset SIGCHLD handler before fork (and restore it after) so we don't miss
2681 the the askpass child's exit status. Correct test for exit status/signal to
2682 account for waitpid() failure; with claudio@ ok claudio@ markus@
2683 - djm@cvs.openbsd.org 2010/12/24 21:41:48
2684 [auth-options.c]
2685 don't send the actual forced command in a debug message; ok markus deraadt
2686 - otto@cvs.openbsd.org 2011/01/04 20:44:13
2687 [ssh-keyscan.c]
2688 handle ecdsa-sha2 with various key lengths; hint and ok djm@
2689
269020110104
2691 - (djm) [configure.ac Makefile.in] Use mandoc as preferred manpage
2692 formatter if it is present, followed by nroff and groff respectively.
2693 Fixes distprep target on OpenBSD (which has bumped groff/nroff to ports
2694 in favour of mandoc). feedback and ok tim
2695
269620110103
2697 - (djm) [Makefile.in] revert local hack I didn't intend to commit
2698
269920110102
2700 - (djm) [loginrec.c] Fix some fd leaks on error paths. ok dtucker
2701 - (djm) [configure.ac] Check whether libdes is needed when building
2702 with Heimdal krb5 support. On OpenBSD this library no longer exists,
2703 so linking it unconditionally causes a build failure; ok dtucker
2704
270520101226
2706 - (dtucker) OpenBSD CVS Sync
2707 - djm@cvs.openbsd.org 2010/12/08 04:02:47
2708 [ssh_config.5 sshd_config.5]
2709 explain that IPQoS arguments are separated by whitespace; iirc requested
2710 by jmc@ a while back
2711
271220101205
2713 - (dtucker) openbsd-compat/openssl-compat.c] remove sleep leftover from
2714 debugging. Spotted by djm.
2715 - (dtucker) OpenBSD CVS Sync
2716 - djm@cvs.openbsd.org 2010/12/03 23:49:26
2717 [schnorr.c]
2718 check that g^x^q === 1 mod p; recommended by JPAKE author Feng Hao
2719 (this code is still disabled, but apprently people are treating it as
2720 a reference implementation)
2721 - djm@cvs.openbsd.org 2010/12/03 23:55:27
2722 [auth-rsa.c]
2723 move check for revoked keys to run earlier (in auth_rsa_key_allowed)
2724 bz#1829; patch from ldv AT altlinux.org; ok markus@
2725 - djm@cvs.openbsd.org 2010/12/04 00:18:01
2726 [sftp-server.c sftp.1 sftp-client.h sftp.c PROTOCOL sftp-client.c]
2727 add a protocol extension to support a hard link operation. It is
2728 available through the "ln" command in the client. The old "ln"
2729 behaviour of creating a symlink is available using its "-s" option
2730 or through the preexisting "symlink" command; based on a patch from
2731 miklos AT szeredi.hu in bz#1555; ok markus@
2732 - djm@cvs.openbsd.org 2010/12/04 13:31:37
2733 [hostfile.c]
2734 fix fd leak; spotted and ok dtucker
2735 - djm@cvs.openbsd.org 2010/12/04 00:21:19
2736 [regress/sftp-cmds.sh]
2737 adjust for hard-link support
2738 - (dtucker) [regress/Makefile] Id sync.
2739
274020101204
2741 - (djm) [openbsd-compat/bindresvport.c] Use arc4random_uniform(range)
2742 instead of (arc4random() % range)
2743 - (dtucker) [configure.ac moduli.c openbsd-compat/openssl-compat.{c,h}] Add
2744 shims for the new, non-deprecated OpenSSL key generation functions for
2745 platforms that don't have the new interfaces.
2746
274720101201
2748 - OpenBSD CVS Sync
2749 - deraadt@cvs.openbsd.org 2010/11/20 05:12:38
2750 [auth2-pubkey.c]
2751 clean up cases of ;;
2752 - djm@cvs.openbsd.org 2010/11/21 01:01:13
2753 [clientloop.c misc.c misc.h ssh-agent.1 ssh-agent.c]
2754 honour $TMPDIR for client xauth and ssh-agent temporary directories;
2755 feedback and ok markus@
2756 - djm@cvs.openbsd.org 2010/11/21 10:57:07
2757 [authfile.c]
2758 Refactor internals of private key loading and saving to work on memory
2759 buffers rather than directly on files. This will make a few things
2760 easier to do in the future; ok markus@
2761 - djm@cvs.openbsd.org 2010/11/23 02:35:50
2762 [auth.c]
2763 use strict_modes already passed as function argument over referencing
2764 global options.strict_modes
2765 - djm@cvs.openbsd.org 2010/11/23 23:57:24
2766 [clientloop.c]
2767 avoid NULL deref on receiving a channel request on an unknown or invalid
2768 channel; report bz#1842 from jchadima AT redhat.com; ok dtucker@
2769 - djm@cvs.openbsd.org 2010/11/24 01:24:14
2770 [channels.c]
2771 remove a debug() that pollutes stderr on client connecting to a server
2772 in debug mode (channel_close_fds is called transitively from the session
2773 code post-fork); bz#1719, ok dtucker
2774 - djm@cvs.openbsd.org 2010/11/25 04:10:09
2775 [session.c]
2776 replace close() loop for fds 3->64 with closefrom();
2777 ok markus deraadt dtucker
2778 - djm@cvs.openbsd.org 2010/11/26 05:52:49
2779 [scp.c]
2780 Pass through ssh command-line flags and options when doing remote-remote
2781 transfers, e.g. to enable agent forwarding which is particularly useful
2782 in this case; bz#1837 ok dtucker@
2783 - markus@cvs.openbsd.org 2010/11/29 18:57:04
2784 [authfile.c]
2785 correctly load comment for encrypted rsa1 keys;
2786 report/fix Joachim Schipper; ok djm@
2787 - djm@cvs.openbsd.org 2010/11/29 23:45:51
2788 [auth.c hostfile.c hostfile.h ssh.c ssh_config.5 sshconnect.c]
2789 [sshconnect.h sshconnect2.c]
2790 automatically order the hostkeys requested by the client based on
2791 which hostkeys are already recorded in known_hosts. This avoids
2792 hostkey warnings when connecting to servers with new ECDSA keys
2793 that are preferred by default; with markus@
2794
279520101124
2796 - (dtucker) [platform.c session.c] Move the getluid call out of session.c and
2797 into the platform-specific code Only affects SCO, tested by and ok tim@.
2798 - (djm) [loginrec.c] Relax permission requirement on btmp logs to allow
2799 group read/write. ok dtucker@
2800 - (dtucker) [packet.c] Remove redundant local declaration of "int tos".
2801 - (djm) [defines.h] Add IP DSCP defines
2802
280320101122
2804 - (dtucker) Bug #1840: fix warning when configuring --with-ssl-engine, patch
2805 from vapier at gentoo org.
2806
280720101120
2808 - OpenBSD CVS Sync
2809 - djm@cvs.openbsd.org 2010/11/05 02:46:47
2810 [packet.c]
2811 whitespace KNF
2812 - djm@cvs.openbsd.org 2010/11/10 01:33:07
2813 [kexdhc.c kexdhs.c kexgexc.c kexgexs.c key.c moduli.c]
2814 use only libcrypto APIs that are retained with OPENSSL_NO_DEPRECATED.
2815 these have been around for years by this time. ok markus
2816 - djm@cvs.openbsd.org 2010/11/13 23:27:51
2817 [clientloop.c misc.c misc.h packet.c packet.h readconf.c readconf.h]
2818 [servconf.c servconf.h session.c ssh.c ssh_config.5 sshd_config.5]
2819 allow ssh and sshd to set arbitrary TOS/DSCP/QoS values instead of
2820 hardcoding lowdelay/throughput.
2821
2822 bz#1733 patch from philipp AT redfish-solutions.com; ok markus@ deraadt@
2823 - jmc@cvs.openbsd.org 2010/11/15 07:40:14
2824 [ssh_config.5]
2825 libary -> library;
2826 - jmc@cvs.openbsd.org 2010/11/18 15:01:00
2827 [scp.1 sftp.1 ssh.1 sshd_config.5]
2828 add IPQoS to the various -o lists, and zap some trailing whitespace;
2829
283020101111
2831 - (djm) [servconf.c ssh-add.c ssh-keygen.c] don't look for ECDSA keys on
2832 platforms that don't support ECC. Fixes some spurious warnings reported
2833 by tim@
2834
283520101109
2836 - (tim) [regress/kextype.sh] Not all platforms have time in /usr/bin.
2837 Feedback from dtucker@
2838 - (tim) [configure.ac openbsd-compat/bsd-misc.h openbsd-compat/bsd-misc.c] Add
2839 support for platforms missing isblank(). ok djm@
2840
284120101108
2842 - (tim) [regress/Makefile] Fixes to allow building/testing outside source
2843 tree.
2844 - (tim) [regress/kextype.sh] Shell portability fix.
2845
284620101107
2847 - (dtucker) [platform.c] includes.h instead of defines.h so that we get
2848 the correct typedefs.
2849
285020101105
2851 - (djm) [loginrec.c loginrec.h] Use correct uid_t/pid_t types instead of
2852 int. Should fix bz#1817 cleanly; ok dtucker@
2853 - OpenBSD CVS Sync
2854 - djm@cvs.openbsd.org 2010/09/22 12:26:05
2855 [regress/Makefile regress/kextype.sh]
2856 regress test for each of the key exchange algorithms that we support
2857 - djm@cvs.openbsd.org 2010/10/28 11:22:09
2858 [authfile.c key.c key.h ssh-keygen.c]
2859 fix a possible NULL deref on loading a corrupt ECDH key
2860
2861 store ECDH group information in private keys files as "named groups"
2862 rather than as a set of explicit group parameters (by setting
2863 the OPENSSL_EC_NAMED_CURVE flag). This makes for shorter key files and
2864 retrieves the group's OpenSSL NID that we need for various things.
2865 - jmc@cvs.openbsd.org 2010/10/28 18:33:28
2866 [scp.1 ssh-add.1 ssh-keygen.1 ssh.1 ssh_config.5 sshd.8 sshd_config.5]
2867 knock out some "-*- nroff -*-" lines;
2868 - djm@cvs.openbsd.org 2010/11/04 02:45:34
2869 [sftp-server.c]
2870 umask should be parsed as octal. reported by candland AT xmission.com;
2871 ok markus@
2872 - (dtucker) [configure.ac platform.{c,h} session.c
2873 openbsd-compat/port-solaris.{c,h}] Bug #1824: Add Solaris Project support.
2874 Patch from cory.erickson at csu mnscu edu with a bit of rework from me.
2875 ok djm@
2876 - (dtucker) [platform.c platform.h session.c] Add a platform hook to run
2877 after the user's groups are established and move the selinux calls into it.
2878 - (dtucker) [platform.c session.c] Move the AIX setpcred+chroot hack into
2879 platform.c
2880 - (dtucker) [platform.c session.c] Move the BSDI setpgrp into platform.c.
2881 - (dtucker) [platform.c] Only call setpgrp on BSDI if running as root to
2882 retain previous behavior.
2883 - (dtucker) [platform.c session.c] Move the PAM credential establishment for
2884 the LOGIN_CAP case into platform.c.
2885 - (dtucker) platform.c session.c] Move the USE_LIBIAF fragment into
2886 platform.c
2887 - (dtucker) [platform.c session.c] Move aix_usrinfo frament into platform.c.
2888 - (dtucker) [platform.c session.c] Move irix setusercontext fragment into
2889 platform.c.
2890 - (dtucker) [platform.c session.c] Move PAM credential establishment for the
2891 non-LOGIN_CAP case into platform.c.
2892 - (dtucker) [platform.c platform.h session.c] Move the Cygwin special-case
2893 check into platform.c
2894 - (dtucker) [regress/keytype.sh] Import new test.
2895 - (dtucker) [Makefile configure.ac regress/Makefile regress/keytype.sh]
2896 Import recent changes to regress/Makefile, pass a flag to enable ECC tests
2897 from configure through to regress/Makefile and use it in the tests.
2898 - (dtucker) [regress/kextype.sh] Add missing "test".
2899 - (dtucker) [regress/kextype.sh] Make sha256 test depend on ECC. This is not
2900 strictly correct since while ECC requires sha256 the reverse is not true
2901 however it does prevent spurious test failures.
2902 - (dtucker) [platform.c] Need servconf.h and extern options.
2903
290420101025
2905 - (tim) [openbsd-compat/glob.h] Remove sys/cdefs.h include that came with
2906 1.12 to unbreak Solaris build.
2907 ok djm@
2908 - (dtucker) [defines.h] Use SIZE_T_MAX for SIZE_MAX for platforms that have a
2909 native one.
2910
291120101024
2912 - (dtucker) [includes.h] Add missing ifdef GLOB_HAS_GL_STATV to fix build.
2913 - (dtucker) [regress/cert-hostkey.sh] Disable ECC-based tests on platforms
2914 which don't have ECC support in libcrypto.
2915 - (dtucker) [regress/cert-userkey.sh] Disable ECC-based tests on platforms
2916 which don't have ECC support in libcrypto.
2917 - (dtucker) [defines.h] Add SIZE_MAX for the benefit of platforms that don't
2918 have it.
2919 - (dtucker) OpenBSD CVS Sync
2920 - sthen@cvs.openbsd.org 2010/10/23 22:06:12
2921 [sftp.c]
2922 escape '[' in filename tab-completion; fix a type while there.
2923 ok djm@
2924
292520101021
2926 - OpenBSD CVS Sync
2927 - dtucker@cvs.openbsd.org 2010/10/12 02:22:24
2928 [mux.c]
2929 Typo in confirmation message. bz#1827, patch from imorgan at
2930 nas nasa gov
2931 - djm@cvs.openbsd.org 2010/08/31 12:24:09
2932 [regress/cert-hostkey.sh regress/cert-userkey.sh]
2933 tests for ECDSA certificates
2934
293520101011
2936 - (djm) [canohost.c] Zero a4 instead of addr to better match type.
2937 bz#1825, reported by foo AT mailinator.com
2938 - (djm) [sshconnect.c] Need signal.h for prototype for kill(2)
2939
294020101011
2941 - (djm) [configure.ac] Use = instead of == in shell tests. Patch from
2942 dr AT vasco.com
2943
294420101007
2945 - (djm) [ssh-agent.c] Fix type for curve name.
2946 - (djm) OpenBSD CVS Sync
2947 - matthew@cvs.openbsd.org 2010/09/24 13:33:00
2948 [misc.c misc.h configure.ac openbsd-compat/openbsd-compat.h]
2949 [openbsd-compat/timingsafe_bcmp.c]
2950 Add timingsafe_bcmp(3) to libc, mention that it's already in the
2951 kernel in kern(9), and remove it from OpenSSH.
2952 ok deraadt@, djm@
2953 NB. re-added under openbsd-compat/ for portable OpenSSH
2954 - djm@cvs.openbsd.org 2010/09/25 09:30:16
2955 [sftp.c configure.ac openbsd-compat/glob.c openbsd-compat/glob.h]
2956 make use of new glob(3) GLOB_KEEPSTAT extension to save extra server
2957 rountrips to fetch per-file stat(2) information.
2958 NB. update openbsd-compat/ glob(3) implementation from OpenBSD libc to
2959 match.
2960 - djm@cvs.openbsd.org 2010/09/26 22:26:33
2961 [sftp.c]
2962 when performing an "ls" in columnated (short) mode, only call
2963 ioctl(TIOCGWINSZ) once to get the window width instead of per-
2964 filename
2965 - djm@cvs.openbsd.org 2010/09/30 11:04:51
2966 [servconf.c]
2967 prevent free() of string in .rodata when overriding AuthorizedKeys in
2968 a Match block; patch from rein AT basefarm.no
2969 - djm@cvs.openbsd.org 2010/10/01 23:05:32
2970 [cipher-3des1.c cipher-bf1.c cipher-ctr.c openbsd-compat/openssl-compat.h]
2971 adapt to API changes in openssl-1.0.0a
2972 NB. contains compat code to select correct API for older OpenSSL
2973 - djm@cvs.openbsd.org 2010/10/05 05:13:18
2974 [sftp.c sshconnect.c]
2975 use default shell /bin/sh if $SHELL is ""; ok markus@
2976 - djm@cvs.openbsd.org 2010/10/06 06:39:28
2977 [clientloop.c ssh.c sshconnect.c sshconnect.h]
2978 kill proxy command on fatal() (we already kill it on clean exit);
2979 ok markus@
2980 - djm@cvs.openbsd.org 2010/10/06 21:10:21
2981 [sshconnect.c]
2982 swapped args to kill(2)
2983 - (djm) [openbsd-compat/glob.c] restore ARG_MAX compat code.
2984 - (djm) [cipher-acss.c] Add missing header.
2985 - (djm) [openbsd-compat/Makefile.in] Actually link timingsafe_bcmp
2986
298720100924
2988 - (djm) OpenBSD CVS Sync
2989 - naddy@cvs.openbsd.org 2010/09/10 15:19:29
2990 [ssh-keygen.1]
2991 * mention ECDSA in more places
2992 * less repetition in FILES section
2993 * SSHv1 keys are still encrypted with 3DES
2994 help and ok jmc@
2995 - djm@cvs.openbsd.org 2010/09/11 21:44:20
2996 [ssh.1]
2997 mention RFC 5656 for ECC stuff
2998 - jmc@cvs.openbsd.org 2010/09/19 21:30:05
2999 [sftp.1]
3000 more wacky macro fixing;
3001 - djm@cvs.openbsd.org 2010/09/20 04:41:47
3002 [ssh.c]
3003 install a SIGCHLD handler to reap expiried child process; ok markus@
3004 - djm@cvs.openbsd.org 2010/09/20 04:50:53
3005 [jpake.c schnorr.c]
3006 check that received values are smaller than the group size in the
3007 disabled and unfinished J-PAKE code.
3008 avoids catastrophic security failure found by Sebastien Martini
3009 - djm@cvs.openbsd.org 2010/09/20 04:54:07
3010 [jpake.c]
3011 missing #include
3012 - djm@cvs.openbsd.org 2010/09/20 07:19:27
3013 [mux.c]
3014 "atomically" create the listening mux socket by binding it on a temorary
3015 name and then linking it into position after listen() has succeeded.
3016 this allows the mux clients to determine that the server socket is
3017 either ready or stale without races. stale server sockets are now
3018 automatically removed
3019 ok deraadt
3020 - djm@cvs.openbsd.org 2010/09/22 05:01:30
3021 [kex.c kex.h kexecdh.c kexecdhc.c kexecdhs.c readconf.c readconf.h]
3022 [servconf.c servconf.h ssh_config.5 sshconnect2.c sshd.c sshd_config.5]
3023 add a KexAlgorithms knob to the client and server configuration to allow
3024 selection of which key exchange methods are used by ssh(1) and sshd(8)
3025 and their order of preference.
3026 ok markus@
3027 - jmc@cvs.openbsd.org 2010/09/22 08:30:08
3028 [ssh.1 ssh_config.5]
3029 ssh.1: add kexalgorithms to the -o list
3030 ssh_config.5: format the kexalgorithms in a more consistent
3031 (prettier!) way
3032 ok djm
3033 - djm@cvs.openbsd.org 2010/09/22 22:58:51
3034 [atomicio.c atomicio.h misc.c misc.h scp.c sftp-client.c]
3035 [sftp-client.h sftp.1 sftp.c]
3036 add an option per-read/write callback to atomicio
3037
3038 factor out bandwidth limiting code from scp(1) into a generic bandwidth
3039 limiter that can be attached using the atomicio callback mechanism
3040
3041 add a bandwidth limit option to sftp(1) using the above
3042 "very nice" markus@
3043 - jmc@cvs.openbsd.org 2010/09/23 13:34:43
3044 [sftp.c]
3045 add [-l limit] to usage();
3046 - jmc@cvs.openbsd.org 2010/09/23 13:36:46
3047 [scp.1 sftp.1]
3048 add KexAlgorithms to the -o list;
3049
305020100910
3051 - (dtucker) [openbsd-compat/port-linux.c] Check is_selinux_enabled for exact
3052 return code since it can apparently return -1 under some conditions. From
3053 openssh bugs werbittewas de, ok djm@
3054 - OpenBSD CVS Sync
3055 - djm@cvs.openbsd.org 2010/08/31 12:33:38
3056 [ssh-add.c ssh-agent.c ssh-keygen.c ssh-keysign.c ssh.c sshd.c]
3057 reintroduce commit from tedu@, which I pulled out for release
3058 engineering:
3059 OpenSSL_add_all_algorithms is the name of the function we have a
3060 man page for, so use that. ok djm
3061 - jmc@cvs.openbsd.org 2010/08/31 17:40:54
3062 [ssh-agent.1]
3063 fix some macro abuse;
3064 - jmc@cvs.openbsd.org 2010/08/31 21:14:58
3065 [ssh.1]
3066 small text tweak to accommodate previous;
3067 - naddy@cvs.openbsd.org 2010/09/01 15:21:35
3068 [servconf.c]
3069 pick up ECDSA host key by default; ok djm@
3070 - markus@cvs.openbsd.org 2010/09/02 16:07:25
3071 [ssh-keygen.c]
3072 permit -b 256, 384 or 521 as key size for ECDSA; ok djm@
3073 - markus@cvs.openbsd.org 2010/09/02 16:08:39
3074 [ssh.c]
3075 unbreak ControlPersist=yes for ControlMaster=yes; ok djm@
3076 - naddy@cvs.openbsd.org 2010/09/02 17:21:50
3077 [ssh-keygen.c]
3078 Switch ECDSA default key size to 256 bits, which according to RFC5656
3079 should still be better than our current RSA-2048 default.
3080 ok djm@, markus@
3081 - jmc@cvs.openbsd.org 2010/09/03 11:09:29
3082 [scp.1]
3083 add an EXIT STATUS section for /usr/bin;
3084 - jmc@cvs.openbsd.org 2010/09/04 09:38:34
3085 [ssh-add.1 ssh.1]
3086 two more EXIT STATUS sections;
3087 - naddy@cvs.openbsd.org 2010/09/06 17:10:19
3088 [sshd_config]
3089 add ssh_host_ecdsa_key to /etc; from Mattieu Baptiste
3090 <mattieu.b@gmail.com>
3091 ok deraadt@
3092 - djm@cvs.openbsd.org 2010/09/08 03:54:36
3093 [authfile.c]
3094 typo
3095 - deraadt@cvs.openbsd.org 2010/09/08 04:13:31
3096 [compress.c]
3097 work around name-space collisions some buggy compilers (looking at you
3098 gcc, at least in earlier versions, but this does not forgive your current
3099 transgressions) seen between zlib and openssl
3100 ok djm
3101 - djm@cvs.openbsd.org 2010/09/09 10:45:45
3102 [kex.c kex.h kexecdh.c key.c key.h monitor.c ssh-ecdsa.c]
3103 ECDH/ECDSA compliance fix: these methods vary the hash function they use
3104 (SHA256/384/512) depending on the length of the curve in use. The previous
3105 code incorrectly used SHA256 in all cases.
3106
3107 This fix will cause authentication failure when using 384 or 521-bit curve
3108 keys if one peer hasn't been upgraded and the other has. (256-bit curve
3109 keys work ok). In particular you may need to specify HostkeyAlgorithms
3110 when connecting to a server that has not been upgraded from an upgraded
3111 client.
3112
3113 ok naddy@
3114 - (djm) [authfd.c authfile.c bufec.c buffer.h configure.ac kex.h kexecdh.c]
3115 [kexecdhc.c kexecdhs.c key.c key.h myproposal.h packet.c readconf.c]
3116 [ssh-agent.c ssh-ecdsa.c ssh-keygen.c ssh.c] Disable ECDH and ECDSA on
3117 platforms that don't have the requisite OpenSSL support. ok dtucker@
3118 - (dtucker) [kex.h key.c packet.h ssh-agent.c ssh.c] A few more ECC ifdefs
3119 for missing headers and compiler warnings.
3120
312120100831
3122 - OpenBSD CVS Sync
3123 - jmc@cvs.openbsd.org 2010/08/08 19:36:30
3124 [ssh-keysign.8 ssh.1 sshd.8]
3125 use the same template for all FILES sections; i.e. -compact/.Pp where we
3126 have multiple items, and .Pa for path names;
3127 - tedu@cvs.openbsd.org 2010/08/12 23:34:39
3128 [ssh-add.c ssh-agent.c ssh-keygen.c ssh-keysign.c ssh.c sshd.c]
3129 OpenSSL_add_all_algorithms is the name of the function we have a man page
3130 for, so use that. ok djm
3131 - djm@cvs.openbsd.org 2010/08/16 04:06:06
3132 [ssh-add.c ssh-agent.c ssh-keygen.c ssh-keysign.c ssh.c sshd.c]
3133 backout previous temporarily; discussed with deraadt@
3134 - djm@cvs.openbsd.org 2010/08/31 09:58:37
3135 [auth-options.c auth1.c auth2.c bufaux.c buffer.h kex.c key.c packet.c]
3136 [packet.h ssh-dss.c ssh-rsa.c]
3137 Add buffer_get_cstring() and related functions that verify that the
3138 string extracted from the buffer contains no embedded \0 characters*
3139 This prevents random (possibly malicious) crap from being appended to
3140 strings where it would not be noticed if the string is used with
3141 a string(3) function.
3142
3143 Use the new API in a few sensitive places.
3144
3145 * actually, we allow a single one at the end of the string for now because
3146 we don't know how many deployed implementations get this wrong, but don't
3147 count on this to remain indefinitely.
3148 - djm@cvs.openbsd.org 2010/08/31 11:54:45
3149 [PROTOCOL PROTOCOL.agent PROTOCOL.certkeys auth2-jpake.c authfd.c]
3150 [authfile.c buffer.h dns.c kex.c kex.h key.c key.h monitor.c]
3151 [monitor_wrap.c myproposal.h packet.c packet.h pathnames.h readconf.c]
3152 [ssh-add.1 ssh-add.c ssh-agent.1 ssh-agent.c ssh-keygen.1 ssh-keygen.c]
3153 [ssh-keyscan.1 ssh-keyscan.c ssh-keysign.8 ssh.1 ssh.c ssh2.h]
3154 [ssh_config.5 sshconnect.c sshconnect2.c sshd.8 sshd.c sshd_config.5]
3155 [uuencode.c uuencode.h bufec.c kexecdh.c kexecdhc.c kexecdhs.c ssh-ecdsa.c]
3156 Implement Elliptic Curve Cryptography modes for key exchange (ECDH) and
3157 host/user keys (ECDSA) as specified by RFC5656. ECDH and ECDSA offer
3158 better performance than plain DH and DSA at the same equivalent symmetric
3159 key length, as well as much shorter keys.
3160
3161 Only the mandatory sections of RFC5656 are implemented, specifically the
3162 three REQUIRED curves nistp256, nistp384 and nistp521 and only ECDH and
3163 ECDSA. Point compression (optional in RFC5656 is NOT implemented).
3164
3165 Certificate host and user keys using the new ECDSA key types are supported.
3166
3167 Note that this code has not been tested for interoperability and may be
3168 subject to change.
3169
3170 feedback and ok markus@
3171 - (djm) [Makefile.in] Add new ECC files
3172 - (djm) [bufec.c kexecdh.c kexecdhc.c kexecdhs.c ssh-ecdsa.c] include
3173 includes.h
3174
317520100827
3176 - (dtucker) [contrib/redhat/sshd.init] Bug #1810: initlog is deprecated,
3177 remove. Patch from martynas at venck us
3178
317920100823
3180 - (djm) Release OpenSSH-5.6p1
3181
318220100816
3183 - (dtucker) [configure.ac openbsd-compat/Makefile.in
3184 openbsd-compat/openbsd-compat.h openbsd-compat/strptime.c] Add strptime to
3185 the compat library which helps on platforms like old IRIX. Based on work
3186 by djm, tested by Tom Christensen.
3187 - OpenBSD CVS Sync
3188 - djm@cvs.openbsd.org 2010/08/12 21:49:44
3189 [ssh.c]
3190 close any extra file descriptors inherited from parent at start and
3191 reopen stdin/stdout to /dev/null when forking for ControlPersist.
3192
3193 prevents tools that fork and run a captive ssh for communication from
3194 failing to exit when the ssh completes while they wait for these fds to
3195 close. The inherited fds may persist arbitrarily long if a background
3196 mux master has been started by ControlPersist. cvs and scp were effected
3197 by this.
3198
3199 "please commit" markus@
3200 - (djm) [regress/README.regress] typo
3201
320220100812
3203 - (tim) [regress/login-timeout.sh regress/reconfigure.sh regress/reexec.sh
3204 regress/test-exec.sh] Under certain conditions when testing with sudo
3205 tests would fail because the pidfile could not be read by a regular user.
3206 "cat: cannot open ...../regress/pidfile: Permission denied (error 13)"
3207 Make sure cat is run by $SUDO. no objection from me. djm@
3208 - (tim) [auth.c] add cast to quiet compiler. Change only affects SVR5 systems.
3209
321020100809
3211 - (djm) bz#1561: don't bother setting IFF_UP on tun(4) device if it is
3212 already set. Makes FreeBSD user openable tunnels useful; patch from
3213 richard.burakowski+ossh AT mrburak.net, ok dtucker@
3214 - (dtucker) bug #1530: strip trailing ":" from hostname in ssh-copy-id.
3215 based in part on a patch from Colin Watson, ok djm@
3216
321720100809
3218 - OpenBSD CVS Sync
3219 - djm@cvs.openbsd.org 2010/08/08 16:26:42
3220 [version.h]
3221 crank to 5.6
3222 - (djm) [README contrib/caldera/openssh.spec contrib/redhat/openssh.spec]
3223 [contrib/suse/openssh.spec] Crank version numbers
3224
322520100805
3226 - OpenBSD CVS Sync
3227 - djm@cvs.openbsd.org 2010/08/04 05:37:01
3228 [ssh.1 ssh_config.5 sshd.8]
3229 Remove mentions of weird "addr/port" alternate address format for IPv6
3230 addresses combinations. It hasn't worked for ages and we have supported
3231 the more commen "[addr]:port" format for a long time. ok jmc@ markus@
3232 - djm@cvs.openbsd.org 2010/08/04 05:40:39
3233 [PROTOCOL.certkeys ssh-keygen.c]
3234 tighten the rules for certificate encoding by requiring that options
3235 appear in lexical order and make our ssh-keygen comply. ok markus@
3236 - djm@cvs.openbsd.org 2010/08/04 05:42:47
3237 [auth.c auth2-hostbased.c authfile.c authfile.h ssh-keysign.8]
3238 [ssh-keysign.c ssh.c]
3239 enable certificates for hostbased authentication, from Iain Morgan;
3240 "looks ok" markus@
3241 - djm@cvs.openbsd.org 2010/08/04 05:49:22
3242 [authfile.c]
3243 commited the wrong version of the hostbased certificate diff; this
3244 version replaces some strlc{py,at} verbosity with xasprintf() at
3245 the request of markus@
3246 - djm@cvs.openbsd.org 2010/08/04 06:07:11
3247 [ssh-keygen.1 ssh-keygen.c]
3248 Support CA keys in PKCS#11 tokens; feedback and ok markus@
3249 - djm@cvs.openbsd.org 2010/08/04 06:08:40
3250 [ssh-keysign.c]
3251 clean for -Wuninitialized (Id sync only; portable had this change)
3252 - djm@cvs.openbsd.org 2010/08/05 13:08:42
3253 [channels.c]
3254 Fix a trio of bugs in the local/remote window calculation for datagram
3255 data channels (i.e. TunnelForward):
3256
3257 Calculate local_consumed correctly in channel_handle_wfd() by measuring
3258 the delta to buffer_len(c->output) from when we start to when we finish.
3259 The proximal problem here is that the output_filter we use in portable
3260 modified the length of the dequeued datagram (to futz with the headers
3261 for !OpenBSD).
3262
3263 In channel_output_poll(), don't enqueue datagrams that won't fit in the
3264 peer's advertised packet size (highly unlikely to ever occur) or which
3265 won't fit in the peer's remaining window (more likely).
3266
3267 In channel_input_data(), account for the 4-byte string header in
3268 datagram packets that we accept from the peer and enqueue in c->output.
3269
3270 report, analysis and testing 2/3 cases from wierbows AT us.ibm.com;
3271 "looks good" markus@
3272
327320100803
3274 - (dtucker) [monitor.c] Bug #1795: Initialize the values to be returned from
3275 PAM to sane values in case the PAM method doesn't write to them. Spotted by
3276 Bitman Zhou, ok djm@.
3277 - OpenBSD CVS Sync
3278 - djm@cvs.openbsd.org 2010/07/16 04:45:30
3279 [ssh-keygen.c]
3280 avoid bogus compiler warning
3281 - djm@cvs.openbsd.org 2010/07/16 14:07:35
3282 [ssh-rsa.c]
3283 more timing paranoia - compare all parts of the expected decrypted
3284 data before returning. AFAIK not exploitable in the SSH protocol.
3285 "groovy" deraadt@
3286 - djm@cvs.openbsd.org 2010/07/19 03:16:33
3287 [sftp-client.c]
3288 bz#1797: fix swapped args in upload_dir_internal(), breaking recursive
3289 upload depth checks and causing verbose printing of transfers to always
3290 be turned on; patch from imorgan AT nas.nasa.gov
3291 - djm@cvs.openbsd.org 2010/07/19 09:15:12
3292 [clientloop.c readconf.c readconf.h ssh.c ssh_config.5]
3293 add a "ControlPersist" option that automatically starts a background
3294 ssh(1) multiplex master when connecting. This connection can stay alive
3295 indefinitely, or can be set to automatically close after a user-specified
3296 duration of inactivity. bz#1330 - patch by dwmw2 AT infradead.org, but
3297 further hacked on by wmertens AT cisco.com, apb AT cequrux.com,
3298 martin-mindrot-bugzilla AT earth.li and myself; "looks ok" markus@
3299 - djm@cvs.openbsd.org 2010/07/21 02:10:58
3300 [misc.c]
3301 sync timingsafe_bcmp() with the one dempsky@ committed to sys/lib/libkern
3302 - dtucker@cvs.openbsd.org 2010/07/23 08:49:25
3303 [ssh.1]
3304 Ciphers is documented in ssh_config(5) these days
3305
330620100819
3307 - (dtucker) [contrib/ssh-copy-ud.1] Bug #1786: update ssh-copy-id.1 with more
3308 details about its behaviour WRT existing directories. Patch from
3309 asguthrie at gmail com, ok djm.
3310
331120100716
3312 - (djm) OpenBSD CVS Sync
3313 - djm@cvs.openbsd.org 2010/07/02 04:32:44
3314 [misc.c]
3315 unbreak strdelim() skipping past quoted strings, e.g.
3316 AllowUsers "blah blah" blah
3317 was broken; report and fix in bz#1757 from bitman.zhou AT centrify.com
3318 ok dtucker;
3319 - djm@cvs.openbsd.org 2010/07/12 22:38:52
3320 [ssh.c]
3321 Make ExitOnForwardFailure work with fork-after-authentication ("ssh -f")
3322 for protocol 2. ok markus@
3323 - djm@cvs.openbsd.org 2010/07/12 22:41:13
3324 [ssh.c ssh_config.5]
3325 expand %h to the hostname in ssh_config Hostname options. While this
3326 sounds useless, it is actually handy for working with unqualified
3327 hostnames:
3328
3329 Host *.*
3330 Hostname %h
3331 Host *
3332 Hostname %h.example.org
3333
3334 "I like it" markus@
3335 - djm@cvs.openbsd.org 2010/07/13 11:52:06
3336 [auth-rsa.c channels.c jpake.c key.c misc.c misc.h monitor.c]
3337 [packet.c ssh-rsa.c]
3338 implement a timing_safe_cmp() function to compare memory without leaking
3339 timing information by short-circuiting like memcmp() and use it for
3340 some of the more sensitive comparisons (though nothing high-value was
3341 readily attackable anyway); "looks ok" markus@
3342 - djm@cvs.openbsd.org 2010/07/13 23:13:16
3343 [auth-rsa.c channels.c jpake.c key.c misc.c misc.h monitor.c packet.c]
3344 [ssh-rsa.c]
3345 s/timing_safe_cmp/timingsafe_bcmp/g
3346 - jmc@cvs.openbsd.org 2010/07/14 17:06:58
3347 [ssh.1]
3348 finally ssh synopsis looks nice again! this commit just removes a ton of
3349 hacks we had in place to make it work with old groff;
3350 - schwarze@cvs.openbsd.org 2010/07/15 21:20:38
3351 [ssh-keygen.1]
3352 repair incorrect block nesting, which screwed up indentation;
3353 problem reported and fix OK by jmc@
3354
335520100714
3356 - (tim) [contrib/redhat/openssh.spec] Bug 1796: Test for skip_x11_askpass
3357 (line 77) should have been for no_x11_askpass.
3358
335920100702
3360 - (djm) OpenBSD CVS Sync
3361 - jmc@cvs.openbsd.org 2010/06/26 00:57:07
3362 [ssh_config.5]
3363 tweak previous;
3364 - djm@cvs.openbsd.org 2010/06/26 23:04:04
3365 [ssh.c]
3366 oops, forgot to #include <canohost.h>; spotted and patch from chl@
3367 - djm@cvs.openbsd.org 2010/06/29 23:15:30
3368 [ssh-keygen.1 ssh-keygen.c]
3369 allow import (-i) and export (-e) of PEM and PKCS#8 encoded keys;
3370 bz#1749; ok markus@
3371 - djm@cvs.openbsd.org 2010/06/29 23:16:46
3372 [auth2-pubkey.c sshd_config.5]
3373 allow key options (command="..." and friends) in AuthorizedPrincipals;
3374 ok markus@
3375 - jmc@cvs.openbsd.org 2010/06/30 07:24:25
3376 [ssh-keygen.1]
3377 tweak previous;
3378 - jmc@cvs.openbsd.org 2010/06/30 07:26:03
3379 [ssh-keygen.c]
3380 sort usage();
3381 - jmc@cvs.openbsd.org 2010/06/30 07:28:34
3382 [sshd_config.5]
3383 tweak previous;
3384 - millert@cvs.openbsd.org 2010/07/01 13:06:59
3385 [scp.c]
3386 Fix a longstanding problem where if you suspend scp at the
3387 password/passphrase prompt the terminal mode is not restored.
3388 OK djm@
3389 - phessler@cvs.openbsd.org 2010/06/27 19:19:56
3390 [regress/Makefile]
3391 fix how we run the tests so we can successfully use SUDO='sudo -E'
3392 in our env
3393 - djm@cvs.openbsd.org 2010/06/29 23:59:54
3394 [cert-userkey.sh]
3395 regress tests for key options in AuthorizedPrincipals
3396
339720100627
3398 - (tim) [openbsd-compat/port-uw.c] Reorder includes. auth-options.h now needs
3399 key.h.
3400
340120100626
3402 - (djm) OpenBSD CVS Sync
3403 - djm@cvs.openbsd.org 2010/05/21 05:00:36
3404 [misc.c]
3405 colon() returns char*, so s/return (0)/return NULL/
3406 - markus@cvs.openbsd.org 2010/06/08 21:32:19
3407 [ssh-pkcs11.c]
3408 check length of value returned C_GetAttributValue for != 0
3409 from mdrtbugzilla@codefive.co.uk; bugzilla #1773; ok dtucker@
3410 - djm@cvs.openbsd.org 2010/06/17 07:07:30
3411 [mux.c]
3412 Correct sizing of object to be allocated by calloc(), replacing
3413 sizeof(state) with sizeof(*state). This worked by accident since
3414 the struct contained a single int at present, but could have broken
3415 in the future. patch from hyc AT symas.com
3416 - djm@cvs.openbsd.org 2010/06/18 00:58:39
3417 [sftp.c]
3418 unbreak ls in working directories that contains globbing characters in
3419 their pathnames. bz#1655 reported by vgiffin AT apple.com
3420 - djm@cvs.openbsd.org 2010/06/18 03:16:03
3421 [session.c]
3422 Missing check for chroot_director == "none" (we already checked against
3423 NULL); bz#1564 from Jan.Pechanec AT Sun.COM
3424 - djm@cvs.openbsd.org 2010/06/18 04:43:08
3425 [sftp-client.c]
3426 fix memory leak in do_realpath() error path; bz#1771, patch from
3427 anicka AT suse.cz
3428 - djm@cvs.openbsd.org 2010/06/22 04:22:59
3429 [servconf.c sshd_config.5]
3430 expose some more sshd_config options inside Match blocks:
3431 AuthorizedKeysFile AuthorizedPrincipalsFile
3432 HostbasedUsesNameFromPacketOnly PermitTunnel
3433 bz#1764; feedback from imorgan AT nas.nasa.gov; ok dtucker@
3434 - djm@cvs.openbsd.org 2010/06/22 04:32:06
3435 [ssh-keygen.c]
3436 standardise error messages when attempting to open private key
3437 files to include "progname: filename: error reason"
3438 bz#1783; ok dtucker@
3439 - djm@cvs.openbsd.org 2010/06/22 04:49:47
3440 [auth.c]
3441 queue auth debug messages for bad ownership or permissions on the user's
3442 keyfiles. These messages will be sent after the user has successfully
3443 authenticated (where our client will display them with LogLevel=debug).
3444 bz#1554; ok dtucker@
3445 - djm@cvs.openbsd.org 2010/06/22 04:54:30
3446 [ssh-keyscan.c]
3447 replace verbose and overflow-prone Linebuf code with read_keyfile_line()
3448 based on patch from joachim AT joachimschipper.nl; bz#1565; ok dtucker@
3449 - djm@cvs.openbsd.org 2010/06/22 04:59:12
3450 [session.c]
3451 include the user name on "subsystem request for ..." log messages;
3452 bz#1571; ok dtucker@
3453 - djm@cvs.openbsd.org 2010/06/23 02:59:02
3454 [ssh-keygen.c]
3455 fix printing of extensions in v01 certificates that I broke in r1.190
3456 - djm@cvs.openbsd.org 2010/06/25 07:14:46
3457 [channels.c mux.c readconf.c readconf.h ssh.h]
3458 bz#1327: remove hardcoded limit of 100 permitopen clauses and port
3459 forwards per direction; ok markus@ stevesk@
3460 - djm@cvs.openbsd.org 2010/06/25 07:20:04
3461 [channels.c session.c]
3462 bz#1750: fix requirement for /dev/null inside ChrootDirectory for
3463 internal-sftp accidentally introduced in r1.253 by removing the code
3464 that opens and dup /dev/null to stderr and modifying the channels code
3465 to read stderr but discard it instead; ok markus@
3466 - djm@cvs.openbsd.org 2010/06/25 08:46:17
3467 [auth1.c auth2-none.c]
3468 skip the initial check for access with an empty password when
3469 PermitEmptyPasswords=no; bz#1638; ok markus@
3470 - djm@cvs.openbsd.org 2010/06/25 23:10:30
3471 [ssh.c]
3472 log the hostname and address that we connected to at LogLevel=verbose
3473 after authentication is successful to mitigate "phishing" attacks by
3474 servers with trusted keys that accept authentication silently and
3475 automatically before presenting fake password/passphrase prompts;
3476 "nice!" markus@
3477 - djm@cvs.openbsd.org 2010/06/25 23:10:30
3478 [ssh.c]
3479 log the hostname and address that we connected to at LogLevel=verbose
3480 after authentication is successful to mitigate "phishing" attacks by
3481 servers with trusted keys that accept authentication silently and
3482 automatically before presenting fake password/passphrase prompts;
3483 "nice!" markus@
3484
348520100622
3486 - (djm) [loginrec.c] crank LINFO_NAMESIZE (username length) to 512
3487 bz#1579; ok dtucker
3488
348920100618
3490 - (djm) [contrib/ssh-copy-id] Update key file explicitly under ~
3491 rather than assuming that $CWD == $HOME. bz#1500, patch from
3492 timothy AT gelter.com
3493
349420100617
3495 - (tim) [contrib/cygwin/README] Remove a reference to the obsolete
3496 minires-devel package, and to add the reference to the libedit-devel
3497 package since CYgwin now provides libedit. Patch from Corinna Vinschen.
3498
349920100521
3500 - (djm) OpenBSD CVS Sync
3501 - djm@cvs.openbsd.org 2010/05/07 11:31:26
3502 [regress/Makefile regress/cert-userkey.sh]
3503 regress tests for AuthorizedPrincipalsFile and "principals=" key option.
3504 feedback and ok markus@
3505 - djm@cvs.openbsd.org 2010/05/11 02:58:04
3506 [auth-rsa.c]
3507 don't accept certificates marked as "cert-authority" here; ok markus@
3508 - djm@cvs.openbsd.org 2010/05/14 00:47:22
3509 [ssh-add.c]
3510 check that the certificate matches the corresponding private key before
3511 grafting it on
3512 - djm@cvs.openbsd.org 2010/05/14 23:29:23
3513 [channels.c channels.h mux.c ssh.c]
3514 Pause the mux channel while waiting for reply from aynch callbacks.
3515 Prevents misordering of replies if new requests arrive while waiting.
3516
3517 Extend channel open confirm callback to allow signalling failure
3518 conditions as well as success. Use this to 1) fix a memory leak, 2)
3519 start using the above pause mechanism and 3) delay sending a success/
3520 failure message on mux slave session open until we receive a reply from
3521 the server.
3522
3523 motivated by and with feedback from markus@
3524 - markus@cvs.openbsd.org 2010/05/16 12:55:51
3525 [PROTOCOL.mux clientloop.h mux.c readconf.c readconf.h ssh.1 ssh.c]
3526 mux support for remote forwarding with dynamic port allocation,
3527 use with
3528 LPORT=`ssh -S muxsocket -R0:localhost:25 -O forward somehost`
3529 feedback and ok djm@
3530 - djm@cvs.openbsd.org 2010/05/20 11:25:26
3531 [auth2-pubkey.c]
3532 fix logspam when key options (from="..." especially) deny non-matching
3533 keys; reported by henning@ also bz#1765; ok markus@ dtucker@
3534 - djm@cvs.openbsd.org 2010/05/20 23:46:02
3535 [PROTOCOL.certkeys auth-options.c ssh-keygen.c]
3536 Move the permit-* options to the non-critical "extensions" field for v01
3537 certificates. The logic is that if another implementation fails to
3538 implement them then the connection just loses features rather than fails
3539 outright.
3540
3541 ok markus@
3542
354320100511
3544 - (dtucker) [Makefile.in] Bug #1770: Link libopenbsd-compat twice to solve
3545 circular dependency problem on old or odd platforms. From Tom Lane, ok
3546 djm@.
3547 - (djm) [openbsd-compat/openssl-compat.h] Fix build breakage on older
3548 libcrypto by defining OPENSSL_[DR]SA_MAX_MODULUS_BITS if they aren't
3549 already. ok dtucker@
3550
355120100510
3552 - OpenBSD CVS Sync
3553 - djm@cvs.openbsd.org 2010/04/23 01:47:41
3554 [ssh-keygen.c]
3555 bz#1740: display a more helpful error message when $HOME is
3556 inaccessible while trying to create .ssh directory. Based on patch
3557 from jchadima AT redhat.com; ok dtucker@
3558 - djm@cvs.openbsd.org 2010/04/23 22:27:38
3559 [mux.c]
3560 set "detach_close" flag when registering channel cleanup callbacks.
3561 This causes the channel to close normally when its fds close and
3562 hangs when terminating a mux slave using ~. bz#1758; ok markus@
3563 - djm@cvs.openbsd.org 2010/04/23 22:42:05
3564 [session.c]
3565 set stderr to /dev/null for subsystems rather than just closing it.
3566 avoids hangs if a subsystem or shell initialisation writes to stderr.
3567 bz#1750; ok markus@
3568 - djm@cvs.openbsd.org 2010/04/23 22:48:31
3569 [ssh-keygen.c]
3570 refuse to generate keys longer than OPENSSL_[RD]SA_MAX_MODULUS_BITS,
3571 since we would refuse to use them anyway. bz#1516; ok dtucker@
3572 - djm@cvs.openbsd.org 2010/04/26 22:28:24
3573 [sshconnect2.c]
3574 bz#1502: authctxt.success is declared as an int, but passed by
3575 reference to function that accepts sig_atomic_t*. Convert it to
3576 the latter; ok markus@ dtucker@
3577 - djm@cvs.openbsd.org 2010/05/01 02:50:50
3578 [PROTOCOL.certkeys]
3579 typo; jmeltzer@
3580 - dtucker@cvs.openbsd.org 2010/05/05 04:22:09
3581 [sftp.c]
3582 restore mput and mget which got lost in the tab-completion changes.
3583 found by Kenneth Whitaker, ok djm@
3584 - djm@cvs.openbsd.org 2010/05/07 11:30:30
3585 [auth-options.c auth-options.h auth.c auth.h auth2-pubkey.c]
3586 [key.c servconf.c servconf.h sshd.8 sshd_config.5]
3587 add some optional indirection to matching of principal names listed
3588 in certificates. Currently, a certificate must include the a user's name
3589 to be accepted for authentication. This change adds the ability to
3590 specify a list of certificate principal names that are acceptable.
3591
3592 When authenticating using a CA trusted through ~/.ssh/authorized_keys,
3593 this adds a new principals="name1[,name2,...]" key option.
3594
3595 For CAs listed through sshd_config's TrustedCAKeys option, a new config
3596 option "AuthorizedPrincipalsFile" specifies a per-user file containing
3597 the list of acceptable names.
3598
3599 If either option is absent, the current behaviour of requiring the
3600 username to appear in principals continues to apply.
3601
3602 These options are useful for role accounts, disjoint account namespaces
3603 and "user@realm"-style naming policies in certificates.
3604
3605 feedback and ok markus@
3606 - jmc@cvs.openbsd.org 2010/05/07 12:49:17
3607 [sshd_config.5]
3608 tweak previous;
3609
361020100423
3611 - (dtucker) [configure.ac] Bug #1756: Check for the existence of a lib64 dir
3612 in the openssl install directory (some newer openssl versions do this on at
3613 least some amd64 platforms).
3614
361520100418
3616 - OpenBSD CVS Sync
3617 - jmc@cvs.openbsd.org 2010/04/16 06:45:01
3618 [ssh_config.5]
3619 tweak previous; ok djm
3620 - jmc@cvs.openbsd.org 2010/04/16 06:47:04
3621 [ssh-keygen.1 ssh-keygen.c]
3622 tweak previous; ok djm
3623 - djm@cvs.openbsd.org 2010/04/16 21:14:27
3624 [sshconnect.c]
3625 oops, %r => remote username, not %u
3626 - djm@cvs.openbsd.org 2010/04/16 01:58:45
3627 [regress/cert-hostkey.sh regress/cert-userkey.sh]
3628 regression tests for v01 certificate format
3629 includes interop tests for v00 certs
3630 - (dtucker) [contrib/aix/buildbff.sh] Fix creation of ssh_prng_cmds.default
3631 file.
3632
363320100416
3634 - (djm) Release openssh-5.5p1
3635 - OpenBSD CVS Sync
3636 - djm@cvs.openbsd.org 2010/03/26 03:13:17
3637 [bufaux.c]
3638 allow buffer_get_int_ret/buffer_get_int64_ret to take a NULL pointer
3639 argument to allow skipping past values in a buffer
3640 - jmc@cvs.openbsd.org 2010/03/26 06:54:36
3641 [ssh.1]
3642 tweak previous;
3643 - jmc@cvs.openbsd.org 2010/03/27 14:26:55
3644 [ssh_config.5]
3645 tweak previous; ok dtucker
3646 - djm@cvs.openbsd.org 2010/04/10 00:00:16
3647 [ssh.c]
3648 bz#1746 - suppress spurious tty warning when using -O and stdin
3649 is not a tty; ok dtucker@ markus@
3650 - djm@cvs.openbsd.org 2010/04/10 00:04:30
3651 [sshconnect.c]
3652 fix terminology: we didn't find a certificate in known_hosts, we found
3653 a CA key
3654 - djm@cvs.openbsd.org 2010/04/10 02:08:44
3655 [clientloop.c]
3656 bz#1698: kill channel when pty allocation requests fail. Fixed
3657 stuck client if the server refuses pty allocation.
3658 ok dtucker@ "think so" markus@
3659 - djm@cvs.openbsd.org 2010/04/10 02:10:56
3660 [sshconnect2.c]
3661 show the key type that we are offering in debug(), helps distinguish
3662 between certs and plain keys as the path to the private key is usually
3663 the same.
3664 - djm@cvs.openbsd.org 2010/04/10 05:48:16
3665 [mux.c]
3666 fix NULL dereference; from matthew.haub AT alumni.adelaide.edu.au
3667 - djm@cvs.openbsd.org 2010/04/14 22:27:42
3668 [ssh_config.5 sshconnect.c]
3669 expand %r => remote username in ssh_config:ProxyCommand;
3670 ok deraadt markus
3671 - markus@cvs.openbsd.org 2010/04/15 20:32:55
3672 [ssh-pkcs11.c]
3673 retry lookup for private key if there's no matching key with CKA_SIGN
3674 attribute enabled; this fixes fixes MuscleCard support (bugzilla #1736)
3675 ok djm@
3676 - djm@cvs.openbsd.org 2010/04/16 01:47:26
3677 [PROTOCOL.certkeys auth-options.c auth-options.h auth-rsa.c]
3678 [auth2-pubkey.c authfd.c key.c key.h myproposal.h ssh-add.c]
3679 [ssh-agent.c ssh-dss.c ssh-keygen.1 ssh-keygen.c ssh-rsa.c]
3680 [sshconnect.c sshconnect2.c sshd.c]
3681 revised certificate format ssh-{dss,rsa}-cert-v01@openssh.com with the
3682 following changes:
3683
3684 move the nonce field to the beginning of the certificate where it can
3685 better protect against chosen-prefix attacks on the signature hash
3686
3687 Rename "constraints" field to "critical options"
3688
3689 Add a new non-critical "extensions" field
3690
3691 Add a serial number
3692
3693 The older format is still support for authentication and cert generation
3694 (use "ssh-keygen -t v00 -s ca_key ..." to generate a v00 certificate)
3695
3696 ok markus@
diff --git a/Makefile.in b/Makefile.in
index 92c95a928..a8aa1272a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
1# $Id: Makefile.in,v 1.340 2013/06/11 01:26:10 dtucker Exp $ 1# $Id: Makefile.in,v 1.352 2014/01/27 06:35:04 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@
@@ -73,7 +73,10 @@ LIBSSH_OBJS=authfd.o authfile.o bufaux.o bufbn.o buffer.o \
73 monitor_fdpass.o rijndael.o ssh-dss.o ssh-ecdsa.o ssh-rsa.o dh.o \ 73 monitor_fdpass.o rijndael.o ssh-dss.o ssh-ecdsa.o ssh-rsa.o dh.o \
74 kexdh.o kexgex.o kexdhc.o kexgexc.o bufec.o kexecdh.o kexecdhc.o \ 74 kexdh.o kexgex.o kexdhc.o kexgexc.o bufec.o kexecdh.o kexecdhc.o \
75 msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o umac128.o \ 75 msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o umac128.o \
76 jpake.o schnorr.o ssh-pkcs11.o krl.o 76 jpake.o schnorr.o ssh-pkcs11.o krl.o smult_curve25519_ref.o \
77 kexc25519.o kexc25519c.o poly1305.o chacha.o cipher-chachapoly.o \
78 ssh-ed25519.o digest.o \
79 sc25519.o ge25519.o fe25519.o ed25519.o verify.o hash.o blocks.o
77 80
78SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \ 81SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \
79 sshconnect.o sshconnect1.o sshconnect2.o mux.o \ 82 sshconnect.o sshconnect1.o sshconnect2.o mux.o \
@@ -87,13 +90,13 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
87 auth-skey.o auth-bsdauth.o auth2-hostbased.o auth2-kbdint.o \ 90 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 \ 91 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 kexecdhs.o \ 92 monitor_mm.o monitor.o monitor_wrap.o kexdhs.o kexgexs.o kexecdhs.o \
90 auth-krb5.o \ 93 kexc25519s.o auth-krb5.o \
91 auth2-gss.o gss-serv.o gss-serv-krb5.o \ 94 auth2-gss.o gss-serv.o gss-serv-krb5.o \
92 loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \ 95 loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \
93 sftp-server.o sftp-common.o \ 96 sftp-server.o sftp-common.o \
94 roaming_common.o roaming_serv.o \ 97 roaming_common.o roaming_serv.o \
95 sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o \ 98 sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o \
96 sandbox-seccomp-filter.o 99 sandbox-seccomp-filter.o sandbox-capsicum.o
97 100
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-keysign.8.out ssh-pkcs11-helper.8.out sshd_config.5.out ssh_config.5.out 101MANPAGES = 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-keysign.8.out ssh-pkcs11-helper.8.out sshd_config.5.out ssh_config.5.out
99MANPAGES_IN = moduli.5 scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.8 sftp-server.8 sftp.1 ssh-keysign.8 ssh-pkcs11-helper.8 sshd_config.5 ssh_config.5 102MANPAGES_IN = moduli.5 scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.8 sftp-server.8 sftp.1 ssh-keysign.8 ssh-pkcs11-helper.8 sshd_config.5 ssh_config.5
@@ -112,6 +115,7 @@ PATHSUBS = \
112 -e 's|/etc/ssh/ssh_host_ecdsa_key|$(sysconfdir)/ssh_host_ecdsa_key|g' \ 115 -e 's|/etc/ssh/ssh_host_ecdsa_key|$(sysconfdir)/ssh_host_ecdsa_key|g' \
113 -e 's|/etc/ssh/ssh_host_dsa_key|$(sysconfdir)/ssh_host_dsa_key|g' \ 116 -e 's|/etc/ssh/ssh_host_dsa_key|$(sysconfdir)/ssh_host_dsa_key|g' \
114 -e 's|/etc/ssh/ssh_host_rsa_key|$(sysconfdir)/ssh_host_rsa_key|g' \ 117 -e 's|/etc/ssh/ssh_host_rsa_key|$(sysconfdir)/ssh_host_rsa_key|g' \
118 -e 's|/etc/ssh/ssh_host_ed25519_key|$(sysconfdir)/ssh_host_ed25519_key|g' \
115 -e 's|/var/run/sshd.pid|$(piddir)/sshd.pid|g' \ 119 -e 's|/var/run/sshd.pid|$(piddir)/sshd.pid|g' \
116 -e 's|/etc/moduli|$(sysconfdir)/moduli|g' \ 120 -e 's|/etc/moduli|$(sysconfdir)/moduli|g' \
117 -e 's|/etc/ssh/moduli|$(sysconfdir)/moduli|g' \ 121 -e 's|/etc/ssh/moduli|$(sysconfdir)/moduli|g' \
@@ -332,6 +336,11 @@ host-key: ssh-keygen$(EXEEXT)
332 else \ 336 else \
333 ./ssh-keygen -t rsa -f $(sysconfdir)/ssh_host_rsa_key -N "" ; \ 337 ./ssh-keygen -t rsa -f $(sysconfdir)/ssh_host_rsa_key -N "" ; \
334 fi ; \ 338 fi ; \
339 if [ -f $(sysconfdir)/ssh_host_ed25519_key ] ; then \
340 echo "$(sysconfdir)/ssh_host_ed25519_key already exists, skipping." ; \
341 else \
342 ./ssh-keygen -t ed25519 -f $(sysconfdir)/ssh_host_ed25519_key -N "" ; \
343 fi ; \
335 if [ -z "@COMMENT_OUT_ECC@" ] ; then \ 344 if [ -z "@COMMENT_OUT_ECC@" ] ; then \
336 if [ -f $(sysconfdir)/ssh_host_ecdsa_key ] ; then \ 345 if [ -f $(sysconfdir)/ssh_host_ecdsa_key ] ; then \
337 echo "$(sysconfdir)/ssh_host_ecdsa_key already exists, skipping." ; \ 346 echo "$(sysconfdir)/ssh_host_ecdsa_key already exists, skipping." ; \
@@ -345,6 +354,7 @@ host-key-force: ssh-keygen$(EXEEXT)
345 ./ssh-keygen -t rsa1 -f $(DESTDIR)$(sysconfdir)/ssh_host_key -N "" 354 ./ssh-keygen -t rsa1 -f $(DESTDIR)$(sysconfdir)/ssh_host_key -N ""
346 ./ssh-keygen -t dsa -f $(DESTDIR)$(sysconfdir)/ssh_host_dsa_key -N "" 355 ./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 "" 356 ./ssh-keygen -t rsa -f $(DESTDIR)$(sysconfdir)/ssh_host_rsa_key -N ""
357 ./ssh-keygen -t ed25519 -f $(DESTDIR)$(sysconfdir)/ssh_host_ed25519_key -N ""
348 test -z "@COMMENT_OUT_ECC@" && ./ssh-keygen -t ecdsa -f $(DESTDIR)$(sysconfdir)/ssh_host_ecdsa_key -N "" 358 test -z "@COMMENT_OUT_ECC@" && ./ssh-keygen -t ecdsa -f $(DESTDIR)$(sysconfdir)/ssh_host_ecdsa_key -N ""
349 359
350uninstallall: uninstall 360uninstallall: uninstall
@@ -391,9 +401,17 @@ regress/modpipe$(EXEEXT): $(srcdir)/regress/modpipe.c
391 $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $? \ 401 $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $? \
392 $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS) 402 $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
393 403
404regress/setuid-allowed$(EXEEXT): $(srcdir)/regress/setuid-allowed.c
405 [ -d `pwd`/regress ] || mkdir -p `pwd`/regress
406 [ -f `pwd`/regress/Makefile ] || \
407 ln -s `cd $(srcdir) && pwd`/regress/Makefile `pwd`/regress/Makefile
408 $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $? \
409 $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
410
394tests interop-tests: $(TARGETS) regress/modpipe$(EXEEXT) 411tests interop-tests: $(TARGETS) regress/modpipe$(EXEEXT)
395 BUILDDIR=`pwd`; \ 412 BUILDDIR=`pwd`; \
396 TEST_SHELL="@TEST_SHELL@"; \ 413 TEST_SHELL="@TEST_SHELL@"; \
414 TEST_SSH_SCP="$${BUILDDIR}/scp"; \
397 TEST_SSH_SSH="$${BUILDDIR}/ssh"; \ 415 TEST_SSH_SSH="$${BUILDDIR}/ssh"; \
398 TEST_SSH_SSHD="$${BUILDDIR}/sshd"; \ 416 TEST_SSH_SSHD="$${BUILDDIR}/sshd"; \
399 TEST_SSH_SSHAGENT="$${BUILDDIR}/ssh-agent"; \ 417 TEST_SSH_SSHAGENT="$${BUILDDIR}/ssh-agent"; \
@@ -408,7 +426,6 @@ tests interop-tests: $(TARGETS) regress/modpipe$(EXEEXT)
408 TEST_SSH_CONCH="conch"; \ 426 TEST_SSH_CONCH="conch"; \
409 TEST_SSH_IPV6="@TEST_SSH_IPV6@" ; \ 427 TEST_SSH_IPV6="@TEST_SSH_IPV6@" ; \
410 TEST_SSH_ECC="@TEST_SSH_ECC@" ; \ 428 TEST_SSH_ECC="@TEST_SSH_ECC@" ; \
411 TEST_SSH_SHA256="@TEST_SSH_SHA256@" ; \
412 cd $(srcdir)/regress || exit $$?; \ 429 cd $(srcdir)/regress || exit $$?; \
413 $(MAKE) \ 430 $(MAKE) \
414 .OBJDIR="$${BUILDDIR}/regress" \ 431 .OBJDIR="$${BUILDDIR}/regress" \
@@ -416,7 +433,9 @@ tests interop-tests: $(TARGETS) regress/modpipe$(EXEEXT)
416 BUILDDIR="$${BUILDDIR}" \ 433 BUILDDIR="$${BUILDDIR}" \
417 OBJ="$${BUILDDIR}/regress/" \ 434 OBJ="$${BUILDDIR}/regress/" \
418 PATH="$${BUILDDIR}:$${PATH}" \ 435 PATH="$${BUILDDIR}:$${PATH}" \
436 TEST_ENV=MALLOC_OPTIONS="@TEST_MALLOC_OPTIONS@" \
419 TEST_SHELL="$${TEST_SHELL}" \ 437 TEST_SHELL="$${TEST_SHELL}" \
438 TEST_SSH_SCP="$${TEST_SSH_SCP}" \
420 TEST_SSH_SSH="$${TEST_SSH_SSH}" \ 439 TEST_SSH_SSH="$${TEST_SSH_SSH}" \
421 TEST_SSH_SSHD="$${TEST_SSH_SSHD}" \ 440 TEST_SSH_SSHD="$${TEST_SSH_SSHD}" \
422 TEST_SSH_SSHAGENT="$${TEST_SSH_SSHAGENT}" \ 441 TEST_SSH_SSHAGENT="$${TEST_SSH_SSHAGENT}" \
@@ -431,7 +450,6 @@ tests interop-tests: $(TARGETS) regress/modpipe$(EXEEXT)
431 TEST_SSH_CONCH="$${TEST_SSH_CONCH}" \ 450 TEST_SSH_CONCH="$${TEST_SSH_CONCH}" \
432 TEST_SSH_IPV6="$${TEST_SSH_IPV6}" \ 451 TEST_SSH_IPV6="$${TEST_SSH_IPV6}" \
433 TEST_SSH_ECC="$${TEST_SSH_ECC}" \ 452 TEST_SSH_ECC="$${TEST_SSH_ECC}" \
434 TEST_SSH_SHA256="$${TEST_SSH_SHA256}" \
435 EXEEXT="$(EXEEXT)" \ 453 EXEEXT="$(EXEEXT)" \
436 $@ && echo all tests passed 454 $@ && echo all tests passed
437 455
@@ -456,4 +474,3 @@ package: $(CONFIGFILES) $(MANPAGES) $(TARGETS)
456 if [ "@MAKE_PACKAGE_SUPPORTED@" = yes ]; then \ 474 if [ "@MAKE_PACKAGE_SUPPORTED@" = yes ]; then \
457 sh buildpkg.sh; \ 475 sh buildpkg.sh; \
458 fi 476 fi
459
diff --git a/PROTOCOL b/PROTOCOL
index 48b3a4400..4a5088f90 100644
--- a/PROTOCOL
+++ b/PROTOCOL
@@ -91,6 +91,17 @@ an MAC algorithm. Additionally, if AES-GCM is selected as the cipher
91the exchanged MAC algorithms are ignored and there doesn't have to be 91the exchanged MAC algorithms are ignored and there doesn't have to be
92a matching MAC. 92a matching MAC.
93 93
941.7 transport: chacha20-poly1305@openssh.com authenticated encryption
95
96OpenSSH supports authenticated encryption using ChaCha20 and Poly1305
97as described in PROTOCOL.chacha20poly1305.
98
991.8 transport: curve25519-sha256@libssh.org key exchange algorithm
100
101OpenSSH supports the use of ECDH in Curve25519 for key exchange as
102described at:
103http://git.libssh.org/users/aris/libssh.git/plain/doc/curve25519-sha256@libssh.org.txt?h=curve25519
104
942. Connection protocol changes 1052. Connection protocol changes
95 106
962.1. connection: Channel write close extension "eow@openssh.com" 1072.1. connection: Channel write close extension "eow@openssh.com"
@@ -331,4 +342,18 @@ link(oldpath, newpath) and will respond with a SSH_FXP_STATUS message.
331This extension is advertised in the SSH_FXP_VERSION hello with version 342This extension is advertised in the SSH_FXP_VERSION hello with version
332"1". 343"1".
333 344
334$OpenBSD: PROTOCOL,v 1.20 2013/01/08 18:49:04 markus Exp $ 34510. sftp: Extension request "fsync@openssh.com"
346
347This request asks the server to call fsync(2) on an open file handle.
348
349 uint32 id
350 string "fsync@openssh.com"
351 string handle
352
353One receiving this request, a server will call fsync(handle_fd) and will
354respond with a SSH_FXP_STATUS message.
355
356This extension is advertised in the SSH_FXP_VERSION hello with version
357"1".
358
359$OpenBSD: PROTOCOL,v 1.23 2013/12/01 23:19:05 djm Exp $
diff --git a/PROTOCOL.chacha20poly1305 b/PROTOCOL.chacha20poly1305
new file mode 100644
index 000000000..9cf73a926
--- /dev/null
+++ b/PROTOCOL.chacha20poly1305
@@ -0,0 +1,105 @@
1This document describes the chacha20-poly1305@openssh.com authenticated
2encryption cipher supported by OpenSSH.
3
4Background
5----------
6
7ChaCha20 is a stream cipher designed by Daniel Bernstein and described
8in [1]. It operates by permuting 128 fixed bits, 128 or 256 bits of key,
9a 64 bit nonce and a 64 bit counter into 64 bytes of output. This output
10is used as a keystream, with any unused bytes simply discarded.
11
12Poly1305[2], also by Daniel Bernstein, is a one-time Carter-Wegman MAC
13that computes a 128 bit integrity tag given a message and a single-use
14256 bit secret key.
15
16The chacha20-poly1305@openssh.com combines these two primitives into an
17authenticated encryption mode. The construction used is based on that
18proposed for TLS by Adam Langley in [3], but differs in the layout of
19data passed to the MAC and in the addition of encyption of the packet
20lengths.
21
22Negotiation
23-----------
24
25The chacha20-poly1305@openssh.com offers both encryption and
26authentication. As such, no separate MAC is required. If the
27chacha20-poly1305@openssh.com cipher is selected in key exchange,
28the offered MAC algorithms are ignored and no MAC is required to be
29negotiated.
30
31Detailed Construction
32---------------------
33
34The chacha20-poly1305@openssh.com cipher requires 512 bits of key
35material as output from the SSH key exchange. This forms two 256 bit
36keys (K_1 and K_2), used by two separate instances of chacha20.
37
38The instance keyed by K_1 is a stream cipher that is used only
39to encrypt the 4 byte packet length field. The second instance,
40keyed by K_2, is used in conjunction with poly1305 to build an AEAD
41(Authenticated Encryption with Associated Data) that is used to encrypt
42and authenticate the entire packet.
43
44Two separate cipher instances are used here so as to keep the packet
45lengths confidential but not create an oracle for the packet payload
46cipher by decrypting and using the packet length prior to checking
47the MAC. By using an independently-keyed cipher instance to encrypt the
48length, an active attacker seeking to exploit the packet input handling
49as a decryption oracle can learn nothing about the payload contents or
50its MAC (assuming key derivation, ChaCha20 and Poly1305 are secure).
51
52The AEAD is constructed as follows: for each packet, generate a Poly1305
53key by taking the first 256 bits of ChaCha20 stream output generated
54using K_2, an IV consisting of the packet sequence number encoded as an
55uint64 under the SSH wire encoding rules and a ChaCha20 block counter of
56zero. The K_2 ChaCha20 block counter is then set to the little-endian
57encoding of 1 (i.e. {1, 0, 0, 0, 0, 0, 0, 0}) and this instance is used
58for encryption of the packet payload.
59
60Packet Handling
61---------------
62
63When receiving a packet, the length must be decrypted first. When 4
64bytes of ciphertext length have been received, they may be decrypted
65using the K_1 key, a nonce consisting of the packet sequence number
66encoded as a uint64 under the usual SSH wire encoding and a zero block
67counter to obtain the plaintext length.
68
69Once the entire packet has been received, the MAC MUST be checked
70before decryption. A per-packet Poly1305 key is generated as described
71above and the MAC tag calculated using Poly1305 with this key over the
72ciphertext of the packet length and the payload together. The calculated
73MAC is then compared in constant time with the one appended to the
74packet and the packet decrypted using ChaCha20 as described above (with
75K_2, the packet sequence number as nonce and a starting block counter of
761).
77
78To send a packet, first encode the 4 byte length and encrypt it using
79K_1. Encrypt the packet payload (using K_2) and append it to the
80encrypted length. Finally, calculate a MAC tag and append it.
81
82Rekeying
83--------
84
85ChaCha20 must never reuse a {key, nonce} for encryption nor may it be
86used to encrypt more than 2^70 bytes under the same {key, nonce}. The
87SSH Transport protocol (RFC4253) recommends a far more conservative
88rekeying every 1GB of data sent or received. If this recommendation
89is followed, then chacha20-poly1305@openssh.com requires no special
90handling in this area.
91
92References
93----------
94
95[1] "ChaCha, a variant of Salsa20", Daniel Bernstein
96 http://cr.yp.to/chacha/chacha-20080128.pdf
97
98[2] "The Poly1305-AES message-authentication code", Daniel Bernstein
99 http://cr.yp.to/mac/poly1305-20050329.pdf
100
101[3] "ChaCha20 and Poly1305 based Cipher Suites for TLS", Adam Langley
102 http://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-03
103
104$OpenBSD: PROTOCOL.chacha20poly1305,v 1.2 2013/12/02 02:50:27 djm Exp $
105
diff --git a/PROTOCOL.key b/PROTOCOL.key
new file mode 100644
index 000000000..959bd7aee
--- /dev/null
+++ b/PROTOCOL.key
@@ -0,0 +1,68 @@
1This document describes the private key format for OpenSSH.
2
31. Overall format
4
5The key consists of a header, a list of public keys, and
6an encrypted list of matching private keys.
7
8#define AUTH_MAGIC "openssh-key-v1"
9
10 byte[] AUTH_MAGIC
11 string ciphername
12 string kdfname
13 string kdfoptions
14 int number of keys N
15 string publickey1
16 string publickey2
17 ...
18 string publickeyN
19 string encrypted, padded list of private keys
20
212. KDF options for kdfname "bcrypt"
22
23The options:
24
25 string salt
26 uint32 rounds
27
28are concatenated and represented as a string.
29
303. Unencrypted list of N private keys
31
32The list of privatekey/comment pairs is padded with the
33bytes 1, 2, 3, ... until the total length is a multiple
34of the cipher block size.
35
36 uint32 checkint
37 uint32 checkint
38 string privatekey1
39 string comment1
40 string privatekey2
41 string comment2
42 ...
43 string privatekeyN
44 string commentN
45 char 1
46 char 2
47 char 3
48 ...
49 char padlen % 255
50
51Before the key is encrypted, a random integer is assigned
52to both checkint fields so successful decryption can be
53quickly checked by verifying that both checkint fields
54hold the same value.
55
564. Encryption
57
58The KDF is used to derive a key, IV (and other values required by
59the cipher) from the passphrase. These values are then used to
60encrypt the unencrypted list of private keys.
61
625. No encryption
63
64For unencrypted keys the cipher "none" and the KDF "none"
65are used with empty passphrases. The options if the KDF "none"
66are the empty string.
67
68$OpenBSD: PROTOCOL.key,v 1.1 2013/12/06 13:34:54 markus Exp $
diff --git a/README b/README
index 0c52f1371..8da9759ef 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
1See http://www.openssh.com/txt/release-6.4 for the release notes. 1See http://www.openssh.com/txt/release-6.5 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.83.4.1 2013/11/08 01:36:17 djm Exp $ 65$Id: README,v 1.85 2014/01/16 07:51:45 djm Exp $
diff --git a/aclocal.m4 b/aclocal.m4
index 1b3bed790..1640683e1 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,4 +1,4 @@
1dnl $Id: aclocal.m4,v 1.9 2013/06/02 21:31:27 tim Exp $ 1dnl $Id: aclocal.m4,v 1.13 2014/01/22 10:30:12 djm Exp $
2dnl 2dnl
3dnl OpenSSH-specific autoconf macros 3dnl OpenSSH-specific autoconf macros
4dnl 4dnl
@@ -8,12 +8,24 @@ dnl Check that $CC accepts a flag 'check_flag'. If it is supported append
8dnl 'define_flag' to $CFLAGS. If 'define_flag' is not specified, then append 8dnl 'define_flag' to $CFLAGS. If 'define_flag' is not specified, then append
9dnl 'check_flag'. 9dnl 'check_flag'.
10AC_DEFUN([OSSH_CHECK_CFLAG_COMPILE], [{ 10AC_DEFUN([OSSH_CHECK_CFLAG_COMPILE], [{
11 AC_MSG_CHECKING([if $CC supports $1]) 11 AC_MSG_CHECKING([if $CC supports compile flag $1])
12 saved_CFLAGS="$CFLAGS" 12 saved_CFLAGS="$CFLAGS"
13 CFLAGS="$CFLAGS $1" 13 CFLAGS="$CFLAGS $WERROR $1"
14 _define_flag="$2" 14 _define_flag="$2"
15 test "x$_define_flag" = "x" && _define_flag="$1" 15 test "x$_define_flag" = "x" && _define_flag="$1"
16 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])], 16 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
17#include <stdlib.h>
18#include <stdio.h>
19int main(int argc, char **argv) {
20 /* Some math to catch -ftrapv problems in the toolchain */
21 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
22 float l = i * 2.1;
23 double m = l / 0.5;
24 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
25 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
26 exit(0);
27}
28 ]])],
17 [ 29 [
18if `grep -i "unrecognized option" conftest.err >/dev/null` 30if `grep -i "unrecognized option" conftest.err >/dev/null`
19then 31then
@@ -28,6 +40,72 @@ fi],
28 ) 40 )
29}]) 41}])
30 42
43dnl OSSH_CHECK_CFLAG_LINK(check_flag[, define_flag])
44dnl Check that $CC accepts a flag 'check_flag'. If it is supported append
45dnl 'define_flag' to $CFLAGS. If 'define_flag' is not specified, then append
46dnl 'check_flag'.
47AC_DEFUN([OSSH_CHECK_CFLAG_LINK], [{
48 AC_MSG_CHECKING([if $CC supports compile flag $1 and linking succeeds])
49 saved_CFLAGS="$CFLAGS"
50 CFLAGS="$CFLAGS $WERROR $1"
51 _define_flag="$2"
52 test "x$_define_flag" = "x" && _define_flag="$1"
53 AC_LINK_IFELSE([AC_LANG_SOURCE([[
54#include <stdlib.h>
55#include <stdio.h>
56int main(int argc, char **argv) {
57 /* Some math to catch -ftrapv problems in the toolchain */
58 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
59 float l = i * 2.1;
60 double m = l / 0.5;
61 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
62 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
63 exit(0);
64}
65 ]])],
66 [
67if `grep -i "unrecognized option" conftest.err >/dev/null`
68then
69 AC_MSG_RESULT([no])
70 CFLAGS="$saved_CFLAGS"
71else
72 AC_MSG_RESULT([yes])
73 CFLAGS="$saved_CFLAGS $_define_flag"
74fi],
75 [ AC_MSG_RESULT([no])
76 CFLAGS="$saved_CFLAGS" ]
77 )
78}])
79
80dnl OSSH_CHECK_LDFLAG_LINK(check_flag[, define_flag])
81dnl Check that $LD accepts a flag 'check_flag'. If it is supported append
82dnl 'define_flag' to $LDFLAGS. If 'define_flag' is not specified, then append
83dnl 'check_flag'.
84AC_DEFUN([OSSH_CHECK_LDFLAG_LINK], [{
85 AC_MSG_CHECKING([if $LD supports link flag $1])
86 saved_LDFLAGS="$LDFLAGS"
87 LDFLAGS="$LDFLAGS $WERROR $1"
88 _define_flag="$2"
89 test "x$_define_flag" = "x" && _define_flag="$1"
90 AC_LINK_IFELSE([AC_LANG_SOURCE([[
91#include <stdlib.h>
92#include <stdio.h>
93int main(int argc, char **argv) {
94 /* Some math to catch -ftrapv problems in the toolchain */
95 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
96 float l = i * 2.1;
97 double m = l / 0.5;
98 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
99 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
100 exit(0);
101}
102 ]])],
103 [ AC_MSG_RESULT([yes])
104 LDFLAGS="$saved_LDFLAGS $_define_flag"],
105 [ AC_MSG_RESULT([no])
106 LDFLAGS="$saved_LDFLAGS" ]
107 )
108}])
31 109
32dnl OSSH_CHECK_HEADER_FOR_FIELD(field, header, symbol) 110dnl OSSH_CHECK_HEADER_FOR_FIELD(field, header, symbol)
33dnl Does AC_EGREP_HEADER on 'header' for the string 'field' 111dnl Does AC_EGREP_HEADER on 'header' for the string 'field'
diff --git a/addrmatch.c b/addrmatch.c
index fb6de92e7..c44314632 100644
--- a/addrmatch.c
+++ b/addrmatch.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: addrmatch.c,v 1.7 2013/05/17 00:13:13 djm Exp $ */ 1/* $OpenBSD: addrmatch.c,v 1.9 2014/01/19 11:21:51 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2004-2008 Damien Miller <djm@mindrot.org> 4 * Copyright (c) 2004-2008 Damien Miller <djm@mindrot.org>
@@ -88,13 +88,13 @@ addr_sa_to_xaddr(struct sockaddr *sa, socklen_t slen, struct xaddr *xa)
88 88
89 switch (sa->sa_family) { 89 switch (sa->sa_family) {
90 case AF_INET: 90 case AF_INET:
91 if (slen < sizeof(*in4)) 91 if (slen < (socklen_t)sizeof(*in4))
92 return -1; 92 return -1;
93 xa->af = AF_INET; 93 xa->af = AF_INET;
94 memcpy(&xa->v4, &in4->sin_addr, sizeof(xa->v4)); 94 memcpy(&xa->v4, &in4->sin_addr, sizeof(xa->v4));
95 break; 95 break;
96 case AF_INET6: 96 case AF_INET6:
97 if (slen < sizeof(*in6)) 97 if (slen < (socklen_t)sizeof(*in6))
98 return -1; 98 return -1;
99 xa->af = AF_INET6; 99 xa->af = AF_INET6;
100 memcpy(&xa->v6, &in6->sin6_addr, sizeof(xa->v6)); 100 memcpy(&xa->v6, &in6->sin6_addr, sizeof(xa->v6));
diff --git a/atomicio.c b/atomicio.c
index 601b3c371..2bac36c91 100644
--- a/atomicio.c
+++ b/atomicio.c
@@ -56,8 +56,10 @@ atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n,
56 ssize_t res; 56 ssize_t res;
57 struct pollfd pfd; 57 struct pollfd pfd;
58 58
59#ifndef BROKEN_READ_COMPARISON
59 pfd.fd = fd; 60 pfd.fd = fd;
60 pfd.events = f == read ? POLLIN : POLLOUT; 61 pfd.events = f == read ? POLLIN : POLLOUT;
62#endif
61 while (n > pos) { 63 while (n > pos) {
62 res = (f) (fd, s + pos, n - pos); 64 res = (f) (fd, s + pos, n - pos);
63 switch (res) { 65 switch (res) {
@@ -65,7 +67,9 @@ atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n,
65 if (errno == EINTR) 67 if (errno == EINTR)
66 continue; 68 continue;
67 if (errno == EAGAIN || errno == EWOULDBLOCK) { 69 if (errno == EAGAIN || errno == EWOULDBLOCK) {
70#ifndef BROKEN_READ_COMPARISON
68 (void)poll(&pfd, 1, -1); 71 (void)poll(&pfd, 1, -1);
72#endif
69 continue; 73 continue;
70 } 74 }
71 return 0; 75 return 0;
diff --git a/auth-krb5.c b/auth-krb5.c
index 7c83f597f..6c62bdf54 100644
--- a/auth-krb5.c
+++ b/auth-krb5.c
@@ -157,7 +157,8 @@ auth_krb5_password(Authctxt *authctxt, const char *password)
157 if (problem) 157 if (problem)
158 goto out; 158 goto out;
159 159
160 if (!krb5_kuserok(authctxt->krb5_ctx, authctxt->krb5_user, client)) { 160 if (!krb5_kuserok(authctxt->krb5_ctx, authctxt->krb5_user,
161 authctxt->pw->pw_name)) {
161 problem = -1; 162 problem = -1;
162 goto out; 163 goto out;
163 } 164 }
diff --git a/auth-options.c b/auth-options.c
index 12e2e1dca..fa209eaab 100644
--- a/auth-options.c
+++ b/auth-options.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth-options.c,v 1.61 2013/11/08 00:39:14 djm Exp $ */ 1/* $OpenBSD: auth-options.c,v 1.62 2013/12/19 00:27:57 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
@@ -33,10 +33,6 @@
33#include "auth-options.h" 33#include "auth-options.h"
34#include "hostfile.h" 34#include "hostfile.h"
35#include "auth.h" 35#include "auth.h"
36#ifdef GSSAPI
37#include "ssh-gss.h"
38#endif
39#include "monitor_wrap.h"
40 36
41/* Flags set authorized_keys flags */ 37/* Flags set authorized_keys flags */
42int no_port_forwarding_flag = 0; 38int no_port_forwarding_flag = 0;
@@ -436,7 +432,7 @@ parse_option_list(u_char *optblob, size_t optblob_len, struct passwd *pw,
436 u_char *data_blob = NULL; 432 u_char *data_blob = NULL;
437 u_int nlen, dlen, clen; 433 u_int nlen, dlen, clen;
438 Buffer c, data; 434 Buffer c, data;
439 int ret = -1, found; 435 int ret = -1, result, found;
440 436
441 buffer_init(&data); 437 buffer_init(&data);
442 438
@@ -505,11 +501,12 @@ parse_option_list(u_char *optblob, size_t optblob_len, struct passwd *pw,
505 goto out; 501 goto out;
506 } 502 }
507 remote_ip = get_remote_ipaddr(); 503 remote_ip = get_remote_ipaddr();
508 switch (addr_match_cidr_list(remote_ip, 504 result = addr_match_cidr_list(remote_ip,
509 allowed)) { 505 allowed);
506 free(allowed);
507 switch (result) {
510 case 1: 508 case 1:
511 /* accepted */ 509 /* accepted */
512 free(allowed);
513 break; 510 break;
514 case 0: 511 case 0:
515 /* no match */ 512 /* no match */
@@ -522,12 +519,11 @@ parse_option_list(u_char *optblob, size_t optblob_len, struct passwd *pw,
522 "is not permitted to use this " 519 "is not permitted to use this "
523 "certificate for login.", 520 "certificate for login.",
524 remote_ip); 521 remote_ip);
525 free(allowed);
526 goto out; 522 goto out;
527 case -1: 523 case -1:
524 default:
528 error("Certificate source-address " 525 error("Certificate source-address "
529 "contents invalid"); 526 "contents invalid");
530 free(allowed);
531 goto out; 527 goto out;
532 } 528 }
533 found = 1; 529 found = 1;
diff --git a/auth-pam.c b/auth-pam.c
index d51318b3a..d789bad7b 100644
--- a/auth-pam.c
+++ b/auth-pam.c
@@ -438,8 +438,10 @@ sshpam_thread(void *ctxtp)
438 const char **ptr_pam_user = &pam_user; 438 const char **ptr_pam_user = &pam_user;
439 char *tz = getenv("TZ"); 439 char *tz = getenv("TZ");
440 440
441 pam_get_item(sshpam_handle, PAM_USER, 441 sshpam_err = pam_get_item(sshpam_handle, PAM_USER,
442 (sshpam_const void **)ptr_pam_user); 442 (sshpam_const void **)ptr_pam_user);
443 if (sshpam_err != PAM_SUCCESS)
444 goto auth_fail;
443 445
444 environ[0] = NULL; 446 environ[0] = NULL;
445 if (tz != NULL) 447 if (tz != NULL)
diff --git a/auth2-hostbased.c b/auth2-hostbased.c
index a344dcc1f..488008f62 100644
--- a/auth2-hostbased.c
+++ b/auth2-hostbased.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2-hostbased.c,v 1.16 2013/06/21 00:34:49 djm Exp $ */ 1/* $OpenBSD: auth2-hostbased.c,v 1.17 2013/12/30 23:52:27 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -100,6 +100,12 @@ userauth_hostbased(Authctxt *authctxt)
100 "(received %d, expected %d)", key->type, pktype); 100 "(received %d, expected %d)", key->type, pktype);
101 goto done; 101 goto done;
102 } 102 }
103 if (key_type_plain(key->type) == KEY_RSA &&
104 (datafellows & SSH_BUG_RSASIGMD5) != 0) {
105 error("Refusing RSA key because peer uses unsafe "
106 "signature format");
107 goto done;
108 }
103 service = datafellows & SSH_BUG_HBSERVICE ? "ssh-userauth" : 109 service = datafellows & SSH_BUG_HBSERVICE ? "ssh-userauth" :
104 authctxt->service; 110 authctxt->service;
105 buffer_init(&b); 111 buffer_init(&b);
diff --git a/auth2-pubkey.c b/auth2-pubkey.c
index 2b3ecb104..0fd27bb92 100644
--- a/auth2-pubkey.c
+++ b/auth2-pubkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2-pubkey.c,v 1.38 2013/06/21 00:34:49 djm Exp $ */ 1/* $OpenBSD: auth2-pubkey.c,v 1.39 2013/12/30 23:52:27 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -116,6 +116,12 @@ userauth_pubkey(Authctxt *authctxt)
116 "(received %d, expected %d)", key->type, pktype); 116 "(received %d, expected %d)", key->type, pktype);
117 goto done; 117 goto done;
118 } 118 }
119 if (key_type_plain(key->type) == KEY_RSA &&
120 (datafellows & SSH_BUG_RSASIGMD5) != 0) {
121 logit("Refusing RSA key because client uses unsafe "
122 "signature scheme");
123 goto done;
124 }
119 if (have_sig) { 125 if (have_sig) {
120 sig = packet_get_string(&slen); 126 sig = packet_get_string(&slen);
121 packet_check_eom(); 127 packet_check_eom();
diff --git a/authfd.c b/authfd.c
index 5cce93b76..f9636903a 100644
--- a/authfd.c
+++ b/authfd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: authfd.c,v 1.88 2013/11/08 00:39:14 djm Exp $ */ 1/* $OpenBSD: authfd.c,v 1.91 2013/12/29 04:29:25 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
@@ -42,8 +42,8 @@
42#include <sys/socket.h> 42#include <sys/socket.h>
43 43
44#include <openssl/evp.h> 44#include <openssl/evp.h>
45
46#include <openssl/crypto.h> 45#include <openssl/crypto.h>
46
47#include <fcntl.h> 47#include <fcntl.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <signal.h> 49#include <signal.h>
@@ -474,58 +474,7 @@ ssh_encode_identity_rsa1(Buffer *b, RSA *key, const char *comment)
474static void 474static void
475ssh_encode_identity_ssh2(Buffer *b, Key *key, const char *comment) 475ssh_encode_identity_ssh2(Buffer *b, Key *key, const char *comment)
476{ 476{
477 buffer_put_cstring(b, key_ssh_name(key)); 477 key_private_serialize(key, b);
478 switch (key->type) {
479 case KEY_RSA:
480 buffer_put_bignum2(b, key->rsa->n);
481 buffer_put_bignum2(b, key->rsa->e);
482 buffer_put_bignum2(b, key->rsa->d);
483 buffer_put_bignum2(b, key->rsa->iqmp);
484 buffer_put_bignum2(b, key->rsa->p);
485 buffer_put_bignum2(b, key->rsa->q);
486 break;
487 case KEY_RSA_CERT_V00:
488 case KEY_RSA_CERT:
489 if (key->cert == NULL || buffer_len(&key->cert->certblob) == 0)
490 fatal("%s: no cert/certblob", __func__);
491 buffer_put_string(b, buffer_ptr(&key->cert->certblob),
492 buffer_len(&key->cert->certblob));
493 buffer_put_bignum2(b, key->rsa->d);
494 buffer_put_bignum2(b, key->rsa->iqmp);
495 buffer_put_bignum2(b, key->rsa->p);
496 buffer_put_bignum2(b, key->rsa->q);
497 break;
498 case KEY_DSA:
499 buffer_put_bignum2(b, key->dsa->p);
500 buffer_put_bignum2(b, key->dsa->q);
501 buffer_put_bignum2(b, key->dsa->g);
502 buffer_put_bignum2(b, key->dsa->pub_key);
503 buffer_put_bignum2(b, key->dsa->priv_key);
504 break;
505 case KEY_DSA_CERT_V00:
506 case KEY_DSA_CERT:
507 if (key->cert == NULL || buffer_len(&key->cert->certblob) == 0)
508 fatal("%s: no cert/certblob", __func__);
509 buffer_put_string(b, buffer_ptr(&key->cert->certblob),
510 buffer_len(&key->cert->certblob));
511 buffer_put_bignum2(b, key->dsa->priv_key);
512 break;
513#ifdef OPENSSL_HAS_ECC
514 case KEY_ECDSA:
515 buffer_put_cstring(b, key_curve_nid_to_name(key->ecdsa_nid));
516 buffer_put_ecpoint(b, EC_KEY_get0_group(key->ecdsa),
517 EC_KEY_get0_public_key(key->ecdsa));
518 buffer_put_bignum2(b, EC_KEY_get0_private_key(key->ecdsa));
519 break;
520 case KEY_ECDSA_CERT:
521 if (key->cert == NULL || buffer_len(&key->cert->certblob) == 0)
522 fatal("%s: no cert/certblob", __func__);
523 buffer_put_string(b, buffer_ptr(&key->cert->certblob),
524 buffer_len(&key->cert->certblob));
525 buffer_put_bignum2(b, EC_KEY_get0_private_key(key->ecdsa));
526 break;
527#endif
528 }
529 buffer_put_cstring(b, comment); 478 buffer_put_cstring(b, comment);
530} 479}
531 480
@@ -559,6 +508,8 @@ ssh_add_identity_constrained(AuthenticationConnection *auth, Key *key,
559 case KEY_DSA_CERT_V00: 508 case KEY_DSA_CERT_V00:
560 case KEY_ECDSA: 509 case KEY_ECDSA:
561 case KEY_ECDSA_CERT: 510 case KEY_ECDSA_CERT:
511 case KEY_ED25519:
512 case KEY_ED25519_CERT:
562 type = constrained ? 513 type = constrained ?
563 SSH2_AGENTC_ADD_ID_CONSTRAINED : 514 SSH2_AGENTC_ADD_ID_CONSTRAINED :
564 SSH2_AGENTC_ADD_IDENTITY; 515 SSH2_AGENTC_ADD_IDENTITY;
@@ -606,9 +557,7 @@ ssh_remove_identity(AuthenticationConnection *auth, Key *key)
606 buffer_put_int(&msg, BN_num_bits(key->rsa->n)); 557 buffer_put_int(&msg, BN_num_bits(key->rsa->n));
607 buffer_put_bignum(&msg, key->rsa->e); 558 buffer_put_bignum(&msg, key->rsa->e);
608 buffer_put_bignum(&msg, key->rsa->n); 559 buffer_put_bignum(&msg, key->rsa->n);
609 } else if (key_type_plain(key->type) == KEY_DSA || 560 } else if (key->type != KEY_UNSPEC) {
610 key_type_plain(key->type) == KEY_RSA ||
611 key_type_plain(key->type) == KEY_ECDSA) {
612 key_to_blob(key, &blob, &blen); 561 key_to_blob(key, &blob, &blen);
613 buffer_put_char(&msg, SSH2_AGENTC_REMOVE_IDENTITY); 562 buffer_put_char(&msg, SSH2_AGENTC_REMOVE_IDENTITY);
614 buffer_put_string(&msg, blob, blen); 563 buffer_put_string(&msg, blob, blen);
diff --git a/authfile.c b/authfile.c
index 63ae16bbd..7eccbb2c9 100644
--- a/authfile.c
+++ b/authfile.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: authfile.c,v 1.97 2013/05/17 00:13:13 djm Exp $ */ 1/* $OpenBSD: authfile.c,v 1.101 2013/12/29 04:35: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
@@ -13,7 +13,7 @@
13 * called by a name other than "ssh" or "Secure Shell". 13 * called by a name other than "ssh" or "Secure Shell".
14 * 14 *
15 * 15 *
16 * Copyright (c) 2000 Markus Friedl. All rights reserved. 16 * Copyright (c) 2000, 2013 Markus Friedl. All rights reserved.
17 * 17 *
18 * Redistribution and use in source and binary forms, with or without 18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions 19 * modification, are permitted provided that the following conditions
@@ -50,6 +50,8 @@
50/* compatibility with old or broken OpenSSL versions */ 50/* compatibility with old or broken OpenSSL versions */
51#include "openbsd-compat/openssl-compat.h" 51#include "openbsd-compat/openssl-compat.h"
52 52
53#include "crypto_api.h"
54
53#include <errno.h> 55#include <errno.h>
54#include <fcntl.h> 56#include <fcntl.h>
55#include <stdarg.h> 57#include <stdarg.h>
@@ -58,6 +60,10 @@
58#include <string.h> 60#include <string.h>
59#include <unistd.h> 61#include <unistd.h>
60 62
63#ifdef HAVE_UTIL_H
64#include <util.h>
65#endif
66
61#include "xmalloc.h" 67#include "xmalloc.h"
62#include "cipher.h" 68#include "cipher.h"
63#include "buffer.h" 69#include "buffer.h"
@@ -68,6 +74,16 @@
68#include "rsa.h" 74#include "rsa.h"
69#include "misc.h" 75#include "misc.h"
70#include "atomicio.h" 76#include "atomicio.h"
77#include "uuencode.h"
78
79/* openssh private key file format */
80#define MARK_BEGIN "-----BEGIN OPENSSH PRIVATE KEY-----\n"
81#define MARK_END "-----END OPENSSH PRIVATE KEY-----\n"
82#define KDFNAME "bcrypt"
83#define AUTH_MAGIC "openssh-key-v1"
84#define SALT_LEN 16
85#define DEFAULT_CIPHERNAME "aes256-cbc"
86#define DEFAULT_ROUNDS 16
71 87
72#define MAX_KEY_FILE_SIZE (1024 * 1024) 88#define MAX_KEY_FILE_SIZE (1024 * 1024)
73 89
@@ -75,6 +91,333 @@
75static const char authfile_id_string[] = 91static const char authfile_id_string[] =
76 "SSH PRIVATE KEY FILE FORMAT 1.1\n"; 92 "SSH PRIVATE KEY FILE FORMAT 1.1\n";
77 93
94static int
95key_private_to_blob2(Key *prv, Buffer *blob, const char *passphrase,
96 const char *comment, const char *ciphername, int rounds)
97{
98 u_char *key, *cp, salt[SALT_LEN];
99 size_t keylen, ivlen, blocksize, authlen;
100 u_int len, check;
101 int i, n;
102 const Cipher *c;
103 Buffer encoded, b, kdf;
104 CipherContext ctx;
105 const char *kdfname = KDFNAME;
106
107 if (rounds <= 0)
108 rounds = DEFAULT_ROUNDS;
109 if (passphrase == NULL || !strlen(passphrase)) {
110 ciphername = "none";
111 kdfname = "none";
112 } else if (ciphername == NULL)
113 ciphername = DEFAULT_CIPHERNAME;
114 else if (cipher_number(ciphername) != SSH_CIPHER_SSH2)
115 fatal("invalid cipher");
116
117 if ((c = cipher_by_name(ciphername)) == NULL)
118 fatal("unknown cipher name");
119 buffer_init(&kdf);
120 blocksize = cipher_blocksize(c);
121 keylen = cipher_keylen(c);
122 ivlen = cipher_ivlen(c);
123 authlen = cipher_authlen(c);
124 key = xcalloc(1, keylen + ivlen);
125 if (strcmp(kdfname, "none") != 0) {
126 arc4random_buf(salt, SALT_LEN);
127 if (bcrypt_pbkdf(passphrase, strlen(passphrase),
128 salt, SALT_LEN, key, keylen + ivlen, rounds) < 0)
129 fatal("bcrypt_pbkdf failed");
130 buffer_put_string(&kdf, salt, SALT_LEN);
131 buffer_put_int(&kdf, rounds);
132 }
133 cipher_init(&ctx, c, key, keylen, key + keylen , ivlen, 1);
134 memset(key, 0, keylen + ivlen);
135 free(key);
136
137 buffer_init(&encoded);
138 buffer_append(&encoded, AUTH_MAGIC, sizeof(AUTH_MAGIC));
139 buffer_put_cstring(&encoded, ciphername);
140 buffer_put_cstring(&encoded, kdfname);
141 buffer_put_string(&encoded, buffer_ptr(&kdf), buffer_len(&kdf));
142 buffer_put_int(&encoded, 1); /* number of keys */
143 key_to_blob(prv, &cp, &len); /* public key */
144 buffer_put_string(&encoded, cp, len);
145
146 memset(cp, 0, len);
147 free(cp);
148
149 buffer_free(&kdf);
150
151 /* set up the buffer that will be encrypted */
152 buffer_init(&b);
153
154 /* Random check bytes */
155 check = arc4random();
156 buffer_put_int(&b, check);
157 buffer_put_int(&b, check);
158
159 /* append private key and comment*/
160 key_private_serialize(prv, &b);
161 buffer_put_cstring(&b, comment);
162
163 /* padding */
164 i = 0;
165 while (buffer_len(&b) % blocksize)
166 buffer_put_char(&b, ++i & 0xff);
167
168 /* length */
169 buffer_put_int(&encoded, buffer_len(&b));
170
171 /* encrypt */
172 cp = buffer_append_space(&encoded, buffer_len(&b) + authlen);
173 if (cipher_crypt(&ctx, 0, cp, buffer_ptr(&b), buffer_len(&b), 0,
174 authlen) != 0)
175 fatal("%s: cipher_crypt failed", __func__);
176 buffer_free(&b);
177 cipher_cleanup(&ctx);
178
179 /* uuencode */
180 len = 2 * buffer_len(&encoded);
181 cp = xmalloc(len);
182 n = uuencode(buffer_ptr(&encoded), buffer_len(&encoded),
183 (char *)cp, len);
184 if (n < 0)
185 fatal("%s: uuencode", __func__);
186
187 buffer_clear(blob);
188 buffer_append(blob, MARK_BEGIN, sizeof(MARK_BEGIN) - 1);
189 for (i = 0; i < n; i++) {
190 buffer_put_char(blob, cp[i]);
191 if (i % 70 == 69)
192 buffer_put_char(blob, '\n');
193 }
194 if (i % 70 != 69)
195 buffer_put_char(blob, '\n');
196 buffer_append(blob, MARK_END, sizeof(MARK_END) - 1);
197 free(cp);
198
199 return buffer_len(blob);
200}
201
202static Key *
203key_parse_private2(Buffer *blob, int type, const char *passphrase,
204 char **commentp)
205{
206 u_char *key = NULL, *cp, *salt = NULL, pad, last;
207 char *comment = NULL, *ciphername = NULL, *kdfname = NULL, *kdfp;
208 u_int keylen = 0, ivlen, blocksize, slen, klen, len, rounds, nkeys;
209 u_int check1, check2, m1len, m2len;
210 size_t authlen;
211 const Cipher *c;
212 Buffer b, encoded, copy, kdf;
213 CipherContext ctx;
214 Key *k = NULL;
215 int dlen, ret, i;
216
217 buffer_init(&b);
218 buffer_init(&kdf);
219 buffer_init(&encoded);
220 buffer_init(&copy);
221
222 /* uudecode */
223 m1len = sizeof(MARK_BEGIN) - 1;
224 m2len = sizeof(MARK_END) - 1;
225 cp = buffer_ptr(blob);
226 len = buffer_len(blob);
227 if (len < m1len || memcmp(cp, MARK_BEGIN, m1len)) {
228 debug("%s: missing begin marker", __func__);
229 goto out;
230 }
231 cp += m1len;
232 len -= m1len;
233 while (len) {
234 if (*cp != '\n' && *cp != '\r')
235 buffer_put_char(&encoded, *cp);
236 last = *cp;
237 len--;
238 cp++;
239 if (last == '\n') {
240 if (len >= m2len && !memcmp(cp, MARK_END, m2len)) {
241 buffer_put_char(&encoded, '\0');
242 break;
243 }
244 }
245 }
246 if (!len) {
247 debug("%s: no end marker", __func__);
248 goto out;
249 }
250 len = buffer_len(&encoded);
251 if ((cp = buffer_append_space(&copy, len)) == NULL) {
252 error("%s: buffer_append_space", __func__);
253 goto out;
254 }
255 if ((dlen = uudecode(buffer_ptr(&encoded), cp, len)) < 0) {
256 error("%s: uudecode failed", __func__);
257 goto out;
258 }
259 if ((u_int)dlen > len) {
260 error("%s: crazy uudecode length %d > %u", __func__, dlen, len);
261 goto out;
262 }
263 buffer_consume_end(&copy, len - dlen);
264 if (buffer_len(&copy) < sizeof(AUTH_MAGIC) ||
265 memcmp(buffer_ptr(&copy), AUTH_MAGIC, sizeof(AUTH_MAGIC))) {
266 error("%s: bad magic", __func__);
267 goto out;
268 }
269 buffer_consume(&copy, sizeof(AUTH_MAGIC));
270
271 ciphername = buffer_get_cstring_ret(&copy, NULL);
272 if (ciphername == NULL ||
273 (c = cipher_by_name(ciphername)) == NULL) {
274 error("%s: unknown cipher name", __func__);
275 goto out;
276 }
277 if ((passphrase == NULL || !strlen(passphrase)) &&
278 strcmp(ciphername, "none") != 0) {
279 /* passphrase required */
280 goto out;
281 }
282 kdfname = buffer_get_cstring_ret(&copy, NULL);
283 if (kdfname == NULL ||
284 (!strcmp(kdfname, "none") && !strcmp(kdfname, "bcrypt"))) {
285 error("%s: unknown kdf name", __func__);
286 goto out;
287 }
288 if (!strcmp(kdfname, "none") && strcmp(ciphername, "none") != 0) {
289 error("%s: cipher %s requires kdf", __func__, ciphername);
290 goto out;
291 }
292 /* kdf options */
293 kdfp = buffer_get_string_ptr_ret(&copy, &klen);
294 if (kdfp == NULL) {
295 error("%s: kdf options not set", __func__);
296 goto out;
297 }
298 if (klen > 0) {
299 if ((cp = buffer_append_space(&kdf, klen)) == NULL) {
300 error("%s: kdf alloc failed", __func__);
301 goto out;
302 }
303 memcpy(cp, kdfp, klen);
304 }
305 /* number of keys */
306 if (buffer_get_int_ret(&nkeys, &copy) < 0) {
307 error("%s: key counter missing", __func__);
308 goto out;
309 }
310 if (nkeys != 1) {
311 error("%s: only one key supported", __func__);
312 goto out;
313 }
314 /* pubkey */
315 if ((cp = buffer_get_string_ret(&copy, &len)) == NULL) {
316 error("%s: pubkey not found", __func__);
317 goto out;
318 }
319 free(cp); /* XXX check pubkey against decrypted private key */
320
321 /* size of encrypted key blob */
322 len = buffer_get_int(&copy);
323 blocksize = cipher_blocksize(c);
324 authlen = cipher_authlen(c);
325 if (len < blocksize) {
326 error("%s: encrypted data too small", __func__);
327 goto out;
328 }
329 if (len % blocksize) {
330 error("%s: length not multiple of blocksize", __func__);
331 goto out;
332 }
333
334 /* setup key */
335 keylen = cipher_keylen(c);
336 ivlen = cipher_ivlen(c);
337 key = xcalloc(1, keylen + ivlen);
338 if (!strcmp(kdfname, "bcrypt")) {
339 if ((salt = buffer_get_string_ret(&kdf, &slen)) == NULL) {
340 error("%s: salt not set", __func__);
341 goto out;
342 }
343 if (buffer_get_int_ret(&rounds, &kdf) < 0) {
344 error("%s: rounds not set", __func__);
345 goto out;
346 }
347 if (bcrypt_pbkdf(passphrase, strlen(passphrase), salt, slen,
348 key, keylen + ivlen, rounds) < 0) {
349 error("%s: bcrypt_pbkdf failed", __func__);
350 goto out;
351 }
352 }
353
354 cp = buffer_append_space(&b, len);
355 cipher_init(&ctx, c, key, keylen, key + keylen, ivlen, 0);
356 ret = cipher_crypt(&ctx, 0, cp, buffer_ptr(&copy), len, 0, authlen);
357 cipher_cleanup(&ctx);
358 buffer_consume(&copy, len);
359
360 /* fail silently on decryption errors */
361 if (ret != 0) {
362 debug("%s: decrypt failed", __func__);
363 goto out;
364 }
365
366 if (buffer_len(&copy) != 0) {
367 error("%s: key blob has trailing data (len = %u)", __func__,
368 buffer_len(&copy));
369 goto out;
370 }
371
372 /* check bytes */
373 if (buffer_get_int_ret(&check1, &b) < 0 ||
374 buffer_get_int_ret(&check2, &b) < 0) {
375 error("check bytes missing");
376 goto out;
377 }
378 if (check1 != check2) {
379 debug("%s: decrypt failed: 0x%08x != 0x%08x", __func__,
380 check1, check2);
381 goto out;
382 }
383
384 k = key_private_deserialize(&b);
385
386 /* comment */
387 comment = buffer_get_cstring_ret(&b, NULL);
388
389 i = 0;
390 while (buffer_len(&b)) {
391 if (buffer_get_char_ret(&pad, &b) == -1 ||
392 pad != (++i & 0xff)) {
393 error("%s: bad padding", __func__);
394 key_free(k);
395 k = NULL;
396 goto out;
397 }
398 }
399
400 if (k && commentp) {
401 *commentp = comment;
402 comment = NULL;
403 }
404
405 /* XXX decode pubkey and check against private */
406 out:
407 free(ciphername);
408 free(kdfname);
409 free(salt);
410 free(comment);
411 if (key)
412 memset(key, 0, keylen + ivlen);
413 free(key);
414 buffer_free(&encoded);
415 buffer_free(&copy);
416 buffer_free(&kdf);
417 buffer_free(&b);
418 return k;
419}
420
78/* 421/*
79 * Serialises the authentication (private) key to a blob, encrypting it with 422 * Serialises the authentication (private) key to a blob, encrypting it with
80 * passphrase. The identification of the blob (lowest 64 bits of n) will 423 * passphrase. The identification of the blob (lowest 64 bits of n) will
@@ -149,8 +492,9 @@ key_private_rsa1_to_blob(Key *key, Buffer *blob, const char *passphrase,
149 492
150 cipher_set_key_string(&ciphercontext, cipher, passphrase, 493 cipher_set_key_string(&ciphercontext, cipher, passphrase,
151 CIPHER_ENCRYPT); 494 CIPHER_ENCRYPT);
152 cipher_crypt(&ciphercontext, cp, 495 if (cipher_crypt(&ciphercontext, 0, cp,
153 buffer_ptr(&buffer), buffer_len(&buffer), 0, 0); 496 buffer_ptr(&buffer), buffer_len(&buffer), 0, 0) != 0)
497 fatal("%s: cipher_crypt failed", __func__);
154 cipher_cleanup(&ciphercontext); 498 cipher_cleanup(&ciphercontext);
155 memset(&ciphercontext, 0, sizeof(ciphercontext)); 499 memset(&ciphercontext, 0, sizeof(ciphercontext));
156 500
@@ -239,7 +583,8 @@ key_save_private_blob(Buffer *keybuf, const char *filename)
239/* Serialise "key" to buffer "blob" */ 583/* Serialise "key" to buffer "blob" */
240static int 584static int
241key_private_to_blob(Key *key, Buffer *blob, const char *passphrase, 585key_private_to_blob(Key *key, Buffer *blob, const char *passphrase,
242 const char *comment) 586 const char *comment, int force_new_format, const char *new_format_cipher,
587 int new_format_rounds)
243{ 588{
244 switch (key->type) { 589 switch (key->type) {
245 case KEY_RSA1: 590 case KEY_RSA1:
@@ -247,7 +592,14 @@ key_private_to_blob(Key *key, Buffer *blob, const char *passphrase,
247 case KEY_DSA: 592 case KEY_DSA:
248 case KEY_ECDSA: 593 case KEY_ECDSA:
249 case KEY_RSA: 594 case KEY_RSA:
595 if (force_new_format) {
596 return key_private_to_blob2(key, blob, passphrase,
597 comment, new_format_cipher, new_format_rounds);
598 }
250 return key_private_pem_to_blob(key, blob, passphrase, comment); 599 return key_private_pem_to_blob(key, blob, passphrase, comment);
600 case KEY_ED25519:
601 return key_private_to_blob2(key, blob, passphrase,
602 comment, new_format_cipher, new_format_rounds);
251 default: 603 default:
252 error("%s: cannot save key type %d", __func__, key->type); 604 error("%s: cannot save key type %d", __func__, key->type);
253 return 0; 605 return 0;
@@ -256,13 +608,15 @@ key_private_to_blob(Key *key, Buffer *blob, const char *passphrase,
256 608
257int 609int
258key_save_private(Key *key, const char *filename, const char *passphrase, 610key_save_private(Key *key, const char *filename, const char *passphrase,
259 const char *comment) 611 const char *comment, int force_new_format, const char *new_format_cipher,
612 int new_format_rounds)
260{ 613{
261 Buffer keyblob; 614 Buffer keyblob;
262 int success = 0; 615 int success = 0;
263 616
264 buffer_init(&keyblob); 617 buffer_init(&keyblob);
265 if (!key_private_to_blob(key, &keyblob, passphrase, comment)) 618 if (!key_private_to_blob(key, &keyblob, passphrase, comment,
619 force_new_format, new_format_cipher, new_format_rounds))
266 goto out; 620 goto out;
267 if (!key_save_private_blob(&keyblob, filename)) 621 if (!key_save_private_blob(&keyblob, filename))
268 goto out; 622 goto out;
@@ -473,8 +827,9 @@ key_parse_private_rsa1(Buffer *blob, const char *passphrase, char **commentp)
473 /* Rest of the buffer is encrypted. Decrypt it using the passphrase. */ 827 /* Rest of the buffer is encrypted. Decrypt it using the passphrase. */
474 cipher_set_key_string(&ciphercontext, cipher, passphrase, 828 cipher_set_key_string(&ciphercontext, cipher, passphrase,
475 CIPHER_DECRYPT); 829 CIPHER_DECRYPT);
476 cipher_crypt(&ciphercontext, cp, 830 if (cipher_crypt(&ciphercontext, 0, cp,
477 buffer_ptr(&copy), buffer_len(&copy), 0, 0); 831 buffer_ptr(&copy), buffer_len(&copy), 0, 0) != 0)
832 fatal("%s: cipher_crypt failed", __func__);
478 cipher_cleanup(&ciphercontext); 833 cipher_cleanup(&ciphercontext);
479 memset(&ciphercontext, 0, sizeof(ciphercontext)); 834 memset(&ciphercontext, 0, sizeof(ciphercontext));
480 buffer_free(&copy); 835 buffer_free(&copy);
@@ -641,13 +996,20 @@ static Key *
641key_parse_private_type(Buffer *blob, int type, const char *passphrase, 996key_parse_private_type(Buffer *blob, int type, const char *passphrase,
642 char **commentp) 997 char **commentp)
643{ 998{
999 Key *k;
1000
644 switch (type) { 1001 switch (type) {
645 case KEY_RSA1: 1002 case KEY_RSA1:
646 return key_parse_private_rsa1(blob, passphrase, commentp); 1003 return key_parse_private_rsa1(blob, passphrase, commentp);
647 case KEY_DSA: 1004 case KEY_DSA:
648 case KEY_ECDSA: 1005 case KEY_ECDSA:
649 case KEY_RSA: 1006 case KEY_RSA:
1007 return key_parse_private_pem(blob, type, passphrase, commentp);
1008 case KEY_ED25519:
1009 return key_parse_private2(blob, type, passphrase, commentp);
650 case KEY_UNSPEC: 1010 case KEY_UNSPEC:
1011 if ((k = key_parse_private2(blob, type, passphrase, commentp)))
1012 return k;
651 return key_parse_private_pem(blob, type, passphrase, commentp); 1013 return key_parse_private_pem(blob, type, passphrase, commentp);
652 default: 1014 default:
653 error("%s: cannot parse key type %d", __func__, type); 1015 error("%s: cannot parse key type %d", __func__, type);
@@ -851,6 +1213,7 @@ key_load_private_cert(int type, const char *filename, const char *passphrase,
851 case KEY_RSA: 1213 case KEY_RSA:
852 case KEY_DSA: 1214 case KEY_DSA:
853 case KEY_ECDSA: 1215 case KEY_ECDSA:
1216 case KEY_ED25519:
854 break; 1217 break;
855 default: 1218 default:
856 error("%s: unsupported key type", __func__); 1219 error("%s: unsupported key type", __func__);
@@ -943,4 +1306,3 @@ key_in_file(Key *key, const char *filename, int strict_type)
943 fclose(f); 1306 fclose(f);
944 return ret; 1307 return ret;
945} 1308}
946
diff --git a/authfile.h b/authfile.h
index 78349beb5..8ba1c2dbe 100644
--- a/authfile.h
+++ b/authfile.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: authfile.h,v 1.16 2011/05/04 21:15:29 djm Exp $ */ 1/* $OpenBSD: authfile.h,v 1.17 2013/12/06 13:34:54 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -15,7 +15,8 @@
15#ifndef AUTHFILE_H 15#ifndef AUTHFILE_H
16#define AUTHFILE_H 16#define AUTHFILE_H
17 17
18int key_save_private(Key *, const char *, const char *, const char *); 18int key_save_private(Key *, const char *, const char *, const char *,
19 int, const char *, int);
19int key_load_file(int, const char *, Buffer *); 20int key_load_file(int, const char *, Buffer *);
20Key *key_load_cert(const char *); 21Key *key_load_cert(const char *);
21Key *key_load_public(const char *, char **); 22Key *key_load_public(const char *, char **);
diff --git a/blocks.c b/blocks.c
new file mode 100644
index 000000000..ad93fe509
--- /dev/null
+++ b/blocks.c
@@ -0,0 +1,248 @@
1/* $OpenBSD: blocks.c,v 1.3 2013/12/09 11:03:45 markus Exp $ */
2
3/*
4 * Public Domain, Author: Daniel J. Bernstein
5 * Copied from nacl-20110221/crypto_hashblocks/sha512/ref/blocks.c
6 */
7
8#include "includes.h"
9
10#include "crypto_api.h"
11
12typedef unsigned long long uint64;
13
14static uint64 load_bigendian(const unsigned char *x)
15{
16 return
17 (uint64) (x[7]) \
18 | (((uint64) (x[6])) << 8) \
19 | (((uint64) (x[5])) << 16) \
20 | (((uint64) (x[4])) << 24) \
21 | (((uint64) (x[3])) << 32) \
22 | (((uint64) (x[2])) << 40) \
23 | (((uint64) (x[1])) << 48) \
24 | (((uint64) (x[0])) << 56)
25 ;
26}
27
28static void store_bigendian(unsigned char *x,uint64 u)
29{
30 x[7] = u; u >>= 8;
31 x[6] = u; u >>= 8;
32 x[5] = u; u >>= 8;
33 x[4] = u; u >>= 8;
34 x[3] = u; u >>= 8;
35 x[2] = u; u >>= 8;
36 x[1] = u; u >>= 8;
37 x[0] = u;
38}
39
40#define SHR(x,c) ((x) >> (c))
41#define ROTR(x,c) (((x) >> (c)) | ((x) << (64 - (c))))
42
43#define Ch(x,y,z) ((x & y) ^ (~x & z))
44#define Maj(x,y,z) ((x & y) ^ (x & z) ^ (y & z))
45#define Sigma0(x) (ROTR(x,28) ^ ROTR(x,34) ^ ROTR(x,39))
46#define Sigma1(x) (ROTR(x,14) ^ ROTR(x,18) ^ ROTR(x,41))
47#define sigma0(x) (ROTR(x, 1) ^ ROTR(x, 8) ^ SHR(x,7))
48#define sigma1(x) (ROTR(x,19) ^ ROTR(x,61) ^ SHR(x,6))
49
50#define M(w0,w14,w9,w1) w0 = sigma1(w14) + w9 + sigma0(w1) + w0;
51
52#define EXPAND \
53 M(w0 ,w14,w9 ,w1 ) \
54 M(w1 ,w15,w10,w2 ) \
55 M(w2 ,w0 ,w11,w3 ) \
56 M(w3 ,w1 ,w12,w4 ) \
57 M(w4 ,w2 ,w13,w5 ) \
58 M(w5 ,w3 ,w14,w6 ) \
59 M(w6 ,w4 ,w15,w7 ) \
60 M(w7 ,w5 ,w0 ,w8 ) \
61 M(w8 ,w6 ,w1 ,w9 ) \
62 M(w9 ,w7 ,w2 ,w10) \
63 M(w10,w8 ,w3 ,w11) \
64 M(w11,w9 ,w4 ,w12) \
65 M(w12,w10,w5 ,w13) \
66 M(w13,w11,w6 ,w14) \
67 M(w14,w12,w7 ,w15) \
68 M(w15,w13,w8 ,w0 )
69
70#define F(w,k) \
71 T1 = h + Sigma1(e) + Ch(e,f,g) + k + w; \
72 T2 = Sigma0(a) + Maj(a,b,c); \
73 h = g; \
74 g = f; \
75 f = e; \
76 e = d + T1; \
77 d = c; \
78 c = b; \
79 b = a; \
80 a = T1 + T2;
81
82int crypto_hashblocks_sha512(unsigned char *statebytes,const unsigned char *in,unsigned long long inlen)
83{
84 uint64 state[8];
85 uint64 a;
86 uint64 b;
87 uint64 c;
88 uint64 d;
89 uint64 e;
90 uint64 f;
91 uint64 g;
92 uint64 h;
93 uint64 T1;
94 uint64 T2;
95
96 a = load_bigendian(statebytes + 0); state[0] = a;
97 b = load_bigendian(statebytes + 8); state[1] = b;
98 c = load_bigendian(statebytes + 16); state[2] = c;
99 d = load_bigendian(statebytes + 24); state[3] = d;
100 e = load_bigendian(statebytes + 32); state[4] = e;
101 f = load_bigendian(statebytes + 40); state[5] = f;
102 g = load_bigendian(statebytes + 48); state[6] = g;
103 h = load_bigendian(statebytes + 56); state[7] = h;
104
105 while (inlen >= 128) {
106 uint64 w0 = load_bigendian(in + 0);
107 uint64 w1 = load_bigendian(in + 8);
108 uint64 w2 = load_bigendian(in + 16);
109 uint64 w3 = load_bigendian(in + 24);
110 uint64 w4 = load_bigendian(in + 32);
111 uint64 w5 = load_bigendian(in + 40);
112 uint64 w6 = load_bigendian(in + 48);
113 uint64 w7 = load_bigendian(in + 56);
114 uint64 w8 = load_bigendian(in + 64);
115 uint64 w9 = load_bigendian(in + 72);
116 uint64 w10 = load_bigendian(in + 80);
117 uint64 w11 = load_bigendian(in + 88);
118 uint64 w12 = load_bigendian(in + 96);
119 uint64 w13 = load_bigendian(in + 104);
120 uint64 w14 = load_bigendian(in + 112);
121 uint64 w15 = load_bigendian(in + 120);
122
123 F(w0 ,0x428a2f98d728ae22ULL)
124 F(w1 ,0x7137449123ef65cdULL)
125 F(w2 ,0xb5c0fbcfec4d3b2fULL)
126 F(w3 ,0xe9b5dba58189dbbcULL)
127 F(w4 ,0x3956c25bf348b538ULL)
128 F(w5 ,0x59f111f1b605d019ULL)
129 F(w6 ,0x923f82a4af194f9bULL)
130 F(w7 ,0xab1c5ed5da6d8118ULL)
131 F(w8 ,0xd807aa98a3030242ULL)
132 F(w9 ,0x12835b0145706fbeULL)
133 F(w10,0x243185be4ee4b28cULL)
134 F(w11,0x550c7dc3d5ffb4e2ULL)
135 F(w12,0x72be5d74f27b896fULL)
136 F(w13,0x80deb1fe3b1696b1ULL)
137 F(w14,0x9bdc06a725c71235ULL)
138 F(w15,0xc19bf174cf692694ULL)
139
140 EXPAND
141
142 F(w0 ,0xe49b69c19ef14ad2ULL)
143 F(w1 ,0xefbe4786384f25e3ULL)
144 F(w2 ,0x0fc19dc68b8cd5b5ULL)
145 F(w3 ,0x240ca1cc77ac9c65ULL)
146 F(w4 ,0x2de92c6f592b0275ULL)
147 F(w5 ,0x4a7484aa6ea6e483ULL)
148 F(w6 ,0x5cb0a9dcbd41fbd4ULL)
149 F(w7 ,0x76f988da831153b5ULL)
150 F(w8 ,0x983e5152ee66dfabULL)
151 F(w9 ,0xa831c66d2db43210ULL)
152 F(w10,0xb00327c898fb213fULL)
153 F(w11,0xbf597fc7beef0ee4ULL)
154 F(w12,0xc6e00bf33da88fc2ULL)
155 F(w13,0xd5a79147930aa725ULL)
156 F(w14,0x06ca6351e003826fULL)
157 F(w15,0x142929670a0e6e70ULL)
158
159 EXPAND
160
161 F(w0 ,0x27b70a8546d22ffcULL)
162 F(w1 ,0x2e1b21385c26c926ULL)
163 F(w2 ,0x4d2c6dfc5ac42aedULL)
164 F(w3 ,0x53380d139d95b3dfULL)
165 F(w4 ,0x650a73548baf63deULL)
166 F(w5 ,0x766a0abb3c77b2a8ULL)
167 F(w6 ,0x81c2c92e47edaee6ULL)
168 F(w7 ,0x92722c851482353bULL)
169 F(w8 ,0xa2bfe8a14cf10364ULL)
170 F(w9 ,0xa81a664bbc423001ULL)
171 F(w10,0xc24b8b70d0f89791ULL)
172 F(w11,0xc76c51a30654be30ULL)
173 F(w12,0xd192e819d6ef5218ULL)
174 F(w13,0xd69906245565a910ULL)
175 F(w14,0xf40e35855771202aULL)
176 F(w15,0x106aa07032bbd1b8ULL)
177
178 EXPAND
179
180 F(w0 ,0x19a4c116b8d2d0c8ULL)
181 F(w1 ,0x1e376c085141ab53ULL)
182 F(w2 ,0x2748774cdf8eeb99ULL)
183 F(w3 ,0x34b0bcb5e19b48a8ULL)
184 F(w4 ,0x391c0cb3c5c95a63ULL)
185 F(w5 ,0x4ed8aa4ae3418acbULL)
186 F(w6 ,0x5b9cca4f7763e373ULL)
187 F(w7 ,0x682e6ff3d6b2b8a3ULL)
188 F(w8 ,0x748f82ee5defb2fcULL)
189 F(w9 ,0x78a5636f43172f60ULL)
190 F(w10,0x84c87814a1f0ab72ULL)
191 F(w11,0x8cc702081a6439ecULL)
192 F(w12,0x90befffa23631e28ULL)
193 F(w13,0xa4506cebde82bde9ULL)
194 F(w14,0xbef9a3f7b2c67915ULL)
195 F(w15,0xc67178f2e372532bULL)
196
197 EXPAND
198
199 F(w0 ,0xca273eceea26619cULL)
200 F(w1 ,0xd186b8c721c0c207ULL)
201 F(w2 ,0xeada7dd6cde0eb1eULL)
202 F(w3 ,0xf57d4f7fee6ed178ULL)
203 F(w4 ,0x06f067aa72176fbaULL)
204 F(w5 ,0x0a637dc5a2c898a6ULL)
205 F(w6 ,0x113f9804bef90daeULL)
206 F(w7 ,0x1b710b35131c471bULL)
207 F(w8 ,0x28db77f523047d84ULL)
208 F(w9 ,0x32caab7b40c72493ULL)
209 F(w10,0x3c9ebe0a15c9bebcULL)
210 F(w11,0x431d67c49c100d4cULL)
211 F(w12,0x4cc5d4becb3e42b6ULL)
212 F(w13,0x597f299cfc657e2aULL)
213 F(w14,0x5fcb6fab3ad6faecULL)
214 F(w15,0x6c44198c4a475817ULL)
215
216 a += state[0];
217 b += state[1];
218 c += state[2];
219 d += state[3];
220 e += state[4];
221 f += state[5];
222 g += state[6];
223 h += state[7];
224
225 state[0] = a;
226 state[1] = b;
227 state[2] = c;
228 state[3] = d;
229 state[4] = e;
230 state[5] = f;
231 state[6] = g;
232 state[7] = h;
233
234 in += 128;
235 inlen -= 128;
236 }
237
238 store_bigendian(statebytes + 0,state[0]);
239 store_bigendian(statebytes + 8,state[1]);
240 store_bigendian(statebytes + 16,state[2]);
241 store_bigendian(statebytes + 24,state[3]);
242 store_bigendian(statebytes + 32,state[4]);
243 store_bigendian(statebytes + 40,state[5]);
244 store_bigendian(statebytes + 48,state[6]);
245 store_bigendian(statebytes + 56,state[7]);
246
247 return inlen;
248}
diff --git a/bufaux.c b/bufaux.c
index de5b3ca1a..9401fe1d0 100644
--- a/bufaux.c
+++ b/bufaux.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bufaux.c,v 1.52 2013/07/12 00:19:58 djm Exp $ */ 1/* $OpenBSD: bufaux.c,v 1.54 2014/01/12 08:13: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
@@ -45,6 +45,7 @@
45 45
46#include <string.h> 46#include <string.h>
47#include <stdarg.h> 47#include <stdarg.h>
48#include <stdlib.h>
48 49
49#include "xmalloc.h" 50#include "xmalloc.h"
50#include "buffer.h" 51#include "buffer.h"
@@ -314,3 +315,76 @@ buffer_put_char(Buffer *buffer, int value)
314 315
315 buffer_append(buffer, &ch, 1); 316 buffer_append(buffer, &ch, 1);
316} 317}
318
319/* Pseudo bignum functions */
320
321void *
322buffer_get_bignum2_as_string_ret(Buffer *buffer, u_int *length_ptr)
323{
324 u_int len;
325 u_char *bin, *p, *ret;
326
327 if ((p = bin = buffer_get_string_ret(buffer, &len)) == NULL) {
328 error("%s: invalid bignum", __func__);
329 return NULL;
330 }
331
332 if (len > 0 && (bin[0] & 0x80)) {
333 error("%s: negative numbers not supported", __func__);
334 free(bin);
335 return NULL;
336 }
337 if (len > 8 * 1024) {
338 error("%s: cannot handle BN of size %d", __func__, len);
339 free(bin);
340 return NULL;
341 }
342 /* Skip zero prefix on numbers with the MSB set */
343 if (len > 1 && bin[0] == 0x00 && (bin[1] & 0x80) != 0) {
344 p++;
345 len--;
346 }
347 ret = xmalloc(len);
348 memcpy(ret, p, len);
349 memset(p, '\0', len);
350 free(bin);
351 return ret;
352}
353
354void *
355buffer_get_bignum2_as_string(Buffer *buffer, u_int *l)
356{
357 void *ret = buffer_get_bignum2_as_string_ret(buffer, l);
358
359 if (ret == NULL)
360 fatal("%s: buffer error", __func__);
361 return ret;
362}
363
364/*
365 * Stores a string using the bignum encoding rules (\0 pad if MSB set).
366 */
367void
368buffer_put_bignum2_from_string(Buffer *buffer, const u_char *s, u_int l)
369{
370 u_char *buf, *p;
371 int pad = 0;
372
373 if (l > 8 * 1024)
374 fatal("%s: length %u too long", __func__, l);
375 p = buf = xmalloc(l + 1);
376 /*
377 * If most significant bit is set then prepend a zero byte to
378 * avoid interpretation as a negative number.
379 */
380 if (l > 0 && (s[0] & 0x80) != 0) {
381 *p++ = '\0';
382 pad = 1;
383 }
384 memcpy(p, s, l);
385 buffer_put_string(buffer, buf, l + pad);
386 memset(buf, '\0', l + pad);
387 free(buf);
388}
389
390
diff --git a/bufbn.c b/bufbn.c
index 1fbfbbcc9..2ebc80a27 100644
--- a/bufbn.c
+++ b/bufbn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bufbn.c,v 1.7 2013/05/17 00:13:13 djm Exp $*/ 1/* $OpenBSD: bufbn.c,v 1.8 2013/11/08 11:15:19 dtucker 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
@@ -45,6 +45,7 @@
45 45
46#include <string.h> 46#include <string.h>
47#include <stdarg.h> 47#include <stdarg.h>
48#include <stdlib.h>
48 49
49#include "xmalloc.h" 50#include "xmalloc.h"
50#include "buffer.h" 51#include "buffer.h"
diff --git a/buffer.c b/buffer.c
index 007e7f94e..9e7c40a5a 100644
--- a/buffer.c
+++ b/buffer.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: buffer.c,v 1.33 2013/05/17 00:13:13 djm Exp $ */ 1/* $OpenBSD: buffer.c,v 1.34 2013/11/08 11:15:19 dtucker 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,7 @@
19#include <stdio.h> 19#include <stdio.h>
20#include <string.h> 20#include <string.h>
21#include <stdarg.h> 21#include <stdarg.h>
22#include <stdlib.h>
22 23
23#include "xmalloc.h" 24#include "xmalloc.h"
24#include "buffer.h" 25#include "buffer.h"
diff --git a/buffer.h b/buffer.h
index 4fa2ca112..7df8a38fa 100644
--- a/buffer.h
+++ b/buffer.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: buffer.h,v 1.22 2013/07/12 00:19:58 djm Exp $ */ 1/* $OpenBSD: buffer.h,v 1.23 2014/01/12 08:13:13 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -86,6 +86,10 @@ char *buffer_get_cstring_ret(Buffer *, u_int *);
86void *buffer_get_string_ptr_ret(Buffer *, u_int *); 86void *buffer_get_string_ptr_ret(Buffer *, u_int *);
87int buffer_get_char_ret(u_char *, Buffer *); 87int buffer_get_char_ret(u_char *, Buffer *);
88 88
89void *buffer_get_bignum2_as_string_ret(Buffer *, u_int *);
90void *buffer_get_bignum2_as_string(Buffer *, u_int *);
91void buffer_put_bignum2_from_string(Buffer *, const u_char *, u_int);
92
89#ifdef OPENSSL_HAS_ECC 93#ifdef OPENSSL_HAS_ECC
90#include <openssl/ec.h> 94#include <openssl/ec.h>
91 95
diff --git a/canohost.c b/canohost.c
index 69e8e6f6d..a19a60cda 100644
--- a/canohost.c
+++ b/canohost.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: canohost.c,v 1.67 2013/05/17 00:13:13 djm Exp $ */ 1/* $OpenBSD: canohost.c,v 1.70 2014/01/19 04:17:29 dtucker 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
@@ -20,7 +20,6 @@
20#include <netinet/in.h> 20#include <netinet/in.h>
21#include <arpa/inet.h> 21#include <arpa/inet.h>
22 22
23#include <ctype.h>
24#include <errno.h> 23#include <errno.h>
25#include <netdb.h> 24#include <netdb.h>
26#include <stdio.h> 25#include <stdio.h>
@@ -48,7 +47,6 @@ static char *
48get_remote_hostname(int sock, int use_dns) 47get_remote_hostname(int sock, int use_dns)
49{ 48{
50 struct sockaddr_storage from; 49 struct sockaddr_storage from;
51 int i;
52 socklen_t fromlen; 50 socklen_t fromlen;
53 struct addrinfo hints, *ai, *aitop; 51 struct addrinfo hints, *ai, *aitop;
54 char name[NI_MAXHOST], ntop[NI_MAXHOST], ntop2[NI_MAXHOST]; 52 char name[NI_MAXHOST], ntop[NI_MAXHOST], ntop2[NI_MAXHOST];
@@ -99,13 +97,9 @@ get_remote_hostname(int sock, int use_dns)
99 return xstrdup(ntop); 97 return xstrdup(ntop);
100 } 98 }
101 99
102 /* 100 /* Names are stores in lowercase. */
103 * Convert it to all lowercase (which is expected by the rest 101 lowercase(name);
104 * of this software). 102
105 */
106 for (i = 0; name[i]; i++)
107 if (isupper(name[i]))
108 name[i] = (char)tolower(name[i]);
109 /* 103 /*
110 * Map it back to an IP address and check that the given 104 * Map it back to an IP address and check that the given
111 * address actually is an address of this host. This is 105 * address actually is an address of this host. This is
@@ -160,8 +154,7 @@ check_ip_options(int sock, char *ipaddr)
160#ifdef IP_OPTIONS 154#ifdef IP_OPTIONS
161 u_char options[200]; 155 u_char options[200];
162 char text[sizeof(options) * 3 + 1]; 156 char text[sizeof(options) * 3 + 1];
163 socklen_t option_size; 157 socklen_t option_size, i;
164 u_int i;
165 int ipproto; 158 int ipproto;
166 struct protoent *ip; 159 struct protoent *ip;
167 160
diff --git a/chacha.c b/chacha.c
new file mode 100644
index 000000000..a84c25ea8
--- /dev/null
+++ b/chacha.c
@@ -0,0 +1,219 @@
1/*
2chacha-merged.c version 20080118
3D. J. Bernstein
4Public domain.
5*/
6
7#include "includes.h"
8
9#include "chacha.h"
10
11/* $OpenBSD: chacha.c,v 1.1 2013/11/21 00:45:44 djm Exp $ */
12
13typedef unsigned char u8;
14typedef unsigned int u32;
15
16typedef struct chacha_ctx chacha_ctx;
17
18#define U8C(v) (v##U)
19#define U32C(v) (v##U)
20
21#define U8V(v) ((u8)(v) & U8C(0xFF))
22#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
23
24#define ROTL32(v, n) \
25 (U32V((v) << (n)) | ((v) >> (32 - (n))))
26
27#define U8TO32_LITTLE(p) \
28 (((u32)((p)[0]) ) | \
29 ((u32)((p)[1]) << 8) | \
30 ((u32)((p)[2]) << 16) | \
31 ((u32)((p)[3]) << 24))
32
33#define U32TO8_LITTLE(p, v) \
34 do { \
35 (p)[0] = U8V((v) ); \
36 (p)[1] = U8V((v) >> 8); \
37 (p)[2] = U8V((v) >> 16); \
38 (p)[3] = U8V((v) >> 24); \
39 } while (0)
40
41#define ROTATE(v,c) (ROTL32(v,c))
42#define XOR(v,w) ((v) ^ (w))
43#define PLUS(v,w) (U32V((v) + (w)))
44#define PLUSONE(v) (PLUS((v),1))
45
46#define QUARTERROUND(a,b,c,d) \
47 a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
48 c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
49 a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
50 c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
51
52static const char sigma[16] = "expand 32-byte k";
53static const char tau[16] = "expand 16-byte k";
54
55void
56chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits)
57{
58 const char *constants;
59
60 x->input[4] = U8TO32_LITTLE(k + 0);
61 x->input[5] = U8TO32_LITTLE(k + 4);
62 x->input[6] = U8TO32_LITTLE(k + 8);
63 x->input[7] = U8TO32_LITTLE(k + 12);
64 if (kbits == 256) { /* recommended */
65 k += 16;
66 constants = sigma;
67 } else { /* kbits == 128 */
68 constants = tau;
69 }
70 x->input[8] = U8TO32_LITTLE(k + 0);
71 x->input[9] = U8TO32_LITTLE(k + 4);
72 x->input[10] = U8TO32_LITTLE(k + 8);
73 x->input[11] = U8TO32_LITTLE(k + 12);
74 x->input[0] = U8TO32_LITTLE(constants + 0);
75 x->input[1] = U8TO32_LITTLE(constants + 4);
76 x->input[2] = U8TO32_LITTLE(constants + 8);
77 x->input[3] = U8TO32_LITTLE(constants + 12);
78}
79
80void
81chacha_ivsetup(chacha_ctx *x, const u8 *iv, const u8 *counter)
82{
83 x->input[12] = counter == NULL ? 0 : U8TO32_LITTLE(counter + 0);
84 x->input[13] = counter == NULL ? 0 : U8TO32_LITTLE(counter + 4);
85 x->input[14] = U8TO32_LITTLE(iv + 0);
86 x->input[15] = U8TO32_LITTLE(iv + 4);
87}
88
89void
90chacha_encrypt_bytes(chacha_ctx *x,const u8 *m,u8 *c,u32 bytes)
91{
92 u32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
93 u32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
94 u8 *ctarget = NULL;
95 u8 tmp[64];
96 u_int i;
97
98 if (!bytes) return;
99
100 j0 = x->input[0];
101 j1 = x->input[1];
102 j2 = x->input[2];
103 j3 = x->input[3];
104 j4 = x->input[4];
105 j5 = x->input[5];
106 j6 = x->input[6];
107 j7 = x->input[7];
108 j8 = x->input[8];
109 j9 = x->input[9];
110 j10 = x->input[10];
111 j11 = x->input[11];
112 j12 = x->input[12];
113 j13 = x->input[13];
114 j14 = x->input[14];
115 j15 = x->input[15];
116
117 for (;;) {
118 if (bytes < 64) {
119 for (i = 0;i < bytes;++i) tmp[i] = m[i];
120 m = tmp;
121 ctarget = c;
122 c = tmp;
123 }
124 x0 = j0;
125 x1 = j1;
126 x2 = j2;
127 x3 = j3;
128 x4 = j4;
129 x5 = j5;
130 x6 = j6;
131 x7 = j7;
132 x8 = j8;
133 x9 = j9;
134 x10 = j10;
135 x11 = j11;
136 x12 = j12;
137 x13 = j13;
138 x14 = j14;
139 x15 = j15;
140 for (i = 20;i > 0;i -= 2) {
141 QUARTERROUND( x0, x4, x8,x12)
142 QUARTERROUND( x1, x5, x9,x13)
143 QUARTERROUND( x2, x6,x10,x14)
144 QUARTERROUND( x3, x7,x11,x15)
145 QUARTERROUND( x0, x5,x10,x15)
146 QUARTERROUND( x1, x6,x11,x12)
147 QUARTERROUND( x2, x7, x8,x13)
148 QUARTERROUND( x3, x4, x9,x14)
149 }
150 x0 = PLUS(x0,j0);
151 x1 = PLUS(x1,j1);
152 x2 = PLUS(x2,j2);
153 x3 = PLUS(x3,j3);
154 x4 = PLUS(x4,j4);
155 x5 = PLUS(x5,j5);
156 x6 = PLUS(x6,j6);
157 x7 = PLUS(x7,j7);
158 x8 = PLUS(x8,j8);
159 x9 = PLUS(x9,j9);
160 x10 = PLUS(x10,j10);
161 x11 = PLUS(x11,j11);
162 x12 = PLUS(x12,j12);
163 x13 = PLUS(x13,j13);
164 x14 = PLUS(x14,j14);
165 x15 = PLUS(x15,j15);
166
167 x0 = XOR(x0,U8TO32_LITTLE(m + 0));
168 x1 = XOR(x1,U8TO32_LITTLE(m + 4));
169 x2 = XOR(x2,U8TO32_LITTLE(m + 8));
170 x3 = XOR(x3,U8TO32_LITTLE(m + 12));
171 x4 = XOR(x4,U8TO32_LITTLE(m + 16));
172 x5 = XOR(x5,U8TO32_LITTLE(m + 20));
173 x6 = XOR(x6,U8TO32_LITTLE(m + 24));
174 x7 = XOR(x7,U8TO32_LITTLE(m + 28));
175 x8 = XOR(x8,U8TO32_LITTLE(m + 32));
176 x9 = XOR(x9,U8TO32_LITTLE(m + 36));
177 x10 = XOR(x10,U8TO32_LITTLE(m + 40));
178 x11 = XOR(x11,U8TO32_LITTLE(m + 44));
179 x12 = XOR(x12,U8TO32_LITTLE(m + 48));
180 x13 = XOR(x13,U8TO32_LITTLE(m + 52));
181 x14 = XOR(x14,U8TO32_LITTLE(m + 56));
182 x15 = XOR(x15,U8TO32_LITTLE(m + 60));
183
184 j12 = PLUSONE(j12);
185 if (!j12) {
186 j13 = PLUSONE(j13);
187 /* stopping at 2^70 bytes per nonce is user's responsibility */
188 }
189
190 U32TO8_LITTLE(c + 0,x0);
191 U32TO8_LITTLE(c + 4,x1);
192 U32TO8_LITTLE(c + 8,x2);
193 U32TO8_LITTLE(c + 12,x3);
194 U32TO8_LITTLE(c + 16,x4);
195 U32TO8_LITTLE(c + 20,x5);
196 U32TO8_LITTLE(c + 24,x6);
197 U32TO8_LITTLE(c + 28,x7);
198 U32TO8_LITTLE(c + 32,x8);
199 U32TO8_LITTLE(c + 36,x9);
200 U32TO8_LITTLE(c + 40,x10);
201 U32TO8_LITTLE(c + 44,x11);
202 U32TO8_LITTLE(c + 48,x12);
203 U32TO8_LITTLE(c + 52,x13);
204 U32TO8_LITTLE(c + 56,x14);
205 U32TO8_LITTLE(c + 60,x15);
206
207 if (bytes <= 64) {
208 if (bytes < 64) {
209 for (i = 0;i < bytes;++i) ctarget[i] = c[i];
210 }
211 x->input[12] = j12;
212 x->input[13] = j13;
213 return;
214 }
215 bytes -= 64;
216 c += 64;
217 m += 64;
218 }
219}
diff --git a/chacha.h b/chacha.h
new file mode 100644
index 000000000..4ef42cc70
--- /dev/null
+++ b/chacha.h
@@ -0,0 +1,35 @@
1/* $OpenBSD: chacha.h,v 1.1 2013/11/21 00:45:44 djm Exp $ */
2
3/*
4chacha-merged.c version 20080118
5D. J. Bernstein
6Public domain.
7*/
8
9#ifndef CHACHA_H
10#define CHACHA_H
11
12#include <sys/types.h>
13
14struct chacha_ctx {
15 u_int input[16];
16};
17
18#define CHACHA_MINKEYLEN 16
19#define CHACHA_NONCELEN 8
20#define CHACHA_CTRLEN 8
21#define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN)
22#define CHACHA_BLOCKLEN 64
23
24void chacha_keysetup(struct chacha_ctx *x, const u_char *k, u_int kbits)
25 __attribute__((__bounded__(__minbytes__, 2, CHACHA_MINKEYLEN)));
26void chacha_ivsetup(struct chacha_ctx *x, const u_char *iv, const u_char *ctr)
27 __attribute__((__bounded__(__minbytes__, 2, CHACHA_NONCELEN)))
28 __attribute__((__bounded__(__minbytes__, 3, CHACHA_CTRLEN)));
29void chacha_encrypt_bytes(struct chacha_ctx *x, const u_char *m,
30 u_char *c, u_int bytes)
31 __attribute__((__bounded__(__buffer__, 2, 4)))
32 __attribute__((__bounded__(__buffer__, 3, 4)));
33
34#endif /* CHACHA_H */
35
diff --git a/channels.c b/channels.c
index a1c31d8a0..e741f29b9 100644
--- a/channels.c
+++ b/channels.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: channels.c,v 1.327 2013/11/08 00:39:15 djm Exp $ */ 1/* $OpenBSD: channels.c,v 1.328 2013/12/19 01:04: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
@@ -1385,6 +1385,8 @@ port_open_helper(Channel *c, char *rtype)
1385{ 1385{
1386 int direct; 1386 int direct;
1387 char buf[1024]; 1387 char buf[1024];
1388 char *local_ipaddr = get_local_ipaddr(c->sock);
1389 int local_port = get_sock_port(c->sock, 1);
1388 char *remote_ipaddr = get_peer_ipaddr(c->sock); 1390 char *remote_ipaddr = get_peer_ipaddr(c->sock);
1389 int remote_port = get_peer_port(c->sock); 1391 int remote_port = get_peer_port(c->sock);
1390 1392
@@ -1399,9 +1401,9 @@ port_open_helper(Channel *c, char *rtype)
1399 1401
1400 snprintf(buf, sizeof buf, 1402 snprintf(buf, sizeof buf,
1401 "%s: listening port %d for %.100s port %d, " 1403 "%s: listening port %d for %.100s port %d, "
1402 "connect from %.200s port %d", 1404 "connect from %.200s port %d to %.100s port %d",
1403 rtype, c->listening_port, c->path, c->host_port, 1405 rtype, c->listening_port, c->path, c->host_port,
1404 remote_ipaddr, remote_port); 1406 remote_ipaddr, remote_port, local_ipaddr, local_port);
1405 1407
1406 free(c->remote_name); 1408 free(c->remote_name);
1407 c->remote_name = xstrdup(buf); 1409 c->remote_name = xstrdup(buf);
@@ -1419,7 +1421,7 @@ port_open_helper(Channel *c, char *rtype)
1419 } else { 1421 } else {
1420 /* listen address, port */ 1422 /* listen address, port */
1421 packet_put_cstring(c->path); 1423 packet_put_cstring(c->path);
1422 packet_put_int(c->listening_port); 1424 packet_put_int(local_port);
1423 } 1425 }
1424 /* originator host and port */ 1426 /* originator host and port */
1425 packet_put_cstring(remote_ipaddr); 1427 packet_put_cstring(remote_ipaddr);
@@ -1436,6 +1438,7 @@ port_open_helper(Channel *c, char *rtype)
1436 packet_send(); 1438 packet_send();
1437 } 1439 }
1438 free(remote_ipaddr); 1440 free(remote_ipaddr);
1441 free(local_ipaddr);
1439} 1442}
1440 1443
1441static void 1444static void
@@ -2710,8 +2713,20 @@ channel_fwd_bind_addr(const char *listen_addr, int *wildcardp,
2710 if (((datafellows & SSH_OLD_FORWARD_ADDR) && 2713 if (((datafellows & SSH_OLD_FORWARD_ADDR) &&
2711 strcmp(listen_addr, "0.0.0.0") == 0 && is_client == 0) || 2714 strcmp(listen_addr, "0.0.0.0") == 0 && is_client == 0) ||
2712 *listen_addr == '\0' || strcmp(listen_addr, "*") == 0 || 2715 *listen_addr == '\0' || strcmp(listen_addr, "*") == 0 ||
2713 (!is_client && gateway_ports == 1)) 2716 (!is_client && gateway_ports == 1)) {
2714 wildcard = 1; 2717 wildcard = 1;
2718 /*
2719 * Notify client if they requested a specific listen
2720 * address and it was overridden.
2721 */
2722 if (*listen_addr != '\0' &&
2723 strcmp(listen_addr, "0.0.0.0") != 0 &&
2724 strcmp(listen_addr, "*") != 0) {
2725 packet_send_debug("Forwarding listen address "
2726 "\"%s\" overridden by server "
2727 "GatewayPorts", listen_addr);
2728 }
2729 }
2715 else if (strcmp(listen_addr, "localhost") != 0) 2730 else if (strcmp(listen_addr, "localhost") != 0)
2716 addr = listen_addr; 2731 addr = listen_addr;
2717 } 2732 }
diff --git a/cipher-chachapoly.c b/cipher-chachapoly.c
new file mode 100644
index 000000000..91b0830fd
--- /dev/null
+++ b/cipher-chachapoly.c
@@ -0,0 +1,114 @@
1/*
2 * Copyright (c) 2013 Damien Miller <djm@mindrot.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17/* $OpenBSD: cipher-chachapoly.c,v 1.3 2013/12/15 21:42:35 djm Exp $ */
18
19#include "includes.h"
20
21#include <sys/types.h>
22#include <stdarg.h> /* needed for log.h */
23#include <string.h>
24#include <stdio.h> /* needed for misc.h */
25
26#include "log.h"
27#include "misc.h"
28#include "cipher-chachapoly.h"
29
30void chachapoly_init(struct chachapoly_ctx *ctx,
31 const u_char *key, u_int keylen)
32{
33 if (keylen != (32 + 32)) /* 2 x 256 bit keys */
34 fatal("%s: invalid keylen %u", __func__, keylen);
35 chacha_keysetup(&ctx->main_ctx, key, 256);
36 chacha_keysetup(&ctx->header_ctx, key + 32, 256);
37}
38
39/*
40 * chachapoly_crypt() operates as following:
41 * En/decrypt with header key 'aadlen' bytes from 'src', storing result
42 * to 'dest'. The ciphertext here is treated as additional authenticated
43 * data for MAC calculation.
44 * En/decrypt 'len' bytes at offset 'aadlen' from 'src' to 'dest'. Use
45 * POLY1305_TAGLEN bytes at offset 'len'+'aadlen' as the authentication
46 * tag. This tag is written on encryption and verified on decryption.
47 */
48int
49chachapoly_crypt(struct chachapoly_ctx *ctx, u_int seqnr, u_char *dest,
50 const u_char *src, u_int len, u_int aadlen, u_int authlen, int do_encrypt)
51{
52 u_char seqbuf[8];
53 const u_char one[8] = { 1, 0, 0, 0, 0, 0, 0, 0 }; /* NB little-endian */
54 u_char expected_tag[POLY1305_TAGLEN], poly_key[POLY1305_KEYLEN];
55 int r = -1;
56
57 /*
58 * Run ChaCha20 once to generate the Poly1305 key. The IV is the
59 * packet sequence number.
60 */
61 bzero(poly_key, sizeof(poly_key));
62 put_u64(seqbuf, seqnr);
63 chacha_ivsetup(&ctx->main_ctx, seqbuf, NULL);
64 chacha_encrypt_bytes(&ctx->main_ctx,
65 poly_key, poly_key, sizeof(poly_key));
66 /* Set Chacha's block counter to 1 */
67 chacha_ivsetup(&ctx->main_ctx, seqbuf, one);
68
69 /* If decrypting, check tag before anything else */
70 if (!do_encrypt) {
71 const u_char *tag = src + aadlen + len;
72
73 poly1305_auth(expected_tag, src, aadlen + len, poly_key);
74 if (timingsafe_bcmp(expected_tag, tag, POLY1305_TAGLEN) != 0)
75 goto out;
76 }
77 /* Crypt additional data */
78 if (aadlen) {
79 chacha_ivsetup(&ctx->header_ctx, seqbuf, NULL);
80 chacha_encrypt_bytes(&ctx->header_ctx, src, dest, aadlen);
81 }
82 chacha_encrypt_bytes(&ctx->main_ctx, src + aadlen,
83 dest + aadlen, len);
84
85 /* If encrypting, calculate and append tag */
86 if (do_encrypt) {
87 poly1305_auth(dest + aadlen + len, dest, aadlen + len,
88 poly_key);
89 }
90 r = 0;
91
92 out:
93 bzero(expected_tag, sizeof(expected_tag));
94 bzero(seqbuf, sizeof(seqbuf));
95 bzero(poly_key, sizeof(poly_key));
96 return r;
97}
98
99/* Decrypt and extract the encrypted packet length */
100int
101chachapoly_get_length(struct chachapoly_ctx *ctx,
102 u_int *plenp, u_int seqnr, const u_char *cp, u_int len)
103{
104 u_char buf[4], seqbuf[8];
105
106 if (len < 4)
107 return -1; /* Insufficient length */
108 put_u64(seqbuf, seqnr);
109 chacha_ivsetup(&ctx->header_ctx, seqbuf, NULL);
110 chacha_encrypt_bytes(&ctx->header_ctx, cp, buf, 4);
111 *plenp = get_u32(buf);
112 return 0;
113}
114
diff --git a/cipher-chachapoly.h b/cipher-chachapoly.h
new file mode 100644
index 000000000..1628693b2
--- /dev/null
+++ b/cipher-chachapoly.h
@@ -0,0 +1,41 @@
1/* $OpenBSD: cipher-chachapoly.h,v 1.1 2013/11/21 00:45:44 djm Exp $ */
2
3/*
4 * Copyright (c) Damien Miller 2013 <djm@mindrot.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18#ifndef CHACHA_POLY_AEAD_H
19#define CHACHA_POLY_AEAD_H
20
21#include <sys/types.h>
22#include "chacha.h"
23#include "poly1305.h"
24
25#define CHACHA_KEYLEN 32 /* Only 256 bit keys used here */
26
27struct chachapoly_ctx {
28 struct chacha_ctx main_ctx, header_ctx;
29};
30
31void chachapoly_init(struct chachapoly_ctx *cpctx,
32 const u_char *key, u_int keylen)
33 __attribute__((__bounded__(__buffer__, 2, 3)));
34int chachapoly_crypt(struct chachapoly_ctx *cpctx, u_int seqnr,
35 u_char *dest, const u_char *src, u_int len, u_int aadlen, u_int authlen,
36 int do_encrypt);
37int chachapoly_get_length(struct chachapoly_ctx *cpctx,
38 u_int *plenp, u_int seqnr, const u_char *cp, u_int len)
39 __attribute__((__bounded__(__buffer__, 4, 5)));
40
41#endif /* CHACHA_POLY_AEAD_H */
diff --git a/cipher.c b/cipher.c
index a2cbe2bea..2476e6539 100644
--- a/cipher.c
+++ b/cipher.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cipher.c,v 1.89 2013/05/17 00:13:13 djm Exp $ */ 1/* $OpenBSD: cipher.c,v 1.94 2014/01/25 10:12:50 dtucker 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
@@ -43,9 +43,11 @@
43 43
44#include <string.h> 44#include <string.h>
45#include <stdarg.h> 45#include <stdarg.h>
46#include <stdio.h>
46 47
47#include "xmalloc.h" 48#include "xmalloc.h"
48#include "log.h" 49#include "log.h"
50#include "misc.h"
49#include "cipher.h" 51#include "cipher.h"
50 52
51/* compatibility with old or broken OpenSSL versions */ 53/* compatibility with old or broken OpenSSL versions */
@@ -63,7 +65,9 @@ struct Cipher {
63 u_int iv_len; /* defaults to block_size */ 65 u_int iv_len; /* defaults to block_size */
64 u_int auth_len; 66 u_int auth_len;
65 u_int discard_len; 67 u_int discard_len;
66 u_int cbc_mode; 68 u_int flags;
69#define CFLAG_CBC (1<<0)
70#define CFLAG_CHACHAPOLY (1<<1)
67 const EVP_CIPHER *(*evptype)(void); 71 const EVP_CIPHER *(*evptype)(void);
68}; 72};
69 73
@@ -95,14 +99,16 @@ static const struct Cipher ciphers[] = {
95 { "aes256-gcm@openssh.com", 99 { "aes256-gcm@openssh.com",
96 SSH_CIPHER_SSH2, 16, 32, 12, 16, 0, 0, EVP_aes_256_gcm }, 100 SSH_CIPHER_SSH2, 16, 32, 12, 16, 0, 0, EVP_aes_256_gcm },
97#endif 101#endif
102 { "chacha20-poly1305@openssh.com",
103 SSH_CIPHER_SSH2, 8, 64, 0, 16, 0, CFLAG_CHACHAPOLY, NULL },
98 { NULL, SSH_CIPHER_INVALID, 0, 0, 0, 0, 0, 0, NULL } 104 { NULL, SSH_CIPHER_INVALID, 0, 0, 0, 0, 0, 0, NULL }
99}; 105};
100 106
101/*--*/ 107/*--*/
102 108
103/* Returns a comma-separated list of supported ciphers. */ 109/* Returns a list of supported ciphers separated by the specified char. */
104char * 110char *
105cipher_alg_list(void) 111cipher_alg_list(char sep, int auth_only)
106{ 112{
107 char *ret = NULL; 113 char *ret = NULL;
108 size_t nlen, rlen = 0; 114 size_t nlen, rlen = 0;
@@ -111,8 +117,10 @@ cipher_alg_list(void)
111 for (c = ciphers; c->name != NULL; c++) { 117 for (c = ciphers; c->name != NULL; c++) {
112 if (c->number != SSH_CIPHER_SSH2) 118 if (c->number != SSH_CIPHER_SSH2)
113 continue; 119 continue;
120 if (auth_only && c->auth_len == 0)
121 continue;
114 if (ret != NULL) 122 if (ret != NULL)
115 ret[rlen++] = '\n'; 123 ret[rlen++] = sep;
116 nlen = strlen(c->name); 124 nlen = strlen(c->name);
117 ret = xrealloc(ret, 1, rlen + nlen + 2); 125 ret = xrealloc(ret, 1, rlen + nlen + 2);
118 memcpy(ret + rlen, c->name, nlen + 1); 126 memcpy(ret + rlen, c->name, nlen + 1);
@@ -134,6 +142,14 @@ cipher_keylen(const Cipher *c)
134} 142}
135 143
136u_int 144u_int
145cipher_seclen(const Cipher *c)
146{
147 if (strcmp("3des-cbc", c->name) == 0)
148 return 14;
149 return cipher_keylen(c);
150}
151
152u_int
137cipher_authlen(const Cipher *c) 153cipher_authlen(const Cipher *c)
138{ 154{
139 return (c->auth_len); 155 return (c->auth_len);
@@ -142,7 +158,12 @@ cipher_authlen(const Cipher *c)
142u_int 158u_int
143cipher_ivlen(const Cipher *c) 159cipher_ivlen(const Cipher *c)
144{ 160{
145 return (c->iv_len ? c->iv_len : c->block_size); 161 /*
162 * Default is cipher block size, except for chacha20+poly1305 that
163 * needs no IV. XXX make iv_len == -1 default?
164 */
165 return (c->iv_len != 0 || (c->flags & CFLAG_CHACHAPOLY) != 0) ?
166 c->iv_len : c->block_size;
146} 167}
147 168
148u_int 169u_int
@@ -154,7 +175,7 @@ cipher_get_number(const Cipher *c)
154u_int 175u_int
155cipher_is_cbc(const Cipher *c) 176cipher_is_cbc(const Cipher *c)
156{ 177{
157 return (c->cbc_mode); 178 return (c->flags & CFLAG_CBC) != 0;
158} 179}
159 180
160u_int 181u_int
@@ -274,8 +295,11 @@ cipher_init(CipherContext *cc, const Cipher *cipher,
274 ivlen, cipher->name); 295 ivlen, cipher->name);
275 cc->cipher = cipher; 296 cc->cipher = cipher;
276 297
298 if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0) {
299 chachapoly_init(&cc->cp_ctx, key, keylen);
300 return;
301 }
277 type = (*cipher->evptype)(); 302 type = (*cipher->evptype)();
278
279 EVP_CIPHER_CTX_init(&cc->evp); 303 EVP_CIPHER_CTX_init(&cc->evp);
280#ifdef SSH_OLD_EVP 304#ifdef SSH_OLD_EVP
281 if (type->key_len > 0 && type->key_len != keylen) { 305 if (type->key_len > 0 && type->key_len != keylen) {
@@ -328,11 +352,16 @@ cipher_init(CipherContext *cc, const Cipher *cipher,
328 * Use 'authlen' bytes at offset 'len'+'aadlen' as the authentication tag. 352 * Use 'authlen' bytes at offset 'len'+'aadlen' as the authentication tag.
329 * This tag is written on encryption and verified on decryption. 353 * This tag is written on encryption and verified on decryption.
330 * Both 'aadlen' and 'authlen' can be set to 0. 354 * Both 'aadlen' and 'authlen' can be set to 0.
355 * cipher_crypt() returns 0 on success and -1 if the decryption integrity
356 * check fails.
331 */ 357 */
332void 358int
333cipher_crypt(CipherContext *cc, u_char *dest, const u_char *src, 359cipher_crypt(CipherContext *cc, u_int seqnr, u_char *dest, const u_char *src,
334 u_int len, u_int aadlen, u_int authlen) 360 u_int len, u_int aadlen, u_int authlen)
335{ 361{
362 if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0)
363 return chachapoly_crypt(&cc->cp_ctx, seqnr, dest, src, len,
364 aadlen, authlen, cc->encrypt);
336 if (authlen) { 365 if (authlen) {
337 u_char lastiv[1]; 366 u_char lastiv[1];
338 367
@@ -365,19 +394,36 @@ cipher_crypt(CipherContext *cc, u_char *dest, const u_char *src,
365 if (cc->encrypt) 394 if (cc->encrypt)
366 fatal("%s: EVP_Cipher(final) failed", __func__); 395 fatal("%s: EVP_Cipher(final) failed", __func__);
367 else 396 else
368 fatal("Decryption integrity check failed"); 397 return -1;
369 } 398 }
370 if (cc->encrypt && 399 if (cc->encrypt &&
371 !EVP_CIPHER_CTX_ctrl(&cc->evp, EVP_CTRL_GCM_GET_TAG, 400 !EVP_CIPHER_CTX_ctrl(&cc->evp, EVP_CTRL_GCM_GET_TAG,
372 authlen, dest + aadlen + len)) 401 authlen, dest + aadlen + len))
373 fatal("%s: EVP_CTRL_GCM_GET_TAG", __func__); 402 fatal("%s: EVP_CTRL_GCM_GET_TAG", __func__);
374 } 403 }
404 return 0;
405}
406
407/* Extract the packet length, including any decryption necessary beforehand */
408int
409cipher_get_length(CipherContext *cc, u_int *plenp, u_int seqnr,
410 const u_char *cp, u_int len)
411{
412 if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0)
413 return chachapoly_get_length(&cc->cp_ctx, plenp, seqnr,
414 cp, len);
415 if (len < 4)
416 return -1;
417 *plenp = get_u32(cp);
418 return 0;
375} 419}
376 420
377void 421void
378cipher_cleanup(CipherContext *cc) 422cipher_cleanup(CipherContext *cc)
379{ 423{
380 if (EVP_CIPHER_CTX_cleanup(&cc->evp) == 0) 424 if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0)
425 memset(&cc->cp_ctx, 0, sizeof(cc->cp_ctx));
426 else if (EVP_CIPHER_CTX_cleanup(&cc->evp) == 0)
381 error("cipher_cleanup: EVP_CIPHER_CTX_cleanup failed"); 427 error("cipher_cleanup: EVP_CIPHER_CTX_cleanup failed");
382} 428}
383 429
@@ -417,6 +463,8 @@ cipher_get_keyiv_len(const CipherContext *cc)
417 463
418 if (c->number == SSH_CIPHER_3DES) 464 if (c->number == SSH_CIPHER_3DES)
419 ivlen = 24; 465 ivlen = 24;
466 else if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0)
467 ivlen = 0;
420 else 468 else
421 ivlen = EVP_CIPHER_CTX_iv_length(&cc->evp); 469 ivlen = EVP_CIPHER_CTX_iv_length(&cc->evp);
422 return (ivlen); 470 return (ivlen);
@@ -428,6 +476,12 @@ cipher_get_keyiv(CipherContext *cc, u_char *iv, u_int len)
428 const Cipher *c = cc->cipher; 476 const Cipher *c = cc->cipher;
429 int evplen; 477 int evplen;
430 478
479 if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0) {
480 if (len != 0)
481 fatal("%s: wrong iv length %d != %d", __func__, len, 0);
482 return;
483 }
484
431 switch (c->number) { 485 switch (c->number) {
432 case SSH_CIPHER_SSH2: 486 case SSH_CIPHER_SSH2:
433 case SSH_CIPHER_DES: 487 case SSH_CIPHER_DES:
@@ -464,6 +518,9 @@ cipher_set_keyiv(CipherContext *cc, u_char *iv)
464 const Cipher *c = cc->cipher; 518 const Cipher *c = cc->cipher;
465 int evplen = 0; 519 int evplen = 0;
466 520
521 if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0)
522 return;
523
467 switch (c->number) { 524 switch (c->number) {
468 case SSH_CIPHER_SSH2: 525 case SSH_CIPHER_SSH2:
469 case SSH_CIPHER_DES: 526 case SSH_CIPHER_DES:
diff --git a/cipher.h b/cipher.h
index b878d50f4..133d2e73d 100644
--- a/cipher.h
+++ b/cipher.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: cipher.h,v 1.40 2013/04/19 01:06:50 djm Exp $ */ 1/* $OpenBSD: cipher.h,v 1.44 2014/01/25 10:12:50 dtucker Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -38,6 +38,8 @@
38#define CIPHER_H 38#define CIPHER_H
39 39
40#include <openssl/evp.h> 40#include <openssl/evp.h>
41#include "cipher-chachapoly.h"
42
41/* 43/*
42 * Cipher types for SSH-1. New types can be added, but old types should not 44 * Cipher types for SSH-1. New types can be added, but old types should not
43 * be removed for compatibility. The maximum allowed value is 31. 45 * be removed for compatibility. The maximum allowed value is 31.
@@ -66,6 +68,7 @@ struct CipherContext {
66 int plaintext; 68 int plaintext;
67 int encrypt; 69 int encrypt;
68 EVP_CIPHER_CTX evp; 70 EVP_CIPHER_CTX evp;
71 struct chachapoly_ctx cp_ctx; /* XXX union with evp? */
69 const Cipher *cipher; 72 const Cipher *cipher;
70}; 73};
71 74
@@ -75,15 +78,18 @@ const Cipher *cipher_by_number(int);
75int cipher_number(const char *); 78int cipher_number(const char *);
76char *cipher_name(int); 79char *cipher_name(int);
77int ciphers_valid(const char *); 80int ciphers_valid(const char *);
78char *cipher_alg_list(void); 81char *cipher_alg_list(char, int);
79void cipher_init(CipherContext *, const Cipher *, const u_char *, u_int, 82void cipher_init(CipherContext *, const Cipher *, const u_char *, u_int,
80 const u_char *, u_int, int); 83 const u_char *, u_int, int);
81void cipher_crypt(CipherContext *, u_char *, const u_char *, 84int cipher_crypt(CipherContext *, u_int, u_char *, const u_char *,
82 u_int, u_int, u_int); 85 u_int, u_int, u_int);
86int cipher_get_length(CipherContext *, u_int *, u_int,
87 const u_char *, u_int);
83void cipher_cleanup(CipherContext *); 88void cipher_cleanup(CipherContext *);
84void cipher_set_key_string(CipherContext *, const Cipher *, const char *, int); 89void cipher_set_key_string(CipherContext *, const Cipher *, const char *, int);
85u_int cipher_blocksize(const Cipher *); 90u_int cipher_blocksize(const Cipher *);
86u_int cipher_keylen(const Cipher *); 91u_int cipher_keylen(const Cipher *);
92u_int cipher_seclen(const Cipher *);
87u_int cipher_authlen(const Cipher *); 93u_int cipher_authlen(const Cipher *);
88u_int cipher_ivlen(const Cipher *); 94u_int cipher_ivlen(const Cipher *);
89u_int cipher_is_cbc(const Cipher *); 95u_int cipher_is_cbc(const Cipher *);
diff --git a/clientloop.c b/clientloop.c
index 23c2f2396..f30c8b6b5 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: clientloop.c,v 1.255 2013/11/08 00:39:15 djm Exp $ */ 1/* $OpenBSD: clientloop.c,v 1.256 2013/11/20 20:54:10 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
@@ -289,7 +289,7 @@ client_x11_display_valid(const char *display)
289 289
290 dlen = strlen(display); 290 dlen = strlen(display);
291 for (i = 0; i < dlen; i++) { 291 for (i = 0; i < dlen; i++) {
292 if (!isalnum(display[i]) && 292 if (!isalnum((u_char)display[i]) &&
293 strchr(SSH_X11_VALID_DISPLAY_CHARS, display[i]) == NULL) { 293 strchr(SSH_X11_VALID_DISPLAY_CHARS, display[i]) == NULL) {
294 debug("Invalid character '%c' in DISPLAY", display[i]); 294 debug("Invalid character '%c' in DISPLAY", display[i]);
295 return 0; 295 return 0;
@@ -884,7 +884,7 @@ process_cmdline(void)
884 cmd = s = read_passphrase("\r\nssh> ", RP_ECHO); 884 cmd = s = read_passphrase("\r\nssh> ", RP_ECHO);
885 if (s == NULL) 885 if (s == NULL)
886 goto out; 886 goto out;
887 while (isspace(*s)) 887 while (isspace((u_char)*s))
888 s++; 888 s++;
889 if (*s == '-') 889 if (*s == '-')
890 s++; /* Skip cmdline '-', if any */ 890 s++; /* Skip cmdline '-', if any */
@@ -938,7 +938,7 @@ process_cmdline(void)
938 goto out; 938 goto out;
939 } 939 }
940 940
941 while (isspace(*++s)) 941 while (isspace((u_char)*++s))
942 ; 942 ;
943 943
944 /* XXX update list of forwards in options */ 944 /* XXX update list of forwards in options */
@@ -1153,7 +1153,7 @@ process_escapes(Channel *c, Buffer *bin, Buffer *bout, Buffer *berr,
1153 "%cB\r\n", escape_char); 1153 "%cB\r\n", escape_char);
1154 buffer_append(berr, string, 1154 buffer_append(berr, string,
1155 strlen(string)); 1155 strlen(string));
1156 channel_request_start(session_ident, 1156 channel_request_start(c->self,
1157 "break", 0); 1157 "break", 0);
1158 packet_put_int(1000); 1158 packet_put_int(1000);
1159 packet_send(); 1159 packet_send();
diff --git a/compat.c b/compat.c
index ac353a706..9d9fabef3 100644
--- a/compat.c
+++ b/compat.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: compat.c,v 1.81 2013/05/17 00:13:13 djm Exp $ */ 1/* $OpenBSD: compat.c,v 1.82 2013/12/30 23:52:27 djm Exp $ */
2/* 2/*
3 * Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved. 3 * Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved.
4 * 4 *
@@ -171,8 +171,9 @@ compat_datafellows(const char *version)
171 for (i = 0; check[i].pat; i++) { 171 for (i = 0; check[i].pat; i++) {
172 if (match_pattern_list(version, check[i].pat, 172 if (match_pattern_list(version, check[i].pat,
173 strlen(check[i].pat), 0) == 1) { 173 strlen(check[i].pat), 0) == 1) {
174 debug("match: %s pat %s", version, check[i].pat);
175 datafellows = check[i].bugs; 174 datafellows = check[i].bugs;
175 debug("match: %s pat %s compat 0x%08x",
176 version, check[i].pat, datafellows);
176 return; 177 return;
177 } 178 }
178 } 179 }
@@ -208,33 +209,59 @@ proto_spec(const char *spec)
208 return ret; 209 return ret;
209} 210}
210 211
211char * 212/*
212compat_cipher_proposal(char *cipher_prop) 213 * Filters a proposal string, excluding any algorithm matching the 'filter'
214 * pattern list.
215 */
216static char *
217filter_proposal(char *proposal, const char *filter)
213{ 218{
214 Buffer b; 219 Buffer b;
215 char *orig_prop, *fix_ciphers; 220 char *orig_prop, *fix_prop;
216 char *cp, *tmp; 221 char *cp, *tmp;
217 222
218 if (!(datafellows & SSH_BUG_BIGENDIANAES))
219 return(cipher_prop);
220
221 buffer_init(&b); 223 buffer_init(&b);
222 tmp = orig_prop = xstrdup(cipher_prop); 224 tmp = orig_prop = xstrdup(proposal);
223 while ((cp = strsep(&tmp, ",")) != NULL) { 225 while ((cp = strsep(&tmp, ",")) != NULL) {
224 if (strncmp(cp, "aes", 3) != 0) { 226 if (match_pattern_list(cp, filter, strlen(cp), 0) != 1) {
225 if (buffer_len(&b) > 0) 227 if (buffer_len(&b) > 0)
226 buffer_append(&b, ",", 1); 228 buffer_append(&b, ",", 1);
227 buffer_append(&b, cp, strlen(cp)); 229 buffer_append(&b, cp, strlen(cp));
228 } 230 } else
231 debug2("Compat: skipping algorithm \"%s\"", cp);
229 } 232 }
230 buffer_append(&b, "\0", 1); 233 buffer_append(&b, "\0", 1);
231 fix_ciphers = xstrdup(buffer_ptr(&b)); 234 fix_prop = xstrdup(buffer_ptr(&b));
232 buffer_free(&b); 235 buffer_free(&b);
233 free(orig_prop); 236 free(orig_prop);
234 debug2("Original cipher proposal: %s", cipher_prop);
235 debug2("Compat cipher proposal: %s", fix_ciphers);
236 if (!*fix_ciphers)
237 fatal("No available ciphers found.");
238 237
239 return(fix_ciphers); 238 return fix_prop;
240} 239}
240
241char *
242compat_cipher_proposal(char *cipher_prop)
243{
244 if (!(datafellows & SSH_BUG_BIGENDIANAES))
245 return cipher_prop;
246 debug2("%s: original cipher proposal: %s", __func__, cipher_prop);
247 cipher_prop = filter_proposal(cipher_prop, "aes*");
248 debug2("%s: compat cipher proposal: %s", __func__, cipher_prop);
249 if (*cipher_prop == '\0')
250 fatal("No supported ciphers found");
251 return cipher_prop;
252}
253
254
255char *
256compat_pkalg_proposal(char *pkalg_prop)
257{
258 if (!(datafellows & SSH_BUG_RSASIGMD5))
259 return pkalg_prop;
260 debug2("%s: original public key proposal: %s", __func__, pkalg_prop);
261 pkalg_prop = filter_proposal(pkalg_prop, "ssh-rsa");
262 debug2("%s: compat public key proposal: %s", __func__, pkalg_prop);
263 if (*pkalg_prop == '\0')
264 fatal("No supported PK algorithms found");
265 return pkalg_prop;
266}
267
diff --git a/compat.h b/compat.h
index 3ae5d9c78..b174fa171 100644
--- a/compat.h
+++ b/compat.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: compat.h,v 1.43 2011/09/23 07:45:05 markus Exp $ */ 1/* $OpenBSD: compat.h,v 1.44 2013/12/30 23:52:27 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999, 2000, 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 1999, 2000, 2001 Markus Friedl. All rights reserved.
@@ -65,6 +65,7 @@ void enable_compat20(void);
65void compat_datafellows(const char *); 65void compat_datafellows(const char *);
66int proto_spec(const char *); 66int proto_spec(const char *);
67char *compat_cipher_proposal(char *); 67char *compat_cipher_proposal(char *);
68char *compat_pkalg_proposal(char *);
68 69
69extern int compat13; 70extern int compat13;
70extern int compat20; 71extern int compat20;
diff --git a/config.h.in b/config.h.in
index b75e501b2..075c619f6 100644
--- a/config.h.in
+++ b/config.h.in
@@ -47,6 +47,10 @@
47/* Can't do comparisons on readv */ 47/* Can't do comparisons on readv */
48#undef BROKEN_READV_COMPARISON 48#undef BROKEN_READV_COMPARISON
49 49
50/* NetBSD read function is sometimes redirected, breaking atomicio comparisons
51 against it */
52#undef BROKEN_READ_COMPARISON
53
50/* Define if you have a broken realpath. */ 54/* Define if you have a broken realpath. */
51#undef BROKEN_REALPATH 55#undef BROKEN_REALPATH
52 56
@@ -74,7 +78,7 @@
74/* Define if your snprintf is busted */ 78/* Define if your snprintf is busted */
75#undef BROKEN_SNPRINTF 79#undef BROKEN_SNPRINTF
76 80
77/* FreeBSD strnvis does not do what we need */ 81/* FreeBSD strnvis argument order is swapped compared to OpenBSD */
78#undef BROKEN_STRNVIS 82#undef BROKEN_STRNVIS
79 83
80/* tcgetattr with ICANON may hang */ 84/* tcgetattr with ICANON may hang */
@@ -182,6 +186,9 @@
182/* Define to 1 if you have the `arc4random_buf' function. */ 186/* Define to 1 if you have the `arc4random_buf' function. */
183#undef HAVE_ARC4RANDOM_BUF 187#undef HAVE_ARC4RANDOM_BUF
184 188
189/* Define to 1 if you have the `arc4random_stir' function. */
190#undef HAVE_ARC4RANDOM_STIR
191
185/* Define to 1 if you have the `arc4random_uniform' function. */ 192/* Define to 1 if you have the `arc4random_uniform' function. */
186#undef HAVE_ARC4RANDOM_UNIFORM 193#undef HAVE_ARC4RANDOM_UNIFORM
187 194
@@ -212,9 +219,30 @@
212/* Define to 1 if you have the `bcopy' function. */ 219/* Define to 1 if you have the `bcopy' function. */
213#undef HAVE_BCOPY 220#undef HAVE_BCOPY
214 221
222/* Define to 1 if you have the `bcrypt_pbkdf' function. */
223#undef HAVE_BCRYPT_PBKDF
224
215/* Define to 1 if you have the `bindresvport_sa' function. */ 225/* Define to 1 if you have the `bindresvport_sa' function. */
216#undef HAVE_BINDRESVPORT_SA 226#undef HAVE_BINDRESVPORT_SA
217 227
228/* Define to 1 if you have the `blf_enc' function. */
229#undef HAVE_BLF_ENC
230
231/* Define to 1 if you have the <blf.h> header file. */
232#undef HAVE_BLF_H
233
234/* Define to 1 if you have the `Blowfish_expand0state' function. */
235#undef HAVE_BLOWFISH_EXPAND0STATE
236
237/* Define to 1 if you have the `Blowfish_expandstate' function. */
238#undef HAVE_BLOWFISH_EXPANDSTATE
239
240/* Define to 1 if you have the `Blowfish_initstate' function. */
241#undef HAVE_BLOWFISH_INITSTATE
242
243/* Define to 1 if you have the `Blowfish_stream2word' function. */
244#undef HAVE_BLOWFISH_STREAM2WORD
245
218/* Define to 1 if you have the `BN_is_prime_ex' function. */ 246/* Define to 1 if you have the `BN_is_prime_ex' function. */
219#undef HAVE_BN_IS_PRIME_EX 247#undef HAVE_BN_IS_PRIME_EX
220 248
@@ -227,6 +255,9 @@
227/* Define to 1 if you have the <bstring.h> header file. */ 255/* Define to 1 if you have the <bstring.h> header file. */
228#undef HAVE_BSTRING_H 256#undef HAVE_BSTRING_H
229 257
258/* Define to 1 if you have the `cap_rights_limit' function. */
259#undef HAVE_CAP_RIGHTS_LIMIT
260
230/* Define to 1 if you have the `clock' function. */ 261/* Define to 1 if you have the `clock' function. */
231#undef HAVE_CLOCK 262#undef HAVE_CLOCK
232 263
@@ -374,6 +405,18 @@
374/* Define if libcrypto has EVP_CIPHER_CTX_ctrl */ 405/* Define if libcrypto has EVP_CIPHER_CTX_ctrl */
375#undef HAVE_EVP_CIPHER_CTX_CTRL 406#undef HAVE_EVP_CIPHER_CTX_CTRL
376 407
408/* Define to 1 if you have the `EVP_DigestFinal_ex' function. */
409#undef HAVE_EVP_DIGESTFINAL_EX
410
411/* Define to 1 if you have the `EVP_DigestInit_ex' function. */
412#undef HAVE_EVP_DIGESTINIT_EX
413
414/* Define to 1 if you have the `EVP_MD_CTX_cleanup' function. */
415#undef HAVE_EVP_MD_CTX_CLEANUP
416
417/* Define to 1 if you have the `EVP_MD_CTX_init' function. */
418#undef HAVE_EVP_MD_CTX_INIT
419
377/* Define to 1 if you have the `EVP_sha256' function. */ 420/* Define to 1 if you have the `EVP_sha256' function. */
378#undef HAVE_EVP_SHA256 421#undef HAVE_EVP_SHA256
379 422
@@ -413,6 +456,9 @@
413/* Define to 1 if the system has the type `fsfilcnt_t'. */ 456/* Define to 1 if the system has the type `fsfilcnt_t'. */
414#undef HAVE_FSFILCNT_T 457#undef HAVE_FSFILCNT_T
415 458
459/* Define to 1 if you have the `fstatfs' function. */
460#undef HAVE_FSTATFS
461
416/* Define to 1 if you have the `fstatvfs' function. */ 462/* Define to 1 if you have the `fstatvfs' function. */
417#undef HAVE_FSTATVFS 463#undef HAVE_FSTATVFS
418 464
@@ -584,6 +630,9 @@
584/* define if you have int64_t data type */ 630/* define if you have int64_t data type */
585#undef HAVE_INT64_T 631#undef HAVE_INT64_T
586 632
633/* Define to 1 if the system has the type `intmax_t'. */
634#undef HAVE_INTMAX_T
635
587/* Define to 1 if you have the <inttypes.h> header file. */ 636/* Define to 1 if you have the <inttypes.h> header file. */
588#undef HAVE_INTTYPES_H 637#undef HAVE_INTTYPES_H
589 638
@@ -1083,6 +1132,9 @@
1083/* Define to 1 if you have the <sys/bsdtty.h> header file. */ 1132/* Define to 1 if you have the <sys/bsdtty.h> header file. */
1084#undef HAVE_SYS_BSDTTY_H 1133#undef HAVE_SYS_BSDTTY_H
1085 1134
1135/* Define to 1 if you have the <sys/capability.h> header file. */
1136#undef HAVE_SYS_CAPABILITY_H
1137
1086/* Define to 1 if you have the <sys/cdefs.h> header file. */ 1138/* Define to 1 if you have the <sys/cdefs.h> header file. */
1087#undef HAVE_SYS_CDEFS_H 1139#undef HAVE_SYS_CDEFS_H
1088 1140
@@ -1197,6 +1249,9 @@
1197/* Define to 1 if you have the <ucred.h> header file. */ 1249/* Define to 1 if you have the <ucred.h> header file. */
1198#undef HAVE_UCRED_H 1250#undef HAVE_UCRED_H
1199 1251
1252/* Define to 1 if the system has the type `uintmax_t'. */
1253#undef HAVE_UINTMAX_T
1254
1200/* define if you have uintxx_t data type */ 1255/* define if you have uintxx_t data type */
1201#undef HAVE_UINTXX_T 1256#undef HAVE_UINTXX_T
1202 1257
@@ -1385,9 +1440,18 @@
1385/* Define if EVP_DigestUpdate returns void */ 1440/* Define if EVP_DigestUpdate returns void */
1386#undef OPENSSL_EVP_DIGESTUPDATE_VOID 1441#undef OPENSSL_EVP_DIGESTUPDATE_VOID
1387 1442
1388/* libcrypto includes complete ECC support */ 1443/* OpenSSL has ECC */
1389#undef OPENSSL_HAS_ECC 1444#undef OPENSSL_HAS_ECC
1390 1445
1446/* libcrypto has NID_X9_62_prime256v1 */
1447#undef OPENSSL_HAS_NISTP256
1448
1449/* libcrypto has NID_secp384r1 */
1450#undef OPENSSL_HAS_NISTP384
1451
1452/* libcrypto has NID_secp521r1 */
1453#undef OPENSSL_HAS_NISTP521
1454
1391/* libcrypto has EVP AES CTR */ 1455/* libcrypto has EVP AES CTR */
1392#undef OPENSSL_HAVE_EVPCTR 1456#undef OPENSSL_HAVE_EVPCTR
1393 1457
@@ -1440,6 +1504,9 @@
1440/* read(1) can return 0 for a non-closed fd */ 1504/* read(1) can return 0 for a non-closed fd */
1441#undef PTY_ZEROREAD 1505#undef PTY_ZEROREAD
1442 1506
1507/* Sandbox using capsicum */
1508#undef SANDBOX_CAPSICUM
1509
1443/* Sandbox using Darwin sandbox_init(3) */ 1510/* Sandbox using Darwin sandbox_init(3) */
1444#undef SANDBOX_DARWIN 1511#undef SANDBOX_DARWIN
1445 1512
@@ -1455,6 +1522,9 @@
1455/* setrlimit RLIMIT_FSIZE works */ 1522/* setrlimit RLIMIT_FSIZE works */
1456#undef SANDBOX_SKIP_RLIMIT_FSIZE 1523#undef SANDBOX_SKIP_RLIMIT_FSIZE
1457 1524
1525/* define if setrlimit RLIMIT_NOFILE breaks things */
1526#undef SANDBOX_SKIP_RLIMIT_NOFILE
1527
1458/* Sandbox using systrace(4) */ 1528/* Sandbox using systrace(4) */
1459#undef SANDBOX_SYSTRACE 1529#undef SANDBOX_SYSTRACE
1460 1530
diff --git a/configure b/configure
index 0d6fad5f4..2d714acae 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
1#! /bin/sh 1#! /bin/sh
2# From configure.ac Revision: 1.536 . 2# From configure.ac Revision: 1.568 .
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.68 for OpenSSH Portable. 4# Generated by GNU Autoconf 2.68 for OpenSSH Portable.
5# 5#
@@ -606,6 +606,7 @@ ac_includes_default="\
606ac_subst_vars='LTLIBOBJS 606ac_subst_vars='LTLIBOBJS
607LIBOBJS 607LIBOBJS
608UNSUPPORTED_ALGORITHMS 608UNSUPPORTED_ALGORITHMS
609TEST_MALLOC_OPTIONS
609TEST_SSH_IPV6 610TEST_SSH_IPV6
610piddir 611piddir
611user_path 612user_path
@@ -623,7 +624,6 @@ SSHLIBS
623SSH_PRIVSEP_USER 624SSH_PRIVSEP_USER
624COMMENT_OUT_ECC 625COMMENT_OUT_ECC
625TEST_SSH_ECC 626TEST_SSH_ECC
626TEST_SSH_SHA256
627LIBEDIT 627LIBEDIT
628PKGCONFIG 628PKGCONFIG
629LD 629LD
@@ -712,6 +712,7 @@ ac_user_opts='
712enable_option_checking 712enable_option_checking
713enable_largefile 713enable_largefile
714with_stackprotect 714with_stackprotect
715with_hardening
715with_rpath 716with_rpath
716with_cflags 717with_cflags
717with_cppflags 718with_cppflags
@@ -728,6 +729,7 @@ with_tcp_wrappers
728with_ldns 729with_ldns
729with_libedit 730with_libedit
730with_audit 731with_audit
732with_pie
731with_ssl_dir 733with_ssl_dir
732with_openssl_header_check 734with_openssl_header_check
733with_ssl_engine 735with_ssl_engine
@@ -1402,6 +1404,7 @@ Optional Packages:
1402 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] 1404 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
1403 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) 1405 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
1404 --without-stackprotect Don't use compiler's stack protection 1406 --without-stackprotect Don't use compiler's stack protection
1407 --without-hardening Don't use toolchain hardening flags
1405 --without-rpath Disable auto-added -R linker paths 1408 --without-rpath Disable auto-added -R linker paths
1406 --with-cflags Specify additional flags to pass to compiler 1409 --with-cflags Specify additional flags to pass to compiler
1407 --with-cppflags Specify additional flags to pass to preprocessor 1410 --with-cppflags Specify additional flags to pass to preprocessor
@@ -1418,6 +1421,7 @@ Optional Packages:
1418 --with-ldns[=PATH] Use ldns for DNSSEC support (optionally in PATH) 1421 --with-ldns[=PATH] Use ldns for DNSSEC support (optionally in PATH)
1419 --with-libedit[=PATH] Enable libedit support for sftp 1422 --with-libedit[=PATH] Enable libedit support for sftp
1420 --with-audit=module Enable audit support (modules=debug,bsm,linux) 1423 --with-audit=module Enable audit support (modules=debug,bsm,linux)
1424 --with-pie Build Position Independent Executables if possible
1421 --with-ssl-dir=PATH Specify path to OpenSSL installation 1425 --with-ssl-dir=PATH Specify path to OpenSSL installation
1422 --without-openssl-header-check Disable OpenSSL version consistency check 1426 --without-openssl-header-check Disable OpenSSL version consistency check
1423 --with-ssl-engine Enable OpenSSL (hardware) ENGINE support 1427 --with-ssl-engine Enable OpenSSL (hardware) ENGINE support
@@ -1425,7 +1429,7 @@ Optional Packages:
1425 --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool) 1429 --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)
1426 --with-pam Enable PAM support 1430 --with-pam Enable PAM support
1427 --with-privsep-user=user Specify non-privileged user for privilege separation 1431 --with-privsep-user=user Specify non-privileged user for privilege separation
1428 --with-sandbox=style Specify privilege separation sandbox (no, darwin, rlimit, systrace, seccomp_filter) 1432 --with-sandbox=style Specify privilege separation sandbox (no, darwin, rlimit, systrace, seccomp_filter, capsicum)
1429 --with-selinux Enable SELinux support 1433 --with-selinux Enable SELinux support
1430 --with-kerberos5=PATH Enable Kerberos 5 support 1434 --with-kerberos5=PATH Enable Kerberos 5 support
1431 --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty) 1435 --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)
@@ -5590,7 +5594,9 @@ if test "x$ac_cv_have_decl_PR_SET_NO_NEW_PRIVS" = xyes; then :
5590 have_linux_no_new_privs=1 5594 have_linux_no_new_privs=1
5591fi 5595fi
5592 5596
5597
5593use_stack_protector=1 5598use_stack_protector=1
5599use_toolchain_hardening=1
5594 5600
5595# Check whether --with-stackprotect was given. 5601# Check whether --with-stackprotect was given.
5596if test "${with_stackprotect+set}" = set; then : 5602if test "${with_stackprotect+set}" = set; then :
@@ -5601,18 +5607,61 @@ if test "${with_stackprotect+set}" = set; then :
5601fi 5607fi
5602 5608
5603 5609
5610# Check whether --with-hardening was given.
5611if test "${with_hardening+set}" = set; then :
5612 withval=$with_hardening;
5613 if test "x$withval" = "xno"; then
5614 use_toolchain_hardening=0
5615 fi
5616fi
5617
5618
5619# We use -Werror for the tests only so that we catch warnings like "this is
5620# on by default" for things like -fPIE.
5621{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -Werror" >&5
5622$as_echo_n "checking if $CC supports -Werror... " >&6; }
5623saved_CFLAGS="$CFLAGS"
5624CFLAGS="$CFLAGS -Werror"
5625cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5626/* end confdefs.h. */
5627int main(void) { return 0; }
5628_ACEOF
5629if ac_fn_c_try_compile "$LINENO"; then :
5630 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
5631$as_echo "yes" >&6; }
5632 WERROR="-Werror"
5633else
5634 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5635$as_echo "no" >&6; }
5636 WERROR=""
5637
5638fi
5639rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5640CFLAGS="$saved_CFLAGS"
5604 5641
5605if test "$GCC" = "yes" || test "$GCC" = "egcs"; then 5642if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
5606 { 5643 {
5607 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -Qunused-arguments -Werror" >&5 5644 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports compile flag -Qunused-arguments" >&5
5608$as_echo_n "checking if $CC supports -Qunused-arguments -Werror... " >&6; } 5645$as_echo_n "checking if $CC supports compile flag -Qunused-arguments... " >&6; }
5609 saved_CFLAGS="$CFLAGS" 5646 saved_CFLAGS="$CFLAGS"
5610 CFLAGS="$CFLAGS -Qunused-arguments -Werror" 5647 CFLAGS="$CFLAGS $WERROR -Qunused-arguments"
5611 _define_flag="-Qunused-arguments" 5648 _define_flag=""
5612 test "x$_define_flag" = "x" && _define_flag="-Qunused-arguments -Werror" 5649 test "x$_define_flag" = "x" && _define_flag="-Qunused-arguments"
5613 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5650 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5614/* end confdefs.h. */ 5651/* end confdefs.h. */
5615int main(void) { return 0; } 5652
5653#include <stdlib.h>
5654#include <stdio.h>
5655int main(int argc, char **argv) {
5656 /* Some math to catch -ftrapv problems in the toolchain */
5657 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
5658 float l = i * 2.1;
5659 double m = l / 0.5;
5660 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
5661 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
5662 exit(0);
5663}
5664
5616_ACEOF 5665_ACEOF
5617if ac_fn_c_try_compile "$LINENO"; then : 5666if ac_fn_c_try_compile "$LINENO"; then :
5618 5667
@@ -5635,15 +5684,27 @@ fi
5635rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 5684rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5636} 5685}
5637 { 5686 {
5638 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -Wunknown-warning-option -Werror" >&5 5687 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports compile flag -Wunknown-warning-option" >&5
5639$as_echo_n "checking if $CC supports -Wunknown-warning-option -Werror... " >&6; } 5688$as_echo_n "checking if $CC supports compile flag -Wunknown-warning-option... " >&6; }
5640 saved_CFLAGS="$CFLAGS" 5689 saved_CFLAGS="$CFLAGS"
5641 CFLAGS="$CFLAGS -Wunknown-warning-option -Werror" 5690 CFLAGS="$CFLAGS $WERROR -Wunknown-warning-option"
5642 _define_flag="-Wno-unknown-warning-option" 5691 _define_flag=""
5643 test "x$_define_flag" = "x" && _define_flag="-Wunknown-warning-option -Werror" 5692 test "x$_define_flag" = "x" && _define_flag="-Wunknown-warning-option"
5644 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5693 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5645/* end confdefs.h. */ 5694/* end confdefs.h. */
5646int main(void) { return 0; } 5695
5696#include <stdlib.h>
5697#include <stdio.h>
5698int main(int argc, char **argv) {
5699 /* Some math to catch -ftrapv problems in the toolchain */
5700 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
5701 float l = i * 2.1;
5702 double m = l / 0.5;
5703 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
5704 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
5705 exit(0);
5706}
5707
5647_ACEOF 5708_ACEOF
5648if ac_fn_c_try_compile "$LINENO"; then : 5709if ac_fn_c_try_compile "$LINENO"; then :
5649 5710
@@ -5666,15 +5727,27 @@ fi
5666rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 5727rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5667} 5728}
5668 { 5729 {
5669 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -Wall" >&5 5730 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports compile flag -Wall" >&5
5670$as_echo_n "checking if $CC supports -Wall... " >&6; } 5731$as_echo_n "checking if $CC supports compile flag -Wall... " >&6; }
5671 saved_CFLAGS="$CFLAGS" 5732 saved_CFLAGS="$CFLAGS"
5672 CFLAGS="$CFLAGS -Wall" 5733 CFLAGS="$CFLAGS $WERROR -Wall"
5673 _define_flag="" 5734 _define_flag=""
5674 test "x$_define_flag" = "x" && _define_flag="-Wall" 5735 test "x$_define_flag" = "x" && _define_flag="-Wall"
5675 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5736 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5676/* end confdefs.h. */ 5737/* end confdefs.h. */
5677int main(void) { return 0; } 5738
5739#include <stdlib.h>
5740#include <stdio.h>
5741int main(int argc, char **argv) {
5742 /* Some math to catch -ftrapv problems in the toolchain */
5743 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
5744 float l = i * 2.1;
5745 double m = l / 0.5;
5746 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
5747 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
5748 exit(0);
5749}
5750
5678_ACEOF 5751_ACEOF
5679if ac_fn_c_try_compile "$LINENO"; then : 5752if ac_fn_c_try_compile "$LINENO"; then :
5680 5753
@@ -5697,15 +5770,27 @@ fi
5697rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 5770rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5698} 5771}
5699 { 5772 {
5700 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -Wpointer-arith" >&5 5773 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports compile flag -Wpointer-arith" >&5
5701$as_echo_n "checking if $CC supports -Wpointer-arith... " >&6; } 5774$as_echo_n "checking if $CC supports compile flag -Wpointer-arith... " >&6; }
5702 saved_CFLAGS="$CFLAGS" 5775 saved_CFLAGS="$CFLAGS"
5703 CFLAGS="$CFLAGS -Wpointer-arith" 5776 CFLAGS="$CFLAGS $WERROR -Wpointer-arith"
5704 _define_flag="" 5777 _define_flag=""
5705 test "x$_define_flag" = "x" && _define_flag="-Wpointer-arith" 5778 test "x$_define_flag" = "x" && _define_flag="-Wpointer-arith"
5706 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5779 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5707/* end confdefs.h. */ 5780/* end confdefs.h. */
5708int main(void) { return 0; } 5781
5782#include <stdlib.h>
5783#include <stdio.h>
5784int main(int argc, char **argv) {
5785 /* Some math to catch -ftrapv problems in the toolchain */
5786 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
5787 float l = i * 2.1;
5788 double m = l / 0.5;
5789 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
5790 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
5791 exit(0);
5792}
5793
5709_ACEOF 5794_ACEOF
5710if ac_fn_c_try_compile "$LINENO"; then : 5795if ac_fn_c_try_compile "$LINENO"; then :
5711 5796
@@ -5728,15 +5813,27 @@ fi
5728rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 5813rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5729} 5814}
5730 { 5815 {
5731 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -Wuninitialized" >&5 5816 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports compile flag -Wuninitialized" >&5
5732$as_echo_n "checking if $CC supports -Wuninitialized... " >&6; } 5817$as_echo_n "checking if $CC supports compile flag -Wuninitialized... " >&6; }
5733 saved_CFLAGS="$CFLAGS" 5818 saved_CFLAGS="$CFLAGS"
5734 CFLAGS="$CFLAGS -Wuninitialized" 5819 CFLAGS="$CFLAGS $WERROR -Wuninitialized"
5735 _define_flag="" 5820 _define_flag=""
5736 test "x$_define_flag" = "x" && _define_flag="-Wuninitialized" 5821 test "x$_define_flag" = "x" && _define_flag="-Wuninitialized"
5737 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5822 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5738/* end confdefs.h. */ 5823/* end confdefs.h. */
5739int main(void) { return 0; } 5824
5825#include <stdlib.h>
5826#include <stdio.h>
5827int main(int argc, char **argv) {
5828 /* Some math to catch -ftrapv problems in the toolchain */
5829 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
5830 float l = i * 2.1;
5831 double m = l / 0.5;
5832 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
5833 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
5834 exit(0);
5835}
5836
5740_ACEOF 5837_ACEOF
5741if ac_fn_c_try_compile "$LINENO"; then : 5838if ac_fn_c_try_compile "$LINENO"; then :
5742 5839
@@ -5759,15 +5856,27 @@ fi
5759rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 5856rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5760} 5857}
5761 { 5858 {
5762 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -Wsign-compare" >&5 5859 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports compile flag -Wsign-compare" >&5
5763$as_echo_n "checking if $CC supports -Wsign-compare... " >&6; } 5860$as_echo_n "checking if $CC supports compile flag -Wsign-compare... " >&6; }
5764 saved_CFLAGS="$CFLAGS" 5861 saved_CFLAGS="$CFLAGS"
5765 CFLAGS="$CFLAGS -Wsign-compare" 5862 CFLAGS="$CFLAGS $WERROR -Wsign-compare"
5766 _define_flag="" 5863 _define_flag=""
5767 test "x$_define_flag" = "x" && _define_flag="-Wsign-compare" 5864 test "x$_define_flag" = "x" && _define_flag="-Wsign-compare"
5768 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5865 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5769/* end confdefs.h. */ 5866/* end confdefs.h. */
5770int main(void) { return 0; } 5867
5868#include <stdlib.h>
5869#include <stdio.h>
5870int main(int argc, char **argv) {
5871 /* Some math to catch -ftrapv problems in the toolchain */
5872 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
5873 float l = i * 2.1;
5874 double m = l / 0.5;
5875 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
5876 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
5877 exit(0);
5878}
5879
5771_ACEOF 5880_ACEOF
5772if ac_fn_c_try_compile "$LINENO"; then : 5881if ac_fn_c_try_compile "$LINENO"; then :
5773 5882
@@ -5790,15 +5899,27 @@ fi
5790rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 5899rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5791} 5900}
5792 { 5901 {
5793 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -Wformat-security" >&5 5902 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports compile flag -Wformat-security" >&5
5794$as_echo_n "checking if $CC supports -Wformat-security... " >&6; } 5903$as_echo_n "checking if $CC supports compile flag -Wformat-security... " >&6; }
5795 saved_CFLAGS="$CFLAGS" 5904 saved_CFLAGS="$CFLAGS"
5796 CFLAGS="$CFLAGS -Wformat-security" 5905 CFLAGS="$CFLAGS $WERROR -Wformat-security"
5797 _define_flag="" 5906 _define_flag=""
5798 test "x$_define_flag" = "x" && _define_flag="-Wformat-security" 5907 test "x$_define_flag" = "x" && _define_flag="-Wformat-security"
5799 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5908 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5800/* end confdefs.h. */ 5909/* end confdefs.h. */
5801int main(void) { return 0; } 5910
5911#include <stdlib.h>
5912#include <stdio.h>
5913int main(int argc, char **argv) {
5914 /* Some math to catch -ftrapv problems in the toolchain */
5915 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
5916 float l = i * 2.1;
5917 double m = l / 0.5;
5918 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
5919 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
5920 exit(0);
5921}
5922
5802_ACEOF 5923_ACEOF
5803if ac_fn_c_try_compile "$LINENO"; then : 5924if ac_fn_c_try_compile "$LINENO"; then :
5804 5925
@@ -5821,15 +5942,27 @@ fi
5821rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 5942rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5822} 5943}
5823 { 5944 {
5824 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -Wsizeof-pointer-memaccess" >&5 5945 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports compile flag -Wsizeof-pointer-memaccess" >&5
5825$as_echo_n "checking if $CC supports -Wsizeof-pointer-memaccess... " >&6; } 5946$as_echo_n "checking if $CC supports compile flag -Wsizeof-pointer-memaccess... " >&6; }
5826 saved_CFLAGS="$CFLAGS" 5947 saved_CFLAGS="$CFLAGS"
5827 CFLAGS="$CFLAGS -Wsizeof-pointer-memaccess" 5948 CFLAGS="$CFLAGS $WERROR -Wsizeof-pointer-memaccess"
5828 _define_flag="" 5949 _define_flag=""
5829 test "x$_define_flag" = "x" && _define_flag="-Wsizeof-pointer-memaccess" 5950 test "x$_define_flag" = "x" && _define_flag="-Wsizeof-pointer-memaccess"
5830 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5951 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5831/* end confdefs.h. */ 5952/* end confdefs.h. */
5832int main(void) { return 0; } 5953
5954#include <stdlib.h>
5955#include <stdio.h>
5956int main(int argc, char **argv) {
5957 /* Some math to catch -ftrapv problems in the toolchain */
5958 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
5959 float l = i * 2.1;
5960 double m = l / 0.5;
5961 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
5962 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
5963 exit(0);
5964}
5965
5833_ACEOF 5966_ACEOF
5834if ac_fn_c_try_compile "$LINENO"; then : 5967if ac_fn_c_try_compile "$LINENO"; then :
5835 5968
@@ -5852,15 +5985,27 @@ fi
5852rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 5985rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5853} 5986}
5854 { 5987 {
5855 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -Wpointer-sign" >&5 5988 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports compile flag -Wpointer-sign" >&5
5856$as_echo_n "checking if $CC supports -Wpointer-sign... " >&6; } 5989$as_echo_n "checking if $CC supports compile flag -Wpointer-sign... " >&6; }
5857 saved_CFLAGS="$CFLAGS" 5990 saved_CFLAGS="$CFLAGS"
5858 CFLAGS="$CFLAGS -Wpointer-sign" 5991 CFLAGS="$CFLAGS $WERROR -Wpointer-sign"
5859 _define_flag="-Wno-pointer-sign" 5992 _define_flag="-Wno-pointer-sign"
5860 test "x$_define_flag" = "x" && _define_flag="-Wpointer-sign" 5993 test "x$_define_flag" = "x" && _define_flag="-Wpointer-sign"
5861 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5994 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5862/* end confdefs.h. */ 5995/* end confdefs.h. */
5863int main(void) { return 0; } 5996
5997#include <stdlib.h>
5998#include <stdio.h>
5999int main(int argc, char **argv) {
6000 /* Some math to catch -ftrapv problems in the toolchain */
6001 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
6002 float l = i * 2.1;
6003 double m = l / 0.5;
6004 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
6005 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
6006 exit(0);
6007}
6008
5864_ACEOF 6009_ACEOF
5865if ac_fn_c_try_compile "$LINENO"; then : 6010if ac_fn_c_try_compile "$LINENO"; then :
5866 6011
@@ -5883,15 +6028,27 @@ fi
5883rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 6028rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5884} 6029}
5885 { 6030 {
5886 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -Wunused-result" >&5 6031 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports compile flag -Wunused-result" >&5
5887$as_echo_n "checking if $CC supports -Wunused-result... " >&6; } 6032$as_echo_n "checking if $CC supports compile flag -Wunused-result... " >&6; }
5888 saved_CFLAGS="$CFLAGS" 6033 saved_CFLAGS="$CFLAGS"
5889 CFLAGS="$CFLAGS -Wunused-result" 6034 CFLAGS="$CFLAGS $WERROR -Wunused-result"
5890 _define_flag="-Wno-unused-result" 6035 _define_flag="-Wno-unused-result"
5891 test "x$_define_flag" = "x" && _define_flag="-Wunused-result" 6036 test "x$_define_flag" = "x" && _define_flag="-Wunused-result"
5892 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 6037 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5893/* end confdefs.h. */ 6038/* end confdefs.h. */
5894int main(void) { return 0; } 6039
6040#include <stdlib.h>
6041#include <stdio.h>
6042int main(int argc, char **argv) {
6043 /* Some math to catch -ftrapv problems in the toolchain */
6044 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
6045 float l = i * 2.1;
6046 double m = l / 0.5;
6047 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
6048 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
6049 exit(0);
6050}
6051
5895_ACEOF 6052_ACEOF
5896if ac_fn_c_try_compile "$LINENO"; then : 6053if ac_fn_c_try_compile "$LINENO"; then :
5897 6054
@@ -5914,15 +6071,27 @@ fi
5914rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 6071rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5915} 6072}
5916 { 6073 {
5917 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -fno-strict-aliasing" >&5 6074 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports compile flag -fno-strict-aliasing" >&5
5918$as_echo_n "checking if $CC supports -fno-strict-aliasing... " >&6; } 6075$as_echo_n "checking if $CC supports compile flag -fno-strict-aliasing... " >&6; }
5919 saved_CFLAGS="$CFLAGS" 6076 saved_CFLAGS="$CFLAGS"
5920 CFLAGS="$CFLAGS -fno-strict-aliasing" 6077 CFLAGS="$CFLAGS $WERROR -fno-strict-aliasing"
5921 _define_flag="" 6078 _define_flag=""
5922 test "x$_define_flag" = "x" && _define_flag="-fno-strict-aliasing" 6079 test "x$_define_flag" = "x" && _define_flag="-fno-strict-aliasing"
5923 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 6080 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5924/* end confdefs.h. */ 6081/* end confdefs.h. */
5925int main(void) { return 0; } 6082
6083#include <stdlib.h>
6084#include <stdio.h>
6085int main(int argc, char **argv) {
6086 /* Some math to catch -ftrapv problems in the toolchain */
6087 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
6088 float l = i * 2.1;
6089 double m = l / 0.5;
6090 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
6091 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
6092 exit(0);
6093}
6094
5926_ACEOF 6095_ACEOF
5927if ac_fn_c_try_compile "$LINENO"; then : 6096if ac_fn_c_try_compile "$LINENO"; then :
5928 6097
@@ -5945,15 +6114,27 @@ fi
5945rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 6114rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5946} 6115}
5947 { 6116 {
5948 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -D_FORTIFY_SOURCE=2" >&5 6117 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports compile flag -D_FORTIFY_SOURCE=2" >&5
5949$as_echo_n "checking if $CC supports -D_FORTIFY_SOURCE=2... " >&6; } 6118$as_echo_n "checking if $CC supports compile flag -D_FORTIFY_SOURCE=2... " >&6; }
5950 saved_CFLAGS="$CFLAGS" 6119 saved_CFLAGS="$CFLAGS"
5951 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2" 6120 CFLAGS="$CFLAGS $WERROR -D_FORTIFY_SOURCE=2"
5952 _define_flag="" 6121 _define_flag=""
5953 test "x$_define_flag" = "x" && _define_flag="-D_FORTIFY_SOURCE=2" 6122 test "x$_define_flag" = "x" && _define_flag="-D_FORTIFY_SOURCE=2"
5954 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 6123 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5955/* end confdefs.h. */ 6124/* end confdefs.h. */
5956int main(void) { return 0; } 6125
6126#include <stdlib.h>
6127#include <stdio.h>
6128int main(int argc, char **argv) {
6129 /* Some math to catch -ftrapv problems in the toolchain */
6130 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
6131 float l = i * 2.1;
6132 double m = l / 0.5;
6133 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
6134 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
6135 exit(0);
6136}
6137
5957_ACEOF 6138_ACEOF
5958if ac_fn_c_try_compile "$LINENO"; then : 6139if ac_fn_c_try_compile "$LINENO"; then :
5959 6140
@@ -5975,6 +6156,165 @@ $as_echo "no" >&6; }
5975fi 6156fi
5976rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 6157rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5977} 6158}
6159 if test "x$use_toolchain_hardening" = "x1"; then
6160 {
6161 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $LD supports link flag -Wl,-z,relro" >&5
6162$as_echo_n "checking if $LD supports link flag -Wl,-z,relro... " >&6; }
6163 saved_LDFLAGS="$LDFLAGS"
6164 LDFLAGS="$LDFLAGS $WERROR -Wl,-z,relro"
6165 _define_flag=""
6166 test "x$_define_flag" = "x" && _define_flag="-Wl,-z,relro"
6167 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6168/* end confdefs.h. */
6169
6170#include <stdlib.h>
6171#include <stdio.h>
6172int main(int argc, char **argv) {
6173 /* Some math to catch -ftrapv problems in the toolchain */
6174 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
6175 float l = i * 2.1;
6176 double m = l / 0.5;
6177 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
6178 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
6179 exit(0);
6180}
6181
6182_ACEOF
6183if ac_fn_c_try_link "$LINENO"; then :
6184 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
6185$as_echo "yes" >&6; }
6186 LDFLAGS="$saved_LDFLAGS $_define_flag"
6187else
6188 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6189$as_echo "no" >&6; }
6190 LDFLAGS="$saved_LDFLAGS"
6191
6192fi
6193rm -f core conftest.err conftest.$ac_objext \
6194 conftest$ac_exeext conftest.$ac_ext
6195}
6196 {
6197 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $LD supports link flag -Wl,-z,now" >&5
6198$as_echo_n "checking if $LD supports link flag -Wl,-z,now... " >&6; }
6199 saved_LDFLAGS="$LDFLAGS"
6200 LDFLAGS="$LDFLAGS $WERROR -Wl,-z,now"
6201 _define_flag=""
6202 test "x$_define_flag" = "x" && _define_flag="-Wl,-z,now"
6203 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6204/* end confdefs.h. */
6205
6206#include <stdlib.h>
6207#include <stdio.h>
6208int main(int argc, char **argv) {
6209 /* Some math to catch -ftrapv problems in the toolchain */
6210 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
6211 float l = i * 2.1;
6212 double m = l / 0.5;
6213 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
6214 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
6215 exit(0);
6216}
6217
6218_ACEOF
6219if ac_fn_c_try_link "$LINENO"; then :
6220 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
6221$as_echo "yes" >&6; }
6222 LDFLAGS="$saved_LDFLAGS $_define_flag"
6223else
6224 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6225$as_echo "no" >&6; }
6226 LDFLAGS="$saved_LDFLAGS"
6227
6228fi
6229rm -f core conftest.err conftest.$ac_objext \
6230 conftest$ac_exeext conftest.$ac_ext
6231}
6232 {
6233 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $LD supports link flag -Wl,-z,noexecstack" >&5
6234$as_echo_n "checking if $LD supports link flag -Wl,-z,noexecstack... " >&6; }
6235 saved_LDFLAGS="$LDFLAGS"
6236 LDFLAGS="$LDFLAGS $WERROR -Wl,-z,noexecstack"
6237 _define_flag=""
6238 test "x$_define_flag" = "x" && _define_flag="-Wl,-z,noexecstack"
6239 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6240/* end confdefs.h. */
6241
6242#include <stdlib.h>
6243#include <stdio.h>
6244int main(int argc, char **argv) {
6245 /* Some math to catch -ftrapv problems in the toolchain */
6246 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
6247 float l = i * 2.1;
6248 double m = l / 0.5;
6249 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
6250 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
6251 exit(0);
6252}
6253
6254_ACEOF
6255if ac_fn_c_try_link "$LINENO"; then :
6256 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
6257$as_echo "yes" >&6; }
6258 LDFLAGS="$saved_LDFLAGS $_define_flag"
6259else
6260 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6261$as_echo "no" >&6; }
6262 LDFLAGS="$saved_LDFLAGS"
6263
6264fi
6265rm -f core conftest.err conftest.$ac_objext \
6266 conftest$ac_exeext conftest.$ac_ext
6267}
6268 # NB. -ftrapv expects certain support functions to be present in
6269 # the compiler library (libgcc or similar) to detect integer operations
6270 # that can overflow. We must check that the result of enabling it
6271 # actually links. The test program compiled/linked includes a number
6272 # of integer operations that should exercise this.
6273 {
6274 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports compile flag -ftrapv and linking succeeds" >&5
6275$as_echo_n "checking if $CC supports compile flag -ftrapv and linking succeeds... " >&6; }
6276 saved_CFLAGS="$CFLAGS"
6277 CFLAGS="$CFLAGS $WERROR -ftrapv"
6278 _define_flag=""
6279 test "x$_define_flag" = "x" && _define_flag="-ftrapv"
6280 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6281/* end confdefs.h. */
6282
6283#include <stdlib.h>
6284#include <stdio.h>
6285int main(int argc, char **argv) {
6286 /* Some math to catch -ftrapv problems in the toolchain */
6287 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
6288 float l = i * 2.1;
6289 double m = l / 0.5;
6290 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
6291 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
6292 exit(0);
6293}
6294
6295_ACEOF
6296if ac_fn_c_try_link "$LINENO"; then :
6297
6298if `grep -i "unrecognized option" conftest.err >/dev/null`
6299then
6300 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6301$as_echo "no" >&6; }
6302 CFLAGS="$saved_CFLAGS"
6303else
6304 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
6305$as_echo "yes" >&6; }
6306 CFLAGS="$saved_CFLAGS $_define_flag"
6307fi
6308else
6309 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6310$as_echo "no" >&6; }
6311 CFLAGS="$saved_CFLAGS"
6312
6313fi
6314rm -f core conftest.err conftest.$ac_objext \
6315 conftest$ac_exeext conftest.$ac_ext
6316}
6317 fi
5978 { $as_echo "$as_me:${as_lineno-$LINENO}: checking gcc version" >&5 6318 { $as_echo "$as_me:${as_lineno-$LINENO}: checking gcc version" >&5
5979$as_echo_n "checking gcc version... " >&6; } 6319$as_echo_n "checking gcc version... " >&6; }
5980 GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'` 6320 GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
@@ -6020,7 +6360,8 @@ rm -f core conftest.err conftest.$ac_objext \
6020 # and/or platforms, so we test if we can. If it's not supported 6360 # and/or platforms, so we test if we can. If it's not supported
6021 # on a given platform gcc will emit a warning so we use -Werror. 6361 # on a given platform gcc will emit a warning so we use -Werror.
6022 if test "x$use_stack_protector" = "x1"; then 6362 if test "x$use_stack_protector" = "x1"; then
6023 for t in -fstack-protector-all -fstack-protector; do 6363 for t in -fstack-protector-strong -fstack-protector-all \
6364 -fstack-protector; do
6024 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports $t" >&5 6365 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports $t" >&5
6025$as_echo_n "checking if $CC supports $t... " >&6; } 6366$as_echo_n "checking if $CC supports $t... " >&6; }
6026 saved_CFLAGS="$CFLAGS" 6367 saved_CFLAGS="$CFLAGS"
@@ -6224,6 +6565,7 @@ fi
6224 6565
6225 6566
6226for ac_header in \ 6567for ac_header in \
6568 blf.h \
6227 bstring.h \ 6569 bstring.h \
6228 crypt.h \ 6570 crypt.h \
6229 crypto/sha2.h \ 6571 crypto/sha2.h \
@@ -6237,6 +6579,7 @@ for ac_header in \
6237 glob.h \ 6579 glob.h \
6238 ia.h \ 6580 ia.h \
6239 iaf.h \ 6581 iaf.h \
6582 inttypes.h \
6240 limits.h \ 6583 limits.h \
6241 locale.h \ 6584 locale.h \
6242 login.h \ 6585 login.h \
@@ -6261,6 +6604,7 @@ for ac_header in \
6261 sys/audit.h \ 6604 sys/audit.h \
6262 sys/bitypes.h \ 6605 sys/bitypes.h \
6263 sys/bsdtty.h \ 6606 sys/bsdtty.h \
6607 sys/capability.h \
6264 sys/cdefs.h \ 6608 sys/cdefs.h \
6265 sys/dir.h \ 6609 sys/dir.h \
6266 sys/mman.h \ 6610 sys/mman.h \
@@ -6713,6 +7057,51 @@ $as_echo "#define SSH_IOBUFSZ 65535" >>confdefs.h
6713 7057
6714$as_echo "#define FILESYSTEM_NO_BACKSLASH 1" >>confdefs.h 7058$as_echo "#define FILESYSTEM_NO_BACKSLASH 1" >>confdefs.h
6715 7059
7060 # Cygwin defines optargs, optargs as declspec(dllimport) for historical
7061 # reasons which cause compile warnings, so we disable those warnings.
7062 {
7063 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports compile flag -Wno-attributes" >&5
7064$as_echo_n "checking if $CC supports compile flag -Wno-attributes... " >&6; }
7065 saved_CFLAGS="$CFLAGS"
7066 CFLAGS="$CFLAGS $WERROR -Wno-attributes"
7067 _define_flag=""
7068 test "x$_define_flag" = "x" && _define_flag="-Wno-attributes"
7069 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7070/* end confdefs.h. */
7071
7072#include <stdlib.h>
7073#include <stdio.h>
7074int main(int argc, char **argv) {
7075 /* Some math to catch -ftrapv problems in the toolchain */
7076 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
7077 float l = i * 2.1;
7078 double m = l / 0.5;
7079 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
7080 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
7081 exit(0);
7082}
7083
7084_ACEOF
7085if ac_fn_c_try_compile "$LINENO"; then :
7086
7087if `grep -i "unrecognized option" conftest.err >/dev/null`
7088then
7089 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
7090$as_echo "no" >&6; }
7091 CFLAGS="$saved_CFLAGS"
7092else
7093 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
7094$as_echo "yes" >&6; }
7095 CFLAGS="$saved_CFLAGS $_define_flag"
7096fi
7097else
7098 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
7099$as_echo "no" >&6; }
7100 CFLAGS="$saved_CFLAGS"
7101
7102fi
7103rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
7104}
6716 ;; 7105 ;;
6717*-*-dgux*) 7106*-*-dgux*)
6718 7107
@@ -6726,6 +7115,7 @@ $as_echo "#define IP_TOS_IS_BROKEN 1" >>confdefs.h
6726 7115
6727 ;; 7116 ;;
6728*-*-darwin*) 7117*-*-darwin*)
7118 use_pie=auto
6729 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we have working getaddrinfo" >&5 7119 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we have working getaddrinfo" >&5
6730$as_echo_n "checking if we have working getaddrinfo... " >&6; } 7120$as_echo_n "checking if we have working getaddrinfo... " >&6; }
6731 if test "$cross_compiling" = yes; then : 7121 if test "$cross_compiling" = yes; then :
@@ -6824,6 +7214,7 @@ done
6824 ;; 7214 ;;
6825*-*-dragonfly*) 7215*-*-dragonfly*)
6826 SSHDLIBS="$SSHDLIBS -lcrypt" 7216 SSHDLIBS="$SSHDLIBS -lcrypt"
7217 TEST_MALLOC_OPTIONS="AFGJPRX"
6827 ;; 7218 ;;
6828*-*-haiku*) 7219*-*-haiku*)
6829 LIBS="$LIBS -lbsd " 7220 LIBS="$LIBS -lbsd "
@@ -7046,6 +7437,7 @@ $as_echo "#define USE_BTMP 1" >>confdefs.h
7046 ;; 7437 ;;
7047*-*-linux*) 7438*-*-linux*)
7048 no_dev_ptmx=1 7439 no_dev_ptmx=1
7440 use_pie=auto
7049 check_for_libcrypt_later=1 7441 check_for_libcrypt_later=1
7050 check_for_openpty_ctty_bug=1 7442 check_for_openpty_ctty_bug=1
7051 7443
@@ -7178,6 +7570,13 @@ fi
7178 7570
7179$as_echo "#define SSH_TUN_PREPEND_AF 1" >>confdefs.h 7571$as_echo "#define SSH_TUN_PREPEND_AF 1" >>confdefs.h
7180 7572
7573 TEST_MALLOC_OPTIONS="AJRX"
7574
7575$as_echo "#define BROKEN_STRNVIS 1" >>confdefs.h
7576
7577
7578$as_echo "#define BROKEN_READ_COMPARISON 1" >>confdefs.h
7579
7181 ;; 7580 ;;
7182*-*-freebsd*) 7581*-*-freebsd*)
7183 check_for_libcrypt_later=1 7582 check_for_libcrypt_later=1
@@ -7203,6 +7602,12 @@ $as_echo "#define BROKEN_GLOB 1" >>confdefs.h
7203 7602
7204$as_echo "#define BROKEN_STRNVIS 1" >>confdefs.h 7603$as_echo "#define BROKEN_STRNVIS 1" >>confdefs.h
7205 7604
7605 TEST_MALLOC_OPTIONS="AJRX"
7606 # Preauth crypto occasionally uses file descriptors for crypto offload
7607 # and will crash if they cannot be opened.
7608
7609$as_echo "#define SANDBOX_SKIP_RLIMIT_NOFILE 1" >>confdefs.h
7610],
7206 ;; 7611 ;;
7207*-*-bsdi*) 7612*-*-bsdi*)
7208 $as_echo "#define SETEUID_BREAKS_SETUID 1" >>confdefs.h 7613 $as_echo "#define SETEUID_BREAKS_SETUID 1" >>confdefs.h
@@ -7229,6 +7634,7 @@ $as_echo "#define BROKEN_SAVED_UIDS 1" >>confdefs.h
7229 7634
7230 ;; 7635 ;;
7231*-*-openbsd*) 7636*-*-openbsd*)
7637 use_pie=auto
7232 7638
7233$as_echo "#define HAVE_ATTRIBUTE__SENTINEL__ 1" >>confdefs.h 7639$as_echo "#define HAVE_ATTRIBUTE__SENTINEL__ 1" >>confdefs.h
7234 7640
@@ -7241,6 +7647,7 @@ $as_echo "#define SSH_TUN_OPENBSD 1" >>confdefs.h
7241 7647
7242$as_echo "#define SYSLOG_R_SAFE_IN_SIGHAND 1" >>confdefs.h 7648$as_echo "#define SYSLOG_R_SAFE_IN_SIGHAND 1" >>confdefs.h
7243 7649
7650 TEST_MALLOC_OPTIONS="AFGJPRX"
7244 ;; 7651 ;;
7245*-*-solaris*) 7652*-*-solaris*)
7246 if test "x$withval" != "xno" ; then 7653 if test "x$withval" != "xno" ; then
@@ -8929,6 +9336,64 @@ fi
8929done 9336done
8930 9337
8931 9338
9339# On some platforms, inet_ntop may be found in libresolv or libnsl.
9340{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing inet_ntop" >&5
9341$as_echo_n "checking for library containing inet_ntop... " >&6; }
9342if ${ac_cv_search_inet_ntop+:} false; then :
9343 $as_echo_n "(cached) " >&6
9344else
9345 ac_func_search_save_LIBS=$LIBS
9346cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9347/* end confdefs.h. */
9348
9349/* Override any GCC internal prototype to avoid an error.
9350 Use char because int might match the return type of a GCC
9351 builtin and then its argument prototype would still apply. */
9352#ifdef __cplusplus
9353extern "C"
9354#endif
9355char inet_ntop ();
9356int
9357main ()
9358{
9359return inet_ntop ();
9360 ;
9361 return 0;
9362}
9363_ACEOF
9364for ac_lib in '' resolv nsl; do
9365 if test -z "$ac_lib"; then
9366 ac_res="none required"
9367 else
9368 ac_res=-l$ac_lib
9369 LIBS="-l$ac_lib $ac_func_search_save_LIBS"
9370 fi
9371 if ac_fn_c_try_link "$LINENO"; then :
9372 ac_cv_search_inet_ntop=$ac_res
9373fi
9374rm -f core conftest.err conftest.$ac_objext \
9375 conftest$ac_exeext
9376 if ${ac_cv_search_inet_ntop+:} false; then :
9377 break
9378fi
9379done
9380if ${ac_cv_search_inet_ntop+:} false; then :
9381
9382else
9383 ac_cv_search_inet_ntop=no
9384fi
9385rm conftest.$ac_ext
9386LIBS=$ac_func_search_save_LIBS
9387fi
9388{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_inet_ntop" >&5
9389$as_echo "$ac_cv_search_inet_ntop" >&6; }
9390ac_res=$ac_cv_search_inet_ntop
9391if test "$ac_res" != no; then :
9392 test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
9393
9394fi
9395
9396
8932for ac_func in strftime 9397for ac_func in strftime
8933do : 9398do :
8934 ac_fn_c_check_func "$LINENO" "strftime" "ac_cv_func_strftime" 9399 ac_fn_c_check_func "$LINENO" "strftime" "ac_cv_func_strftime"
@@ -9495,7 +9960,7 @@ $as_echo "no" >&6; }
9495 fi 9960 fi
9496 fi 9961 fi
9497 if test "x$use_pkgconfig_for_libedit" = "xyes"; then 9962 if test "x$use_pkgconfig_for_libedit" = "xyes"; then
9498 LIBEDIT=`$PKGCONFIG --libs-only-l libedit` 9963 LIBEDIT=`$PKGCONFIG --libs libedit`
9499 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`" 9964 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`"
9500 else 9965 else
9501 LIBEDIT="-ledit -lcurses" 9966 LIBEDIT="-ledit -lcurses"
@@ -9689,7 +10154,7 @@ done
9689 10154
9690$as_echo "#define USE_BSM_AUDIT 1" >>confdefs.h 10155$as_echo "#define USE_BSM_AUDIT 1" >>confdefs.h
9691 10156
9692 if test "$sol2ver" -eq 11; then 10157 if test "$sol2ver" -ge 11; then
9693 SSHDLIBS="$SSHDLIBS -lscf" 10158 SSHDLIBS="$SSHDLIBS -lscf"
9694 10159
9695$as_echo "#define BROKEN_BSM_API 1" >>confdefs.h 10160$as_echo "#define BROKEN_BSM_API 1" >>confdefs.h
@@ -9737,9 +10202,155 @@ $as_echo "no" >&6; }
9737fi 10202fi
9738 10203
9739 10204
10205
10206# Check whether --with-pie was given.
10207if test "${with_pie+set}" = set; then :
10208 withval=$with_pie;
10209 if test "x$withval" = "xno"; then
10210 use_pie=no
10211 fi
10212 if test "x$withval" = "xyes"; then
10213 use_pie=yes
10214 fi
10215
10216
10217fi
10218
10219if test "x$use_pie" = "x"; then
10220 use_pie=no
10221fi
10222if test "x$use_toolchain_hardening" != "x1" && test "x$use_pie" = "xauto"; then
10223 # Turn off automatic PIE when toolchain hardening is off.
10224 use_pie=no
10225fi
10226if test "x$use_pie" = "xauto"; then
10227 # Automatic PIE requires gcc >= 4.x
10228 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc >= 4.x" >&5
10229$as_echo_n "checking for gcc >= 4.x... " >&6; }
10230 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10231/* end confdefs.h. */
10232
10233#if !defined(__GNUC__) || __GNUC__ < 4
10234#error gcc is too old
10235#endif
10236
10237_ACEOF
10238if ac_fn_c_try_compile "$LINENO"; then :
10239 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
10240$as_echo "yes" >&6; }
10241else
10242 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10243$as_echo "no" >&6; }
10244 use_pie=no
10245
10246fi
10247rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
10248fi
10249if test "x$use_pie" != "xno"; then
10250 SAVED_CFLAGS="$CFLAGS"
10251 SAVED_LDFLAGS="$LDFLAGS"
10252 {
10253 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports compile flag -fPIE" >&5
10254$as_echo_n "checking if $CC supports compile flag -fPIE... " >&6; }
10255 saved_CFLAGS="$CFLAGS"
10256 CFLAGS="$CFLAGS $WERROR -fPIE"
10257 _define_flag=""
10258 test "x$_define_flag" = "x" && _define_flag="-fPIE"
10259 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10260/* end confdefs.h. */
10261
10262#include <stdlib.h>
10263#include <stdio.h>
10264int main(int argc, char **argv) {
10265 /* Some math to catch -ftrapv problems in the toolchain */
10266 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
10267 float l = i * 2.1;
10268 double m = l / 0.5;
10269 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
10270 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
10271 exit(0);
10272}
10273
10274_ACEOF
10275if ac_fn_c_try_compile "$LINENO"; then :
10276
10277if `grep -i "unrecognized option" conftest.err >/dev/null`
10278then
10279 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10280$as_echo "no" >&6; }
10281 CFLAGS="$saved_CFLAGS"
10282else
10283 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
10284$as_echo "yes" >&6; }
10285 CFLAGS="$saved_CFLAGS $_define_flag"
10286fi
10287else
10288 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10289$as_echo "no" >&6; }
10290 CFLAGS="$saved_CFLAGS"
10291
10292fi
10293rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
10294}
10295 {
10296 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $LD supports link flag -pie" >&5
10297$as_echo_n "checking if $LD supports link flag -pie... " >&6; }
10298 saved_LDFLAGS="$LDFLAGS"
10299 LDFLAGS="$LDFLAGS $WERROR -pie"
10300 _define_flag=""
10301 test "x$_define_flag" = "x" && _define_flag="-pie"
10302 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10303/* end confdefs.h. */
10304
10305#include <stdlib.h>
10306#include <stdio.h>
10307int main(int argc, char **argv) {
10308 /* Some math to catch -ftrapv problems in the toolchain */
10309 int i = 123 * argc, j = 456 + argc, k = 789 - argc;
10310 float l = i * 2.1;
10311 double m = l / 0.5;
10312 long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
10313 printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o);
10314 exit(0);
10315}
10316
10317_ACEOF
10318if ac_fn_c_try_link "$LINENO"; then :
10319 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
10320$as_echo "yes" >&6; }
10321 LDFLAGS="$saved_LDFLAGS $_define_flag"
10322else
10323 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10324$as_echo "no" >&6; }
10325 LDFLAGS="$saved_LDFLAGS"
10326
10327fi
10328rm -f core conftest.err conftest.$ac_objext \
10329 conftest$ac_exeext conftest.$ac_ext
10330}
10331 # We use both -fPIE and -pie or neither.
10332 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether both -fPIE and -pie are supported" >&5
10333$as_echo_n "checking whether both -fPIE and -pie are supported... " >&6; }
10334 if echo "x $CFLAGS" | grep ' -fPIE' >/dev/null 2>&1 && \
10335 echo "x $LDFLAGS" | grep ' -pie' >/dev/null 2>&1 ; then
10336 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
10337$as_echo "yes" >&6; }
10338 else
10339 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10340$as_echo "no" >&6; }
10341 CFLAGS="$SAVED_CFLAGS"
10342 LDFLAGS="$SAVED_LDFLAGS"
10343 fi
10344fi
10345
9740for ac_func in \ 10346for ac_func in \
10347 Blowfish_initstate \
10348 Blowfish_expandstate \
10349 Blowfish_expand0state \
10350 Blowfish_stream2word \
9741 arc4random \ 10351 arc4random \
9742 arc4random_buf \ 10352 arc4random_buf \
10353 arc4random_stir \
9743 arc4random_uniform \ 10354 arc4random_uniform \
9744 asprintf \ 10355 asprintf \
9745 b64_ntop \ 10356 b64_ntop \
@@ -9747,7 +10358,10 @@ for ac_func in \
9747 b64_pton \ 10358 b64_pton \
9748 __b64_pton \ 10359 __b64_pton \
9749 bcopy \ 10360 bcopy \
10361 bcrypt_pbkdf \
9750 bindresvport_sa \ 10362 bindresvport_sa \
10363 blf_enc \
10364 cap_rights_limit \
9751 clock \ 10365 clock \
9752 closefrom \ 10366 closefrom \
9753 dirfd \ 10367 dirfd \
@@ -9755,6 +10369,7 @@ for ac_func in \
9755 fchmod \ 10369 fchmod \
9756 fchown \ 10370 fchown \
9757 freeaddrinfo \ 10371 freeaddrinfo \
10372 fstatfs \
9758 fstatvfs \ 10373 fstatvfs \
9759 futimes \ 10374 futimes \
9760 getaddrinfo \ 10375 getaddrinfo \
@@ -11491,7 +12106,17 @@ fi
11491rm -f core conftest.err conftest.$ac_objext \ 12106rm -f core conftest.err conftest.$ac_objext \
11492 conftest$ac_exeext conftest.$ac_ext 12107 conftest$ac_exeext conftest.$ac_ext
11493 12108
11494for ac_func in RSA_generate_key_ex DSA_generate_parameters_ex BN_is_prime_ex RSA_get_default_method HMAC_CTX_init 12109for ac_func in \
12110 BN_is_prime_ex \
12111 DSA_generate_parameters_ex \
12112 EVP_DigestInit_ex \
12113 EVP_DigestFinal_ex \
12114 EVP_MD_CTX_init \
12115 EVP_MD_CTX_cleanup \
12116 HMAC_CTX_init \
12117 RSA_generate_key_ex \
12118 RSA_get_default_method \
12119
11495do : 12120do :
11496 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` 12121 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
11497ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" 12122ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -11876,10 +12501,9 @@ if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
11876 cat >>confdefs.h <<_ACEOF 12501 cat >>confdefs.h <<_ACEOF
11877#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 12502#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
11878_ACEOF 12503_ACEOF
11879 TEST_SSH_SHA256=yes 12504
11880else 12505else
11881 TEST_SSH_SHA256=no 12506 unsupported_algorithms="$unsupported_algorithms \
11882 unsupported_algorithms="$unsupported_algorithms \
11883 hmac-sha2-256 hmac-sha2-512 \ 12507 hmac-sha2-256 hmac-sha2-512 \
11884 diffie-hellman-group-exchange-sha256 \ 12508 diffie-hellman-group-exchange-sha256 \
11885 hmac-sha2-256-etm@openssh.com hmac-sha2-512-etm@openssh.com" 12509 hmac-sha2-256-etm@openssh.com hmac-sha2-512-etm@openssh.com"
@@ -11889,10 +12513,9 @@ fi
11889done 12513done
11890 12514
11891 12515
11892
11893# Check complete ECC support in OpenSSL 12516# Check complete ECC support in OpenSSL
11894{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether OpenSSL has complete ECC support" >&5 12517{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether OpenSSL has NID_X9_62_prime256v1" >&5
11895$as_echo_n "checking whether OpenSSL has complete ECC support... " >&6; } 12518$as_echo_n "checking whether OpenSSL has NID_X9_62_prime256v1... " >&6; }
11896cat confdefs.h - <<_ACEOF >conftest.$ac_ext 12519cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11897/* end confdefs.h. */ 12520/* end confdefs.h. */
11898 12521
@@ -11910,41 +12533,183 @@ int
11910main () 12533main ()
11911{ 12534{
11912 12535
11913 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1); 12536 EC_KEY *e = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
11914 const EVP_MD *m = EVP_sha512(); /* We need this too */ 12537 const EVP_MD *m = EVP_sha256(); /* We need this too */
11915 12538
11916 ; 12539 ;
11917 return 0; 12540 return 0;
11918} 12541}
11919_ACEOF 12542_ACEOF
11920if ac_fn_c_try_link "$LINENO"; then : 12543if ac_fn_c_try_link "$LINENO"; then :
12544 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
12545$as_echo "yes" >&6; }
12546 enable_nistp256=1
12547else
12548 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
12549$as_echo "no" >&6; }
11921 12550
11922 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 12551fi
12552rm -f core conftest.err conftest.$ac_objext \
12553 conftest$ac_exeext conftest.$ac_ext
12554
12555{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether OpenSSL has NID_secp384r1" >&5
12556$as_echo_n "checking whether OpenSSL has NID_secp384r1... " >&6; }
12557cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12558/* end confdefs.h. */
12559
12560#include <openssl/ec.h>
12561#include <openssl/ecdh.h>
12562#include <openssl/ecdsa.h>
12563#include <openssl/evp.h>
12564#include <openssl/objects.h>
12565#include <openssl/opensslv.h>
12566#if OPENSSL_VERSION_NUMBER < 0x0090807f /* 0.9.8g */
12567# error "OpenSSL < 0.9.8g has unreliable ECC code"
12568#endif
12569
12570int
12571main ()
12572{
12573
12574 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp384r1);
12575 const EVP_MD *m = EVP_sha384(); /* We need this too */
12576
12577 ;
12578 return 0;
12579}
12580_ACEOF
12581if ac_fn_c_try_link "$LINENO"; then :
12582 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
11923$as_echo "yes" >&6; } 12583$as_echo "yes" >&6; }
12584 enable_nistp384=1
12585else
12586 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
12587$as_echo "no" >&6; }
11924 12588
11925$as_echo "#define OPENSSL_HAS_ECC 1" >>confdefs.h 12589fi
12590rm -f core conftest.err conftest.$ac_objext \
12591 conftest$ac_exeext conftest.$ac_ext
12592
12593{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether OpenSSL has NID_secp521r1" >&5
12594$as_echo_n "checking whether OpenSSL has NID_secp521r1... " >&6; }
12595cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12596/* end confdefs.h. */
12597
12598#include <openssl/ec.h>
12599#include <openssl/ecdh.h>
12600#include <openssl/ecdsa.h>
12601#include <openssl/evp.h>
12602#include <openssl/objects.h>
12603#include <openssl/opensslv.h>
12604#if OPENSSL_VERSION_NUMBER < 0x0090807f /* 0.9.8g */
12605# error "OpenSSL < 0.9.8g has unreliable ECC code"
12606#endif
12607
12608int
12609main ()
12610{
11926 12611
11927 TEST_SSH_ECC=yes 12612 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
11928 COMMENT_OUT_ECC="" 12613 const EVP_MD *m = EVP_sha512(); /* We need this too */
12614
12615 ;
12616 return 0;
12617}
12618_ACEOF
12619if ac_fn_c_try_link "$LINENO"; then :
12620 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
12621$as_echo "yes" >&6; }
12622 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if OpenSSL's NID_secp521r1 is functional" >&5
12623$as_echo_n "checking if OpenSSL's NID_secp521r1 is functional... " >&6; }
12624 if test "$cross_compiling" = yes; then :
12625 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cross-compiling: assuming yes" >&5
12626$as_echo "$as_me: WARNING: cross-compiling: assuming yes" >&2;}
12627 enable_nistp521=1
11929 12628
11930else 12629else
12630 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12631/* end confdefs.h. */
11931 12632
11932 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 12633#include <openssl/ec.h>
12634#include <openssl/ecdh.h>
12635#include <openssl/ecdsa.h>
12636#include <openssl/evp.h>
12637#include <openssl/objects.h>
12638#include <openssl/opensslv.h>
12639
12640int
12641main ()
12642{
12643
12644 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
12645 const EVP_MD *m = EVP_sha512(); /* We need this too */
12646 exit(e == NULL || m == NULL);
12647
12648 ;
12649 return 0;
12650}
12651_ACEOF
12652if ac_fn_c_try_run "$LINENO"; then :
12653 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
12654$as_echo "yes" >&6; }
12655 enable_nistp521=1
12656else
12657 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
11933$as_echo "no" >&6; } 12658$as_echo "no" >&6; }
11934 TEST_SSH_ECC=no 12659fi
11935 COMMENT_OUT_ECC="#no ecc#" 12660rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
11936 unsupported_algorithms="$unsupported_algorithms \ 12661 conftest.$ac_objext conftest.beam conftest.$ac_ext
11937 ecdh-sha2-nistp256 ecdh-sha2-nistp384 ecdh-sha2-nistp521 \ 12662fi
11938 ecdsa-sha2-nistp256-cert-v01@openssh.com \
11939 ecdsa-sha2-nistp384-cert-v01@openssh.com \
11940 ecdsa-sha2-nistp521-cert-v01@openssh.com \
11941 ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521"
11942 12663
12664else
12665 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
12666$as_echo "no" >&6; }
11943 12667
11944fi 12668fi
11945rm -f core conftest.err conftest.$ac_objext \ 12669rm -f core conftest.err conftest.$ac_objext \
11946 conftest$ac_exeext conftest.$ac_ext 12670 conftest$ac_exeext conftest.$ac_ext
11947 12671
12672COMMENT_OUT_ECC="#no ecc#"
12673TEST_SSH_ECC=no
12674
12675if test x$enable_nistp256 = x1 || test x$enable_nistp384 = x1 || \
12676 test x$enable_nistp521 = x1; then
12677
12678$as_echo "#define OPENSSL_HAS_ECC 1" >>confdefs.h
12679
12680fi
12681if test x$enable_nistp256 = x1; then
12682
12683$as_echo "#define OPENSSL_HAS_NISTP256 1" >>confdefs.h
12684
12685 TEST_SSH_ECC=yes
12686 COMMENT_OUT_ECC=""
12687else
12688 unsupported_algorithms="$unsupported_algorithms ecdsa-sha2-nistp256 \
12689 ecdh-sha2-nistp256 ecdsa-sha2-nistp256-cert-v01@openssh.com"
12690fi
12691if test x$enable_nistp384 = x1; then
12692
12693$as_echo "#define OPENSSL_HAS_NISTP384 1" >>confdefs.h
12694
12695 TEST_SSH_ECC=yes
12696 COMMENT_OUT_ECC=""
12697else
12698 unsupported_algorithms="$unsupported_algorithms ecdsa-sha2-nistp384 \
12699 ecdh-sha2-nistp384 ecdsa-sha2-nistp384-cert-v01@openssh.com"
12700fi
12701if test x$enable_nistp521 = x1; then
12702
12703$as_echo "#define OPENSSL_HAS_NISTP521 1" >>confdefs.h
12704
12705 TEST_SSH_ECC=yes
12706 COMMENT_OUT_ECC=""
12707else
12708 unsupported_algorithms="$unsupported_algorithms ecdh-sha2-nistp521 \
12709 ecdsa-sha2-nistp521 ecdsa-sha2-nistp521-cert-v01@openssh.com"
12710fi
12711
12712
11948 12713
11949 12714
11950saved_LIBS="$LIBS" 12715saved_LIBS="$LIBS"
@@ -12635,6 +13400,18 @@ elif test "x$sandbox_arg" = "xseccomp_filter" || \
12635 13400
12636$as_echo "#define SANDBOX_SECCOMP_FILTER 1" >>confdefs.h 13401$as_echo "#define SANDBOX_SECCOMP_FILTER 1" >>confdefs.h
12637 13402
13403elif test "x$sandbox_arg" = "xcapsicum" || \
13404 ( test -z "$sandbox_arg" && \
13405 test "x$ac_cv_header_sys_capability_h" = "xyes" && \
13406 test "x$ac_cv_func_cap_rights_limit" = "xyes") ; then
13407 test "x$ac_cv_header_sys_capability_h" != "xyes" && \
13408 as_fn_error $? "capsicum sandbox requires sys/capability.h header" "$LINENO" 5
13409 test "x$ac_cv_func_cap_rights_limit" != "xyes" && \
13410 as_fn_error $? "capsicum sandbox requires cap_rights_limit function" "$LINENO" 5
13411 SANDBOX_STYLE="capsicum"
13412
13413$as_echo "#define SANDBOX_CAPSICUM 1" >>confdefs.h
13414
12638elif test "x$sandbox_arg" = "xrlimit" || \ 13415elif test "x$sandbox_arg" = "xrlimit" || \
12639 ( test -z "$sandbox_arg" && test "x$ac_cv_func_setrlimit" = "xyes" && \ 13416 ( test -z "$sandbox_arg" && test "x$ac_cv_func_setrlimit" = "xyes" && \
12640 test "x$select_works_with_rlimit" = "xyes" && \ 13417 test "x$select_works_with_rlimit" = "xyes" && \
@@ -13204,7 +13981,9 @@ $as_echo "#define HAVE_U_INT64_T 1" >>confdefs.h
13204 have_u_int64_t=1 13981 have_u_int64_t=1
13205fi 13982fi
13206 13983
13207if test -z "$have_u_int64_t" ; then 13984if (test -z "$have_u_int64_t" && \
13985 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
13986then
13208 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for u_int64_t type in sys/bitypes.h" >&5 13987 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for u_int64_t type in sys/bitypes.h" >&5
13209$as_echo_n "checking for u_int64_t type in sys/bitypes.h... " >&6; } 13988$as_echo_n "checking for u_int64_t type in sys/bitypes.h... " >&6; }
13210 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 13989 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -13276,7 +14055,9 @@ $as_echo "#define HAVE_UINTXX_T 1" >>confdefs.h
13276 fi 14055 fi
13277fi 14056fi
13278 14057
13279if test -z "$have_uintxx_t" ; then 14058if (test -z "$have_uintxx_t" && \
14059 test "x$ac_cv_header_stdint_h" = "xyes")
14060then
13280 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uintXX_t types in stdint.h" >&5 14061 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uintXX_t types in stdint.h" >&5
13281$as_echo_n "checking for uintXX_t types in stdint.h... " >&6; } 14062$as_echo_n "checking for uintXX_t types in stdint.h... " >&6; }
13282 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 14063 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -13305,6 +14086,37 @@ fi
13305rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 14086rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13306fi 14087fi
13307 14088
14089if (test -z "$have_uintxx_t" && \
14090 test "x$ac_cv_header_inttypes_h" = "xyes")
14091then
14092 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uintXX_t types in inttypes.h" >&5
14093$as_echo_n "checking for uintXX_t types in inttypes.h... " >&6; }
14094 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14095/* end confdefs.h. */
14096 #include <inttypes.h>
14097int
14098main ()
14099{
14100 uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;
14101 ;
14102 return 0;
14103}
14104_ACEOF
14105if ac_fn_c_try_compile "$LINENO"; then :
14106
14107 $as_echo "#define HAVE_UINTXX_T 1" >>confdefs.h
14108
14109 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
14110$as_echo "yes" >&6; }
14111
14112else
14113 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
14114$as_echo "no" >&6; }
14115
14116fi
14117rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14118fi
14119
13308if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \ 14120if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
13309 test "x$ac_cv_header_sys_bitypes_h" = "xyes") 14121 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
13310then 14122then
@@ -13379,6 +14191,34 @@ $as_echo "#define HAVE_U_CHAR 1" >>confdefs.h
13379 14191
13380fi 14192fi
13381 14193
14194ac_fn_c_check_type "$LINENO" "intmax_t" "ac_cv_type_intmax_t" "
14195#include <sys/types.h>
14196#include <stdint.h>
14197
14198"
14199if test "x$ac_cv_type_intmax_t" = xyes; then :
14200
14201cat >>confdefs.h <<_ACEOF
14202#define HAVE_INTMAX_T 1
14203_ACEOF
14204
14205
14206fi
14207ac_fn_c_check_type "$LINENO" "uintmax_t" "ac_cv_type_uintmax_t" "
14208#include <sys/types.h>
14209#include <stdint.h>
14210
14211"
14212if test "x$ac_cv_type_uintmax_t" = xyes; then :
14213
14214cat >>confdefs.h <<_ACEOF
14215#define HAVE_UINTMAX_T 1
14216_ACEOF
14217
14218
14219fi
14220
14221
13382 14222
13383 ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include <sys/types.h> 14223 ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include <sys/types.h>
13384#include <sys/socket.h> 14224#include <sys/socket.h>
@@ -17492,6 +18332,8 @@ fi
17492 18332
17493TEST_SSH_IPV6=$TEST_SSH_IPV6 18333TEST_SSH_IPV6=$TEST_SSH_IPV6
17494 18334
18335TEST_MALLOC_OPTIONS=$TEST_MALLOC_OPTIONS
18336
17495UNSUPPORTED_ALGORITHMS=$unsupported_algorithms 18337UNSUPPORTED_ALGORITHMS=$unsupported_algorithms
17496 18338
17497 18339
diff --git a/configure.ac b/configure.ac
index 4a1b50331..dfd32cd85 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
1# $Id: configure.ac,v 1.536 2013/08/04 11:48:41 dtucker Exp $ 1# $Id: configure.ac,v 1.568 2014/01/30 00:26:46 djm Exp $
2# 2#
3# Copyright (c) 1999-2004 Damien Miller 3# Copyright (c) 1999-2004 Damien Miller
4# 4#
@@ -15,7 +15,7 @@
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.536 $) 18AC_REVISION($Revision: 1.568 $)
19AC_CONFIG_SRCDIR([ssh.c]) 19AC_CONFIG_SRCDIR([ssh.c])
20AC_LANG([C]) 20AC_LANG([C])
21 21
@@ -120,19 +120,36 @@ AC_CHECK_DECL([PR_SET_NO_NEW_PRIVS], [have_linux_no_new_privs=1], , [
120 #include <sys/types.h> 120 #include <sys/types.h>
121 #include <linux/prctl.h> 121 #include <linux/prctl.h>
122]) 122])
123
123use_stack_protector=1 124use_stack_protector=1
125use_toolchain_hardening=1
124AC_ARG_WITH([stackprotect], 126AC_ARG_WITH([stackprotect],
125 [ --without-stackprotect Don't use compiler's stack protection], [ 127 [ --without-stackprotect Don't use compiler's stack protection], [
126 if test "x$withval" = "xno"; then 128 if test "x$withval" = "xno"; then
127 use_stack_protector=0 129 use_stack_protector=0
128 fi ]) 130 fi ])
131AC_ARG_WITH([hardening],
132 [ --without-hardening Don't use toolchain hardening flags], [
133 if test "x$withval" = "xno"; then
134 use_toolchain_hardening=0
135 fi ])
129 136
137# We use -Werror for the tests only so that we catch warnings like "this is
138# on by default" for things like -fPIE.
139AC_MSG_CHECKING([if $CC supports -Werror])
140saved_CFLAGS="$CFLAGS"
141CFLAGS="$CFLAGS -Werror"
142AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])],
143 [ AC_MSG_RESULT([yes])
144 WERROR="-Werror"],
145 [ AC_MSG_RESULT([no])
146 WERROR="" ]
147)
148CFLAGS="$saved_CFLAGS"
130 149
131if test "$GCC" = "yes" || test "$GCC" = "egcs"; then 150if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
132 OSSH_CHECK_CFLAG_COMPILE([-Qunused-arguments -Werror], 151 OSSH_CHECK_CFLAG_COMPILE([-Qunused-arguments])
133 [-Qunused-arguments]) 152 OSSH_CHECK_CFLAG_COMPILE([-Wunknown-warning-option])
134 OSSH_CHECK_CFLAG_COMPILE([-Wunknown-warning-option -Werror],
135 [-Wno-unknown-warning-option])
136 OSSH_CHECK_CFLAG_COMPILE([-Wall]) 153 OSSH_CHECK_CFLAG_COMPILE([-Wall])
137 OSSH_CHECK_CFLAG_COMPILE([-Wpointer-arith]) 154 OSSH_CHECK_CFLAG_COMPILE([-Wpointer-arith])
138 OSSH_CHECK_CFLAG_COMPILE([-Wuninitialized]) 155 OSSH_CHECK_CFLAG_COMPILE([-Wuninitialized])
@@ -143,6 +160,17 @@ if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
143 OSSH_CHECK_CFLAG_COMPILE([-Wunused-result], [-Wno-unused-result]) 160 OSSH_CHECK_CFLAG_COMPILE([-Wunused-result], [-Wno-unused-result])
144 OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing]) 161 OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing])
145 OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2]) 162 OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2])
163 if test "x$use_toolchain_hardening" = "x1"; then
164 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,relro])
165 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,now])
166 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,noexecstack])
167 # NB. -ftrapv expects certain support functions to be present in
168 # the compiler library (libgcc or similar) to detect integer operations
169 # that can overflow. We must check that the result of enabling it
170 # actually links. The test program compiled/linked includes a number
171 # of integer operations that should exercise this.
172 OSSH_CHECK_CFLAG_LINK([-ftrapv])
173 fi
146 AC_MSG_CHECKING([gcc version]) 174 AC_MSG_CHECKING([gcc version])
147 GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'` 175 GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
148 case $GCC_VER in 176 case $GCC_VER in
@@ -169,7 +197,8 @@ if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
169 # and/or platforms, so we test if we can. If it's not supported 197 # and/or platforms, so we test if we can. If it's not supported
170 # on a given platform gcc will emit a warning so we use -Werror. 198 # on a given platform gcc will emit a warning so we use -Werror.
171 if test "x$use_stack_protector" = "x1"; then 199 if test "x$use_stack_protector" = "x1"; then
172 for t in -fstack-protector-all -fstack-protector; do 200 for t in -fstack-protector-strong -fstack-protector-all \
201 -fstack-protector; do
173 AC_MSG_CHECKING([if $CC supports $t]) 202 AC_MSG_CHECKING([if $CC supports $t])
174 saved_CFLAGS="$CFLAGS" 203 saved_CFLAGS="$CFLAGS"
175 saved_LDFLAGS="$LDFLAGS" 204 saved_LDFLAGS="$LDFLAGS"
@@ -296,6 +325,7 @@ AC_ARG_WITH([Werror],
296) 325)
297 326
298AC_CHECK_HEADERS([ \ 327AC_CHECK_HEADERS([ \
328 blf.h \
299 bstring.h \ 329 bstring.h \
300 crypt.h \ 330 crypt.h \
301 crypto/sha2.h \ 331 crypto/sha2.h \
@@ -309,6 +339,7 @@ AC_CHECK_HEADERS([ \
309 glob.h \ 339 glob.h \
310 ia.h \ 340 ia.h \
311 iaf.h \ 341 iaf.h \
342 inttypes.h \
312 limits.h \ 343 limits.h \
313 locale.h \ 344 locale.h \
314 login.h \ 345 login.h \
@@ -333,6 +364,7 @@ AC_CHECK_HEADERS([ \
333 sys/audit.h \ 364 sys/audit.h \
334 sys/bitypes.h \ 365 sys/bitypes.h \
335 sys/bsdtty.h \ 366 sys/bsdtty.h \
367 sys/capability.h \
336 sys/cdefs.h \ 368 sys/cdefs.h \
337 sys/dir.h \ 369 sys/dir.h \
338 sys/mman.h \ 370 sys/mman.h \
@@ -513,7 +545,10 @@ case "$host" in
513 [Define if your platform needs to skip post auth 545 [Define if your platform needs to skip post auth
514 file descriptor passing]) 546 file descriptor passing])
515 AC_DEFINE([SSH_IOBUFSZ], [65535], [Windows is sensitive to read buffer size]) 547 AC_DEFINE([SSH_IOBUFSZ], [65535], [Windows is sensitive to read buffer size])
516 AC_DEFINE([FILESYSTEM_NO_BACKSLASH], [1], [File names may not contain backslash characters]) 548 AC_DEFINE([FILESYSTEM_NO_BACKSLASH], [1], [File names may not contain backslash characters])
549 # Cygwin defines optargs, optargs as declspec(dllimport) for historical
550 # reasons which cause compile warnings, so we disable those warnings.
551 OSSH_CHECK_CFLAG_COMPILE([-Wno-attributes])
517 ;; 552 ;;
518*-*-dgux*) 553*-*-dgux*)
519 AC_DEFINE([IP_TOS_IS_BROKEN], [1], 554 AC_DEFINE([IP_TOS_IS_BROKEN], [1],
@@ -523,6 +558,7 @@ case "$host" in
523 AC_DEFINE([BROKEN_SETREGID]) 558 AC_DEFINE([BROKEN_SETREGID])
524 ;; 559 ;;
525*-*-darwin*) 560*-*-darwin*)
561 use_pie=auto
526 AC_MSG_CHECKING([if we have working getaddrinfo]) 562 AC_MSG_CHECKING([if we have working getaddrinfo])
527 AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <mach-o/dyld.h> 563 AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <mach-o/dyld.h>
528main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16)) 564main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
@@ -563,6 +599,7 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
563 ;; 599 ;;
564*-*-dragonfly*) 600*-*-dragonfly*)
565 SSHDLIBS="$SSHDLIBS -lcrypt" 601 SSHDLIBS="$SSHDLIBS -lcrypt"
602 TEST_MALLOC_OPTIONS="AFGJPRX"
566 ;; 603 ;;
567*-*-haiku*) 604*-*-haiku*)
568 LIBS="$LIBS -lbsd " 605 LIBS="$LIBS -lbsd "
@@ -660,6 +697,7 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
660 ;; 697 ;;
661*-*-linux*) 698*-*-linux*)
662 no_dev_ptmx=1 699 no_dev_ptmx=1
700 use_pie=auto
663 check_for_libcrypt_later=1 701 check_for_libcrypt_later=1
664 check_for_openpty_ctty_bug=1 702 check_for_openpty_ctty_bug=1
665 AC_DEFINE([PAM_TTY_KLUDGE], [1], 703 AC_DEFINE([PAM_TTY_KLUDGE], [1],
@@ -728,6 +766,11 @@ mips-sony-bsd|mips-sony-newsos4)
728 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support])) 766 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
729 AC_DEFINE([SSH_TUN_PREPEND_AF], [1], 767 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
730 [Prepend the address family to IP tunnel traffic]) 768 [Prepend the address family to IP tunnel traffic])
769 TEST_MALLOC_OPTIONS="AJRX"
770 AC_DEFINE([BROKEN_STRNVIS], [1],
771 [NetBSD strnvis argument order is swapped compared to OpenBSD])
772 AC_DEFINE([BROKEN_READ_COMPARISON], [1],
773 [NetBSD read function is sometimes redirected, breaking atomicio comparisons against it])
731 ;; 774 ;;
732*-*-freebsd*) 775*-*-freebsd*)
733 check_for_libcrypt_later=1 776 check_for_libcrypt_later=1
@@ -736,7 +779,13 @@ mips-sony-bsd|mips-sony-newsos4)
736 AC_CHECK_HEADER([net/if_tap.h], , 779 AC_CHECK_HEADER([net/if_tap.h], ,
737 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support])) 780 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
738 AC_DEFINE([BROKEN_GLOB], [1], [FreeBSD glob does not do what we need]) 781 AC_DEFINE([BROKEN_GLOB], [1], [FreeBSD glob does not do what we need])
739 AC_DEFINE([BROKEN_STRNVIS], [1], [FreeBSD strnvis does not do what we need]) 782 AC_DEFINE([BROKEN_STRNVIS], [1],
783 [FreeBSD strnvis argument order is swapped compared to OpenBSD])
784 TEST_MALLOC_OPTIONS="AJRX"
785 # Preauth crypto occasionally uses file descriptors for crypto offload
786 # and will crash if they cannot be opened.
787 AC_DEFINE([SANDBOX_SKIP_RLIMIT_NOFILE], [1],
788 [define if setrlimit RLIMIT_NOFILE breaks things])],
740 ;; 789 ;;
741*-*-bsdi*) 790*-*-bsdi*)
742 AC_DEFINE([SETEUID_BREAKS_SETUID]) 791 AC_DEFINE([SETEUID_BREAKS_SETUID])
@@ -754,11 +803,13 @@ mips-sony-bsd|mips-sony-newsos4)
754 AC_DEFINE([BROKEN_SAVED_UIDS], [1], [Needed for NeXT]) 803 AC_DEFINE([BROKEN_SAVED_UIDS], [1], [Needed for NeXT])
755 ;; 804 ;;
756*-*-openbsd*) 805*-*-openbsd*)
806 use_pie=auto
757 AC_DEFINE([HAVE_ATTRIBUTE__SENTINEL__], [1], [OpenBSD's gcc has sentinel]) 807 AC_DEFINE([HAVE_ATTRIBUTE__SENTINEL__], [1], [OpenBSD's gcc has sentinel])
758 AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD's gcc has bounded]) 808 AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD's gcc has bounded])
759 AC_DEFINE([SSH_TUN_OPENBSD], [1], [Open tunnel devices the OpenBSD way]) 809 AC_DEFINE([SSH_TUN_OPENBSD], [1], [Open tunnel devices the OpenBSD way])
760 AC_DEFINE([SYSLOG_R_SAFE_IN_SIGHAND], [1], 810 AC_DEFINE([SYSLOG_R_SAFE_IN_SIGHAND], [1],
761 [syslog_r function is safe to use in in a signal handler]) 811 [syslog_r function is safe to use in in a signal handler])
812 TEST_MALLOC_OPTIONS="AFGJPRX"
762 ;; 813 ;;
763*-*-solaris*) 814*-*-solaris*)
764 if test "x$withval" != "xno" ; then 815 if test "x$withval" != "xno" ; then
@@ -1191,6 +1242,9 @@ AC_SEARCH_LIBS([openpty], [util bsd])
1191AC_SEARCH_LIBS([updwtmp], [util bsd]) 1242AC_SEARCH_LIBS([updwtmp], [util bsd])
1192AC_CHECK_FUNCS([fmt_scaled scan_scaled login logout openpty updwtmp logwtmp]) 1243AC_CHECK_FUNCS([fmt_scaled scan_scaled login logout openpty updwtmp logwtmp])
1193 1244
1245# On some platforms, inet_ntop may be found in libresolv or libnsl.
1246AC_SEARCH_LIBS([inet_ntop], [resolv nsl])
1247
1194AC_FUNC_STRFTIME 1248AC_FUNC_STRFTIME
1195 1249
1196# Check for ALTDIRFUNC glob() extension 1250# Check for ALTDIRFUNC glob() extension
@@ -1442,7 +1496,7 @@ AC_ARG_WITH([libedit],
1442 fi 1496 fi
1443 fi 1497 fi
1444 if test "x$use_pkgconfig_for_libedit" = "xyes"; then 1498 if test "x$use_pkgconfig_for_libedit" = "xyes"; then
1445 LIBEDIT=`$PKGCONFIG --libs-only-l libedit` 1499 LIBEDIT=`$PKGCONFIG --libs libedit`
1446 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`" 1500 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`"
1447 else 1501 else
1448 LIBEDIT="-ledit -lcurses" 1502 LIBEDIT="-ledit -lcurses"
@@ -1496,7 +1550,7 @@ AC_ARG_WITH([audit],
1496 # These are optional 1550 # These are optional
1497 AC_CHECK_FUNCS([getaudit_addr aug_get_machine]) 1551 AC_CHECK_FUNCS([getaudit_addr aug_get_machine])
1498 AC_DEFINE([USE_BSM_AUDIT], [1], [Use BSM audit module]) 1552 AC_DEFINE([USE_BSM_AUDIT], [1], [Use BSM audit module])
1499 if test "$sol2ver" -eq 11; then 1553 if test "$sol2ver" -ge 11; then
1500 SSHDLIBS="$SSHDLIBS -lscf" 1554 SSHDLIBS="$SSHDLIBS -lscf"
1501 AC_DEFINE([BROKEN_BSM_API], [1], 1555 AC_DEFINE([BROKEN_BSM_API], [1],
1502 [The system has incomplete BSM API]) 1556 [The system has incomplete BSM API])
@@ -1524,10 +1578,62 @@ AC_ARG_WITH([audit],
1524 esac ] 1578 esac ]
1525) 1579)
1526 1580
1581AC_ARG_WITH([pie],
1582 [ --with-pie Build Position Independent Executables if possible], [
1583 if test "x$withval" = "xno"; then
1584 use_pie=no
1585 fi
1586 if test "x$withval" = "xyes"; then
1587 use_pie=yes
1588 fi
1589 ]
1590)
1591if test "x$use_pie" = "x"; then
1592 use_pie=no
1593fi
1594if test "x$use_toolchain_hardening" != "x1" && test "x$use_pie" = "xauto"; then
1595 # Turn off automatic PIE when toolchain hardening is off.
1596 use_pie=no
1597fi
1598if test "x$use_pie" = "xauto"; then
1599 # Automatic PIE requires gcc >= 4.x
1600 AC_MSG_CHECKING([for gcc >= 4.x])
1601 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1602#if !defined(__GNUC__) || __GNUC__ < 4
1603#error gcc is too old
1604#endif
1605]])],
1606 [ AC_MSG_RESULT([yes]) ],
1607 [ AC_MSG_RESULT([no])
1608 use_pie=no ]
1609)
1610fi
1611if test "x$use_pie" != "xno"; then
1612 SAVED_CFLAGS="$CFLAGS"
1613 SAVED_LDFLAGS="$LDFLAGS"
1614 OSSH_CHECK_CFLAG_COMPILE([-fPIE])
1615 OSSH_CHECK_LDFLAG_LINK([-pie])
1616 # We use both -fPIE and -pie or neither.
1617 AC_MSG_CHECKING([whether both -fPIE and -pie are supported])
1618 if echo "x $CFLAGS" | grep ' -fPIE' >/dev/null 2>&1 && \
1619 echo "x $LDFLAGS" | grep ' -pie' >/dev/null 2>&1 ; then
1620 AC_MSG_RESULT([yes])
1621 else
1622 AC_MSG_RESULT([no])
1623 CFLAGS="$SAVED_CFLAGS"
1624 LDFLAGS="$SAVED_LDFLAGS"
1625 fi
1626fi
1627
1527dnl Checks for library functions. Please keep in alphabetical order 1628dnl Checks for library functions. Please keep in alphabetical order
1528AC_CHECK_FUNCS([ \ 1629AC_CHECK_FUNCS([ \
1630 Blowfish_initstate \
1631 Blowfish_expandstate \
1632 Blowfish_expand0state \
1633 Blowfish_stream2word \
1529 arc4random \ 1634 arc4random \
1530 arc4random_buf \ 1635 arc4random_buf \
1636 arc4random_stir \
1531 arc4random_uniform \ 1637 arc4random_uniform \
1532 asprintf \ 1638 asprintf \
1533 b64_ntop \ 1639 b64_ntop \
@@ -1535,7 +1641,10 @@ AC_CHECK_FUNCS([ \
1535 b64_pton \ 1641 b64_pton \
1536 __b64_pton \ 1642 __b64_pton \
1537 bcopy \ 1643 bcopy \
1644 bcrypt_pbkdf \
1538 bindresvport_sa \ 1645 bindresvport_sa \
1646 blf_enc \
1647 cap_rights_limit \
1539 clock \ 1648 clock \
1540 closefrom \ 1649 closefrom \
1541 dirfd \ 1650 dirfd \
@@ -1543,6 +1652,7 @@ AC_CHECK_FUNCS([ \
1543 fchmod \ 1652 fchmod \
1544 fchown \ 1653 fchown \
1545 freeaddrinfo \ 1654 freeaddrinfo \
1655 fstatfs \
1546 fstatvfs \ 1656 fstatvfs \
1547 futimes \ 1657 futimes \
1548 getaddrinfo \ 1658 getaddrinfo \
@@ -2312,7 +2422,17 @@ AC_LINK_IFELSE(
2312 ] 2422 ]
2313) 2423)
2314 2424
2315AC_CHECK_FUNCS([RSA_generate_key_ex DSA_generate_parameters_ex BN_is_prime_ex RSA_get_default_method HMAC_CTX_init]) 2425AC_CHECK_FUNCS([ \
2426 BN_is_prime_ex \
2427 DSA_generate_parameters_ex \
2428 EVP_DigestInit_ex \
2429 EVP_DigestFinal_ex \
2430 EVP_MD_CTX_init \
2431 EVP_MD_CTX_cleanup \
2432 HMAC_CTX_init \
2433 RSA_generate_key_ex \
2434 RSA_get_default_method \
2435])
2316 2436
2317AC_ARG_WITH([ssl-engine], 2437AC_ARG_WITH([ssl-engine],
2318 [ --with-ssl-engine Enable OpenSSL (hardware) ENGINE support ], 2438 [ --with-ssl-engine Enable OpenSSL (hardware) ENGINE support ],
@@ -2436,19 +2556,58 @@ fi
2436AC_CHECK_FUNCS([crypt DES_crypt]) 2556AC_CHECK_FUNCS([crypt DES_crypt])
2437 2557
2438# Search for SHA256 support in libc and/or OpenSSL 2558# Search for SHA256 support in libc and/or OpenSSL
2439AC_CHECK_FUNCS([SHA256_Update EVP_sha256], 2559AC_CHECK_FUNCS([SHA256_Update EVP_sha256], ,
2440 [TEST_SSH_SHA256=yes], 2560 [unsupported_algorithms="$unsupported_algorithms \
2441 [TEST_SSH_SHA256=no
2442 unsupported_algorithms="$unsupported_algorithms \
2443 hmac-sha2-256 hmac-sha2-512 \ 2561 hmac-sha2-256 hmac-sha2-512 \
2444 diffie-hellman-group-exchange-sha256 \ 2562 diffie-hellman-group-exchange-sha256 \
2445 hmac-sha2-256-etm@openssh.com hmac-sha2-512-etm@openssh.com" 2563 hmac-sha2-256-etm@openssh.com hmac-sha2-512-etm@openssh.com"
2446 ] 2564 ]
2447) 2565)
2448AC_SUBST([TEST_SSH_SHA256])
2449 2566
2450# Check complete ECC support in OpenSSL 2567# Check complete ECC support in OpenSSL
2451AC_MSG_CHECKING([whether OpenSSL has complete ECC support]) 2568AC_MSG_CHECKING([whether OpenSSL has NID_X9_62_prime256v1])
2569AC_LINK_IFELSE(
2570 [AC_LANG_PROGRAM([[
2571#include <openssl/ec.h>
2572#include <openssl/ecdh.h>
2573#include <openssl/ecdsa.h>
2574#include <openssl/evp.h>
2575#include <openssl/objects.h>
2576#include <openssl/opensslv.h>
2577#if OPENSSL_VERSION_NUMBER < 0x0090807f /* 0.9.8g */
2578# error "OpenSSL < 0.9.8g has unreliable ECC code"
2579#endif
2580 ]], [[
2581 EC_KEY *e = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
2582 const EVP_MD *m = EVP_sha256(); /* We need this too */
2583 ]])],
2584 [ AC_MSG_RESULT([yes])
2585 enable_nistp256=1 ],
2586 [ AC_MSG_RESULT([no]) ]
2587)
2588
2589AC_MSG_CHECKING([whether OpenSSL has NID_secp384r1])
2590AC_LINK_IFELSE(
2591 [AC_LANG_PROGRAM([[
2592#include <openssl/ec.h>
2593#include <openssl/ecdh.h>
2594#include <openssl/ecdsa.h>
2595#include <openssl/evp.h>
2596#include <openssl/objects.h>
2597#include <openssl/opensslv.h>
2598#if OPENSSL_VERSION_NUMBER < 0x0090807f /* 0.9.8g */
2599# error "OpenSSL < 0.9.8g has unreliable ECC code"
2600#endif
2601 ]], [[
2602 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp384r1);
2603 const EVP_MD *m = EVP_sha384(); /* We need this too */
2604 ]])],
2605 [ AC_MSG_RESULT([yes])
2606 enable_nistp384=1 ],
2607 [ AC_MSG_RESULT([no]) ]
2608)
2609
2610AC_MSG_CHECKING([whether OpenSSL has NID_secp521r1])
2452AC_LINK_IFELSE( 2611AC_LINK_IFELSE(
2453 [AC_LANG_PROGRAM([[ 2612 [AC_LANG_PROGRAM([[
2454#include <openssl/ec.h> 2613#include <openssl/ec.h>
@@ -2464,25 +2623,63 @@ AC_LINK_IFELSE(
2464 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1); 2623 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2465 const EVP_MD *m = EVP_sha512(); /* We need this too */ 2624 const EVP_MD *m = EVP_sha512(); /* We need this too */
2466 ]])], 2625 ]])],
2467 [ 2626 [ AC_MSG_RESULT([yes])
2468 AC_MSG_RESULT([yes]) 2627 AC_MSG_CHECKING([if OpenSSL's NID_secp521r1 is functional])
2469 AC_DEFINE([OPENSSL_HAS_ECC], [1], 2628 AC_RUN_IFELSE(
2470 [libcrypto includes complete ECC support]) 2629 [AC_LANG_PROGRAM([[
2471 TEST_SSH_ECC=yes 2630#include <openssl/ec.h>
2472 COMMENT_OUT_ECC="" 2631#include <openssl/ecdh.h>
2473 ], 2632#include <openssl/ecdsa.h>
2474 [ 2633#include <openssl/evp.h>
2475 AC_MSG_RESULT([no]) 2634#include <openssl/objects.h>
2476 TEST_SSH_ECC=no 2635#include <openssl/opensslv.h>
2477 COMMENT_OUT_ECC="#no ecc#" 2636 ]],[[
2478 unsupported_algorithms="$unsupported_algorithms \ 2637 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2479 ecdh-sha2-nistp256 ecdh-sha2-nistp384 ecdh-sha2-nistp521 \ 2638 const EVP_MD *m = EVP_sha512(); /* We need this too */
2480 ecdsa-sha2-nistp256-cert-v01@openssh.com \ 2639 exit(e == NULL || m == NULL);
2481 ecdsa-sha2-nistp384-cert-v01@openssh.com \ 2640 ]])],
2482 ecdsa-sha2-nistp521-cert-v01@openssh.com \ 2641 [ AC_MSG_RESULT([yes])
2483 ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521" 2642 enable_nistp521=1 ],
2484 ] 2643 [ AC_MSG_RESULT([no]) ],
2644 [ AC_MSG_WARN([cross-compiling: assuming yes])
2645 enable_nistp521=1 ]
2646 )],
2647 AC_MSG_RESULT([no])
2485) 2648)
2649
2650COMMENT_OUT_ECC="#no ecc#"
2651TEST_SSH_ECC=no
2652
2653if test x$enable_nistp256 = x1 || test x$enable_nistp384 = x1 || \
2654 test x$enable_nistp521 = x1; then
2655 AC_DEFINE(OPENSSL_HAS_ECC, [1], [OpenSSL has ECC])
2656fi
2657if test x$enable_nistp256 = x1; then
2658 AC_DEFINE([OPENSSL_HAS_NISTP256], [1],
2659 [libcrypto has NID_X9_62_prime256v1])
2660 TEST_SSH_ECC=yes
2661 COMMENT_OUT_ECC=""
2662else
2663 unsupported_algorithms="$unsupported_algorithms ecdsa-sha2-nistp256 \
2664 ecdh-sha2-nistp256 ecdsa-sha2-nistp256-cert-v01@openssh.com"
2665fi
2666if test x$enable_nistp384 = x1; then
2667 AC_DEFINE([OPENSSL_HAS_NISTP384], [1], [libcrypto has NID_secp384r1])
2668 TEST_SSH_ECC=yes
2669 COMMENT_OUT_ECC=""
2670else
2671 unsupported_algorithms="$unsupported_algorithms ecdsa-sha2-nistp384 \
2672 ecdh-sha2-nistp384 ecdsa-sha2-nistp384-cert-v01@openssh.com"
2673fi
2674if test x$enable_nistp521 = x1; then
2675 AC_DEFINE([OPENSSL_HAS_NISTP521], [1], [libcrypto has NID_secp521r1])
2676 TEST_SSH_ECC=yes
2677 COMMENT_OUT_ECC=""
2678else
2679 unsupported_algorithms="$unsupported_algorithms ecdh-sha2-nistp521 \
2680 ecdsa-sha2-nistp521 ecdsa-sha2-nistp521-cert-v01@openssh.com"
2681fi
2682
2486AC_SUBST([TEST_SSH_ECC]) 2683AC_SUBST([TEST_SSH_ECC])
2487AC_SUBST([COMMENT_OUT_ECC]) 2684AC_SUBST([COMMENT_OUT_ECC])
2488 2685
@@ -2714,7 +2911,7 @@ fi
2714# Decide which sandbox style to use 2911# Decide which sandbox style to use
2715sandbox_arg="" 2912sandbox_arg=""
2716AC_ARG_WITH([sandbox], 2913AC_ARG_WITH([sandbox],
2717 [ --with-sandbox=style Specify privilege separation sandbox (no, darwin, rlimit, systrace, seccomp_filter)], 2914 [ --with-sandbox=style Specify privilege separation sandbox (no, darwin, rlimit, systrace, seccomp_filter, capsicum)],
2718 [ 2915 [
2719 if test "x$withval" = "xyes" ; then 2916 if test "x$withval" = "xyes" ; then
2720 sandbox_arg="" 2917 sandbox_arg=""
@@ -2843,6 +3040,16 @@ elif test "x$sandbox_arg" = "xseccomp_filter" || \
2843 AC_MSG_ERROR([seccomp_filter sandbox requires prctl function]) 3040 AC_MSG_ERROR([seccomp_filter sandbox requires prctl function])
2844 SANDBOX_STYLE="seccomp_filter" 3041 SANDBOX_STYLE="seccomp_filter"
2845 AC_DEFINE([SANDBOX_SECCOMP_FILTER], [1], [Sandbox using seccomp filter]) 3042 AC_DEFINE([SANDBOX_SECCOMP_FILTER], [1], [Sandbox using seccomp filter])
3043elif test "x$sandbox_arg" = "xcapsicum" || \
3044 ( test -z "$sandbox_arg" && \
3045 test "x$ac_cv_header_sys_capability_h" = "xyes" && \
3046 test "x$ac_cv_func_cap_rights_limit" = "xyes") ; then
3047 test "x$ac_cv_header_sys_capability_h" != "xyes" && \
3048 AC_MSG_ERROR([capsicum sandbox requires sys/capability.h header])
3049 test "x$ac_cv_func_cap_rights_limit" != "xyes" && \
3050 AC_MSG_ERROR([capsicum sandbox requires cap_rights_limit function])
3051 SANDBOX_STYLE="capsicum"
3052 AC_DEFINE([SANDBOX_CAPSICUM], [1], [Sandbox using capsicum])
2846elif test "x$sandbox_arg" = "xrlimit" || \ 3053elif test "x$sandbox_arg" = "xrlimit" || \
2847 ( test -z "$sandbox_arg" && test "x$ac_cv_func_setrlimit" = "xyes" && \ 3054 ( test -z "$sandbox_arg" && test "x$ac_cv_func_setrlimit" = "xyes" && \
2848 test "x$select_works_with_rlimit" = "xyes" && \ 3055 test "x$select_works_with_rlimit" = "xyes" && \
@@ -3066,7 +3273,9 @@ if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
3066 have_u_int64_t=1 3273 have_u_int64_t=1
3067fi 3274fi
3068 3275
3069if test -z "$have_u_int64_t" ; then 3276if (test -z "$have_u_int64_t" && \
3277 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
3278then
3070 AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h]) 3279 AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h])
3071 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/bitypes.h> ]], 3280 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/bitypes.h> ]],
3072 [[ u_int64_t a; a = 1]])], 3281 [[ u_int64_t a; a = 1]])],
@@ -3096,7 +3305,9 @@ if test -z "$have_u_intxx_t" ; then
3096 fi 3305 fi
3097fi 3306fi
3098 3307
3099if test -z "$have_uintxx_t" ; then 3308if (test -z "$have_uintxx_t" && \
3309 test "x$ac_cv_header_stdint_h" = "xyes")
3310then
3100 AC_MSG_CHECKING([for uintXX_t types in stdint.h]) 3311 AC_MSG_CHECKING([for uintXX_t types in stdint.h])
3101 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]], 3312 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3102 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])], 3313 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
@@ -3107,6 +3318,19 @@ if test -z "$have_uintxx_t" ; then
3107 ]) 3318 ])
3108fi 3319fi
3109 3320
3321if (test -z "$have_uintxx_t" && \
3322 test "x$ac_cv_header_inttypes_h" = "xyes")
3323then
3324 AC_MSG_CHECKING([for uintXX_t types in inttypes.h])
3325 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <inttypes.h> ]],
3326 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
3327 [
3328 AC_DEFINE([HAVE_UINTXX_T])
3329 AC_MSG_RESULT([yes])
3330 ], [ AC_MSG_RESULT([no])
3331 ])
3332fi
3333
3110if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \ 3334if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
3111 test "x$ac_cv_header_sys_bitypes_h" = "xyes") 3335 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
3112then 3336then
@@ -3137,6 +3361,11 @@ if test "x$ac_cv_have_u_char" = "xyes" ; then
3137 AC_DEFINE([HAVE_U_CHAR], [1], [define if you have u_char data type]) 3361 AC_DEFINE([HAVE_U_CHAR], [1], [define if you have u_char data type])
3138fi 3362fi
3139 3363
3364AC_CHECK_TYPES([intmax_t, uintmax_t], , , [
3365#include <sys/types.h>
3366#include <stdint.h>
3367])
3368
3140TYPE_SOCKLEN_T 3369TYPE_SOCKLEN_T
3141 3370
3142AC_CHECK_TYPES([sig_atomic_t], , , [#include <signal.h>]) 3371AC_CHECK_TYPES([sig_atomic_t], , , [#include <signal.h>])
@@ -4561,6 +4790,7 @@ else
4561fi 4790fi
4562AC_CHECK_DECL([BROKEN_GETADDRINFO], [TEST_SSH_IPV6=no]) 4791AC_CHECK_DECL([BROKEN_GETADDRINFO], [TEST_SSH_IPV6=no])
4563AC_SUBST([TEST_SSH_IPV6], [$TEST_SSH_IPV6]) 4792AC_SUBST([TEST_SSH_IPV6], [$TEST_SSH_IPV6])
4793AC_SUBST([TEST_MALLOC_OPTIONS], [$TEST_MALLOC_OPTIONS])
4564AC_SUBST([UNSUPPORTED_ALGORITHMS], [$unsupported_algorithms]) 4794AC_SUBST([UNSUPPORTED_ALGORITHMS], [$unsupported_algorithms])
4565 4795
4566AC_EXEEXT 4796AC_EXEEXT
diff --git a/contrib/caldera/openssh.spec b/contrib/caldera/openssh.spec
index d026b72d8..3c417bb8f 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 6.4p1 19%define version 6.5p1
20%if %{use_stable} 20%if %{use_stable}
21 %define cvs %{nil} 21 %define cvs %{nil}
22 %define release 1 22 %define release 1
@@ -363,4 +363,4 @@ fi
363* Mon Jan 01 1998 ... 363* Mon Jan 01 1998 ...
364Template Version: 1.31 364Template Version: 1.31
365 365
366$Id: openssh.spec,v 1.80.4.1 2013/11/08 01:36:19 djm Exp $ 366$Id: openssh.spec,v 1.82 2014/01/16 07:51:10 djm Exp $
diff --git a/contrib/cygwin/ssh-host-config b/contrib/cygwin/ssh-host-config
index c542d5cb6..05efd3b3b 100644
--- a/contrib/cygwin/ssh-host-config
+++ b/contrib/cygwin/ssh-host-config
@@ -68,54 +68,6 @@ password_value=
68opt_force=no 68opt_force=no
69 69
70# ====================================================================== 70# ======================================================================
71# Routine: create_host_keys
72# ======================================================================
73create_host_keys() {
74 local ret=0
75
76 if [ ! -f "${SYSCONFDIR}/ssh_host_key" ]
77 then
78 csih_inform "Generating ${SYSCONFDIR}/ssh_host_key"
79 if ! /usr/bin/ssh-keygen -t rsa1 -f ${SYSCONFDIR}/ssh_host_key -N '' > /dev/null
80 then
81 csih_warning "Generating ${SYSCONFDIR}/ssh_host_key failed!"
82 let ++ret
83 fi
84 fi
85
86 if [ ! -f "${SYSCONFDIR}/ssh_host_rsa_key" ]
87 then
88 csih_inform "Generating ${SYSCONFDIR}/ssh_host_rsa_key"
89 if ! /usr/bin/ssh-keygen -t rsa -f ${SYSCONFDIR}/ssh_host_rsa_key -N '' > /dev/null
90 then
91 csih_warning "Generating ${SYSCONFDIR}/ssh_host_key failed!"
92 let ++ret
93 fi
94 fi
95
96 if [ ! -f "${SYSCONFDIR}/ssh_host_dsa_key" ]
97 then
98 csih_inform "Generating ${SYSCONFDIR}/ssh_host_dsa_key"
99 if ! /usr/bin/ssh-keygen -t dsa -f ${SYSCONFDIR}/ssh_host_dsa_key -N '' > /dev/null
100 then
101 csih_warning "Generating ${SYSCONFDIR}/ssh_host_key failed!"
102 let ++ret
103 fi
104 fi
105
106 if [ ! -f "${SYSCONFDIR}/ssh_host_ecdsa_key" ]
107 then
108 csih_inform "Generating ${SYSCONFDIR}/ssh_host_ecdsa_key"
109 if ! /usr/bin/ssh-keygen -t ecdsa -f ${SYSCONFDIR}/ssh_host_ecdsa_key -N '' > /dev/null
110 then
111 csih_warning "Generating ${SYSCONFDIR}/ssh_host_key failed!"
112 let ++ret
113 fi
114 fi
115 return $ret
116} # --- End of create_host_keys --- #
117
118# ======================================================================
119# Routine: update_services_file 71# Routine: update_services_file
120# ====================================================================== 72# ======================================================================
121update_services_file() { 73update_services_file() {
@@ -719,8 +671,8 @@ then
719 let ++warning_cnt 671 let ++warning_cnt
720fi 672fi
721 673
722# host keys 674# generate missing host keys
723create_host_keys || let warning_cnt+=$? 675/usr/bin/ssh-keygen -A || let warning_cnt+=$?
724 676
725# handle ssh_config 677# handle ssh_config
726csih_install_config "${SYSCONFDIR}/ssh_config" "${SYSCONFDIR}/defaults" || let ++warning_cnt 678csih_install_config "${SYSCONFDIR}/ssh_config" "${SYSCONFDIR}/defaults" || let ++warning_cnt
diff --git a/contrib/redhat/openssh.spec b/contrib/redhat/openssh.spec
index 29a38dedc..d47cf3862 100644
--- a/contrib/redhat/openssh.spec
+++ b/contrib/redhat/openssh.spec
@@ -1,4 +1,4 @@
1%define ver 6.4p1 1%define ver 6.5p1
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/suse/openssh.spec b/contrib/suse/openssh.spec
index 3a612bd23..6693fe2bc 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: 6.4p1 16Version: 6.5p1
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/crypto_api.h b/crypto_api.h
new file mode 100644
index 000000000..5820ce8fa
--- /dev/null
+++ b/crypto_api.h
@@ -0,0 +1,44 @@
1/* $OpenBSD: crypto_api.h,v 1.3 2013/12/17 10:36:38 markus Exp $ */
2
3/*
4 * Assembled from generated headers and source files by Markus Friedl.
5 * Placed in the public domain.
6 */
7
8#ifndef crypto_api_h
9#define crypto_api_h
10
11#ifdef HAVE_STDINT_H
12# include <stdint.h>
13#endif
14#include <stdlib.h>
15
16typedef int32_t crypto_int32;
17typedef uint32_t crypto_uint32;
18
19#define randombytes(buf, buf_len) arc4random_buf((buf), (buf_len))
20
21#define crypto_hashblocks_sha512_STATEBYTES 64U
22#define crypto_hashblocks_sha512_BLOCKBYTES 128U
23
24int crypto_hashblocks_sha512(unsigned char *, const unsigned char *,
25 unsigned long long);
26
27#define crypto_hash_sha512_BYTES 64U
28
29int crypto_hash_sha512(unsigned char *, const unsigned char *,
30 unsigned long long);
31
32int crypto_verify_32(const unsigned char *, const unsigned char *);
33
34#define crypto_sign_ed25519_SECRETKEYBYTES 64U
35#define crypto_sign_ed25519_PUBLICKEYBYTES 32U
36#define crypto_sign_ed25519_BYTES 64U
37
38int crypto_sign_ed25519(unsigned char *, unsigned long long *,
39 const unsigned char *, unsigned long long, const unsigned char *);
40int crypto_sign_ed25519_open(unsigned char *, unsigned long long *,
41 const unsigned char *, unsigned long long, const unsigned char *);
42int crypto_sign_ed25519_keypair(unsigned char *, unsigned char *);
43
44#endif /* crypto_api_h */
diff --git a/defines.h b/defines.h
index d5ce52f32..354d5b614 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.172 2013/06/01 21:18:48 dtucker Exp $ */ 28/* $Id: defines.h,v 1.176 2014/01/17 13:12:38 dtucker Exp $ */
29 29
30 30
31/* Constants */ 31/* Constants */
@@ -269,6 +269,21 @@ typedef unsigned long long int u_int64_t;
269# endif 269# endif
270#endif 270#endif
271 271
272#ifndef HAVE_UINTXX_T
273typedef u_int8_t uint8_t;
274typedef u_int16_t uint16_t;
275typedef u_int32_t uint32_t;
276typedef u_int64_t uint64_t;
277#endif
278
279#ifndef HAVE_INTMAX_T
280typedef long long intmax_t;
281#endif
282
283#ifndef HAVE_UINTMAX_T
284typedef unsigned long long uintmax_t;
285#endif
286
272#ifndef HAVE_U_CHAR 287#ifndef HAVE_U_CHAR
273typedef unsigned char u_char; 288typedef unsigned char u_char;
274# define HAVE_U_CHAR 289# define HAVE_U_CHAR
@@ -802,4 +817,13 @@ struct winsize {
802# endif 817# endif
803#endif 818#endif
804 819
820/*
821 * Platforms that have arc4random_uniform() and not arc4random_stir()
822 * shouldn't need the latter.
823 */
824#if defined(HAVE_ARC4RANDOM) && defined(HAVE_ARC4RANDOM_UNIFORM) && \
825 !defined(HAVE_ARC4RANDOM_STIR)
826# define arc4random_stir()
827#endif
828
805#endif /* _DEFINES_H */ 829#endif /* _DEFINES_H */
diff --git a/dh.c b/dh.c
index 449dd3858..3331cda6c 100644
--- a/dh.c
+++ b/dh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh.c,v 1.51 2013/07/02 12:31:43 markus Exp $ */ 1/* $OpenBSD: dh.c,v 1.53 2013/11/21 00:45:44 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Niels Provos. All rights reserved. 3 * Copyright (c) 2000 Niels Provos. All rights reserved.
4 * 4 *
@@ -254,33 +254,19 @@ dh_pub_is_valid(DH *dh, BIGNUM *dh_pub)
254void 254void
255dh_gen_key(DH *dh, int need) 255dh_gen_key(DH *dh, int need)
256{ 256{
257 int i, bits_set, tries = 0; 257 int pbits;
258 258
259 if (need < 0) 259 if (need <= 0)
260 fatal("dh_gen_key: need < 0"); 260 fatal("%s: need <= 0", __func__);
261 if (dh->p == NULL) 261 if (dh->p == NULL)
262 fatal("dh_gen_key: dh->p == NULL"); 262 fatal("%s: dh->p == NULL", __func__);
263 if (need > INT_MAX / 2 || 2 * need >= BN_num_bits(dh->p)) 263 if ((pbits = BN_num_bits(dh->p)) <= 0)
264 fatal("dh_gen_key: group too small: %d (2*need %d)", 264 fatal("%s: bits(p) <= 0", __func__);
265 BN_num_bits(dh->p), 2*need); 265 dh->length = MIN(need * 2, pbits - 1);
266 do { 266 if (DH_generate_key(dh) == 0)
267 if (dh->priv_key != NULL) 267 fatal("%s: key generation failed", __func__);
268 BN_clear_free(dh->priv_key); 268 if (!dh_pub_is_valid(dh, dh->pub_key))
269 if ((dh->priv_key = BN_new()) == NULL) 269 fatal("%s: generated invalid key", __func__);
270 fatal("dh_gen_key: BN_new failed");
271 /* generate a 2*need bits random private exponent */
272 if (!BN_rand(dh->priv_key, 2*need, 0, 0))
273 fatal("dh_gen_key: BN_rand failed");
274 if (DH_generate_key(dh) == 0)
275 fatal("DH_generate_key");
276 for (i = 0, bits_set = 0; i <= BN_num_bits(dh->priv_key); i++)
277 if (BN_is_bit_set(dh->priv_key, i))
278 bits_set++;
279 debug2("dh_gen_key: priv key bits set: %d/%d",
280 bits_set, BN_num_bits(dh->priv_key));
281 if (tries++ > 10)
282 fatal("dh_gen_key: too many bad keys: giving up");
283 } while (!dh_pub_is_valid(dh, dh->pub_key));
284} 270}
285 271
286DH * 272DH *
@@ -352,17 +338,20 @@ dh_new_group14(void)
352 338
353/* 339/*
354 * Estimates the group order for a Diffie-Hellman group that has an 340 * Estimates the group order for a Diffie-Hellman group that has an
355 * attack complexity approximately the same as O(2**bits). Estimate 341 * attack complexity approximately the same as O(2**bits).
356 * with: O(exp(1.9223 * (ln q)^(1/3) (ln ln q)^(2/3))) 342 * Values from NIST Special Publication 800-57: Recommendation for Key
343 * Management Part 1 (rev 3) limited by the recommended maximum value
344 * from RFC4419 section 3.
357 */ 345 */
358 346
359int 347int
360dh_estimate(int bits) 348dh_estimate(int bits)
361{ 349{
362 350 if (bits <= 112)
351 return 2048;
363 if (bits <= 128) 352 if (bits <= 128)
364 return (1024); /* O(2**86) */ 353 return 3072;
365 if (bits <= 192) 354 if (bits <= 192)
366 return (2048); /* O(2**116) */ 355 return 7680;
367 return (4096); /* O(2**156) */ 356 return 8192;
368} 357}
diff --git a/dh.h b/dh.h
index dfc1480ea..48f7b68ea 100644
--- a/dh.h
+++ b/dh.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh.h,v 1.10 2008/06/26 09:19:40 djm Exp $ */ 1/* $OpenBSD: dh.h,v 1.11 2013/10/08 11:42:13 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Niels Provos. All rights reserved. 4 * Copyright (c) 2000 Niels Provos. All rights reserved.
@@ -43,6 +43,7 @@ int dh_pub_is_valid(DH *, BIGNUM *);
43 43
44int dh_estimate(int); 44int dh_estimate(int);
45 45
46/* Min and max values from RFC4419. */
46#define DH_GRP_MIN 1024 47#define DH_GRP_MIN 1024
47#define DH_GRP_MAX 8192 48#define DH_GRP_MAX 8192
48 49
diff --git a/digest.c b/digest.c
new file mode 100644
index 000000000..a221819eb
--- /dev/null
+++ b/digest.c
@@ -0,0 +1,149 @@
1/* $OpenBSD: digest.c,v 1.3 2014/01/20 00:08:48 djm Exp $ */
2/*
3 * Copyright (c) 2013 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#include <sys/types.h>
21#include <limits.h>
22#include <stdlib.h>
23#include <string.h>
24
25#include <openssl/evp.h>
26
27#include "openbsd-compat/openssl-compat.h"
28
29#include "buffer.h"
30#include "digest.h"
31
32struct ssh_digest_ctx {
33 int alg;
34 EVP_MD_CTX mdctx;
35};
36
37struct ssh_digest {
38 int id;
39 const char *name;
40 size_t digest_len;
41 const EVP_MD *(*mdfunc)(void);
42};
43
44/* NB. Indexed directly by algorithm number */
45const struct ssh_digest digests[] = {
46 { SSH_DIGEST_MD5, "MD5", 16, EVP_md5 },
47 { SSH_DIGEST_RIPEMD160, "RIPEMD160", 20, EVP_ripemd160 },
48 { SSH_DIGEST_SHA1, "SHA1", 20, EVP_sha1 },
49#ifdef HAVE_EVP_SHA256 /* XXX replace with local if missing */
50 { SSH_DIGEST_SHA256, "SHA256", 32, EVP_sha256 },
51 { SSH_DIGEST_SHA384, "SHA384", 48, EVP_sha384 },
52 { SSH_DIGEST_SHA512, "SHA512", 64, EVP_sha512 },
53#endif
54 { -1, NULL, 0, NULL },
55};
56
57static const struct ssh_digest *
58ssh_digest_by_alg(int alg)
59{
60 if (alg < 0 || alg >= SSH_DIGEST_MAX)
61 return NULL;
62 if (digests[alg].id != alg) /* sanity */
63 return NULL;
64 return &(digests[alg]);
65}
66
67size_t
68ssh_digest_bytes(int alg)
69{
70 const struct ssh_digest *digest = ssh_digest_by_alg(alg);
71
72 return digest == NULL ? 0 : digest->digest_len;
73}
74
75struct ssh_digest_ctx *
76ssh_digest_start(int alg)
77{
78 const struct ssh_digest *digest = ssh_digest_by_alg(alg);
79 struct ssh_digest_ctx *ret;
80
81 if (digest == NULL || ((ret = calloc(1, sizeof(*ret))) == NULL))
82 return NULL;
83 ret->alg = alg;
84 EVP_MD_CTX_init(&ret->mdctx);
85 if (EVP_DigestInit_ex(&ret->mdctx, digest->mdfunc(), NULL) != 1) {
86 free(ret);
87 return NULL;
88 }
89 return ret;
90}
91
92int
93ssh_digest_update(struct ssh_digest_ctx *ctx, const void *m, size_t mlen)
94{
95 if (EVP_DigestUpdate(&ctx->mdctx, m, mlen) != 1)
96 return -1;
97 return 0;
98}
99
100int
101ssh_digest_update_buffer(struct ssh_digest_ctx *ctx, const Buffer *b)
102{
103 return ssh_digest_update(ctx, buffer_ptr(b), buffer_len(b));
104}
105
106int
107ssh_digest_final(struct ssh_digest_ctx *ctx, u_char *d, size_t dlen)
108{
109 const struct ssh_digest *digest = ssh_digest_by_alg(ctx->alg);
110 u_int l = dlen;
111
112 if (dlen > UINT_MAX)
113 return -1;
114 if (dlen < digest->digest_len) /* No truncation allowed */
115 return -1;
116 if (EVP_DigestFinal_ex(&ctx->mdctx, d, &l) != 1)
117 return -1;
118 if (l != digest->digest_len) /* sanity */
119 return -1;
120 return 0;
121}
122
123void
124ssh_digest_free(struct ssh_digest_ctx *ctx)
125{
126 EVP_MD_CTX_cleanup(&ctx->mdctx);
127 memset(ctx, 0, sizeof(*ctx));
128 free(ctx);
129}
130
131int
132ssh_digest_memory(int alg, const void *m, size_t mlen, u_char *d, size_t dlen)
133{
134 struct ssh_digest_ctx *ctx = ssh_digest_start(alg);
135
136 if (ctx == NULL)
137 return -1;
138 if (ssh_digest_update(ctx, m, mlen) != 0 ||
139 ssh_digest_final(ctx, d, dlen) != 0)
140 return -1;
141 ssh_digest_free(ctx);
142 return 0;
143}
144
145int
146ssh_digest_buffer(int alg, const Buffer *b, u_char *d, size_t dlen)
147{
148 return ssh_digest_memory(alg, buffer_ptr(b), buffer_len(b), d, dlen);
149}
diff --git a/digest.h b/digest.h
new file mode 100644
index 000000000..faefda3f5
--- /dev/null
+++ b/digest.h
@@ -0,0 +1,55 @@
1/* $OpenBSD: digest.h,v 1.1 2014/01/09 23:20:00 djm Exp $ */
2/*
3 * Copyright (c) 2013 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#ifndef _DIGEST_H
19#define _DIGEST_H
20
21/* Maximum digest output length */
22#define SSH_DIGEST_MAX_LENGTH 64
23
24/* Digest algorithms */
25#define SSH_DIGEST_MD5 0
26#define SSH_DIGEST_RIPEMD160 1
27#define SSH_DIGEST_SHA1 2
28#define SSH_DIGEST_SHA256 3
29#define SSH_DIGEST_SHA384 4
30#define SSH_DIGEST_SHA512 5
31#define SSH_DIGEST_MAX 6
32
33/* Returns the algorithm's digest length in bytes or 0 for invalid algorithm */
34size_t ssh_digest_bytes(int alg);
35
36/* One-shot API */
37int ssh_digest_memory(int alg, const void *m, size_t mlen,
38 u_char *d, size_t dlen)
39 __attribute__((__bounded__(__buffer__, 2, 3)))
40 __attribute__((__bounded__(__buffer__, 4, 5)));
41int ssh_digest_buffer(int alg, const Buffer *b, u_char *d, size_t dlen)
42 __attribute__((__bounded__(__buffer__, 3, 4)));
43
44/* Update API */
45struct ssh_digest_ctx;
46struct ssh_digest_ctx *ssh_digest_start(int alg);
47int ssh_digest_update(struct ssh_digest_ctx *ctx, const void *m, size_t mlen)
48 __attribute__((__bounded__(__buffer__, 2, 3)));
49int ssh_digest_update_buffer(struct ssh_digest_ctx *ctx, const Buffer *b);
50int ssh_digest_final(struct ssh_digest_ctx *ctx, u_char *d, size_t dlen)
51 __attribute__((__bounded__(__buffer__, 2, 3)));
52void ssh_digest_free(struct ssh_digest_ctx *ctx);
53
54#endif /* _DIGEST_H */
55
diff --git a/ed25519.c b/ed25519.c
new file mode 100644
index 000000000..767ec24d6
--- /dev/null
+++ b/ed25519.c
@@ -0,0 +1,144 @@
1/* $OpenBSD: ed25519.c,v 1.3 2013/12/09 11:03:45 markus Exp $ */
2
3/*
4 * Public Domain, Authors: Daniel J. Bernstein, Niels Duif, Tanja Lange,
5 * Peter Schwabe, Bo-Yin Yang.
6 * Copied from supercop-20130419/crypto_sign/ed25519/ref/ed25519.c
7 */
8
9#include "includes.h"
10#include "crypto_api.h"
11
12#include "ge25519.h"
13
14static void get_hram(unsigned char *hram, const unsigned char *sm, const unsigned char *pk, unsigned char *playground, unsigned long long smlen)
15{
16 unsigned long long i;
17
18 for (i = 0;i < 32;++i) playground[i] = sm[i];
19 for (i = 32;i < 64;++i) playground[i] = pk[i-32];
20 for (i = 64;i < smlen;++i) playground[i] = sm[i];
21
22 crypto_hash_sha512(hram,playground,smlen);
23}
24
25
26int crypto_sign_ed25519_keypair(
27 unsigned char *pk,
28 unsigned char *sk
29 )
30{
31 sc25519 scsk;
32 ge25519 gepk;
33 unsigned char extsk[64];
34 int i;
35
36 randombytes(sk, 32);
37 crypto_hash_sha512(extsk, sk, 32);
38 extsk[0] &= 248;
39 extsk[31] &= 127;
40 extsk[31] |= 64;
41
42 sc25519_from32bytes(&scsk,extsk);
43
44 ge25519_scalarmult_base(&gepk, &scsk);
45 ge25519_pack(pk, &gepk);
46 for(i=0;i<32;i++)
47 sk[32 + i] = pk[i];
48 return 0;
49}
50
51int crypto_sign_ed25519(
52 unsigned char *sm,unsigned long long *smlen,
53 const unsigned char *m,unsigned long long mlen,
54 const unsigned char *sk
55 )
56{
57 sc25519 sck, scs, scsk;
58 ge25519 ger;
59 unsigned char r[32];
60 unsigned char s[32];
61 unsigned char extsk[64];
62 unsigned long long i;
63 unsigned char hmg[crypto_hash_sha512_BYTES];
64 unsigned char hram[crypto_hash_sha512_BYTES];
65
66 crypto_hash_sha512(extsk, sk, 32);
67 extsk[0] &= 248;
68 extsk[31] &= 127;
69 extsk[31] |= 64;
70
71 *smlen = mlen+64;
72 for(i=0;i<mlen;i++)
73 sm[64 + i] = m[i];
74 for(i=0;i<32;i++)
75 sm[32 + i] = extsk[32+i];
76
77 crypto_hash_sha512(hmg, sm+32, mlen+32); /* Generate k as h(extsk[32],...,extsk[63],m) */
78
79 /* Computation of R */
80 sc25519_from64bytes(&sck, hmg);
81 ge25519_scalarmult_base(&ger, &sck);
82 ge25519_pack(r, &ger);
83
84 /* Computation of s */
85 for(i=0;i<32;i++)
86 sm[i] = r[i];
87
88 get_hram(hram, sm, sk+32, sm, mlen+64);
89
90 sc25519_from64bytes(&scs, hram);
91 sc25519_from32bytes(&scsk, extsk);
92 sc25519_mul(&scs, &scs, &scsk);
93
94 sc25519_add(&scs, &scs, &sck);
95
96 sc25519_to32bytes(s,&scs); /* cat s */
97 for(i=0;i<32;i++)
98 sm[32 + i] = s[i];
99
100 return 0;
101}
102
103int crypto_sign_ed25519_open(
104 unsigned char *m,unsigned long long *mlen,
105 const unsigned char *sm,unsigned long long smlen,
106 const unsigned char *pk
107 )
108{
109 unsigned int i;
110 int ret;
111 unsigned char t2[32];
112 ge25519 get1, get2;
113 sc25519 schram, scs;
114 unsigned char hram[crypto_hash_sha512_BYTES];
115
116 *mlen = (unsigned long long) -1;
117 if (smlen < 64) return -1;
118
119 if (ge25519_unpackneg_vartime(&get1, pk)) return -1;
120
121 get_hram(hram,sm,pk,m,smlen);
122
123 sc25519_from64bytes(&schram, hram);
124
125 sc25519_from32bytes(&scs, sm+32);
126
127 ge25519_double_scalarmult_vartime(&get2, &get1, &schram, &ge25519_base, &scs);
128 ge25519_pack(t2, &get2);
129
130 ret = crypto_verify_32(sm, t2);
131
132 if (!ret)
133 {
134 for(i=0;i<smlen-64;i++)
135 m[i] = sm[i + 64];
136 *mlen = smlen-64;
137 }
138 else
139 {
140 for(i=0;i<smlen-64;i++)
141 m[i] = 0;
142 }
143 return ret;
144}
diff --git a/fe25519.c b/fe25519.c
new file mode 100644
index 000000000..e54fd1547
--- /dev/null
+++ b/fe25519.c
@@ -0,0 +1,337 @@
1/* $OpenBSD: fe25519.c,v 1.3 2013/12/09 11:03:45 markus Exp $ */
2
3/*
4 * Public Domain, Authors: Daniel J. Bernstein, Niels Duif, Tanja Lange,
5 * Peter Schwabe, Bo-Yin Yang.
6 * Copied from supercop-20130419/crypto_sign/ed25519/ref/fe25519.c
7 */
8
9#include "includes.h"
10
11#define WINDOWSIZE 1 /* Should be 1,2, or 4 */
12#define WINDOWMASK ((1<<WINDOWSIZE)-1)
13
14#include "fe25519.h"
15
16static crypto_uint32 equal(crypto_uint32 a,crypto_uint32 b) /* 16-bit inputs */
17{
18 crypto_uint32 x = a ^ b; /* 0: yes; 1..65535: no */
19 x -= 1; /* 4294967295: yes; 0..65534: no */
20 x >>= 31; /* 1: yes; 0: no */
21 return x;
22}
23
24static crypto_uint32 ge(crypto_uint32 a,crypto_uint32 b) /* 16-bit inputs */
25{
26 unsigned int x = a;
27 x -= (unsigned int) b; /* 0..65535: yes; 4294901761..4294967295: no */
28 x >>= 31; /* 0: yes; 1: no */
29 x ^= 1; /* 1: yes; 0: no */
30 return x;
31}
32
33static crypto_uint32 times19(crypto_uint32 a)
34{
35 return (a << 4) + (a << 1) + a;
36}
37
38static crypto_uint32 times38(crypto_uint32 a)
39{
40 return (a << 5) + (a << 2) + (a << 1);
41}
42
43static void reduce_add_sub(fe25519 *r)
44{
45 crypto_uint32 t;
46 int i,rep;
47
48 for(rep=0;rep<4;rep++)
49 {
50 t = r->v[31] >> 7;
51 r->v[31] &= 127;
52 t = times19(t);
53 r->v[0] += t;
54 for(i=0;i<31;i++)
55 {
56 t = r->v[i] >> 8;
57 r->v[i+1] += t;
58 r->v[i] &= 255;
59 }
60 }
61}
62
63static void reduce_mul(fe25519 *r)
64{
65 crypto_uint32 t;
66 int i,rep;
67
68 for(rep=0;rep<2;rep++)
69 {
70 t = r->v[31] >> 7;
71 r->v[31] &= 127;
72 t = times19(t);
73 r->v[0] += t;
74 for(i=0;i<31;i++)
75 {
76 t = r->v[i] >> 8;
77 r->v[i+1] += t;
78 r->v[i] &= 255;
79 }
80 }
81}
82
83/* reduction modulo 2^255-19 */
84void fe25519_freeze(fe25519 *r)
85{
86 int i;
87 crypto_uint32 m = equal(r->v[31],127);
88 for(i=30;i>0;i--)
89 m &= equal(r->v[i],255);
90 m &= ge(r->v[0],237);
91
92 m = -m;
93
94 r->v[31] -= m&127;
95 for(i=30;i>0;i--)
96 r->v[i] -= m&255;
97 r->v[0] -= m&237;
98}
99
100void fe25519_unpack(fe25519 *r, const unsigned char x[32])
101{
102 int i;
103 for(i=0;i<32;i++) r->v[i] = x[i];
104 r->v[31] &= 127;
105}
106
107/* Assumes input x being reduced below 2^255 */
108void fe25519_pack(unsigned char r[32], const fe25519 *x)
109{
110 int i;
111 fe25519 y = *x;
112 fe25519_freeze(&y);
113 for(i=0;i<32;i++)
114 r[i] = y.v[i];
115}
116
117int fe25519_iszero(const fe25519 *x)
118{
119 int i;
120 int r;
121 fe25519 t = *x;
122 fe25519_freeze(&t);
123 r = equal(t.v[0],0);
124 for(i=1;i<32;i++)
125 r &= equal(t.v[i],0);
126 return r;
127}
128
129int fe25519_iseq_vartime(const fe25519 *x, const fe25519 *y)
130{
131 int i;
132 fe25519 t1 = *x;
133 fe25519 t2 = *y;
134 fe25519_freeze(&t1);
135 fe25519_freeze(&t2);
136 for(i=0;i<32;i++)
137 if(t1.v[i] != t2.v[i]) return 0;
138 return 1;
139}
140
141void fe25519_cmov(fe25519 *r, const fe25519 *x, unsigned char b)
142{
143 int i;
144 crypto_uint32 mask = b;
145 mask = -mask;
146 for(i=0;i<32;i++) r->v[i] ^= mask & (x->v[i] ^ r->v[i]);
147}
148
149unsigned char fe25519_getparity(const fe25519 *x)
150{
151 fe25519 t = *x;
152 fe25519_freeze(&t);
153 return t.v[0] & 1;
154}
155
156void fe25519_setone(fe25519 *r)
157{
158 int i;
159 r->v[0] = 1;
160 for(i=1;i<32;i++) r->v[i]=0;
161}
162
163void fe25519_setzero(fe25519 *r)
164{
165 int i;
166 for(i=0;i<32;i++) r->v[i]=0;
167}
168
169void fe25519_neg(fe25519 *r, const fe25519 *x)
170{
171 fe25519 t;
172 int i;
173 for(i=0;i<32;i++) t.v[i]=x->v[i];
174 fe25519_setzero(r);
175 fe25519_sub(r, r, &t);
176}
177
178void fe25519_add(fe25519 *r, const fe25519 *x, const fe25519 *y)
179{
180 int i;
181 for(i=0;i<32;i++) r->v[i] = x->v[i] + y->v[i];
182 reduce_add_sub(r);
183}
184
185void fe25519_sub(fe25519 *r, const fe25519 *x, const fe25519 *y)
186{
187 int i;
188 crypto_uint32 t[32];
189 t[0] = x->v[0] + 0x1da;
190 t[31] = x->v[31] + 0xfe;
191 for(i=1;i<31;i++) t[i] = x->v[i] + 0x1fe;
192 for(i=0;i<32;i++) r->v[i] = t[i] - y->v[i];
193 reduce_add_sub(r);
194}
195
196void fe25519_mul(fe25519 *r, const fe25519 *x, const fe25519 *y)
197{
198 int i,j;
199 crypto_uint32 t[63];
200 for(i=0;i<63;i++)t[i] = 0;
201
202 for(i=0;i<32;i++)
203 for(j=0;j<32;j++)
204 t[i+j] += x->v[i] * y->v[j];
205
206 for(i=32;i<63;i++)
207 r->v[i-32] = t[i-32] + times38(t[i]);
208 r->v[31] = t[31]; /* result now in r[0]...r[31] */
209
210 reduce_mul(r);
211}
212
213void fe25519_square(fe25519 *r, const fe25519 *x)
214{
215 fe25519_mul(r, x, x);
216}
217
218void fe25519_invert(fe25519 *r, const fe25519 *x)
219{
220 fe25519 z2;
221 fe25519 z9;
222 fe25519 z11;
223 fe25519 z2_5_0;
224 fe25519 z2_10_0;
225 fe25519 z2_20_0;
226 fe25519 z2_50_0;
227 fe25519 z2_100_0;
228 fe25519 t0;
229 fe25519 t1;
230 int i;
231
232 /* 2 */ fe25519_square(&z2,x);
233 /* 4 */ fe25519_square(&t1,&z2);
234 /* 8 */ fe25519_square(&t0,&t1);
235 /* 9 */ fe25519_mul(&z9,&t0,x);
236 /* 11 */ fe25519_mul(&z11,&z9,&z2);
237 /* 22 */ fe25519_square(&t0,&z11);
238 /* 2^5 - 2^0 = 31 */ fe25519_mul(&z2_5_0,&t0,&z9);
239
240 /* 2^6 - 2^1 */ fe25519_square(&t0,&z2_5_0);
241 /* 2^7 - 2^2 */ fe25519_square(&t1,&t0);
242 /* 2^8 - 2^3 */ fe25519_square(&t0,&t1);
243 /* 2^9 - 2^4 */ fe25519_square(&t1,&t0);
244 /* 2^10 - 2^5 */ fe25519_square(&t0,&t1);
245 /* 2^10 - 2^0 */ fe25519_mul(&z2_10_0,&t0,&z2_5_0);
246
247 /* 2^11 - 2^1 */ fe25519_square(&t0,&z2_10_0);
248 /* 2^12 - 2^2 */ fe25519_square(&t1,&t0);
249 /* 2^20 - 2^10 */ for (i = 2;i < 10;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); }
250 /* 2^20 - 2^0 */ fe25519_mul(&z2_20_0,&t1,&z2_10_0);
251
252 /* 2^21 - 2^1 */ fe25519_square(&t0,&z2_20_0);
253 /* 2^22 - 2^2 */ fe25519_square(&t1,&t0);
254 /* 2^40 - 2^20 */ for (i = 2;i < 20;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); }
255 /* 2^40 - 2^0 */ fe25519_mul(&t0,&t1,&z2_20_0);
256
257 /* 2^41 - 2^1 */ fe25519_square(&t1,&t0);
258 /* 2^42 - 2^2 */ fe25519_square(&t0,&t1);
259 /* 2^50 - 2^10 */ for (i = 2;i < 10;i += 2) { fe25519_square(&t1,&t0); fe25519_square(&t0,&t1); }
260 /* 2^50 - 2^0 */ fe25519_mul(&z2_50_0,&t0,&z2_10_0);
261
262 /* 2^51 - 2^1 */ fe25519_square(&t0,&z2_50_0);
263 /* 2^52 - 2^2 */ fe25519_square(&t1,&t0);
264 /* 2^100 - 2^50 */ for (i = 2;i < 50;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); }
265 /* 2^100 - 2^0 */ fe25519_mul(&z2_100_0,&t1,&z2_50_0);
266
267 /* 2^101 - 2^1 */ fe25519_square(&t1,&z2_100_0);
268 /* 2^102 - 2^2 */ fe25519_square(&t0,&t1);
269 /* 2^200 - 2^100 */ for (i = 2;i < 100;i += 2) { fe25519_square(&t1,&t0); fe25519_square(&t0,&t1); }
270 /* 2^200 - 2^0 */ fe25519_mul(&t1,&t0,&z2_100_0);
271
272 /* 2^201 - 2^1 */ fe25519_square(&t0,&t1);
273 /* 2^202 - 2^2 */ fe25519_square(&t1,&t0);
274 /* 2^250 - 2^50 */ for (i = 2;i < 50;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); }
275 /* 2^250 - 2^0 */ fe25519_mul(&t0,&t1,&z2_50_0);
276
277 /* 2^251 - 2^1 */ fe25519_square(&t1,&t0);
278 /* 2^252 - 2^2 */ fe25519_square(&t0,&t1);
279 /* 2^253 - 2^3 */ fe25519_square(&t1,&t0);
280 /* 2^254 - 2^4 */ fe25519_square(&t0,&t1);
281 /* 2^255 - 2^5 */ fe25519_square(&t1,&t0);
282 /* 2^255 - 21 */ fe25519_mul(r,&t1,&z11);
283}
284
285void fe25519_pow2523(fe25519 *r, const fe25519 *x)
286{
287 fe25519 z2;
288 fe25519 z9;
289 fe25519 z11;
290 fe25519 z2_5_0;
291 fe25519 z2_10_0;
292 fe25519 z2_20_0;
293 fe25519 z2_50_0;
294 fe25519 z2_100_0;
295 fe25519 t;
296 int i;
297
298 /* 2 */ fe25519_square(&z2,x);
299 /* 4 */ fe25519_square(&t,&z2);
300 /* 8 */ fe25519_square(&t,&t);
301 /* 9 */ fe25519_mul(&z9,&t,x);
302 /* 11 */ fe25519_mul(&z11,&z9,&z2);
303 /* 22 */ fe25519_square(&t,&z11);
304 /* 2^5 - 2^0 = 31 */ fe25519_mul(&z2_5_0,&t,&z9);
305
306 /* 2^6 - 2^1 */ fe25519_square(&t,&z2_5_0);
307 /* 2^10 - 2^5 */ for (i = 1;i < 5;i++) { fe25519_square(&t,&t); }
308 /* 2^10 - 2^0 */ fe25519_mul(&z2_10_0,&t,&z2_5_0);
309
310 /* 2^11 - 2^1 */ fe25519_square(&t,&z2_10_0);
311 /* 2^20 - 2^10 */ for (i = 1;i < 10;i++) { fe25519_square(&t,&t); }
312 /* 2^20 - 2^0 */ fe25519_mul(&z2_20_0,&t,&z2_10_0);
313
314 /* 2^21 - 2^1 */ fe25519_square(&t,&z2_20_0);
315 /* 2^40 - 2^20 */ for (i = 1;i < 20;i++) { fe25519_square(&t,&t); }
316 /* 2^40 - 2^0 */ fe25519_mul(&t,&t,&z2_20_0);
317
318 /* 2^41 - 2^1 */ fe25519_square(&t,&t);
319 /* 2^50 - 2^10 */ for (i = 1;i < 10;i++) { fe25519_square(&t,&t); }
320 /* 2^50 - 2^0 */ fe25519_mul(&z2_50_0,&t,&z2_10_0);
321
322 /* 2^51 - 2^1 */ fe25519_square(&t,&z2_50_0);
323 /* 2^100 - 2^50 */ for (i = 1;i < 50;i++) { fe25519_square(&t,&t); }
324 /* 2^100 - 2^0 */ fe25519_mul(&z2_100_0,&t,&z2_50_0);
325
326 /* 2^101 - 2^1 */ fe25519_square(&t,&z2_100_0);
327 /* 2^200 - 2^100 */ for (i = 1;i < 100;i++) { fe25519_square(&t,&t); }
328 /* 2^200 - 2^0 */ fe25519_mul(&t,&t,&z2_100_0);
329
330 /* 2^201 - 2^1 */ fe25519_square(&t,&t);
331 /* 2^250 - 2^50 */ for (i = 1;i < 50;i++) { fe25519_square(&t,&t); }
332 /* 2^250 - 2^0 */ fe25519_mul(&t,&t,&z2_50_0);
333
334 /* 2^251 - 2^1 */ fe25519_square(&t,&t);
335 /* 2^252 - 2^2 */ fe25519_square(&t,&t);
336 /* 2^252 - 3 */ fe25519_mul(r,&t,x);
337}
diff --git a/fe25519.h b/fe25519.h
new file mode 100644
index 000000000..41b3cbb49
--- /dev/null
+++ b/fe25519.h
@@ -0,0 +1,70 @@
1/* $OpenBSD: fe25519.h,v 1.3 2013/12/09 11:03:45 markus Exp $ */
2
3/*
4 * Public Domain, Authors: Daniel J. Bernstein, Niels Duif, Tanja Lange,
5 * Peter Schwabe, Bo-Yin Yang.
6 * Copied from supercop-20130419/crypto_sign/ed25519/ref/fe25519.h
7 */
8
9#ifndef FE25519_H
10#define FE25519_H
11
12#include "crypto_api.h"
13
14#define fe25519 crypto_sign_ed25519_ref_fe25519
15#define fe25519_freeze crypto_sign_ed25519_ref_fe25519_freeze
16#define fe25519_unpack crypto_sign_ed25519_ref_fe25519_unpack
17#define fe25519_pack crypto_sign_ed25519_ref_fe25519_pack
18#define fe25519_iszero crypto_sign_ed25519_ref_fe25519_iszero
19#define fe25519_iseq_vartime crypto_sign_ed25519_ref_fe25519_iseq_vartime
20#define fe25519_cmov crypto_sign_ed25519_ref_fe25519_cmov
21#define fe25519_setone crypto_sign_ed25519_ref_fe25519_setone
22#define fe25519_setzero crypto_sign_ed25519_ref_fe25519_setzero
23#define fe25519_neg crypto_sign_ed25519_ref_fe25519_neg
24#define fe25519_getparity crypto_sign_ed25519_ref_fe25519_getparity
25#define fe25519_add crypto_sign_ed25519_ref_fe25519_add
26#define fe25519_sub crypto_sign_ed25519_ref_fe25519_sub
27#define fe25519_mul crypto_sign_ed25519_ref_fe25519_mul
28#define fe25519_square crypto_sign_ed25519_ref_fe25519_square
29#define fe25519_invert crypto_sign_ed25519_ref_fe25519_invert
30#define fe25519_pow2523 crypto_sign_ed25519_ref_fe25519_pow2523
31
32typedef struct
33{
34 crypto_uint32 v[32];
35}
36fe25519;
37
38void fe25519_freeze(fe25519 *r);
39
40void fe25519_unpack(fe25519 *r, const unsigned char x[32]);
41
42void fe25519_pack(unsigned char r[32], const fe25519 *x);
43
44int fe25519_iszero(const fe25519 *x);
45
46int fe25519_iseq_vartime(const fe25519 *x, const fe25519 *y);
47
48void fe25519_cmov(fe25519 *r, const fe25519 *x, unsigned char b);
49
50void fe25519_setone(fe25519 *r);
51
52void fe25519_setzero(fe25519 *r);
53
54void fe25519_neg(fe25519 *r, const fe25519 *x);
55
56unsigned char fe25519_getparity(const fe25519 *x);
57
58void fe25519_add(fe25519 *r, const fe25519 *x, const fe25519 *y);
59
60void fe25519_sub(fe25519 *r, const fe25519 *x, const fe25519 *y);
61
62void fe25519_mul(fe25519 *r, const fe25519 *x, const fe25519 *y);
63
64void fe25519_square(fe25519 *r, const fe25519 *x);
65
66void fe25519_invert(fe25519 *r, const fe25519 *x);
67
68void fe25519_pow2523(fe25519 *r, const fe25519 *x);
69
70#endif
diff --git a/ge25519.c b/ge25519.c
new file mode 100644
index 000000000..dfe3849b9
--- /dev/null
+++ b/ge25519.c
@@ -0,0 +1,321 @@
1/* $OpenBSD: ge25519.c,v 1.3 2013/12/09 11:03:45 markus Exp $ */
2
3/*
4 * Public Domain, Authors: Daniel J. Bernstein, Niels Duif, Tanja Lange,
5 * Peter Schwabe, Bo-Yin Yang.
6 * Copied from supercop-20130419/crypto_sign/ed25519/ref/ge25519.c
7 */
8
9#include "includes.h"
10
11#include "fe25519.h"
12#include "sc25519.h"
13#include "ge25519.h"
14
15/*
16 * Arithmetic on the twisted Edwards curve -x^2 + y^2 = 1 + dx^2y^2
17 * with d = -(121665/121666) = 37095705934669439343138083508754565189542113879843219016388785533085940283555
18 * Base point: (15112221349535400772501151409588531511454012693041857206046113283949847762202,46316835694926478169428394003475163141307993866256225615783033603165251855960);
19 */
20
21/* d */
22static const fe25519 ge25519_ecd = {{0xA3, 0x78, 0x59, 0x13, 0xCA, 0x4D, 0xEB, 0x75, 0xAB, 0xD8, 0x41, 0x41, 0x4D, 0x0A, 0x70, 0x00,
23 0x98, 0xE8, 0x79, 0x77, 0x79, 0x40, 0xC7, 0x8C, 0x73, 0xFE, 0x6F, 0x2B, 0xEE, 0x6C, 0x03, 0x52}};
24/* 2*d */
25static const fe25519 ge25519_ec2d = {{0x59, 0xF1, 0xB2, 0x26, 0x94, 0x9B, 0xD6, 0xEB, 0x56, 0xB1, 0x83, 0x82, 0x9A, 0x14, 0xE0, 0x00,
26 0x30, 0xD1, 0xF3, 0xEE, 0xF2, 0x80, 0x8E, 0x19, 0xE7, 0xFC, 0xDF, 0x56, 0xDC, 0xD9, 0x06, 0x24}};
27/* sqrt(-1) */
28static const fe25519 ge25519_sqrtm1 = {{0xB0, 0xA0, 0x0E, 0x4A, 0x27, 0x1B, 0xEE, 0xC4, 0x78, 0xE4, 0x2F, 0xAD, 0x06, 0x18, 0x43, 0x2F,
29 0xA7, 0xD7, 0xFB, 0x3D, 0x99, 0x00, 0x4D, 0x2B, 0x0B, 0xDF, 0xC1, 0x4F, 0x80, 0x24, 0x83, 0x2B}};
30
31#define ge25519_p3 ge25519
32
33typedef struct
34{
35 fe25519 x;
36 fe25519 z;
37 fe25519 y;
38 fe25519 t;
39} ge25519_p1p1;
40
41typedef struct
42{
43 fe25519 x;
44 fe25519 y;
45 fe25519 z;
46} ge25519_p2;
47
48typedef struct
49{
50 fe25519 x;
51 fe25519 y;
52} ge25519_aff;
53
54
55/* Packed coordinates of the base point */
56const ge25519 ge25519_base = {{{0x1A, 0xD5, 0x25, 0x8F, 0x60, 0x2D, 0x56, 0xC9, 0xB2, 0xA7, 0x25, 0x95, 0x60, 0xC7, 0x2C, 0x69,
57 0x5C, 0xDC, 0xD6, 0xFD, 0x31, 0xE2, 0xA4, 0xC0, 0xFE, 0x53, 0x6E, 0xCD, 0xD3, 0x36, 0x69, 0x21}},
58 {{0x58, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
59 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66}},
60 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
62 {{0xA3, 0xDD, 0xB7, 0xA5, 0xB3, 0x8A, 0xDE, 0x6D, 0xF5, 0x52, 0x51, 0x77, 0x80, 0x9F, 0xF0, 0x20,
63 0x7D, 0xE3, 0xAB, 0x64, 0x8E, 0x4E, 0xEA, 0x66, 0x65, 0x76, 0x8B, 0xD7, 0x0F, 0x5F, 0x87, 0x67}}};
64
65/* Multiples of the base point in affine representation */
66static const ge25519_aff ge25519_base_multiples_affine[425] = {
67#include "ge25519_base.data"
68};
69
70static void p1p1_to_p2(ge25519_p2 *r, const ge25519_p1p1 *p)
71{
72 fe25519_mul(&r->x, &p->x, &p->t);
73 fe25519_mul(&r->y, &p->y, &p->z);
74 fe25519_mul(&r->z, &p->z, &p->t);
75}
76
77static void p1p1_to_p3(ge25519_p3 *r, const ge25519_p1p1 *p)
78{
79 p1p1_to_p2((ge25519_p2 *)r, p);
80 fe25519_mul(&r->t, &p->x, &p->y);
81}
82
83static void ge25519_mixadd2(ge25519_p3 *r, const ge25519_aff *q)
84{
85 fe25519 a,b,t1,t2,c,d,e,f,g,h,qt;
86 fe25519_mul(&qt, &q->x, &q->y);
87 fe25519_sub(&a, &r->y, &r->x); /* A = (Y1-X1)*(Y2-X2) */
88 fe25519_add(&b, &r->y, &r->x); /* B = (Y1+X1)*(Y2+X2) */
89 fe25519_sub(&t1, &q->y, &q->x);
90 fe25519_add(&t2, &q->y, &q->x);
91 fe25519_mul(&a, &a, &t1);
92 fe25519_mul(&b, &b, &t2);
93 fe25519_sub(&e, &b, &a); /* E = B-A */
94 fe25519_add(&h, &b, &a); /* H = B+A */
95 fe25519_mul(&c, &r->t, &qt); /* C = T1*k*T2 */
96 fe25519_mul(&c, &c, &ge25519_ec2d);
97 fe25519_add(&d, &r->z, &r->z); /* D = Z1*2 */
98 fe25519_sub(&f, &d, &c); /* F = D-C */
99 fe25519_add(&g, &d, &c); /* G = D+C */
100 fe25519_mul(&r->x, &e, &f);
101 fe25519_mul(&r->y, &h, &g);
102 fe25519_mul(&r->z, &g, &f);
103 fe25519_mul(&r->t, &e, &h);
104}
105
106static void add_p1p1(ge25519_p1p1 *r, const ge25519_p3 *p, const ge25519_p3 *q)
107{
108 fe25519 a, b, c, d, t;
109
110 fe25519_sub(&a, &p->y, &p->x); /* A = (Y1-X1)*(Y2-X2) */
111 fe25519_sub(&t, &q->y, &q->x);
112 fe25519_mul(&a, &a, &t);
113 fe25519_add(&b, &p->x, &p->y); /* B = (Y1+X1)*(Y2+X2) */
114 fe25519_add(&t, &q->x, &q->y);
115 fe25519_mul(&b, &b, &t);
116 fe25519_mul(&c, &p->t, &q->t); /* C = T1*k*T2 */
117 fe25519_mul(&c, &c, &ge25519_ec2d);
118 fe25519_mul(&d, &p->z, &q->z); /* D = Z1*2*Z2 */
119 fe25519_add(&d, &d, &d);
120 fe25519_sub(&r->x, &b, &a); /* E = B-A */
121 fe25519_sub(&r->t, &d, &c); /* F = D-C */
122 fe25519_add(&r->z, &d, &c); /* G = D+C */
123 fe25519_add(&r->y, &b, &a); /* H = B+A */
124}
125
126/* See http://www.hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html#doubling-dbl-2008-hwcd */
127static void dbl_p1p1(ge25519_p1p1 *r, const ge25519_p2 *p)
128{
129 fe25519 a,b,c,d;
130 fe25519_square(&a, &p->x);
131 fe25519_square(&b, &p->y);
132 fe25519_square(&c, &p->z);
133 fe25519_add(&c, &c, &c);
134 fe25519_neg(&d, &a);
135
136 fe25519_add(&r->x, &p->x, &p->y);
137 fe25519_square(&r->x, &r->x);
138 fe25519_sub(&r->x, &r->x, &a);
139 fe25519_sub(&r->x, &r->x, &b);
140 fe25519_add(&r->z, &d, &b);
141 fe25519_sub(&r->t, &r->z, &c);
142 fe25519_sub(&r->y, &d, &b);
143}
144
145/* Constant-time version of: if(b) r = p */
146static void cmov_aff(ge25519_aff *r, const ge25519_aff *p, unsigned char b)
147{
148 fe25519_cmov(&r->x, &p->x, b);
149 fe25519_cmov(&r->y, &p->y, b);
150}
151
152static unsigned char equal(signed char b,signed char c)
153{
154 unsigned char ub = b;
155 unsigned char uc = c;
156 unsigned char x = ub ^ uc; /* 0: yes; 1..255: no */
157 crypto_uint32 y = x; /* 0: yes; 1..255: no */
158 y -= 1; /* 4294967295: yes; 0..254: no */
159 y >>= 31; /* 1: yes; 0: no */
160 return y;
161}
162
163static unsigned char negative(signed char b)
164{
165 unsigned long long x = b; /* 18446744073709551361..18446744073709551615: yes; 0..255: no */
166 x >>= 63; /* 1: yes; 0: no */
167 return x;
168}
169
170static void choose_t(ge25519_aff *t, unsigned long long pos, signed char b)
171{
172 /* constant time */
173 fe25519 v;
174 *t = ge25519_base_multiples_affine[5*pos+0];
175 cmov_aff(t, &ge25519_base_multiples_affine[5*pos+1],equal(b,1) | equal(b,-1));
176 cmov_aff(t, &ge25519_base_multiples_affine[5*pos+2],equal(b,2) | equal(b,-2));
177 cmov_aff(t, &ge25519_base_multiples_affine[5*pos+3],equal(b,3) | equal(b,-3));
178 cmov_aff(t, &ge25519_base_multiples_affine[5*pos+4],equal(b,-4));
179 fe25519_neg(&v, &t->x);
180 fe25519_cmov(&t->x, &v, negative(b));
181}
182
183static void setneutral(ge25519 *r)
184{
185 fe25519_setzero(&r->x);
186 fe25519_setone(&r->y);
187 fe25519_setone(&r->z);
188 fe25519_setzero(&r->t);
189}
190
191/* ********************************************************************
192 * EXPORTED FUNCTIONS
193 ******************************************************************** */
194
195/* return 0 on success, -1 otherwise */
196int ge25519_unpackneg_vartime(ge25519_p3 *r, const unsigned char p[32])
197{
198 unsigned char par;
199 fe25519 t, chk, num, den, den2, den4, den6;
200 fe25519_setone(&r->z);
201 par = p[31] >> 7;
202 fe25519_unpack(&r->y, p);
203 fe25519_square(&num, &r->y); /* x = y^2 */
204 fe25519_mul(&den, &num, &ge25519_ecd); /* den = dy^2 */
205 fe25519_sub(&num, &num, &r->z); /* x = y^2-1 */
206 fe25519_add(&den, &r->z, &den); /* den = dy^2+1 */
207
208 /* Computation of sqrt(num/den) */
209 /* 1.: computation of num^((p-5)/8)*den^((7p-35)/8) = (num*den^7)^((p-5)/8) */
210 fe25519_square(&den2, &den);
211 fe25519_square(&den4, &den2);
212 fe25519_mul(&den6, &den4, &den2);
213 fe25519_mul(&t, &den6, &num);
214 fe25519_mul(&t, &t, &den);
215
216 fe25519_pow2523(&t, &t);
217 /* 2. computation of r->x = t * num * den^3 */
218 fe25519_mul(&t, &t, &num);
219 fe25519_mul(&t, &t, &den);
220 fe25519_mul(&t, &t, &den);
221 fe25519_mul(&r->x, &t, &den);
222
223 /* 3. Check whether sqrt computation gave correct result, multiply by sqrt(-1) if not: */
224 fe25519_square(&chk, &r->x);
225 fe25519_mul(&chk, &chk, &den);
226 if (!fe25519_iseq_vartime(&chk, &num))
227 fe25519_mul(&r->x, &r->x, &ge25519_sqrtm1);
228
229 /* 4. Now we have one of the two square roots, except if input was not a square */
230 fe25519_square(&chk, &r->x);
231 fe25519_mul(&chk, &chk, &den);
232 if (!fe25519_iseq_vartime(&chk, &num))
233 return -1;
234
235 /* 5. Choose the desired square root according to parity: */
236 if(fe25519_getparity(&r->x) != (1-par))
237 fe25519_neg(&r->x, &r->x);
238
239 fe25519_mul(&r->t, &r->x, &r->y);
240 return 0;
241}
242
243void ge25519_pack(unsigned char r[32], const ge25519_p3 *p)
244{
245 fe25519 tx, ty, zi;
246 fe25519_invert(&zi, &p->z);
247 fe25519_mul(&tx, &p->x, &zi);
248 fe25519_mul(&ty, &p->y, &zi);
249 fe25519_pack(r, &ty);
250 r[31] ^= fe25519_getparity(&tx) << 7;
251}
252
253int ge25519_isneutral_vartime(const ge25519_p3 *p)
254{
255 int ret = 1;
256 if(!fe25519_iszero(&p->x)) ret = 0;
257 if(!fe25519_iseq_vartime(&p->y, &p->z)) ret = 0;
258 return ret;
259}
260
261/* computes [s1]p1 + [s2]p2 */
262void ge25519_double_scalarmult_vartime(ge25519_p3 *r, const ge25519_p3 *p1, const sc25519 *s1, const ge25519_p3 *p2, const sc25519 *s2)
263{
264 ge25519_p1p1 tp1p1;
265 ge25519_p3 pre[16];
266 unsigned char b[127];
267 int i;
268
269 /* precomputation s2 s1 */
270 setneutral(pre); /* 00 00 */
271 pre[1] = *p1; /* 00 01 */
272 dbl_p1p1(&tp1p1,(ge25519_p2 *)p1); p1p1_to_p3( &pre[2], &tp1p1); /* 00 10 */
273 add_p1p1(&tp1p1,&pre[1], &pre[2]); p1p1_to_p3( &pre[3], &tp1p1); /* 00 11 */
274 pre[4] = *p2; /* 01 00 */
275 add_p1p1(&tp1p1,&pre[1], &pre[4]); p1p1_to_p3( &pre[5], &tp1p1); /* 01 01 */
276 add_p1p1(&tp1p1,&pre[2], &pre[4]); p1p1_to_p3( &pre[6], &tp1p1); /* 01 10 */
277 add_p1p1(&tp1p1,&pre[3], &pre[4]); p1p1_to_p3( &pre[7], &tp1p1); /* 01 11 */
278 dbl_p1p1(&tp1p1,(ge25519_p2 *)p2); p1p1_to_p3( &pre[8], &tp1p1); /* 10 00 */
279 add_p1p1(&tp1p1,&pre[1], &pre[8]); p1p1_to_p3( &pre[9], &tp1p1); /* 10 01 */
280 dbl_p1p1(&tp1p1,(ge25519_p2 *)&pre[5]); p1p1_to_p3(&pre[10], &tp1p1); /* 10 10 */
281 add_p1p1(&tp1p1,&pre[3], &pre[8]); p1p1_to_p3(&pre[11], &tp1p1); /* 10 11 */
282 add_p1p1(&tp1p1,&pre[4], &pre[8]); p1p1_to_p3(&pre[12], &tp1p1); /* 11 00 */
283 add_p1p1(&tp1p1,&pre[1],&pre[12]); p1p1_to_p3(&pre[13], &tp1p1); /* 11 01 */
284 add_p1p1(&tp1p1,&pre[2],&pre[12]); p1p1_to_p3(&pre[14], &tp1p1); /* 11 10 */
285 add_p1p1(&tp1p1,&pre[3],&pre[12]); p1p1_to_p3(&pre[15], &tp1p1); /* 11 11 */
286
287 sc25519_2interleave2(b,s1,s2);
288
289 /* scalar multiplication */
290 *r = pre[b[126]];
291 for(i=125;i>=0;i--)
292 {
293 dbl_p1p1(&tp1p1, (ge25519_p2 *)r);
294 p1p1_to_p2((ge25519_p2 *) r, &tp1p1);
295 dbl_p1p1(&tp1p1, (ge25519_p2 *)r);
296 if(b[i]!=0)
297 {
298 p1p1_to_p3(r, &tp1p1);
299 add_p1p1(&tp1p1, r, &pre[b[i]]);
300 }
301 if(i != 0) p1p1_to_p2((ge25519_p2 *)r, &tp1p1);
302 else p1p1_to_p3(r, &tp1p1);
303 }
304}
305
306void ge25519_scalarmult_base(ge25519_p3 *r, const sc25519 *s)
307{
308 signed char b[85];
309 int i;
310 ge25519_aff t;
311 sc25519_window3(b,s);
312
313 choose_t((ge25519_aff *)r, 0, b[0]);
314 fe25519_setone(&r->z);
315 fe25519_mul(&r->t, &r->x, &r->y);
316 for(i=1;i<85;i++)
317 {
318 choose_t(&t, (unsigned long long) i, b[i]);
319 ge25519_mixadd2(r, &t);
320 }
321}
diff --git a/ge25519.h b/ge25519.h
new file mode 100644
index 000000000..64f63c6f8
--- /dev/null
+++ b/ge25519.h
@@ -0,0 +1,43 @@
1/* $OpenBSD: ge25519.h,v 1.3 2013/12/09 11:03:45 markus Exp $ */
2
3/*
4 * Public Domain, Authors: Daniel J. Bernstein, Niels Duif, Tanja Lange,
5 * Peter Schwabe, Bo-Yin Yang.
6 * Copied from supercop-20130419/crypto_sign/ed25519/ref/ge25519.h
7 */
8
9#ifndef GE25519_H
10#define GE25519_H
11
12#include "fe25519.h"
13#include "sc25519.h"
14
15#define ge25519 crypto_sign_ed25519_ref_ge25519
16#define ge25519_base crypto_sign_ed25519_ref_ge25519_base
17#define ge25519_unpackneg_vartime crypto_sign_ed25519_ref_unpackneg_vartime
18#define ge25519_pack crypto_sign_ed25519_ref_pack
19#define ge25519_isneutral_vartime crypto_sign_ed25519_ref_isneutral_vartime
20#define ge25519_double_scalarmult_vartime crypto_sign_ed25519_ref_double_scalarmult_vartime
21#define ge25519_scalarmult_base crypto_sign_ed25519_ref_scalarmult_base
22
23typedef struct
24{
25 fe25519 x;
26 fe25519 y;
27 fe25519 z;
28 fe25519 t;
29} ge25519;
30
31const ge25519 ge25519_base;
32
33int ge25519_unpackneg_vartime(ge25519 *r, const unsigned char p[32]);
34
35void ge25519_pack(unsigned char r[32], const ge25519 *p);
36
37int ge25519_isneutral_vartime(const ge25519 *p);
38
39void ge25519_double_scalarmult_vartime(ge25519 *r, const ge25519 *p1, const sc25519 *s1, const ge25519 *p2, const sc25519 *s2);
40
41void ge25519_scalarmult_base(ge25519 *r, const sc25519 *s);
42
43#endif
diff --git a/ge25519_base.data b/ge25519_base.data
new file mode 100644
index 000000000..66fb1b61c
--- /dev/null
+++ b/ge25519_base.data
@@ -0,0 +1,858 @@
1/* $OpenBSD: ge25519_base.data,v 1.3 2013/12/09 11:03:45 markus Exp $ */
2
3/*
4 * Public Domain, Authors: Daniel J. Bernstein, Niels Duif, Tanja Lange,
5 * Peter Schwabe, Bo-Yin Yang.
6 * Copied from supercop-20130419/crypto_sign/ed25519/ref/ge25519_base.data
7 */
8
9{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
10 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
11{{{0x1a, 0xd5, 0x25, 0x8f, 0x60, 0x2d, 0x56, 0xc9, 0xb2, 0xa7, 0x25, 0x95, 0x60, 0xc7, 0x2c, 0x69, 0x5c, 0xdc, 0xd6, 0xfd, 0x31, 0xe2, 0xa4, 0xc0, 0xfe, 0x53, 0x6e, 0xcd, 0xd3, 0x36, 0x69, 0x21}} ,
12 {{0x58, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66}}},
13{{{0x0e, 0xce, 0x43, 0x28, 0x4e, 0xa1, 0xc5, 0x83, 0x5f, 0xa4, 0xd7, 0x15, 0x45, 0x8e, 0x0d, 0x08, 0xac, 0xe7, 0x33, 0x18, 0x7d, 0x3b, 0x04, 0x3d, 0x6c, 0x04, 0x5a, 0x9f, 0x4c, 0x38, 0xab, 0x36}} ,
14 {{0xc9, 0xa3, 0xf8, 0x6a, 0xae, 0x46, 0x5f, 0x0e, 0x56, 0x51, 0x38, 0x64, 0x51, 0x0f, 0x39, 0x97, 0x56, 0x1f, 0xa2, 0xc9, 0xe8, 0x5e, 0xa2, 0x1d, 0xc2, 0x29, 0x23, 0x09, 0xf3, 0xcd, 0x60, 0x22}}},
15{{{0x5c, 0xe2, 0xf8, 0xd3, 0x5f, 0x48, 0x62, 0xac, 0x86, 0x48, 0x62, 0x81, 0x19, 0x98, 0x43, 0x63, 0x3a, 0xc8, 0xda, 0x3e, 0x74, 0xae, 0xf4, 0x1f, 0x49, 0x8f, 0x92, 0x22, 0x4a, 0x9c, 0xae, 0x67}} ,
16 {{0xd4, 0xb4, 0xf5, 0x78, 0x48, 0x68, 0xc3, 0x02, 0x04, 0x03, 0x24, 0x67, 0x17, 0xec, 0x16, 0x9f, 0xf7, 0x9e, 0x26, 0x60, 0x8e, 0xa1, 0x26, 0xa1, 0xab, 0x69, 0xee, 0x77, 0xd1, 0xb1, 0x67, 0x12}}},
17{{{0x70, 0xf8, 0xc9, 0xc4, 0x57, 0xa6, 0x3a, 0x49, 0x47, 0x15, 0xce, 0x93, 0xc1, 0x9e, 0x73, 0x1a, 0xf9, 0x20, 0x35, 0x7a, 0xb8, 0xd4, 0x25, 0x83, 0x46, 0xf1, 0xcf, 0x56, 0xdb, 0xa8, 0x3d, 0x20}} ,
18 {{0x2f, 0x11, 0x32, 0xca, 0x61, 0xab, 0x38, 0xdf, 0xf0, 0x0f, 0x2f, 0xea, 0x32, 0x28, 0xf2, 0x4c, 0x6c, 0x71, 0xd5, 0x80, 0x85, 0xb8, 0x0e, 0x47, 0xe1, 0x95, 0x15, 0xcb, 0x27, 0xe8, 0xd0, 0x47}}},
19{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
20 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
21{{{0xc8, 0x84, 0xa5, 0x08, 0xbc, 0xfd, 0x87, 0x3b, 0x99, 0x8b, 0x69, 0x80, 0x7b, 0xc6, 0x3a, 0xeb, 0x93, 0xcf, 0x4e, 0xf8, 0x5c, 0x2d, 0x86, 0x42, 0xb6, 0x71, 0xd7, 0x97, 0x5f, 0xe1, 0x42, 0x67}} ,
22 {{0xb4, 0xb9, 0x37, 0xfc, 0xa9, 0x5b, 0x2f, 0x1e, 0x93, 0xe4, 0x1e, 0x62, 0xfc, 0x3c, 0x78, 0x81, 0x8f, 0xf3, 0x8a, 0x66, 0x09, 0x6f, 0xad, 0x6e, 0x79, 0x73, 0xe5, 0xc9, 0x00, 0x06, 0xd3, 0x21}}},
23{{{0xf8, 0xf9, 0x28, 0x6c, 0x6d, 0x59, 0xb2, 0x59, 0x74, 0x23, 0xbf, 0xe7, 0x33, 0x8d, 0x57, 0x09, 0x91, 0x9c, 0x24, 0x08, 0x15, 0x2b, 0xe2, 0xb8, 0xee, 0x3a, 0xe5, 0x27, 0x06, 0x86, 0xa4, 0x23}} ,
24 {{0xeb, 0x27, 0x67, 0xc1, 0x37, 0xab, 0x7a, 0xd8, 0x27, 0x9c, 0x07, 0x8e, 0xff, 0x11, 0x6a, 0xb0, 0x78, 0x6e, 0xad, 0x3a, 0x2e, 0x0f, 0x98, 0x9f, 0x72, 0xc3, 0x7f, 0x82, 0xf2, 0x96, 0x96, 0x70}}},
25{{{0x81, 0x6b, 0x88, 0xe8, 0x1e, 0xc7, 0x77, 0x96, 0x0e, 0xa1, 0xa9, 0x52, 0xe0, 0xd8, 0x0e, 0x61, 0x9e, 0x79, 0x2d, 0x95, 0x9c, 0x8d, 0x96, 0xe0, 0x06, 0x40, 0x5d, 0x87, 0x28, 0x5f, 0x98, 0x70}} ,
26 {{0xf1, 0x79, 0x7b, 0xed, 0x4f, 0x44, 0xb2, 0xe7, 0x08, 0x0d, 0xc2, 0x08, 0x12, 0xd2, 0x9f, 0xdf, 0xcd, 0x93, 0x20, 0x8a, 0xcf, 0x33, 0xca, 0x6d, 0x89, 0xb9, 0x77, 0xc8, 0x93, 0x1b, 0x4e, 0x60}}},
27{{{0x26, 0x4f, 0x7e, 0x97, 0xf6, 0x40, 0xdd, 0x4f, 0xfc, 0x52, 0x78, 0xf9, 0x90, 0x31, 0x03, 0xe6, 0x7d, 0x56, 0x39, 0x0b, 0x1d, 0x56, 0x82, 0x85, 0xf9, 0x1a, 0x42, 0x17, 0x69, 0x6c, 0xcf, 0x39}} ,
28 {{0x69, 0xd2, 0x06, 0x3a, 0x4f, 0x39, 0x2d, 0xf9, 0x38, 0x40, 0x8c, 0x4c, 0xe7, 0x05, 0x12, 0xb4, 0x78, 0x8b, 0xf8, 0xc0, 0xec, 0x93, 0xde, 0x7a, 0x6b, 0xce, 0x2c, 0xe1, 0x0e, 0xa9, 0x34, 0x44}}},
29{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
30 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
31{{{0x0b, 0xa4, 0x3c, 0xb0, 0x0f, 0x7a, 0x51, 0xf1, 0x78, 0xd6, 0xd9, 0x6a, 0xfd, 0x46, 0xe8, 0xb8, 0xa8, 0x79, 0x1d, 0x87, 0xf9, 0x90, 0xf2, 0x9c, 0x13, 0x29, 0xf8, 0x0b, 0x20, 0x64, 0xfa, 0x05}} ,
32 {{0x26, 0x09, 0xda, 0x17, 0xaf, 0x95, 0xd6, 0xfb, 0x6a, 0x19, 0x0d, 0x6e, 0x5e, 0x12, 0xf1, 0x99, 0x4c, 0xaa, 0xa8, 0x6f, 0x79, 0x86, 0xf4, 0x72, 0x28, 0x00, 0x26, 0xf9, 0xea, 0x9e, 0x19, 0x3d}}},
33{{{0x87, 0xdd, 0xcf, 0xf0, 0x5b, 0x49, 0xa2, 0x5d, 0x40, 0x7a, 0x23, 0x26, 0xa4, 0x7a, 0x83, 0x8a, 0xb7, 0x8b, 0xd2, 0x1a, 0xbf, 0xea, 0x02, 0x24, 0x08, 0x5f, 0x7b, 0xa9, 0xb1, 0xbe, 0x9d, 0x37}} ,
34 {{0xfc, 0x86, 0x4b, 0x08, 0xee, 0xe7, 0xa0, 0xfd, 0x21, 0x45, 0x09, 0x34, 0xc1, 0x61, 0x32, 0x23, 0xfc, 0x9b, 0x55, 0x48, 0x53, 0x99, 0xf7, 0x63, 0xd0, 0x99, 0xce, 0x01, 0xe0, 0x9f, 0xeb, 0x28}}},
35{{{0x47, 0xfc, 0xab, 0x5a, 0x17, 0xf0, 0x85, 0x56, 0x3a, 0x30, 0x86, 0x20, 0x28, 0x4b, 0x8e, 0x44, 0x74, 0x3a, 0x6e, 0x02, 0xf1, 0x32, 0x8f, 0x9f, 0x3f, 0x08, 0x35, 0xe9, 0xca, 0x16, 0x5f, 0x6e}} ,
36 {{0x1c, 0x59, 0x1c, 0x65, 0x5d, 0x34, 0xa4, 0x09, 0xcd, 0x13, 0x9c, 0x70, 0x7d, 0xb1, 0x2a, 0xc5, 0x88, 0xaf, 0x0b, 0x60, 0xc7, 0x9f, 0x34, 0x8d, 0xd6, 0xb7, 0x7f, 0xea, 0x78, 0x65, 0x8d, 0x77}}},
37{{{0x56, 0xa5, 0xc2, 0x0c, 0xdd, 0xbc, 0xb8, 0x20, 0x6d, 0x57, 0x61, 0xb5, 0xfb, 0x78, 0xb5, 0xd4, 0x49, 0x54, 0x90, 0x26, 0xc1, 0xcb, 0xe9, 0xe6, 0xbf, 0xec, 0x1d, 0x4e, 0xed, 0x07, 0x7e, 0x5e}} ,
38 {{0xc7, 0xf6, 0x6c, 0x56, 0x31, 0x20, 0x14, 0x0e, 0xa8, 0xd9, 0x27, 0xc1, 0x9a, 0x3d, 0x1b, 0x7d, 0x0e, 0x26, 0xd3, 0x81, 0xaa, 0xeb, 0xf5, 0x6b, 0x79, 0x02, 0xf1, 0x51, 0x5c, 0x75, 0x55, 0x0f}}},
39{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
40 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
41{{{0x0a, 0x34, 0xcd, 0x82, 0x3c, 0x33, 0x09, 0x54, 0xd2, 0x61, 0x39, 0x30, 0x9b, 0xfd, 0xef, 0x21, 0x26, 0xd4, 0x70, 0xfa, 0xee, 0xf9, 0x31, 0x33, 0x73, 0x84, 0xd0, 0xb3, 0x81, 0xbf, 0xec, 0x2e}} ,
42 {{0xe8, 0x93, 0x8b, 0x00, 0x64, 0xf7, 0x9c, 0xb8, 0x74, 0xe0, 0xe6, 0x49, 0x48, 0x4d, 0x4d, 0x48, 0xb6, 0x19, 0xa1, 0x40, 0xb7, 0xd9, 0x32, 0x41, 0x7c, 0x82, 0x37, 0xa1, 0x2d, 0xdc, 0xd2, 0x54}}},
43{{{0x68, 0x2b, 0x4a, 0x5b, 0xd5, 0xc7, 0x51, 0x91, 0x1d, 0xe1, 0x2a, 0x4b, 0xc4, 0x47, 0xf1, 0xbc, 0x7a, 0xb3, 0xcb, 0xc8, 0xb6, 0x7c, 0xac, 0x90, 0x05, 0xfd, 0xf3, 0xf9, 0x52, 0x3a, 0x11, 0x6b}} ,
44 {{0x3d, 0xc1, 0x27, 0xf3, 0x59, 0x43, 0x95, 0x90, 0xc5, 0x96, 0x79, 0xf5, 0xf4, 0x95, 0x65, 0x29, 0x06, 0x9c, 0x51, 0x05, 0x18, 0xda, 0xb8, 0x2e, 0x79, 0x7e, 0x69, 0x59, 0x71, 0x01, 0xeb, 0x1a}}},
45{{{0x15, 0x06, 0x49, 0xb6, 0x8a, 0x3c, 0xea, 0x2f, 0x34, 0x20, 0x14, 0xc3, 0xaa, 0xd6, 0xaf, 0x2c, 0x3e, 0xbd, 0x65, 0x20, 0xe2, 0x4d, 0x4b, 0x3b, 0xeb, 0x9f, 0x4a, 0xc3, 0xad, 0xa4, 0x3b, 0x60}} ,
46 {{0xbc, 0x58, 0xe6, 0xc0, 0x95, 0x2a, 0x2a, 0x81, 0x9a, 0x7a, 0xf3, 0xd2, 0x06, 0xbe, 0x48, 0xbc, 0x0c, 0xc5, 0x46, 0xe0, 0x6a, 0xd4, 0xac, 0x0f, 0xd9, 0xcc, 0x82, 0x34, 0x2c, 0xaf, 0xdb, 0x1f}}},
47{{{0xf7, 0x17, 0x13, 0xbd, 0xfb, 0xbc, 0xd2, 0xec, 0x45, 0xb3, 0x15, 0x31, 0xe9, 0xaf, 0x82, 0x84, 0x3d, 0x28, 0xc6, 0xfc, 0x11, 0xf5, 0x41, 0xb5, 0x8b, 0xd3, 0x12, 0x76, 0x52, 0xe7, 0x1a, 0x3c}} ,
48 {{0x4e, 0x36, 0x11, 0x07, 0xa2, 0x15, 0x20, 0x51, 0xc4, 0x2a, 0xc3, 0x62, 0x8b, 0x5e, 0x7f, 0xa6, 0x0f, 0xf9, 0x45, 0x85, 0x6c, 0x11, 0x86, 0xb7, 0x7e, 0xe5, 0xd7, 0xf9, 0xc3, 0x91, 0x1c, 0x05}}},
49{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
50 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
51{{{0xea, 0xd6, 0xde, 0x29, 0x3a, 0x00, 0xb9, 0x02, 0x59, 0xcb, 0x26, 0xc4, 0xba, 0x99, 0xb1, 0x97, 0x2f, 0x8e, 0x00, 0x92, 0x26, 0x4f, 0x52, 0xeb, 0x47, 0x1b, 0x89, 0x8b, 0x24, 0xc0, 0x13, 0x7d}} ,
52 {{0xd5, 0x20, 0x5b, 0x80, 0xa6, 0x80, 0x20, 0x95, 0xc3, 0xe9, 0x9f, 0x8e, 0x87, 0x9e, 0x1e, 0x9e, 0x7a, 0xc7, 0xcc, 0x75, 0x6c, 0xa5, 0xf1, 0x91, 0x1a, 0xa8, 0x01, 0x2c, 0xab, 0x76, 0xa9, 0x59}}},
53{{{0xde, 0xc9, 0xb1, 0x31, 0x10, 0x16, 0xaa, 0x35, 0x14, 0x6a, 0xd4, 0xb5, 0x34, 0x82, 0x71, 0xd2, 0x4a, 0x5d, 0x9a, 0x1f, 0x53, 0x26, 0x3c, 0xe5, 0x8e, 0x8d, 0x33, 0x7f, 0xff, 0xa9, 0xd5, 0x17}} ,
54 {{0x89, 0xaf, 0xf6, 0xa4, 0x64, 0xd5, 0x10, 0xe0, 0x1d, 0xad, 0xef, 0x44, 0xbd, 0xda, 0x83, 0xac, 0x7a, 0xa8, 0xf0, 0x1c, 0x07, 0xf9, 0xc3, 0x43, 0x6c, 0x3f, 0xb7, 0xd3, 0x87, 0x22, 0x02, 0x73}}},
55{{{0x64, 0x1d, 0x49, 0x13, 0x2f, 0x71, 0xec, 0x69, 0x87, 0xd0, 0x42, 0xee, 0x13, 0xec, 0xe3, 0xed, 0x56, 0x7b, 0xbf, 0xbd, 0x8c, 0x2f, 0x7d, 0x7b, 0x9d, 0x28, 0xec, 0x8e, 0x76, 0x2f, 0x6f, 0x08}} ,
56 {{0x22, 0xf5, 0x5f, 0x4d, 0x15, 0xef, 0xfc, 0x4e, 0x57, 0x03, 0x36, 0x89, 0xf0, 0xeb, 0x5b, 0x91, 0xd6, 0xe2, 0xca, 0x01, 0xa5, 0xee, 0x52, 0xec, 0xa0, 0x3c, 0x8f, 0x33, 0x90, 0x5a, 0x94, 0x72}}},
57{{{0x8a, 0x4b, 0xe7, 0x38, 0xbc, 0xda, 0xc2, 0xb0, 0x85, 0xe1, 0x4a, 0xfe, 0x2d, 0x44, 0x84, 0xcb, 0x20, 0x6b, 0x2d, 0xbf, 0x11, 0x9c, 0xd7, 0xbe, 0xd3, 0x3e, 0x5f, 0xbf, 0x68, 0xbc, 0xa8, 0x07}} ,
58 {{0x01, 0x89, 0x28, 0x22, 0x6a, 0x78, 0xaa, 0x29, 0x03, 0xc8, 0x74, 0x95, 0x03, 0x3e, 0xdc, 0xbd, 0x07, 0x13, 0xa8, 0xa2, 0x20, 0x2d, 0xb3, 0x18, 0x70, 0x42, 0xfd, 0x7a, 0xc4, 0xd7, 0x49, 0x72}}},
59{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
60 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
61{{{0x02, 0xff, 0x32, 0x2b, 0x5c, 0x93, 0x54, 0x32, 0xe8, 0x57, 0x54, 0x1a, 0x8b, 0x33, 0x60, 0x65, 0xd3, 0x67, 0xa4, 0xc1, 0x26, 0xc4, 0xa4, 0x34, 0x1f, 0x9b, 0xa7, 0xa9, 0xf4, 0xd9, 0x4f, 0x5b}} ,
62 {{0x46, 0x8d, 0xb0, 0x33, 0x54, 0x26, 0x5b, 0x68, 0xdf, 0xbb, 0xc5, 0xec, 0xc2, 0xf9, 0x3c, 0x5a, 0x37, 0xc1, 0x8e, 0x27, 0x47, 0xaa, 0x49, 0x5a, 0xf8, 0xfb, 0x68, 0x04, 0x23, 0xd1, 0xeb, 0x40}}},
63{{{0x65, 0xa5, 0x11, 0x84, 0x8a, 0x67, 0x9d, 0x9e, 0xd1, 0x44, 0x68, 0x7a, 0x34, 0xe1, 0x9f, 0xa3, 0x54, 0xcd, 0x07, 0xca, 0x79, 0x1f, 0x54, 0x2f, 0x13, 0x70, 0x4e, 0xee, 0xa2, 0xfa, 0xe7, 0x5d}} ,
64 {{0x36, 0xec, 0x54, 0xf8, 0xce, 0xe4, 0x85, 0xdf, 0xf6, 0x6f, 0x1d, 0x90, 0x08, 0xbc, 0xe8, 0xc0, 0x92, 0x2d, 0x43, 0x6b, 0x92, 0xa9, 0x8e, 0xab, 0x0a, 0x2e, 0x1c, 0x1e, 0x64, 0x23, 0x9f, 0x2c}}},
65{{{0xa7, 0xd6, 0x2e, 0xd5, 0xcc, 0xd4, 0xcb, 0x5a, 0x3b, 0xa7, 0xf9, 0x46, 0x03, 0x1d, 0xad, 0x2b, 0x34, 0x31, 0x90, 0x00, 0x46, 0x08, 0x82, 0x14, 0xc4, 0xe0, 0x9c, 0xf0, 0xe3, 0x55, 0x43, 0x31}} ,
66 {{0x60, 0xd6, 0xdd, 0x78, 0xe6, 0xd4, 0x22, 0x42, 0x1f, 0x00, 0xf9, 0xb1, 0x6a, 0x63, 0xe2, 0x92, 0x59, 0xd1, 0x1a, 0xb7, 0x00, 0x54, 0x29, 0xc9, 0xc1, 0xf6, 0x6f, 0x7a, 0xc5, 0x3c, 0x5f, 0x65}}},
67{{{0x27, 0x4f, 0xd0, 0x72, 0xb1, 0x11, 0x14, 0x27, 0x15, 0x94, 0x48, 0x81, 0x7e, 0x74, 0xd8, 0x32, 0xd5, 0xd1, 0x11, 0x28, 0x60, 0x63, 0x36, 0x32, 0x37, 0xb5, 0x13, 0x1c, 0xa0, 0x37, 0xe3, 0x74}} ,
68 {{0xf1, 0x25, 0x4e, 0x11, 0x96, 0x67, 0xe6, 0x1c, 0xc2, 0xb2, 0x53, 0xe2, 0xda, 0x85, 0xee, 0xb2, 0x9f, 0x59, 0xf3, 0xba, 0xbd, 0xfa, 0xcf, 0x6e, 0xf9, 0xda, 0xa4, 0xb3, 0x02, 0x8f, 0x64, 0x08}}},
69{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
70 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
71{{{0x34, 0x94, 0xf2, 0x64, 0x54, 0x47, 0x37, 0x07, 0x40, 0x8a, 0x20, 0xba, 0x4a, 0x55, 0xd7, 0x3f, 0x47, 0xba, 0x25, 0x23, 0x14, 0xb0, 0x2c, 0xe8, 0x55, 0xa8, 0xa6, 0xef, 0x51, 0xbd, 0x6f, 0x6a}} ,
72 {{0x71, 0xd6, 0x16, 0x76, 0xb2, 0x06, 0xea, 0x79, 0xf5, 0xc4, 0xc3, 0x52, 0x7e, 0x61, 0xd1, 0xe1, 0xad, 0x70, 0x78, 0x1d, 0x16, 0x11, 0xf8, 0x7c, 0x2b, 0xfc, 0x55, 0x9f, 0x52, 0xf8, 0xf5, 0x16}}},
73{{{0x34, 0x96, 0x9a, 0xf6, 0xc5, 0xe0, 0x14, 0x03, 0x24, 0x0e, 0x4c, 0xad, 0x9e, 0x9a, 0x70, 0x23, 0x96, 0xb2, 0xf1, 0x2e, 0x9d, 0xc3, 0x32, 0x9b, 0x54, 0xa5, 0x73, 0xde, 0x88, 0xb1, 0x3e, 0x24}} ,
74 {{0xf6, 0xe2, 0x4c, 0x1f, 0x5b, 0xb2, 0xaf, 0x82, 0xa5, 0xcf, 0x81, 0x10, 0x04, 0xef, 0xdb, 0xa2, 0xcc, 0x24, 0xb2, 0x7e, 0x0b, 0x7a, 0xeb, 0x01, 0xd8, 0x52, 0xf4, 0x51, 0x89, 0x29, 0x79, 0x37}}},
75{{{0x74, 0xde, 0x12, 0xf3, 0x68, 0xb7, 0x66, 0xc3, 0xee, 0x68, 0xdc, 0x81, 0xb5, 0x55, 0x99, 0xab, 0xd9, 0x28, 0x63, 0x6d, 0x8b, 0x40, 0x69, 0x75, 0x6c, 0xcd, 0x5c, 0x2a, 0x7e, 0x32, 0x7b, 0x29}} ,
76 {{0x02, 0xcc, 0x22, 0x74, 0x4d, 0x19, 0x07, 0xc0, 0xda, 0xb5, 0x76, 0x51, 0x2a, 0xaa, 0xa6, 0x0a, 0x5f, 0x26, 0xd4, 0xbc, 0xaf, 0x48, 0x88, 0x7f, 0x02, 0xbc, 0xf2, 0xe1, 0xcf, 0xe9, 0xdd, 0x15}}},
77{{{0xed, 0xb5, 0x9a, 0x8c, 0x9a, 0xdd, 0x27, 0xf4, 0x7f, 0x47, 0xd9, 0x52, 0xa7, 0xcd, 0x65, 0xa5, 0x31, 0x22, 0xed, 0xa6, 0x63, 0x5b, 0x80, 0x4a, 0xad, 0x4d, 0xed, 0xbf, 0xee, 0x49, 0xb3, 0x06}} ,
78 {{0xf8, 0x64, 0x8b, 0x60, 0x90, 0xe9, 0xde, 0x44, 0x77, 0xb9, 0x07, 0x36, 0x32, 0xc2, 0x50, 0xf5, 0x65, 0xdf, 0x48, 0x4c, 0x37, 0xaa, 0x68, 0xab, 0x9a, 0x1f, 0x3e, 0xff, 0x89, 0x92, 0xa0, 0x07}}},
79{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
80 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
81{{{0x7d, 0x4f, 0x9c, 0x19, 0xc0, 0x4a, 0x31, 0xec, 0xf9, 0xaa, 0xeb, 0xb2, 0x16, 0x9c, 0xa3, 0x66, 0x5f, 0xd1, 0xd4, 0xed, 0xb8, 0x92, 0x1c, 0xab, 0xda, 0xea, 0xd9, 0x57, 0xdf, 0x4c, 0x2a, 0x48}} ,
82 {{0x4b, 0xb0, 0x4e, 0x6e, 0x11, 0x3b, 0x51, 0xbd, 0x6a, 0xfd, 0xe4, 0x25, 0xa5, 0x5f, 0x11, 0x3f, 0x98, 0x92, 0x51, 0x14, 0xc6, 0x5f, 0x3c, 0x0b, 0xa8, 0xf7, 0xc2, 0x81, 0x43, 0xde, 0x91, 0x73}}},
83{{{0x3c, 0x8f, 0x9f, 0x33, 0x2a, 0x1f, 0x43, 0x33, 0x8f, 0x68, 0xff, 0x1f, 0x3d, 0x73, 0x6b, 0xbf, 0x68, 0xcc, 0x7d, 0x13, 0x6c, 0x24, 0x4b, 0xcc, 0x4d, 0x24, 0x0d, 0xfe, 0xde, 0x86, 0xad, 0x3b}} ,
84 {{0x79, 0x51, 0x81, 0x01, 0xdc, 0x73, 0x53, 0xe0, 0x6e, 0x9b, 0xea, 0x68, 0x3f, 0x5c, 0x14, 0x84, 0x53, 0x8d, 0x4b, 0xc0, 0x9f, 0x9f, 0x89, 0x2b, 0x8c, 0xba, 0x86, 0xfa, 0xf2, 0xcd, 0xe3, 0x2d}}},
85{{{0x06, 0xf9, 0x29, 0x5a, 0xdb, 0x3d, 0x84, 0x52, 0xab, 0xcc, 0x6b, 0x60, 0x9d, 0xb7, 0x4a, 0x0e, 0x36, 0x63, 0x91, 0xad, 0xa0, 0x95, 0xb0, 0x97, 0x89, 0x4e, 0xcf, 0x7d, 0x3c, 0xe5, 0x7c, 0x28}} ,
86 {{0x2e, 0x69, 0x98, 0xfd, 0xc6, 0xbd, 0xcc, 0xca, 0xdf, 0x9a, 0x44, 0x7e, 0x9d, 0xca, 0x89, 0x6d, 0xbf, 0x27, 0xc2, 0xf8, 0xcd, 0x46, 0x00, 0x2b, 0xb5, 0x58, 0x4e, 0xb7, 0x89, 0x09, 0xe9, 0x2d}}},
87{{{0x54, 0xbe, 0x75, 0xcb, 0x05, 0xb0, 0x54, 0xb7, 0xe7, 0x26, 0x86, 0x4a, 0xfc, 0x19, 0xcf, 0x27, 0x46, 0xd4, 0x22, 0x96, 0x5a, 0x11, 0xe8, 0xd5, 0x1b, 0xed, 0x71, 0xc5, 0x5d, 0xc8, 0xaf, 0x45}} ,
88 {{0x40, 0x7b, 0x77, 0x57, 0x49, 0x9e, 0x80, 0x39, 0x23, 0xee, 0x81, 0x0b, 0x22, 0xcf, 0xdb, 0x7a, 0x2f, 0x14, 0xb8, 0x57, 0x8f, 0xa1, 0x39, 0x1e, 0x77, 0xfc, 0x0b, 0xa6, 0xbf, 0x8a, 0x0c, 0x6c}}},
89{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
90 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
91{{{0x77, 0x3a, 0xd4, 0xd8, 0x27, 0xcf, 0xe8, 0xa1, 0x72, 0x9d, 0xca, 0xdd, 0x0d, 0x96, 0xda, 0x79, 0xed, 0x56, 0x42, 0x15, 0x60, 0xc7, 0x1c, 0x6b, 0x26, 0x30, 0xf6, 0x6a, 0x95, 0x67, 0xf3, 0x0a}} ,
92 {{0xc5, 0x08, 0xa4, 0x2b, 0x2f, 0xbd, 0x31, 0x81, 0x2a, 0xa6, 0xb6, 0xe4, 0x00, 0x91, 0xda, 0x3d, 0xb2, 0xb0, 0x96, 0xce, 0x8a, 0xd2, 0x8d, 0x70, 0xb3, 0xd3, 0x34, 0x01, 0x90, 0x8d, 0x10, 0x21}}},
93{{{0x33, 0x0d, 0xe7, 0xba, 0x4f, 0x07, 0xdf, 0x8d, 0xea, 0x7d, 0xa0, 0xc5, 0xd6, 0xb1, 0xb0, 0xe5, 0x57, 0x1b, 0x5b, 0xf5, 0x45, 0x13, 0x14, 0x64, 0x5a, 0xeb, 0x5c, 0xfc, 0x54, 0x01, 0x76, 0x2b}} ,
94 {{0x02, 0x0c, 0xc2, 0xaf, 0x96, 0x36, 0xfe, 0x4a, 0xe2, 0x54, 0x20, 0x6a, 0xeb, 0xb2, 0x9f, 0x62, 0xd7, 0xce, 0xa2, 0x3f, 0x20, 0x11, 0x34, 0x37, 0xe0, 0x42, 0xed, 0x6f, 0xf9, 0x1a, 0xc8, 0x7d}}},
95{{{0xd8, 0xb9, 0x11, 0xe8, 0x36, 0x3f, 0x42, 0xc1, 0xca, 0xdc, 0xd3, 0xf1, 0xc8, 0x23, 0x3d, 0x4f, 0x51, 0x7b, 0x9d, 0x8d, 0xd8, 0xe4, 0xa0, 0xaa, 0xf3, 0x04, 0xd6, 0x11, 0x93, 0xc8, 0x35, 0x45}} ,
96 {{0x61, 0x36, 0xd6, 0x08, 0x90, 0xbf, 0xa7, 0x7a, 0x97, 0x6c, 0x0f, 0x84, 0xd5, 0x33, 0x2d, 0x37, 0xc9, 0x6a, 0x80, 0x90, 0x3d, 0x0a, 0xa2, 0xaa, 0xe1, 0xb8, 0x84, 0xba, 0x61, 0x36, 0xdd, 0x69}}},
97{{{0x6b, 0xdb, 0x5b, 0x9c, 0xc6, 0x92, 0xbc, 0x23, 0xaf, 0xc5, 0xb8, 0x75, 0xf8, 0x42, 0xfa, 0xd6, 0xb6, 0x84, 0x94, 0x63, 0x98, 0x93, 0x48, 0x78, 0x38, 0xcd, 0xbb, 0x18, 0x34, 0xc3, 0xdb, 0x67}} ,
98 {{0x96, 0xf3, 0x3a, 0x09, 0x56, 0xb0, 0x6f, 0x7c, 0x51, 0x1e, 0x1b, 0x39, 0x48, 0xea, 0xc9, 0x0c, 0x25, 0xa2, 0x7a, 0xca, 0xe7, 0x92, 0xfc, 0x59, 0x30, 0xa3, 0x89, 0x85, 0xdf, 0x6f, 0x43, 0x38}}},
99{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
100 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
101{{{0x79, 0x84, 0x44, 0x19, 0xbd, 0xe9, 0x54, 0xc4, 0xc0, 0x6e, 0x2a, 0xa8, 0xa8, 0x9b, 0x43, 0xd5, 0x71, 0x22, 0x5f, 0xdc, 0x01, 0xfa, 0xdf, 0xb3, 0xb8, 0x47, 0x4b, 0x0a, 0xa5, 0x44, 0xea, 0x29}} ,
102 {{0x05, 0x90, 0x50, 0xaf, 0x63, 0x5f, 0x9d, 0x9e, 0xe1, 0x9d, 0x38, 0x97, 0x1f, 0x6c, 0xac, 0x30, 0x46, 0xb2, 0x6a, 0x19, 0xd1, 0x4b, 0xdb, 0xbb, 0x8c, 0xda, 0x2e, 0xab, 0xc8, 0x5a, 0x77, 0x6c}}},
103{{{0x2b, 0xbe, 0xaf, 0xa1, 0x6d, 0x2f, 0x0b, 0xb1, 0x8f, 0xe3, 0xe0, 0x38, 0xcd, 0x0b, 0x41, 0x1b, 0x4a, 0x15, 0x07, 0xf3, 0x6f, 0xdc, 0xb8, 0xe9, 0xde, 0xb2, 0xa3, 0x40, 0x01, 0xa6, 0x45, 0x1e}} ,
104 {{0x76, 0x0a, 0xda, 0x8d, 0x2c, 0x07, 0x3f, 0x89, 0x7d, 0x04, 0xad, 0x43, 0x50, 0x6e, 0xd2, 0x47, 0xcb, 0x8a, 0xe6, 0x85, 0x1a, 0x24, 0xf3, 0xd2, 0x60, 0xfd, 0xdf, 0x73, 0xa4, 0x0d, 0x73, 0x0e}}},
105{{{0xfd, 0x67, 0x6b, 0x71, 0x9b, 0x81, 0x53, 0x39, 0x39, 0xf4, 0xb8, 0xd5, 0xc3, 0x30, 0x9b, 0x3b, 0x7c, 0xa3, 0xf0, 0xd0, 0x84, 0x21, 0xd6, 0xbf, 0xb7, 0x4c, 0x87, 0x13, 0x45, 0x2d, 0xa7, 0x55}} ,
106 {{0x5d, 0x04, 0xb3, 0x40, 0x28, 0x95, 0x2d, 0x30, 0x83, 0xec, 0x5e, 0xe4, 0xff, 0x75, 0xfe, 0x79, 0x26, 0x9d, 0x1d, 0x36, 0xcd, 0x0a, 0x15, 0xd2, 0x24, 0x14, 0x77, 0x71, 0xd7, 0x8a, 0x1b, 0x04}}},
107{{{0x5d, 0x93, 0xc9, 0xbe, 0xaa, 0x90, 0xcd, 0x9b, 0xfb, 0x73, 0x7e, 0xb0, 0x64, 0x98, 0x57, 0x44, 0x42, 0x41, 0xb1, 0xaf, 0xea, 0xc1, 0xc3, 0x22, 0xff, 0x60, 0x46, 0xcb, 0x61, 0x81, 0x70, 0x61}} ,
108 {{0x0d, 0x82, 0xb9, 0xfe, 0x21, 0xcd, 0xc4, 0xf5, 0x98, 0x0c, 0x4e, 0x72, 0xee, 0x87, 0x49, 0xf8, 0xa1, 0x95, 0xdf, 0x8f, 0x2d, 0xbd, 0x21, 0x06, 0x7c, 0x15, 0xe8, 0x12, 0x6d, 0x93, 0xd6, 0x38}}},
109{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
110 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
111{{{0x91, 0xf7, 0x51, 0xd9, 0xef, 0x7d, 0x42, 0x01, 0x13, 0xe9, 0xb8, 0x7f, 0xa6, 0x49, 0x17, 0x64, 0x21, 0x80, 0x83, 0x2c, 0x63, 0x4c, 0x60, 0x09, 0x59, 0x91, 0x92, 0x77, 0x39, 0x51, 0xf4, 0x48}} ,
112 {{0x60, 0xd5, 0x22, 0x83, 0x08, 0x2f, 0xff, 0x99, 0x3e, 0x69, 0x6d, 0x88, 0xda, 0xe7, 0x5b, 0x52, 0x26, 0x31, 0x2a, 0xe5, 0x89, 0xde, 0x68, 0x90, 0xb6, 0x22, 0x5a, 0xbd, 0xd3, 0x85, 0x53, 0x31}}},
113{{{0xd8, 0xce, 0xdc, 0xf9, 0x3c, 0x4b, 0xa2, 0x1d, 0x2c, 0x2f, 0x36, 0xbe, 0x7a, 0xfc, 0xcd, 0xbc, 0xdc, 0xf9, 0x30, 0xbd, 0xff, 0x05, 0xc7, 0xe4, 0x8e, 0x17, 0x62, 0xf8, 0x4d, 0xa0, 0x56, 0x79}} ,
114 {{0x82, 0xe7, 0xf6, 0xba, 0x53, 0x84, 0x0a, 0xa3, 0x34, 0xff, 0x3c, 0xa3, 0x6a, 0xa1, 0x37, 0xea, 0xdd, 0xb6, 0x95, 0xb3, 0x78, 0x19, 0x76, 0x1e, 0x55, 0x2f, 0x77, 0x2e, 0x7f, 0xc1, 0xea, 0x5e}}},
115{{{0x83, 0xe1, 0x6e, 0xa9, 0x07, 0x33, 0x3e, 0x83, 0xff, 0xcb, 0x1c, 0x9f, 0xb1, 0xa3, 0xb4, 0xc9, 0xe1, 0x07, 0x97, 0xff, 0xf8, 0x23, 0x8f, 0xce, 0x40, 0xfd, 0x2e, 0x5e, 0xdb, 0x16, 0x43, 0x2d}} ,
116 {{0xba, 0x38, 0x02, 0xf7, 0x81, 0x43, 0x83, 0xa3, 0x20, 0x4f, 0x01, 0x3b, 0x8a, 0x04, 0x38, 0x31, 0xc6, 0x0f, 0xc8, 0xdf, 0xd7, 0xfa, 0x2f, 0x88, 0x3f, 0xfc, 0x0c, 0x76, 0xc4, 0xa6, 0x45, 0x72}}},
117{{{0xbb, 0x0c, 0xbc, 0x6a, 0xa4, 0x97, 0x17, 0x93, 0x2d, 0x6f, 0xde, 0x72, 0x10, 0x1c, 0x08, 0x2c, 0x0f, 0x80, 0x32, 0x68, 0x27, 0xd4, 0xab, 0xdd, 0xc5, 0x58, 0x61, 0x13, 0x6d, 0x11, 0x1e, 0x4d}} ,
118 {{0x1a, 0xb9, 0xc9, 0x10, 0xfb, 0x1e, 0x4e, 0xf4, 0x84, 0x4b, 0x8a, 0x5e, 0x7b, 0x4b, 0xe8, 0x43, 0x8c, 0x8f, 0x00, 0xb5, 0x54, 0x13, 0xc5, 0x5c, 0xb6, 0x35, 0x4e, 0x9d, 0xe4, 0x5b, 0x41, 0x6d}}},
119{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
120 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
121{{{0x15, 0x7d, 0x12, 0x48, 0x82, 0x14, 0x42, 0xcd, 0x32, 0xd4, 0x4b, 0xc1, 0x72, 0x61, 0x2a, 0x8c, 0xec, 0xe2, 0xf8, 0x24, 0x45, 0x94, 0xe3, 0xbe, 0xdd, 0x67, 0xa8, 0x77, 0x5a, 0xae, 0x5b, 0x4b}} ,
122 {{0xcb, 0x77, 0x9a, 0x20, 0xde, 0xb8, 0x23, 0xd9, 0xa0, 0x0f, 0x8c, 0x7b, 0xa5, 0xcb, 0xae, 0xb6, 0xec, 0x42, 0x67, 0x0e, 0x58, 0xa4, 0x75, 0x98, 0x21, 0x71, 0x84, 0xb3, 0xe0, 0x76, 0x94, 0x73}}},
123{{{0xdf, 0xfc, 0x69, 0x28, 0x23, 0x3f, 0x5b, 0xf8, 0x3b, 0x24, 0x37, 0xf3, 0x1d, 0xd5, 0x22, 0x6b, 0xd0, 0x98, 0xa8, 0x6c, 0xcf, 0xff, 0x06, 0xe1, 0x13, 0xdf, 0xb9, 0xc1, 0x0c, 0xa9, 0xbf, 0x33}} ,
124 {{0xd9, 0x81, 0xda, 0xb2, 0x4f, 0x82, 0x9d, 0x43, 0x81, 0x09, 0xf1, 0xd2, 0x01, 0xef, 0xac, 0xf4, 0x2d, 0x7d, 0x01, 0x09, 0xf1, 0xff, 0xa5, 0x9f, 0xe5, 0xca, 0x27, 0x63, 0xdb, 0x20, 0xb1, 0x53}}},
125{{{0x67, 0x02, 0xe8, 0xad, 0xa9, 0x34, 0xd4, 0xf0, 0x15, 0x81, 0xaa, 0xc7, 0x4d, 0x87, 0x94, 0xea, 0x75, 0xe7, 0x4c, 0x94, 0x04, 0x0e, 0x69, 0x87, 0xe7, 0x51, 0x91, 0x10, 0x03, 0xc7, 0xbe, 0x56}} ,
126 {{0x32, 0xfb, 0x86, 0xec, 0x33, 0x6b, 0x2e, 0x51, 0x2b, 0xc8, 0xfa, 0x6c, 0x70, 0x47, 0x7e, 0xce, 0x05, 0x0c, 0x71, 0xf3, 0xb4, 0x56, 0xa6, 0xdc, 0xcc, 0x78, 0x07, 0x75, 0xd0, 0xdd, 0xb2, 0x6a}}},
127{{{0xc6, 0xef, 0xb9, 0xc0, 0x2b, 0x22, 0x08, 0x1e, 0x71, 0x70, 0xb3, 0x35, 0x9c, 0x7a, 0x01, 0x92, 0x44, 0x9a, 0xf6, 0xb0, 0x58, 0x95, 0xc1, 0x9b, 0x02, 0xed, 0x2d, 0x7c, 0x34, 0x29, 0x49, 0x44}} ,
128 {{0x45, 0x62, 0x1d, 0x2e, 0xff, 0x2a, 0x1c, 0x21, 0xa4, 0x25, 0x7b, 0x0d, 0x8c, 0x15, 0x39, 0xfc, 0x8f, 0x7c, 0xa5, 0x7d, 0x1e, 0x25, 0xa3, 0x45, 0xd6, 0xab, 0xbd, 0xcb, 0xc5, 0x5e, 0x78, 0x77}}},
129{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
130 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
131{{{0xd0, 0xd3, 0x42, 0xed, 0x1d, 0x00, 0x3c, 0x15, 0x2c, 0x9c, 0x77, 0x81, 0xd2, 0x73, 0xd1, 0x06, 0xd5, 0xc4, 0x7f, 0x94, 0xbb, 0x92, 0x2d, 0x2c, 0x4b, 0x45, 0x4b, 0xe9, 0x2a, 0x89, 0x6b, 0x2b}} ,
132 {{0xd2, 0x0c, 0x88, 0xc5, 0x48, 0x4d, 0xea, 0x0d, 0x4a, 0xc9, 0x52, 0x6a, 0x61, 0x79, 0xe9, 0x76, 0xf3, 0x85, 0x52, 0x5c, 0x1b, 0x2c, 0xe1, 0xd6, 0xc4, 0x0f, 0x18, 0x0e, 0x4e, 0xf6, 0x1c, 0x7f}}},
133{{{0xb4, 0x04, 0x2e, 0x42, 0xcb, 0x1f, 0x2b, 0x11, 0x51, 0x7b, 0x08, 0xac, 0xaa, 0x3e, 0x9e, 0x52, 0x60, 0xb7, 0xc2, 0x61, 0x57, 0x8c, 0x84, 0xd5, 0x18, 0xa6, 0x19, 0xfc, 0xb7, 0x75, 0x91, 0x1b}} ,
134 {{0xe8, 0x68, 0xca, 0x44, 0xc8, 0x38, 0x38, 0xcc, 0x53, 0x0a, 0x32, 0x35, 0xcc, 0x52, 0xcb, 0x0e, 0xf7, 0xc5, 0xe7, 0xec, 0x3d, 0x85, 0xcc, 0x58, 0xe2, 0x17, 0x47, 0xff, 0x9f, 0xa5, 0x30, 0x17}}},
135{{{0xe3, 0xae, 0xc8, 0xc1, 0x71, 0x75, 0x31, 0x00, 0x37, 0x41, 0x5c, 0x0e, 0x39, 0xda, 0x73, 0xa0, 0xc7, 0x97, 0x36, 0x6c, 0x5b, 0xf2, 0xee, 0x64, 0x0a, 0x3d, 0x89, 0x1e, 0x1d, 0x49, 0x8c, 0x37}} ,
136 {{0x4c, 0xe6, 0xb0, 0xc1, 0xa5, 0x2a, 0x82, 0x09, 0x08, 0xad, 0x79, 0x9c, 0x56, 0xf6, 0xf9, 0xc1, 0xd7, 0x7c, 0x39, 0x7f, 0x93, 0xca, 0x11, 0x55, 0xbf, 0x07, 0x1b, 0x82, 0x29, 0x69, 0x95, 0x5c}}},
137{{{0x87, 0xee, 0xa6, 0x56, 0x9e, 0xc2, 0x9a, 0x56, 0x24, 0x42, 0x85, 0x4d, 0x98, 0x31, 0x1e, 0x60, 0x4d, 0x87, 0x85, 0x04, 0xae, 0x46, 0x12, 0xf9, 0x8e, 0x7f, 0xe4, 0x7f, 0xf6, 0x1c, 0x37, 0x01}} ,
138 {{0x73, 0x4c, 0xb6, 0xc5, 0xc4, 0xe9, 0x6c, 0x85, 0x48, 0x4a, 0x5a, 0xac, 0xd9, 0x1f, 0x43, 0xf8, 0x62, 0x5b, 0xee, 0x98, 0x2a, 0x33, 0x8e, 0x79, 0xce, 0x61, 0x06, 0x35, 0xd8, 0xd7, 0xca, 0x71}}},
139{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
140 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
141{{{0x72, 0xd3, 0xae, 0xa6, 0xca, 0x8f, 0xcd, 0xcc, 0x78, 0x8e, 0x19, 0x4d, 0xa7, 0xd2, 0x27, 0xe9, 0xa4, 0x3c, 0x16, 0x5b, 0x84, 0x80, 0xf9, 0xd0, 0xcc, 0x6a, 0x1e, 0xca, 0x1e, 0x67, 0xbd, 0x63}} ,
142 {{0x7b, 0x6e, 0x2a, 0xd2, 0x87, 0x48, 0xff, 0xa1, 0xca, 0xe9, 0x15, 0x85, 0xdc, 0xdb, 0x2c, 0x39, 0x12, 0x91, 0xa9, 0x20, 0xaa, 0x4f, 0x29, 0xf4, 0x15, 0x7a, 0xd2, 0xf5, 0x32, 0xcc, 0x60, 0x04}}},
143{{{0xe5, 0x10, 0x47, 0x3b, 0xfa, 0x90, 0xfc, 0x30, 0xb5, 0xea, 0x6f, 0x56, 0x8f, 0xfb, 0x0e, 0xa7, 0x3b, 0xc8, 0xb2, 0xff, 0x02, 0x7a, 0x33, 0x94, 0x93, 0x2a, 0x03, 0xe0, 0x96, 0x3a, 0x6c, 0x0f}} ,
144 {{0x5a, 0x63, 0x67, 0xe1, 0x9b, 0x47, 0x78, 0x9f, 0x38, 0x79, 0xac, 0x97, 0x66, 0x1d, 0x5e, 0x51, 0xee, 0x24, 0x42, 0xe8, 0x58, 0x4b, 0x8a, 0x03, 0x75, 0x86, 0x37, 0x86, 0xe2, 0x97, 0x4e, 0x3d}}},
145{{{0x3f, 0x75, 0x8e, 0xb4, 0xff, 0xd8, 0xdd, 0xd6, 0x37, 0x57, 0x9d, 0x6d, 0x3b, 0xbd, 0xd5, 0x60, 0x88, 0x65, 0x9a, 0xb9, 0x4a, 0x68, 0x84, 0xa2, 0x67, 0xdd, 0x17, 0x25, 0x97, 0x04, 0x8b, 0x5e}} ,
146 {{0xbb, 0x40, 0x5e, 0xbc, 0x16, 0x92, 0x05, 0xc4, 0xc0, 0x4e, 0x72, 0x90, 0x0e, 0xab, 0xcf, 0x8a, 0xed, 0xef, 0xb9, 0x2d, 0x3b, 0xf8, 0x43, 0x5b, 0xba, 0x2d, 0xeb, 0x2f, 0x52, 0xd2, 0xd1, 0x5a}}},
147{{{0x40, 0xb4, 0xab, 0xe6, 0xad, 0x9f, 0x46, 0x69, 0x4a, 0xb3, 0x8e, 0xaa, 0xea, 0x9c, 0x8a, 0x20, 0x16, 0x5d, 0x8c, 0x13, 0xbd, 0xf6, 0x1d, 0xc5, 0x24, 0xbd, 0x90, 0x2a, 0x1c, 0xc7, 0x13, 0x3b}} ,
148 {{0x54, 0xdc, 0x16, 0x0d, 0x18, 0xbe, 0x35, 0x64, 0x61, 0x52, 0x02, 0x80, 0xaf, 0x05, 0xf7, 0xa6, 0x42, 0xd3, 0x8f, 0x2e, 0x79, 0x26, 0xa8, 0xbb, 0xb2, 0x17, 0x48, 0xb2, 0x7a, 0x0a, 0x89, 0x14}}},
149{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
150 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
151{{{0x20, 0xa8, 0x88, 0xe3, 0x91, 0xc0, 0x6e, 0xbb, 0x8a, 0x27, 0x82, 0x51, 0x83, 0xb2, 0x28, 0xa9, 0x83, 0xeb, 0xa6, 0xa9, 0x4d, 0x17, 0x59, 0x22, 0x54, 0x00, 0x50, 0x45, 0xcb, 0x48, 0x4b, 0x18}} ,
152 {{0x33, 0x7c, 0xe7, 0x26, 0xba, 0x4d, 0x32, 0xfe, 0x53, 0xf4, 0xfa, 0x83, 0xe3, 0xa5, 0x79, 0x66, 0x73, 0xef, 0x80, 0x23, 0x68, 0xc2, 0x60, 0xdd, 0xa9, 0x33, 0xdc, 0x03, 0x7a, 0xe0, 0xe0, 0x3e}}},
153{{{0x34, 0x5c, 0x13, 0xfb, 0xc0, 0xe3, 0x78, 0x2b, 0x54, 0x58, 0x22, 0x9b, 0x76, 0x81, 0x7f, 0x93, 0x9c, 0x25, 0x3c, 0xd2, 0xe9, 0x96, 0x21, 0x26, 0x08, 0xf5, 0xed, 0x95, 0x11, 0xae, 0x04, 0x5a}} ,
154 {{0xb9, 0xe8, 0xc5, 0x12, 0x97, 0x1f, 0x83, 0xfe, 0x3e, 0x94, 0x99, 0xd4, 0x2d, 0xf9, 0x52, 0x59, 0x5c, 0x82, 0xa6, 0xf0, 0x75, 0x7e, 0xe8, 0xec, 0xcc, 0xac, 0x18, 0x21, 0x09, 0x67, 0x66, 0x67}}},
155{{{0xb3, 0x40, 0x29, 0xd1, 0xcb, 0x1b, 0x08, 0x9e, 0x9c, 0xb7, 0x53, 0xb9, 0x3b, 0x71, 0x08, 0x95, 0x12, 0x1a, 0x58, 0xaf, 0x7e, 0x82, 0x52, 0x43, 0x4f, 0x11, 0x39, 0xf4, 0x93, 0x1a, 0x26, 0x05}} ,
156 {{0x6e, 0x44, 0xa3, 0xf9, 0x64, 0xaf, 0xe7, 0x6d, 0x7d, 0xdf, 0x1e, 0xac, 0x04, 0xea, 0x3b, 0x5f, 0x9b, 0xe8, 0x24, 0x9d, 0x0e, 0xe5, 0x2e, 0x3e, 0xdf, 0xa9, 0xf7, 0xd4, 0x50, 0x71, 0xf0, 0x78}}},
157{{{0x3e, 0xa8, 0x38, 0xc2, 0x57, 0x56, 0x42, 0x9a, 0xb1, 0xe2, 0xf8, 0x45, 0xaa, 0x11, 0x48, 0x5f, 0x17, 0xc4, 0x54, 0x27, 0xdc, 0x5d, 0xaa, 0xdd, 0x41, 0xbc, 0xdf, 0x81, 0xb9, 0x53, 0xee, 0x52}} ,
158 {{0xc3, 0xf1, 0xa7, 0x6d, 0xb3, 0x5f, 0x92, 0x6f, 0xcc, 0x91, 0xb8, 0x95, 0x05, 0xdf, 0x3c, 0x64, 0x57, 0x39, 0x61, 0x51, 0xad, 0x8c, 0x38, 0x7b, 0xc8, 0xde, 0x00, 0x34, 0xbe, 0xa1, 0xb0, 0x7e}}},
159{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
160 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
161{{{0x25, 0x24, 0x1d, 0x8a, 0x67, 0x20, 0xee, 0x42, 0xeb, 0x38, 0xed, 0x0b, 0x8b, 0xcd, 0x46, 0x9d, 0x5e, 0x6b, 0x1e, 0x24, 0x9d, 0x12, 0x05, 0x1a, 0xcc, 0x05, 0x4e, 0x92, 0x38, 0xe1, 0x1f, 0x50}} ,
162 {{0x4e, 0xee, 0x1c, 0x91, 0xe6, 0x11, 0xbd, 0x8e, 0x55, 0x1a, 0x18, 0x75, 0x66, 0xaf, 0x4d, 0x7b, 0x0f, 0xae, 0x6d, 0x85, 0xca, 0x82, 0x58, 0x21, 0x9c, 0x18, 0xe0, 0xed, 0xec, 0x22, 0x80, 0x2f}}},
163{{{0x68, 0x3b, 0x0a, 0x39, 0x1d, 0x6a, 0x15, 0x57, 0xfc, 0xf0, 0x63, 0x54, 0xdb, 0x39, 0xdb, 0xe8, 0x5c, 0x64, 0xff, 0xa0, 0x09, 0x4f, 0x3b, 0xb7, 0x32, 0x60, 0x99, 0x94, 0xfd, 0x94, 0x82, 0x2d}} ,
164 {{0x24, 0xf6, 0x5a, 0x44, 0xf1, 0x55, 0x2c, 0xdb, 0xea, 0x7c, 0x84, 0x7c, 0x01, 0xac, 0xe3, 0xfd, 0xc9, 0x27, 0xc1, 0x5a, 0xb9, 0xde, 0x4f, 0x5a, 0x90, 0xdd, 0xc6, 0x67, 0xaa, 0x6f, 0x8a, 0x3a}}},
165{{{0x78, 0x52, 0x87, 0xc9, 0x97, 0x63, 0xb1, 0xdd, 0x54, 0x5f, 0xc1, 0xf8, 0xf1, 0x06, 0xa6, 0xa8, 0xa3, 0x88, 0x82, 0xd4, 0xcb, 0xa6, 0x19, 0xdd, 0xd1, 0x11, 0x87, 0x08, 0x17, 0x4c, 0x37, 0x2a}} ,
166 {{0xa1, 0x0c, 0xf3, 0x08, 0x43, 0xd9, 0x24, 0x1e, 0x83, 0xa7, 0xdf, 0x91, 0xca, 0xbd, 0x69, 0x47, 0x8d, 0x1b, 0xe2, 0xb9, 0x4e, 0xb5, 0xe1, 0x76, 0xb3, 0x1c, 0x93, 0x03, 0xce, 0x5f, 0xb3, 0x5a}}},
167{{{0x1d, 0xda, 0xe4, 0x61, 0x03, 0x50, 0xa9, 0x8b, 0x68, 0x18, 0xef, 0xb2, 0x1c, 0x84, 0x3b, 0xa2, 0x44, 0x95, 0xa3, 0x04, 0x3b, 0xd6, 0x99, 0x00, 0xaf, 0x76, 0x42, 0x67, 0x02, 0x7d, 0x85, 0x56}} ,
168 {{0xce, 0x72, 0x0e, 0x29, 0x84, 0xb2, 0x7d, 0xd2, 0x45, 0xbe, 0x57, 0x06, 0xed, 0x7f, 0xcf, 0xed, 0xcd, 0xef, 0x19, 0xd6, 0xbc, 0x15, 0x79, 0x64, 0xd2, 0x18, 0xe3, 0x20, 0x67, 0x3a, 0x54, 0x0b}}},
169{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
170 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
171{{{0x52, 0xfd, 0x04, 0xc5, 0xfb, 0x99, 0xe7, 0xe8, 0xfb, 0x8c, 0xe1, 0x42, 0x03, 0xef, 0x9d, 0xd9, 0x9e, 0x4d, 0xf7, 0x80, 0xcf, 0x2e, 0xcc, 0x9b, 0x45, 0xc9, 0x7b, 0x7a, 0xbc, 0x37, 0xa8, 0x52}} ,
172 {{0x96, 0x11, 0x41, 0x8a, 0x47, 0x91, 0xfe, 0xb6, 0xda, 0x7a, 0x54, 0x63, 0xd1, 0x14, 0x35, 0x05, 0x86, 0x8c, 0xa9, 0x36, 0x3f, 0xf2, 0x85, 0x54, 0x4e, 0x92, 0xd8, 0x85, 0x01, 0x46, 0xd6, 0x50}}},
173{{{0x53, 0xcd, 0xf3, 0x86, 0x40, 0xe6, 0x39, 0x42, 0x95, 0xd6, 0xcb, 0x45, 0x1a, 0x20, 0xc8, 0x45, 0x4b, 0x32, 0x69, 0x04, 0xb1, 0xaf, 0x20, 0x46, 0xc7, 0x6b, 0x23, 0x5b, 0x69, 0xee, 0x30, 0x3f}} ,
174 {{0x70, 0x83, 0x47, 0xc0, 0xdb, 0x55, 0x08, 0xa8, 0x7b, 0x18, 0x6d, 0xf5, 0x04, 0x5a, 0x20, 0x0c, 0x4a, 0x8c, 0x60, 0xae, 0xae, 0x0f, 0x64, 0x55, 0x55, 0x2e, 0xd5, 0x1d, 0x53, 0x31, 0x42, 0x41}}},
175{{{0xca, 0xfc, 0x88, 0x6b, 0x96, 0x78, 0x0a, 0x8b, 0x83, 0xdc, 0xbc, 0xaf, 0x40, 0xb6, 0x8d, 0x7f, 0xef, 0xb4, 0xd1, 0x3f, 0xcc, 0xa2, 0x74, 0xc9, 0xc2, 0x92, 0x55, 0x00, 0xab, 0xdb, 0xbf, 0x4f}} ,
176 {{0x93, 0x1c, 0x06, 0x2d, 0x66, 0x65, 0x02, 0xa4, 0x97, 0x18, 0xfd, 0x00, 0xe7, 0xab, 0x03, 0xec, 0xce, 0xc1, 0xbf, 0x37, 0xf8, 0x13, 0x53, 0xa5, 0xe5, 0x0c, 0x3a, 0xa8, 0x55, 0xb9, 0xff, 0x68}}},
177{{{0xe4, 0xe6, 0x6d, 0x30, 0x7d, 0x30, 0x35, 0xc2, 0x78, 0x87, 0xf9, 0xfc, 0x6b, 0x5a, 0xc3, 0xb7, 0x65, 0xd8, 0x2e, 0xc7, 0xa5, 0x0c, 0xc6, 0xdc, 0x12, 0xaa, 0xd6, 0x4f, 0xc5, 0x38, 0xbc, 0x0e}} ,
178 {{0xe2, 0x3c, 0x76, 0x86, 0x38, 0xf2, 0x7b, 0x2c, 0x16, 0x78, 0x8d, 0xf5, 0xa4, 0x15, 0xda, 0xdb, 0x26, 0x85, 0xa0, 0x56, 0xdd, 0x1d, 0xe3, 0xb3, 0xfd, 0x40, 0xef, 0xf2, 0xd9, 0xa1, 0xb3, 0x04}}},
179{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
180 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
181{{{0xdb, 0x49, 0x0e, 0xe6, 0x58, 0x10, 0x7a, 0x52, 0xda, 0xb5, 0x7d, 0x37, 0x6a, 0x3e, 0xa1, 0x78, 0xce, 0xc7, 0x1c, 0x24, 0x23, 0xdb, 0x7d, 0xfb, 0x8c, 0x8d, 0xdc, 0x30, 0x67, 0x69, 0x75, 0x3b}} ,
182 {{0xa9, 0xea, 0x6d, 0x16, 0x16, 0x60, 0xf4, 0x60, 0x87, 0x19, 0x44, 0x8c, 0x4a, 0x8b, 0x3e, 0xfb, 0x16, 0x00, 0x00, 0x54, 0xa6, 0x9e, 0x9f, 0xef, 0xcf, 0xd9, 0xd2, 0x4c, 0x74, 0x31, 0xd0, 0x34}}},
183{{{0xa4, 0xeb, 0x04, 0xa4, 0x8c, 0x8f, 0x71, 0x27, 0x95, 0x85, 0x5d, 0x55, 0x4b, 0xb1, 0x26, 0x26, 0xc8, 0xae, 0x6a, 0x7d, 0xa2, 0x21, 0xca, 0xce, 0x38, 0xab, 0x0f, 0xd0, 0xd5, 0x2b, 0x6b, 0x00}} ,
184 {{0xe5, 0x67, 0x0c, 0xf1, 0x3a, 0x9a, 0xea, 0x09, 0x39, 0xef, 0xd1, 0x30, 0xbc, 0x33, 0xba, 0xb1, 0x6a, 0xc5, 0x27, 0x08, 0x7f, 0x54, 0x80, 0x3d, 0xab, 0xf6, 0x15, 0x7a, 0xc2, 0x40, 0x73, 0x72}}},
185{{{0x84, 0x56, 0x82, 0xb6, 0x12, 0x70, 0x7f, 0xf7, 0xf0, 0xbd, 0x5b, 0xa9, 0xd5, 0xc5, 0x5f, 0x59, 0xbf, 0x7f, 0xb3, 0x55, 0x22, 0x02, 0xc9, 0x44, 0x55, 0x87, 0x8f, 0x96, 0x98, 0x64, 0x6d, 0x15}} ,
186 {{0xb0, 0x8b, 0xaa, 0x1e, 0xec, 0xc7, 0xa5, 0x8f, 0x1f, 0x92, 0x04, 0xc6, 0x05, 0xf6, 0xdf, 0xa1, 0xcc, 0x1f, 0x81, 0xf5, 0x0e, 0x9c, 0x57, 0xdc, 0xe3, 0xbb, 0x06, 0x87, 0x1e, 0xfe, 0x23, 0x6c}}},
187{{{0xd8, 0x2b, 0x5b, 0x16, 0xea, 0x20, 0xf1, 0xd3, 0x68, 0x8f, 0xae, 0x5b, 0xd0, 0xa9, 0x1a, 0x19, 0xa8, 0x36, 0xfb, 0x2b, 0x57, 0x88, 0x7d, 0x90, 0xd5, 0xa6, 0xf3, 0xdc, 0x38, 0x89, 0x4e, 0x1f}} ,
188 {{0xcc, 0x19, 0xda, 0x9b, 0x3b, 0x43, 0x48, 0x21, 0x2e, 0x23, 0x4d, 0x3d, 0xae, 0xf8, 0x8c, 0xfc, 0xdd, 0xa6, 0x74, 0x37, 0x65, 0xca, 0xee, 0x1a, 0x19, 0x8e, 0x9f, 0x64, 0x6f, 0x0c, 0x8b, 0x5a}}},
189{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
190 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
191{{{0x25, 0xb9, 0xc2, 0xf0, 0x72, 0xb8, 0x15, 0x16, 0xcc, 0x8d, 0x3c, 0x6f, 0x25, 0xed, 0xf4, 0x46, 0x2e, 0x0c, 0x60, 0x0f, 0xe2, 0x84, 0x34, 0x55, 0x89, 0x59, 0x34, 0x1b, 0xf5, 0x8d, 0xfe, 0x08}} ,
192 {{0xf8, 0xab, 0x93, 0xbc, 0x44, 0xba, 0x1b, 0x75, 0x4b, 0x49, 0x6f, 0xd0, 0x54, 0x2e, 0x63, 0xba, 0xb5, 0xea, 0xed, 0x32, 0x14, 0xc9, 0x94, 0xd8, 0xc5, 0xce, 0xf4, 0x10, 0x68, 0xe0, 0x38, 0x27}}},
193{{{0x74, 0x1c, 0x14, 0x9b, 0xd4, 0x64, 0x61, 0x71, 0x5a, 0xb6, 0x21, 0x33, 0x4f, 0xf7, 0x8e, 0xba, 0xa5, 0x48, 0x9a, 0xc7, 0xfa, 0x9a, 0xf0, 0xb4, 0x62, 0xad, 0xf2, 0x5e, 0xcc, 0x03, 0x24, 0x1a}} ,
194 {{0xf5, 0x76, 0xfd, 0xe4, 0xaf, 0xb9, 0x03, 0x59, 0xce, 0x63, 0xd2, 0x3b, 0x1f, 0xcd, 0x21, 0x0c, 0xad, 0x44, 0xa5, 0x97, 0xac, 0x80, 0x11, 0x02, 0x9b, 0x0c, 0xe5, 0x8b, 0xcd, 0xfb, 0x79, 0x77}}},
195{{{0x15, 0xbe, 0x9a, 0x0d, 0xba, 0x38, 0x72, 0x20, 0x8a, 0xf5, 0xbe, 0x59, 0x93, 0x79, 0xb7, 0xf6, 0x6a, 0x0c, 0x38, 0x27, 0x1a, 0x60, 0xf4, 0x86, 0x3b, 0xab, 0x5a, 0x00, 0xa0, 0xce, 0x21, 0x7d}} ,
196 {{0x6c, 0xba, 0x14, 0xc5, 0xea, 0x12, 0x9e, 0x2e, 0x82, 0x63, 0xce, 0x9b, 0x4a, 0xe7, 0x1d, 0xec, 0xf1, 0x2e, 0x51, 0x1c, 0xf4, 0xd0, 0x69, 0x15, 0x42, 0x9d, 0xa3, 0x3f, 0x0e, 0xbf, 0xe9, 0x5c}}},
197{{{0xe4, 0x0d, 0xf4, 0xbd, 0xee, 0x31, 0x10, 0xed, 0xcb, 0x12, 0x86, 0xad, 0xd4, 0x2f, 0x90, 0x37, 0x32, 0xc3, 0x0b, 0x73, 0xec, 0x97, 0x85, 0xa4, 0x01, 0x1c, 0x76, 0x35, 0xfe, 0x75, 0xdd, 0x71}} ,
198 {{0x11, 0xa4, 0x88, 0x9f, 0x3e, 0x53, 0x69, 0x3b, 0x1b, 0xe0, 0xf7, 0xba, 0x9b, 0xad, 0x4e, 0x81, 0x5f, 0xb5, 0x5c, 0xae, 0xbe, 0x67, 0x86, 0x37, 0x34, 0x8e, 0x07, 0x32, 0x45, 0x4a, 0x67, 0x39}}},
199{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
200 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
201{{{0x90, 0x70, 0x58, 0x20, 0x03, 0x1e, 0x67, 0xb2, 0xc8, 0x9b, 0x58, 0xc5, 0xb1, 0xeb, 0x2d, 0x4a, 0xde, 0x82, 0x8c, 0xf2, 0xd2, 0x14, 0xb8, 0x70, 0x61, 0x4e, 0x73, 0xd6, 0x0b, 0x6b, 0x0d, 0x30}} ,
202 {{0x81, 0xfc, 0x55, 0x5c, 0xbf, 0xa7, 0xc4, 0xbd, 0xe2, 0xf0, 0x4b, 0x8f, 0xe9, 0x7d, 0x99, 0xfa, 0xd3, 0xab, 0xbc, 0xc7, 0x83, 0x2b, 0x04, 0x7f, 0x0c, 0x19, 0x43, 0x03, 0x3d, 0x07, 0xca, 0x40}}},
203{{{0xf9, 0xc8, 0xbe, 0x8c, 0x16, 0x81, 0x39, 0x96, 0xf6, 0x17, 0x58, 0xc8, 0x30, 0x58, 0xfb, 0xc2, 0x03, 0x45, 0xd2, 0x52, 0x76, 0xe0, 0x6a, 0x26, 0x28, 0x5c, 0x88, 0x59, 0x6a, 0x5a, 0x54, 0x42}} ,
204 {{0x07, 0xb5, 0x2e, 0x2c, 0x67, 0x15, 0x9b, 0xfb, 0x83, 0x69, 0x1e, 0x0f, 0xda, 0xd6, 0x29, 0xb1, 0x60, 0xe0, 0xb2, 0xba, 0x69, 0xa2, 0x9e, 0xbd, 0xbd, 0xe0, 0x1c, 0xbd, 0xcd, 0x06, 0x64, 0x70}}},
205{{{0x41, 0xfa, 0x8c, 0xe1, 0x89, 0x8f, 0x27, 0xc8, 0x25, 0x8f, 0x6f, 0x5f, 0x55, 0xf8, 0xde, 0x95, 0x6d, 0x2f, 0x75, 0x16, 0x2b, 0x4e, 0x44, 0xfd, 0x86, 0x6e, 0xe9, 0x70, 0x39, 0x76, 0x97, 0x7e}} ,
206 {{0x17, 0x62, 0x6b, 0x14, 0xa1, 0x7c, 0xd0, 0x79, 0x6e, 0xd8, 0x8a, 0xa5, 0x6d, 0x8c, 0x93, 0xd2, 0x3f, 0xec, 0x44, 0x8d, 0x6e, 0x91, 0x01, 0x8c, 0x8f, 0xee, 0x01, 0x8f, 0xc0, 0xb4, 0x85, 0x0e}}},
207{{{0x02, 0x3a, 0x70, 0x41, 0xe4, 0x11, 0x57, 0x23, 0xac, 0xe6, 0xfc, 0x54, 0x7e, 0xcd, 0xd7, 0x22, 0xcb, 0x76, 0x9f, 0x20, 0xce, 0xa0, 0x73, 0x76, 0x51, 0x3b, 0xa4, 0xf8, 0xe3, 0x62, 0x12, 0x6c}} ,
208 {{0x7f, 0x00, 0x9c, 0x26, 0x0d, 0x6f, 0x48, 0x7f, 0x3a, 0x01, 0xed, 0xc5, 0x96, 0xb0, 0x1f, 0x4f, 0xa8, 0x02, 0x62, 0x27, 0x8a, 0x50, 0x8d, 0x9a, 0x8b, 0x52, 0x0f, 0x1e, 0xcf, 0x41, 0x38, 0x19}}},
209{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
210 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
211{{{0xf5, 0x6c, 0xd4, 0x2f, 0x0f, 0x69, 0x0f, 0x87, 0x3f, 0x61, 0x65, 0x1e, 0x35, 0x34, 0x85, 0xba, 0x02, 0x30, 0xac, 0x25, 0x3d, 0xe2, 0x62, 0xf1, 0xcc, 0xe9, 0x1b, 0xc2, 0xef, 0x6a, 0x42, 0x57}} ,
212 {{0x34, 0x1f, 0x2e, 0xac, 0xd1, 0xc7, 0x04, 0x52, 0x32, 0x66, 0xb2, 0x33, 0x73, 0x21, 0x34, 0x54, 0xf7, 0x71, 0xed, 0x06, 0xb0, 0xff, 0xa6, 0x59, 0x6f, 0x8a, 0x4e, 0xfb, 0x02, 0xb0, 0x45, 0x6b}}},
213{{{0xf5, 0x48, 0x0b, 0x03, 0xc5, 0x22, 0x7d, 0x80, 0x08, 0x53, 0xfe, 0x32, 0xb1, 0xa1, 0x8a, 0x74, 0x6f, 0xbd, 0x3f, 0x85, 0xf4, 0xcf, 0xf5, 0x60, 0xaf, 0x41, 0x7e, 0x3e, 0x46, 0xa3, 0x5a, 0x20}} ,
214 {{0xaa, 0x35, 0x87, 0x44, 0x63, 0x66, 0x97, 0xf8, 0x6e, 0x55, 0x0c, 0x04, 0x3e, 0x35, 0x50, 0xbf, 0x93, 0x69, 0xd2, 0x8b, 0x05, 0x55, 0x99, 0xbe, 0xe2, 0x53, 0x61, 0xec, 0xe8, 0x08, 0x0b, 0x32}}},
215{{{0xb3, 0x10, 0x45, 0x02, 0x69, 0x59, 0x2e, 0x97, 0xd9, 0x64, 0xf8, 0xdb, 0x25, 0x80, 0xdc, 0xc4, 0xd5, 0x62, 0x3c, 0xed, 0x65, 0x91, 0xad, 0xd1, 0x57, 0x81, 0x94, 0xaa, 0xa1, 0x29, 0xfc, 0x68}} ,
216 {{0xdd, 0xb5, 0x7d, 0xab, 0x5a, 0x21, 0x41, 0x53, 0xbb, 0x17, 0x79, 0x0d, 0xd1, 0xa8, 0x0c, 0x0c, 0x20, 0x88, 0x09, 0xe9, 0x84, 0xe8, 0x25, 0x11, 0x67, 0x7a, 0x8b, 0x1a, 0xe4, 0x5d, 0xe1, 0x5d}}},
217{{{0x37, 0xea, 0xfe, 0x65, 0x3b, 0x25, 0xe8, 0xe1, 0xc2, 0xc5, 0x02, 0xa4, 0xbe, 0x98, 0x0a, 0x2b, 0x61, 0xc1, 0x9b, 0xe2, 0xd5, 0x92, 0xe6, 0x9e, 0x7d, 0x1f, 0xca, 0x43, 0x88, 0x8b, 0x2c, 0x59}} ,
218 {{0xe0, 0xb5, 0x00, 0x1d, 0x2a, 0x6f, 0xaf, 0x79, 0x86, 0x2f, 0xa6, 0x5a, 0x93, 0xd1, 0xfe, 0xae, 0x3a, 0xee, 0xdb, 0x7c, 0x61, 0xbe, 0x7c, 0x01, 0xf9, 0xfe, 0x52, 0xdc, 0xd8, 0x52, 0xa3, 0x42}}},
219{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
220 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
221{{{0x22, 0xaf, 0x13, 0x37, 0xbd, 0x37, 0x71, 0xac, 0x04, 0x46, 0x63, 0xac, 0xa4, 0x77, 0xed, 0x25, 0x38, 0xe0, 0x15, 0xa8, 0x64, 0x00, 0x0d, 0xce, 0x51, 0x01, 0xa9, 0xbc, 0x0f, 0x03, 0x1c, 0x04}} ,
222 {{0x89, 0xf9, 0x80, 0x07, 0xcf, 0x3f, 0xb3, 0xe9, 0xe7, 0x45, 0x44, 0x3d, 0x2a, 0x7c, 0xe9, 0xe4, 0x16, 0x5c, 0x5e, 0x65, 0x1c, 0xc7, 0x7d, 0xc6, 0x7a, 0xfb, 0x43, 0xee, 0x25, 0x76, 0x46, 0x72}}},
223{{{0x02, 0xa2, 0xed, 0xf4, 0x8f, 0x6b, 0x0b, 0x3e, 0xeb, 0x35, 0x1a, 0xd5, 0x7e, 0xdb, 0x78, 0x00, 0x96, 0x8a, 0xa0, 0xb4, 0xcf, 0x60, 0x4b, 0xd4, 0xd5, 0xf9, 0x2d, 0xbf, 0x88, 0xbd, 0x22, 0x62}} ,
224 {{0x13, 0x53, 0xe4, 0x82, 0x57, 0xfa, 0x1e, 0x8f, 0x06, 0x2b, 0x90, 0xba, 0x08, 0xb6, 0x10, 0x54, 0x4f, 0x7c, 0x1b, 0x26, 0xed, 0xda, 0x6b, 0xdd, 0x25, 0xd0, 0x4e, 0xea, 0x42, 0xbb, 0x25, 0x03}}},
225{{{0x51, 0x16, 0x50, 0x7c, 0xd5, 0x5d, 0xf6, 0x99, 0xe8, 0x77, 0x72, 0x4e, 0xfa, 0x62, 0xcb, 0x76, 0x75, 0x0c, 0xe2, 0x71, 0x98, 0x92, 0xd5, 0xfa, 0x45, 0xdf, 0x5c, 0x6f, 0x1e, 0x9e, 0x28, 0x69}} ,
226 {{0x0d, 0xac, 0x66, 0x6d, 0xc3, 0x8b, 0xba, 0x16, 0xb5, 0xe2, 0xa0, 0x0d, 0x0c, 0xbd, 0xa4, 0x8e, 0x18, 0x6c, 0xf2, 0xdc, 0xf9, 0xdc, 0x4a, 0x86, 0x25, 0x95, 0x14, 0xcb, 0xd8, 0x1a, 0x04, 0x0f}}},
227{{{0x97, 0xa5, 0xdb, 0x8b, 0x2d, 0xaa, 0x42, 0x11, 0x09, 0xf2, 0x93, 0xbb, 0xd9, 0x06, 0x84, 0x4e, 0x11, 0xa8, 0xa0, 0x25, 0x2b, 0xa6, 0x5f, 0xae, 0xc4, 0xb4, 0x4c, 0xc8, 0xab, 0xc7, 0x3b, 0x02}} ,
228 {{0xee, 0xc9, 0x29, 0x0f, 0xdf, 0x11, 0x85, 0xed, 0xce, 0x0d, 0x62, 0x2c, 0x8f, 0x4b, 0xf9, 0x04, 0xe9, 0x06, 0x72, 0x1d, 0x37, 0x20, 0x50, 0xc9, 0x14, 0xeb, 0xec, 0x39, 0xa7, 0x97, 0x2b, 0x4d}}},
229{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
230 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
231{{{0x69, 0xd1, 0x39, 0xbd, 0xfb, 0x33, 0xbe, 0xc4, 0xf0, 0x5c, 0xef, 0xf0, 0x56, 0x68, 0xfc, 0x97, 0x47, 0xc8, 0x72, 0xb6, 0x53, 0xa4, 0x0a, 0x98, 0xa5, 0xb4, 0x37, 0x71, 0xcf, 0x66, 0x50, 0x6d}} ,
232 {{0x17, 0xa4, 0x19, 0x52, 0x11, 0x47, 0xb3, 0x5c, 0x5b, 0xa9, 0x2e, 0x22, 0xb4, 0x00, 0x52, 0xf9, 0x57, 0x18, 0xb8, 0xbe, 0x5a, 0xe3, 0xab, 0x83, 0xc8, 0x87, 0x0a, 0x2a, 0xd8, 0x8c, 0xbb, 0x54}}},
233{{{0xa9, 0x62, 0x93, 0x85, 0xbe, 0xe8, 0x73, 0x4a, 0x0e, 0xb0, 0xb5, 0x2d, 0x94, 0x50, 0xaa, 0xd3, 0xb2, 0xea, 0x9d, 0x62, 0x76, 0x3b, 0x07, 0x34, 0x4e, 0x2d, 0x70, 0xc8, 0x9a, 0x15, 0x66, 0x6b}} ,
234 {{0xc5, 0x96, 0xca, 0xc8, 0x22, 0x1a, 0xee, 0x5f, 0xe7, 0x31, 0x60, 0x22, 0x83, 0x08, 0x63, 0xce, 0xb9, 0x32, 0x44, 0x58, 0x5d, 0x3a, 0x9b, 0xe4, 0x04, 0xd5, 0xef, 0x38, 0xef, 0x4b, 0xdd, 0x19}}},
235{{{0x4d, 0xc2, 0x17, 0x75, 0xa1, 0x68, 0xcd, 0xc3, 0xc6, 0x03, 0x44, 0xe3, 0x78, 0x09, 0x91, 0x47, 0x3f, 0x0f, 0xe4, 0x92, 0x58, 0xfa, 0x7d, 0x1f, 0x20, 0x94, 0x58, 0x5e, 0xbc, 0x19, 0x02, 0x6f}} ,
236 {{0x20, 0xd6, 0xd8, 0x91, 0x54, 0xa7, 0xf3, 0x20, 0x4b, 0x34, 0x06, 0xfa, 0x30, 0xc8, 0x6f, 0x14, 0x10, 0x65, 0x74, 0x13, 0x4e, 0xf0, 0x69, 0x26, 0xce, 0xcf, 0x90, 0xf4, 0xd0, 0xc5, 0xc8, 0x64}}},
237{{{0x26, 0xa2, 0x50, 0x02, 0x24, 0x72, 0xf1, 0xf0, 0x4e, 0x2d, 0x93, 0xd5, 0x08, 0xe7, 0xae, 0x38, 0xf7, 0x18, 0xa5, 0x32, 0x34, 0xc2, 0xf0, 0xa6, 0xec, 0xb9, 0x61, 0x7b, 0x64, 0x99, 0xac, 0x71}} ,
238 {{0x25, 0xcf, 0x74, 0x55, 0x1b, 0xaa, 0xa9, 0x38, 0x41, 0x40, 0xd5, 0x95, 0x95, 0xab, 0x1c, 0x5e, 0xbc, 0x41, 0x7e, 0x14, 0x30, 0xbe, 0x13, 0x89, 0xf4, 0xe5, 0xeb, 0x28, 0xc0, 0xc2, 0x96, 0x3a}}},
239{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
240 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
241{{{0x2b, 0x77, 0x45, 0xec, 0x67, 0x76, 0x32, 0x4c, 0xb9, 0xdf, 0x25, 0x32, 0x6b, 0xcb, 0xe7, 0x14, 0x61, 0x43, 0xee, 0xba, 0x9b, 0x71, 0xef, 0xd2, 0x48, 0x65, 0xbb, 0x1b, 0x8a, 0x13, 0x1b, 0x22}} ,
242 {{0x84, 0xad, 0x0c, 0x18, 0x38, 0x5a, 0xba, 0xd0, 0x98, 0x59, 0xbf, 0x37, 0xb0, 0x4f, 0x97, 0x60, 0x20, 0xb3, 0x9b, 0x97, 0xf6, 0x08, 0x6c, 0xa4, 0xff, 0xfb, 0xb7, 0xfa, 0x95, 0xb2, 0x51, 0x79}}},
243{{{0x28, 0x5c, 0x3f, 0xdb, 0x6b, 0x18, 0x3b, 0x5c, 0xd1, 0x04, 0x28, 0xde, 0x85, 0x52, 0x31, 0xb5, 0xbb, 0xf6, 0xa9, 0xed, 0xbe, 0x28, 0x4f, 0xb3, 0x7e, 0x05, 0x6a, 0xdb, 0x95, 0x0d, 0x1b, 0x1c}} ,
244 {{0xd5, 0xc5, 0xc3, 0x9a, 0x0a, 0xd0, 0x31, 0x3e, 0x07, 0x36, 0x8e, 0xc0, 0x8a, 0x62, 0xb1, 0xca, 0xd6, 0x0e, 0x1e, 0x9d, 0xef, 0xab, 0x98, 0x4d, 0xbb, 0x6c, 0x05, 0xe0, 0xe4, 0x5d, 0xbd, 0x57}}},
245{{{0xcc, 0x21, 0x27, 0xce, 0xfd, 0xa9, 0x94, 0x8e, 0xe1, 0xab, 0x49, 0xe0, 0x46, 0x26, 0xa1, 0xa8, 0x8c, 0xa1, 0x99, 0x1d, 0xb4, 0x27, 0x6d, 0x2d, 0xc8, 0x39, 0x30, 0x5e, 0x37, 0x52, 0xc4, 0x6e}} ,
246 {{0xa9, 0x85, 0xf4, 0xe7, 0xb0, 0x15, 0x33, 0x84, 0x1b, 0x14, 0x1a, 0x02, 0xd9, 0x3b, 0xad, 0x0f, 0x43, 0x6c, 0xea, 0x3e, 0x0f, 0x7e, 0xda, 0xdd, 0x6b, 0x4c, 0x7f, 0x6e, 0xd4, 0x6b, 0xbf, 0x0f}}},
247{{{0x47, 0x9f, 0x7c, 0x56, 0x7c, 0x43, 0x91, 0x1c, 0xbb, 0x4e, 0x72, 0x3e, 0x64, 0xab, 0xa0, 0xa0, 0xdf, 0xb4, 0xd8, 0x87, 0x3a, 0xbd, 0xa8, 0x48, 0xc9, 0xb8, 0xef, 0x2e, 0xad, 0x6f, 0x84, 0x4f}} ,
248 {{0x2d, 0x2d, 0xf0, 0x1b, 0x7e, 0x2a, 0x6c, 0xf8, 0xa9, 0x6a, 0xe1, 0xf0, 0x99, 0xa1, 0x67, 0x9a, 0xd4, 0x13, 0xca, 0xca, 0xba, 0x27, 0x92, 0xaa, 0xa1, 0x5d, 0x50, 0xde, 0xcc, 0x40, 0x26, 0x0a}}},
249{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
250 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
251{{{0x9f, 0x3e, 0xf2, 0xb2, 0x90, 0xce, 0xdb, 0x64, 0x3e, 0x03, 0xdd, 0x37, 0x36, 0x54, 0x70, 0x76, 0x24, 0xb5, 0x69, 0x03, 0xfc, 0xa0, 0x2b, 0x74, 0xb2, 0x05, 0x0e, 0xcc, 0xd8, 0x1f, 0x6a, 0x1f}} ,
252 {{0x19, 0x5e, 0x60, 0x69, 0x58, 0x86, 0xa0, 0x31, 0xbd, 0x32, 0xe9, 0x2c, 0x5c, 0xd2, 0x85, 0xba, 0x40, 0x64, 0xa8, 0x74, 0xf8, 0x0e, 0x1c, 0xb3, 0xa9, 0x69, 0xe8, 0x1e, 0x40, 0x64, 0x99, 0x77}}},
253{{{0x6c, 0x32, 0x4f, 0xfd, 0xbb, 0x5c, 0xbb, 0x8d, 0x64, 0x66, 0x4a, 0x71, 0x1f, 0x79, 0xa3, 0xad, 0x8d, 0xf9, 0xd4, 0xec, 0xcf, 0x67, 0x70, 0xfa, 0x05, 0x4a, 0x0f, 0x6e, 0xaf, 0x87, 0x0a, 0x6f}} ,
254 {{0xc6, 0x36, 0x6e, 0x6c, 0x8c, 0x24, 0x09, 0x60, 0xbe, 0x26, 0xd2, 0x4c, 0x5e, 0x17, 0xca, 0x5f, 0x1d, 0xcc, 0x87, 0xe8, 0x42, 0x6a, 0xcb, 0xcb, 0x7d, 0x92, 0x05, 0x35, 0x81, 0x13, 0x60, 0x6b}}},
255{{{0xf4, 0x15, 0xcd, 0x0f, 0x0a, 0xaf, 0x4e, 0x6b, 0x51, 0xfd, 0x14, 0xc4, 0x2e, 0x13, 0x86, 0x74, 0x44, 0xcb, 0x66, 0x6b, 0xb6, 0x9d, 0x74, 0x56, 0x32, 0xac, 0x8d, 0x8e, 0x8c, 0x8c, 0x8c, 0x39}} ,
256 {{0xca, 0x59, 0x74, 0x1a, 0x11, 0xef, 0x6d, 0xf7, 0x39, 0x5c, 0x3b, 0x1f, 0xfa, 0xe3, 0x40, 0x41, 0x23, 0x9e, 0xf6, 0xd1, 0x21, 0xa2, 0xbf, 0xad, 0x65, 0x42, 0x6b, 0x59, 0x8a, 0xe8, 0xc5, 0x7f}}},
257{{{0x64, 0x05, 0x7a, 0x84, 0x4a, 0x13, 0xc3, 0xf6, 0xb0, 0x6e, 0x9a, 0x6b, 0x53, 0x6b, 0x32, 0xda, 0xd9, 0x74, 0x75, 0xc4, 0xba, 0x64, 0x3d, 0x3b, 0x08, 0xdd, 0x10, 0x46, 0xef, 0xc7, 0x90, 0x1f}} ,
258 {{0x7b, 0x2f, 0x3a, 0xce, 0xc8, 0xa1, 0x79, 0x3c, 0x30, 0x12, 0x44, 0x28, 0xf6, 0xbc, 0xff, 0xfd, 0xf4, 0xc0, 0x97, 0xb0, 0xcc, 0xc3, 0x13, 0x7a, 0xb9, 0x9a, 0x16, 0xe4, 0xcb, 0x4c, 0x34, 0x63}}},
259{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
260 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
261{{{0x07, 0x4e, 0xd3, 0x2d, 0x09, 0x33, 0x0e, 0xd2, 0x0d, 0xbe, 0x3e, 0xe7, 0xe4, 0xaa, 0xb7, 0x00, 0x8b, 0xe8, 0xad, 0xaa, 0x7a, 0x8d, 0x34, 0x28, 0xa9, 0x81, 0x94, 0xc5, 0xe7, 0x42, 0xac, 0x47}} ,
262 {{0x24, 0x89, 0x7a, 0x8f, 0xb5, 0x9b, 0xf0, 0xc2, 0x03, 0x64, 0xd0, 0x1e, 0xf5, 0xa4, 0xb2, 0xf3, 0x74, 0xe9, 0x1a, 0x16, 0xfd, 0xcb, 0x15, 0xea, 0xeb, 0x10, 0x6c, 0x35, 0xd1, 0xc1, 0xa6, 0x28}}},
263{{{0xcc, 0xd5, 0x39, 0xfc, 0xa5, 0xa4, 0xad, 0x32, 0x15, 0xce, 0x19, 0xe8, 0x34, 0x2b, 0x1c, 0x60, 0x91, 0xfc, 0x05, 0xa9, 0xb3, 0xdc, 0x80, 0x29, 0xc4, 0x20, 0x79, 0x06, 0x39, 0xc0, 0xe2, 0x22}} ,
264 {{0xbb, 0xa8, 0xe1, 0x89, 0x70, 0x57, 0x18, 0x54, 0x3c, 0xf6, 0x0d, 0x82, 0x12, 0x05, 0x87, 0x96, 0x06, 0x39, 0xe3, 0xf8, 0xb3, 0x95, 0xe5, 0xd7, 0x26, 0xbf, 0x09, 0x5a, 0x94, 0xf9, 0x1c, 0x63}}},
265{{{0x2b, 0x8c, 0x2d, 0x9a, 0x8b, 0x84, 0xf2, 0x56, 0xfb, 0xad, 0x2e, 0x7f, 0xb7, 0xfc, 0x30, 0xe1, 0x35, 0x89, 0xba, 0x4d, 0xa8, 0x6d, 0xce, 0x8c, 0x8b, 0x30, 0xe0, 0xda, 0x29, 0x18, 0x11, 0x17}} ,
266 {{0x19, 0xa6, 0x5a, 0x65, 0x93, 0xc3, 0xb5, 0x31, 0x22, 0x4f, 0xf3, 0xf6, 0x0f, 0xeb, 0x28, 0xc3, 0x7c, 0xeb, 0xce, 0x86, 0xec, 0x67, 0x76, 0x6e, 0x35, 0x45, 0x7b, 0xd8, 0x6b, 0x92, 0x01, 0x65}}},
267{{{0x3d, 0xd5, 0x9a, 0x64, 0x73, 0x36, 0xb1, 0xd6, 0x86, 0x98, 0x42, 0x3f, 0x8a, 0xf1, 0xc7, 0xf5, 0x42, 0xa8, 0x9c, 0x52, 0xa8, 0xdc, 0xf9, 0x24, 0x3f, 0x4a, 0xa1, 0xa4, 0x5b, 0xe8, 0x62, 0x1a}} ,
268 {{0xc5, 0xbd, 0xc8, 0x14, 0xd5, 0x0d, 0xeb, 0xe1, 0xa5, 0xe6, 0x83, 0x11, 0x09, 0x00, 0x1d, 0x55, 0x83, 0x51, 0x7e, 0x75, 0x00, 0x81, 0xb9, 0xcb, 0xd8, 0xc5, 0xe5, 0xa1, 0xd9, 0x17, 0x6d, 0x1f}}},
269{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
270 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
271{{{0xea, 0xf9, 0xe4, 0xe9, 0xe1, 0x52, 0x3f, 0x51, 0x19, 0x0d, 0xdd, 0xd9, 0x9d, 0x93, 0x31, 0x87, 0x23, 0x09, 0xd5, 0x83, 0xeb, 0x92, 0x09, 0x76, 0x6e, 0xe3, 0xf8, 0xc0, 0xa2, 0x66, 0xb5, 0x36}} ,
272 {{0x3a, 0xbb, 0x39, 0xed, 0x32, 0x02, 0xe7, 0x43, 0x7a, 0x38, 0x14, 0x84, 0xe3, 0x44, 0xd2, 0x5e, 0x94, 0xdd, 0x78, 0x89, 0x55, 0x4c, 0x73, 0x9e, 0xe1, 0xe4, 0x3e, 0x43, 0xd0, 0x4a, 0xde, 0x1b}}},
273{{{0xb2, 0xe7, 0x8f, 0xe3, 0xa3, 0xc5, 0xcb, 0x72, 0xee, 0x79, 0x41, 0xf8, 0xdf, 0xee, 0x65, 0xc5, 0x45, 0x77, 0x27, 0x3c, 0xbd, 0x58, 0xd3, 0x75, 0xe2, 0x04, 0x4b, 0xbb, 0x65, 0xf3, 0xc8, 0x0f}} ,
274 {{0x24, 0x7b, 0x93, 0x34, 0xb5, 0xe2, 0x74, 0x48, 0xcd, 0xa0, 0x0b, 0x92, 0x97, 0x66, 0x39, 0xf4, 0xb0, 0xe2, 0x5d, 0x39, 0x6a, 0x5b, 0x45, 0x17, 0x78, 0x1e, 0xdb, 0x91, 0x81, 0x1c, 0xf9, 0x16}}},
275{{{0x16, 0xdf, 0xd1, 0x5a, 0xd5, 0xe9, 0x4e, 0x58, 0x95, 0x93, 0x5f, 0x51, 0x09, 0xc3, 0x2a, 0xc9, 0xd4, 0x55, 0x48, 0x79, 0xa4, 0xa3, 0xb2, 0xc3, 0x62, 0xaa, 0x8c, 0xe8, 0xad, 0x47, 0x39, 0x1b}} ,
276 {{0x46, 0xda, 0x9e, 0x51, 0x3a, 0xe6, 0xd1, 0xa6, 0xbb, 0x4d, 0x7b, 0x08, 0xbe, 0x8c, 0xd5, 0xf3, 0x3f, 0xfd, 0xf7, 0x44, 0x80, 0x2d, 0x53, 0x4b, 0xd0, 0x87, 0x68, 0xc1, 0xb5, 0xd8, 0xf7, 0x07}}},
277{{{0xf4, 0x10, 0x46, 0xbe, 0xb7, 0xd2, 0xd1, 0xce, 0x5e, 0x76, 0xa2, 0xd7, 0x03, 0xdc, 0xe4, 0x81, 0x5a, 0xf6, 0x3c, 0xde, 0xae, 0x7a, 0x9d, 0x21, 0x34, 0xa5, 0xf6, 0xa9, 0x73, 0xe2, 0x8d, 0x60}} ,
278 {{0xfa, 0x44, 0x71, 0xf6, 0x41, 0xd8, 0xc6, 0x58, 0x13, 0x37, 0xeb, 0x84, 0x0f, 0x96, 0xc7, 0xdc, 0xc8, 0xa9, 0x7a, 0x83, 0xb2, 0x2f, 0x31, 0xb1, 0x1a, 0xd8, 0x98, 0x3f, 0x11, 0xd0, 0x31, 0x3b}}},
279{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
280 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
281{{{0x81, 0xd5, 0x34, 0x16, 0x01, 0xa3, 0x93, 0xea, 0x52, 0x94, 0xec, 0x93, 0xb7, 0x81, 0x11, 0x2d, 0x58, 0xf9, 0xb5, 0x0a, 0xaa, 0x4f, 0xf6, 0x2e, 0x3f, 0x36, 0xbf, 0x33, 0x5a, 0xe7, 0xd1, 0x08}} ,
282 {{0x1a, 0xcf, 0x42, 0xae, 0xcc, 0xb5, 0x77, 0x39, 0xc4, 0x5b, 0x5b, 0xd0, 0x26, 0x59, 0x27, 0xd0, 0x55, 0x71, 0x12, 0x9d, 0x88, 0x3d, 0x9c, 0xea, 0x41, 0x6a, 0xf0, 0x50, 0x93, 0x93, 0xdd, 0x47}}},
283{{{0x6f, 0xc9, 0x51, 0x6d, 0x1c, 0xaa, 0xf5, 0xa5, 0x90, 0x3f, 0x14, 0xe2, 0x6e, 0x8e, 0x64, 0xfd, 0xac, 0xe0, 0x4e, 0x22, 0xe5, 0xc1, 0xbc, 0x29, 0x0a, 0x6a, 0x9e, 0xa1, 0x60, 0xcb, 0x2f, 0x0b}} ,
284 {{0xdc, 0x39, 0x32, 0xf3, 0xa1, 0x44, 0xe9, 0xc5, 0xc3, 0x78, 0xfb, 0x95, 0x47, 0x34, 0x35, 0x34, 0xe8, 0x25, 0xde, 0x93, 0xc6, 0xb4, 0x76, 0x6d, 0x86, 0x13, 0xc6, 0xe9, 0x68, 0xb5, 0x01, 0x63}}},
285{{{0x1f, 0x9a, 0x52, 0x64, 0x97, 0xd9, 0x1c, 0x08, 0x51, 0x6f, 0x26, 0x9d, 0xaa, 0x93, 0x33, 0x43, 0xfa, 0x77, 0xe9, 0x62, 0x9b, 0x5d, 0x18, 0x75, 0xeb, 0x78, 0xf7, 0x87, 0x8f, 0x41, 0xb4, 0x4d}} ,
286 {{0x13, 0xa8, 0x82, 0x3e, 0xe9, 0x13, 0xad, 0xeb, 0x01, 0xca, 0xcf, 0xda, 0xcd, 0xf7, 0x6c, 0xc7, 0x7a, 0xdc, 0x1e, 0x6e, 0xc8, 0x4e, 0x55, 0x62, 0x80, 0xea, 0x78, 0x0c, 0x86, 0xb9, 0x40, 0x51}}},
287{{{0x27, 0xae, 0xd3, 0x0d, 0x4c, 0x8f, 0x34, 0xea, 0x7d, 0x3c, 0xe5, 0x8a, 0xcf, 0x5b, 0x92, 0xd8, 0x30, 0x16, 0xb4, 0xa3, 0x75, 0xff, 0xeb, 0x27, 0xc8, 0x5c, 0x6c, 0xc2, 0xee, 0x6c, 0x21, 0x0b}} ,
288 {{0xc3, 0xba, 0x12, 0x53, 0x2a, 0xaa, 0x77, 0xad, 0x19, 0x78, 0x55, 0x8a, 0x2e, 0x60, 0x87, 0xc2, 0x6e, 0x91, 0x38, 0x91, 0x3f, 0x7a, 0xc5, 0x24, 0x8f, 0x51, 0xc5, 0xde, 0xb0, 0x53, 0x30, 0x56}}},
289{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
290 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
291{{{0x02, 0xfe, 0x54, 0x12, 0x18, 0xca, 0x7d, 0xa5, 0x68, 0x43, 0xa3, 0x6d, 0x14, 0x2a, 0x6a, 0xa5, 0x8e, 0x32, 0xe7, 0x63, 0x4f, 0xe3, 0xc6, 0x44, 0x3e, 0xab, 0x63, 0xca, 0x17, 0x86, 0x74, 0x3f}} ,
292 {{0x1e, 0x64, 0xc1, 0x7d, 0x52, 0xdc, 0x13, 0x5a, 0xa1, 0x9c, 0x4e, 0xee, 0x99, 0x28, 0xbb, 0x4c, 0xee, 0xac, 0xa9, 0x1b, 0x89, 0xa2, 0x38, 0x39, 0x7b, 0xc4, 0x0f, 0x42, 0xe6, 0x89, 0xed, 0x0f}}},
293{{{0xf3, 0x3c, 0x8c, 0x80, 0x83, 0x10, 0x8a, 0x37, 0x50, 0x9c, 0xb4, 0xdf, 0x3f, 0x8c, 0xf7, 0x23, 0x07, 0xd6, 0xff, 0xa0, 0x82, 0x6c, 0x75, 0x3b, 0xe4, 0xb5, 0xbb, 0xe4, 0xe6, 0x50, 0xf0, 0x08}} ,
294 {{0x62, 0xee, 0x75, 0x48, 0x92, 0x33, 0xf2, 0xf4, 0xad, 0x15, 0x7a, 0xa1, 0x01, 0x46, 0xa9, 0x32, 0x06, 0x88, 0xb6, 0x36, 0x47, 0x35, 0xb9, 0xb4, 0x42, 0x85, 0x76, 0xf0, 0x48, 0x00, 0x90, 0x38}}},
295{{{0x51, 0x15, 0x9d, 0xc3, 0x95, 0xd1, 0x39, 0xbb, 0x64, 0x9d, 0x15, 0x81, 0xc1, 0x68, 0xd0, 0xb6, 0xa4, 0x2c, 0x7d, 0x5e, 0x02, 0x39, 0x00, 0xe0, 0x3b, 0xa4, 0xcc, 0xca, 0x1d, 0x81, 0x24, 0x10}} ,
296 {{0xe7, 0x29, 0xf9, 0x37, 0xd9, 0x46, 0x5a, 0xcd, 0x70, 0xfe, 0x4d, 0x5b, 0xbf, 0xa5, 0xcf, 0x91, 0xf4, 0xef, 0xee, 0x8a, 0x29, 0xd0, 0xe7, 0xc4, 0x25, 0x92, 0x8a, 0xff, 0x36, 0xfc, 0xe4, 0x49}}},
297{{{0xbd, 0x00, 0xb9, 0x04, 0x7d, 0x35, 0xfc, 0xeb, 0xd0, 0x0b, 0x05, 0x32, 0x52, 0x7a, 0x89, 0x24, 0x75, 0x50, 0xe1, 0x63, 0x02, 0x82, 0x8e, 0xe7, 0x85, 0x0c, 0xf2, 0x56, 0x44, 0x37, 0x83, 0x25}} ,
298 {{0x8f, 0xa1, 0xce, 0xcb, 0x60, 0xda, 0x12, 0x02, 0x1e, 0x29, 0x39, 0x2a, 0x03, 0xb7, 0xeb, 0x77, 0x40, 0xea, 0xc9, 0x2b, 0x2c, 0xd5, 0x7d, 0x7e, 0x2c, 0xc7, 0x5a, 0xfd, 0xff, 0xc4, 0xd1, 0x62}}},
299{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
300 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
301{{{0x1d, 0x88, 0x98, 0x5b, 0x4e, 0xfc, 0x41, 0x24, 0x05, 0xe6, 0x50, 0x2b, 0xae, 0x96, 0x51, 0xd9, 0x6b, 0x72, 0xb2, 0x33, 0x42, 0x98, 0x68, 0xbb, 0x10, 0x5a, 0x7a, 0x8c, 0x9d, 0x07, 0xb4, 0x05}} ,
302 {{0x2f, 0x61, 0x9f, 0xd7, 0xa8, 0x3f, 0x83, 0x8c, 0x10, 0x69, 0x90, 0xe6, 0xcf, 0xd2, 0x63, 0xa3, 0xe4, 0x54, 0x7e, 0xe5, 0x69, 0x13, 0x1c, 0x90, 0x57, 0xaa, 0xe9, 0x53, 0x22, 0x43, 0x29, 0x23}}},
303{{{0xe5, 0x1c, 0xf8, 0x0a, 0xfd, 0x2d, 0x7e, 0xf5, 0xf5, 0x70, 0x7d, 0x41, 0x6b, 0x11, 0xfe, 0xbe, 0x99, 0xd1, 0x55, 0x29, 0x31, 0xbf, 0xc0, 0x97, 0x6c, 0xd5, 0x35, 0xcc, 0x5e, 0x8b, 0xd9, 0x69}} ,
304 {{0x8e, 0x4e, 0x9f, 0x25, 0xf8, 0x81, 0x54, 0x2d, 0x0e, 0xd5, 0x54, 0x81, 0x9b, 0xa6, 0x92, 0xce, 0x4b, 0xe9, 0x8f, 0x24, 0x3b, 0xca, 0xe0, 0x44, 0xab, 0x36, 0xfe, 0xfb, 0x87, 0xd4, 0x26, 0x3e}}},
305{{{0x0f, 0x93, 0x9c, 0x11, 0xe7, 0xdb, 0xf1, 0xf0, 0x85, 0x43, 0x28, 0x15, 0x37, 0xdd, 0xde, 0x27, 0xdf, 0xad, 0x3e, 0x49, 0x4f, 0xe0, 0x5b, 0xf6, 0x80, 0x59, 0x15, 0x3c, 0x85, 0xb7, 0x3e, 0x12}} ,
306 {{0xf5, 0xff, 0xcc, 0xf0, 0xb4, 0x12, 0x03, 0x5f, 0xc9, 0x84, 0xcb, 0x1d, 0x17, 0xe0, 0xbc, 0xcc, 0x03, 0x62, 0xa9, 0x8b, 0x94, 0xa6, 0xaa, 0x18, 0xcb, 0x27, 0x8d, 0x49, 0xa6, 0x17, 0x15, 0x07}}},
307{{{0xd9, 0xb6, 0xd4, 0x9d, 0xd4, 0x6a, 0xaf, 0x70, 0x07, 0x2c, 0x10, 0x9e, 0xbd, 0x11, 0xad, 0xe4, 0x26, 0x33, 0x70, 0x92, 0x78, 0x1c, 0x74, 0x9f, 0x75, 0x60, 0x56, 0xf4, 0x39, 0xa8, 0xa8, 0x62}} ,
308 {{0x3b, 0xbf, 0x55, 0x35, 0x61, 0x8b, 0x44, 0x97, 0xe8, 0x3a, 0x55, 0xc1, 0xc8, 0x3b, 0xfd, 0x95, 0x29, 0x11, 0x60, 0x96, 0x1e, 0xcb, 0x11, 0x9d, 0xc2, 0x03, 0x8a, 0x1b, 0xc6, 0xd6, 0x45, 0x3d}}},
309{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
310 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
311{{{0x7e, 0x0e, 0x50, 0xb2, 0xcc, 0x0d, 0x6b, 0xa6, 0x71, 0x5b, 0x42, 0xed, 0xbd, 0xaf, 0xac, 0xf0, 0xfc, 0x12, 0xa2, 0x3f, 0x4e, 0xda, 0xe8, 0x11, 0xf3, 0x23, 0xe1, 0x04, 0x62, 0x03, 0x1c, 0x4e}} ,
312 {{0xc8, 0xb1, 0x1b, 0x6f, 0x73, 0x61, 0x3d, 0x27, 0x0d, 0x7d, 0x7a, 0x25, 0x5f, 0x73, 0x0e, 0x2f, 0x93, 0xf6, 0x24, 0xd8, 0x4f, 0x90, 0xac, 0xa2, 0x62, 0x0a, 0xf0, 0x61, 0xd9, 0x08, 0x59, 0x6a}}},
313{{{0x6f, 0x2d, 0x55, 0xf8, 0x2f, 0x8e, 0xf0, 0x18, 0x3b, 0xea, 0xdd, 0x26, 0x72, 0xd1, 0xf5, 0xfe, 0xe5, 0xb8, 0xe6, 0xd3, 0x10, 0x48, 0x46, 0x49, 0x3a, 0x9f, 0x5e, 0x45, 0x6b, 0x90, 0xe8, 0x7f}} ,
314 {{0xd3, 0x76, 0x69, 0x33, 0x7b, 0xb9, 0x40, 0x70, 0xee, 0xa6, 0x29, 0x6b, 0xdd, 0xd0, 0x5d, 0x8d, 0xc1, 0x3e, 0x4a, 0xea, 0x37, 0xb1, 0x03, 0x02, 0x03, 0x35, 0xf1, 0x28, 0x9d, 0xff, 0x00, 0x13}}},
315{{{0x7a, 0xdb, 0x12, 0xd2, 0x8a, 0x82, 0x03, 0x1b, 0x1e, 0xaf, 0xf9, 0x4b, 0x9c, 0xbe, 0xae, 0x7c, 0xe4, 0x94, 0x2a, 0x23, 0xb3, 0x62, 0x86, 0xe7, 0xfd, 0x23, 0xaa, 0x99, 0xbd, 0x2b, 0x11, 0x6c}} ,
316 {{0x8d, 0xa6, 0xd5, 0xac, 0x9d, 0xcc, 0x68, 0x75, 0x7f, 0xc3, 0x4d, 0x4b, 0xdd, 0x6c, 0xbb, 0x11, 0x5a, 0x60, 0xe5, 0xbd, 0x7d, 0x27, 0x8b, 0xda, 0xb4, 0x95, 0xf6, 0x03, 0x27, 0xa4, 0x92, 0x3f}}},
317{{{0x22, 0xd6, 0xb5, 0x17, 0x84, 0xbf, 0x12, 0xcc, 0x23, 0x14, 0x4a, 0xdf, 0x14, 0x31, 0xbc, 0xa1, 0xac, 0x6e, 0xab, 0xfa, 0x57, 0x11, 0x53, 0xb3, 0x27, 0xe6, 0xf9, 0x47, 0x33, 0x44, 0x34, 0x1e}} ,
318 {{0x79, 0xfc, 0xa6, 0xb4, 0x0b, 0x35, 0x20, 0xc9, 0x4d, 0x22, 0x84, 0xc4, 0xa9, 0x20, 0xec, 0x89, 0x94, 0xba, 0x66, 0x56, 0x48, 0xb9, 0x87, 0x7f, 0xca, 0x1e, 0x06, 0xed, 0xa5, 0x55, 0x59, 0x29}}},
319{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
320 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
321{{{0x56, 0xe1, 0xf5, 0xf1, 0xd5, 0xab, 0xa8, 0x2b, 0xae, 0x89, 0xf3, 0xcf, 0x56, 0x9f, 0xf2, 0x4b, 0x31, 0xbc, 0x18, 0xa9, 0x06, 0x5b, 0xbe, 0xb4, 0x61, 0xf8, 0xb2, 0x06, 0x9c, 0x81, 0xab, 0x4c}} ,
322 {{0x1f, 0x68, 0x76, 0x01, 0x16, 0x38, 0x2b, 0x0f, 0x77, 0x97, 0x92, 0x67, 0x4e, 0x86, 0x6a, 0x8b, 0xe5, 0xe8, 0x0c, 0xf7, 0x36, 0x39, 0xb5, 0x33, 0xe6, 0xcf, 0x5e, 0xbd, 0x18, 0xfb, 0x10, 0x1f}}},
323{{{0x83, 0xf0, 0x0d, 0x63, 0xef, 0x53, 0x6b, 0xb5, 0x6b, 0xf9, 0x83, 0xcf, 0xde, 0x04, 0x22, 0x9b, 0x2c, 0x0a, 0xe0, 0xa5, 0xd8, 0xc7, 0x9c, 0xa5, 0xa3, 0xf6, 0x6f, 0xcf, 0x90, 0x6b, 0x68, 0x7c}} ,
324 {{0x33, 0x15, 0xd7, 0x7f, 0x1a, 0xd5, 0x21, 0x58, 0xc4, 0x18, 0xa5, 0xf0, 0xcc, 0x73, 0xa8, 0xfd, 0xfa, 0x18, 0xd1, 0x03, 0x91, 0x8d, 0x52, 0xd2, 0xa3, 0xa4, 0xd3, 0xb1, 0xea, 0x1d, 0x0f, 0x00}}},
325{{{0xcc, 0x48, 0x83, 0x90, 0xe5, 0xfd, 0x3f, 0x84, 0xaa, 0xf9, 0x8b, 0x82, 0x59, 0x24, 0x34, 0x68, 0x4f, 0x1c, 0x23, 0xd9, 0xcc, 0x71, 0xe1, 0x7f, 0x8c, 0xaf, 0xf1, 0xee, 0x00, 0xb6, 0xa0, 0x77}} ,
326 {{0xf5, 0x1a, 0x61, 0xf7, 0x37, 0x9d, 0x00, 0xf4, 0xf2, 0x69, 0x6f, 0x4b, 0x01, 0x85, 0x19, 0x45, 0x4d, 0x7f, 0x02, 0x7c, 0x6a, 0x05, 0x47, 0x6c, 0x1f, 0x81, 0x20, 0xd4, 0xe8, 0x50, 0x27, 0x72}}},
327{{{0x2c, 0x3a, 0xe5, 0xad, 0xf4, 0xdd, 0x2d, 0xf7, 0x5c, 0x44, 0xb5, 0x5b, 0x21, 0xa3, 0x89, 0x5f, 0x96, 0x45, 0xca, 0x4d, 0xa4, 0x21, 0x99, 0x70, 0xda, 0xc4, 0xc4, 0xa0, 0xe5, 0xf4, 0xec, 0x0a}} ,
328 {{0x07, 0x68, 0x21, 0x65, 0xe9, 0x08, 0xa0, 0x0b, 0x6a, 0x4a, 0xba, 0xb5, 0x80, 0xaf, 0xd0, 0x1b, 0xc5, 0xf5, 0x4b, 0x73, 0x50, 0x60, 0x2d, 0x71, 0x69, 0x61, 0x0e, 0xc0, 0x20, 0x40, 0x30, 0x19}}},
329{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
330 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
331{{{0xd0, 0x75, 0x57, 0x3b, 0xeb, 0x5c, 0x14, 0x56, 0x50, 0xc9, 0x4f, 0xb8, 0xb8, 0x1e, 0xa3, 0xf4, 0xab, 0xf5, 0xa9, 0x20, 0x15, 0x94, 0x82, 0xda, 0x96, 0x1c, 0x9b, 0x59, 0x8c, 0xff, 0xf4, 0x51}} ,
332 {{0xc1, 0x3a, 0x86, 0xd7, 0xb0, 0x06, 0x84, 0x7f, 0x1b, 0xbd, 0xd4, 0x07, 0x78, 0x80, 0x2e, 0xb1, 0xb4, 0xee, 0x52, 0x38, 0xee, 0x9a, 0xf9, 0xf6, 0xf3, 0x41, 0x6e, 0xd4, 0x88, 0x95, 0xac, 0x35}}},
333{{{0x41, 0x97, 0xbf, 0x71, 0x6a, 0x9b, 0x72, 0xec, 0xf3, 0xf8, 0x6b, 0xe6, 0x0e, 0x6c, 0x69, 0xa5, 0x2f, 0x68, 0x52, 0xd8, 0x61, 0x81, 0xc0, 0x63, 0x3f, 0xa6, 0x3c, 0x13, 0x90, 0xe6, 0x8d, 0x56}} ,
334 {{0xe8, 0x39, 0x30, 0x77, 0x23, 0xb1, 0xfd, 0x1b, 0x3d, 0x3e, 0x74, 0x4d, 0x7f, 0xae, 0x5b, 0x3a, 0xb4, 0x65, 0x0e, 0x3a, 0x43, 0xdc, 0xdc, 0x41, 0x47, 0xe6, 0xe8, 0x92, 0x09, 0x22, 0x48, 0x4c}}},
335{{{0x85, 0x57, 0x9f, 0xb5, 0xc8, 0x06, 0xb2, 0x9f, 0x47, 0x3f, 0xf0, 0xfa, 0xe6, 0xa9, 0xb1, 0x9b, 0x6f, 0x96, 0x7d, 0xf9, 0xa4, 0x65, 0x09, 0x75, 0x32, 0xa6, 0x6c, 0x7f, 0x47, 0x4b, 0x2f, 0x4f}} ,
336 {{0x34, 0xe9, 0x59, 0x93, 0x9d, 0x26, 0x80, 0x54, 0xf2, 0xcc, 0x3c, 0xc2, 0x25, 0x85, 0xe3, 0x6a, 0xc1, 0x62, 0x04, 0xa7, 0x08, 0x32, 0x6d, 0xa1, 0x39, 0x84, 0x8a, 0x3b, 0x87, 0x5f, 0x11, 0x13}}},
337{{{0xda, 0x03, 0x34, 0x66, 0xc4, 0x0c, 0x73, 0x6e, 0xbc, 0x24, 0xb5, 0xf9, 0x70, 0x81, 0x52, 0xe9, 0xf4, 0x7c, 0x23, 0xdd, 0x9f, 0xb8, 0x46, 0xef, 0x1d, 0x22, 0x55, 0x7d, 0x71, 0xc4, 0x42, 0x33}} ,
338 {{0xc5, 0x37, 0x69, 0x5b, 0xa8, 0xc6, 0x9d, 0xa4, 0xfc, 0x61, 0x6e, 0x68, 0x46, 0xea, 0xd7, 0x1c, 0x67, 0xd2, 0x7d, 0xfa, 0xf1, 0xcc, 0x54, 0x8d, 0x36, 0x35, 0xc9, 0x00, 0xdf, 0x6c, 0x67, 0x50}}},
339{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
340 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
341{{{0x9a, 0x4d, 0x42, 0x29, 0x5d, 0xa4, 0x6b, 0x6f, 0xa8, 0x8a, 0x4d, 0x91, 0x7b, 0xd2, 0xdf, 0x36, 0xef, 0x01, 0x22, 0xc5, 0xcc, 0x8d, 0xeb, 0x58, 0x3d, 0xb3, 0x50, 0xfc, 0x8b, 0x97, 0x96, 0x33}} ,
342 {{0x93, 0x33, 0x07, 0xc8, 0x4a, 0xca, 0xd0, 0xb1, 0xab, 0xbd, 0xdd, 0xa7, 0x7c, 0xac, 0x3e, 0x45, 0xcb, 0xcc, 0x07, 0x91, 0xbf, 0x35, 0x9d, 0xcb, 0x7d, 0x12, 0x3c, 0x11, 0x59, 0x13, 0xcf, 0x5c}}},
343{{{0x45, 0xb8, 0x41, 0xd7, 0xab, 0x07, 0x15, 0x00, 0x8e, 0xce, 0xdf, 0xb2, 0x43, 0x5c, 0x01, 0xdc, 0xf4, 0x01, 0x51, 0x95, 0x10, 0x5a, 0xf6, 0x24, 0x24, 0xa0, 0x19, 0x3a, 0x09, 0x2a, 0xaa, 0x3f}} ,
344 {{0xdc, 0x8e, 0xeb, 0xc6, 0xbf, 0xdd, 0x11, 0x7b, 0xe7, 0x47, 0xe6, 0xce, 0xe7, 0xb6, 0xc5, 0xe8, 0x8a, 0xdc, 0x4b, 0x57, 0x15, 0x3b, 0x66, 0xca, 0x89, 0xa3, 0xfd, 0xac, 0x0d, 0xe1, 0x1d, 0x7a}}},
345{{{0x89, 0xef, 0xbf, 0x03, 0x75, 0xd0, 0x29, 0x50, 0xcb, 0x7d, 0xd6, 0xbe, 0xad, 0x5f, 0x7b, 0x00, 0x32, 0xaa, 0x98, 0xed, 0x3f, 0x8f, 0x92, 0xcb, 0x81, 0x56, 0x01, 0x63, 0x64, 0xa3, 0x38, 0x39}} ,
346 {{0x8b, 0xa4, 0xd6, 0x50, 0xb4, 0xaa, 0x5d, 0x64, 0x64, 0x76, 0x2e, 0xa1, 0xa6, 0xb3, 0xb8, 0x7c, 0x7a, 0x56, 0xf5, 0x5c, 0x4e, 0x84, 0x5c, 0xfb, 0xdd, 0xca, 0x48, 0x8b, 0x48, 0xb9, 0xba, 0x34}}},
347{{{0xc5, 0xe3, 0xe8, 0xae, 0x17, 0x27, 0xe3, 0x64, 0x60, 0x71, 0x47, 0x29, 0x02, 0x0f, 0x92, 0x5d, 0x10, 0x93, 0xc8, 0x0e, 0xa1, 0xed, 0xba, 0xa9, 0x96, 0x1c, 0xc5, 0x76, 0x30, 0xcd, 0xf9, 0x30}} ,
348 {{0x95, 0xb0, 0xbd, 0x8c, 0xbc, 0xa7, 0x4f, 0x7e, 0xfd, 0x4e, 0x3a, 0xbf, 0x5f, 0x04, 0x79, 0x80, 0x2b, 0x5a, 0x9f, 0x4f, 0x68, 0x21, 0x19, 0x71, 0xc6, 0x20, 0x01, 0x42, 0xaa, 0xdf, 0xae, 0x2c}}},
349{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
350 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
351{{{0x90, 0x6e, 0x7e, 0x4b, 0x71, 0x93, 0xc0, 0x72, 0xed, 0xeb, 0x71, 0x24, 0x97, 0x26, 0x9c, 0xfe, 0xcb, 0x3e, 0x59, 0x19, 0xa8, 0x0f, 0x75, 0x7d, 0xbe, 0x18, 0xe6, 0x96, 0x1e, 0x95, 0x70, 0x60}} ,
352 {{0x89, 0x66, 0x3e, 0x1d, 0x4c, 0x5f, 0xfe, 0xc0, 0x04, 0x43, 0xd6, 0x44, 0x19, 0xb5, 0xad, 0xc7, 0x22, 0xdc, 0x71, 0x28, 0x64, 0xde, 0x41, 0x38, 0x27, 0x8f, 0x2c, 0x6b, 0x08, 0xb8, 0xb8, 0x7b}}},
353{{{0x3d, 0x70, 0x27, 0x9d, 0xd9, 0xaf, 0xb1, 0x27, 0xaf, 0xe3, 0x5d, 0x1e, 0x3a, 0x30, 0x54, 0x61, 0x60, 0xe8, 0xc3, 0x26, 0x3a, 0xbc, 0x7e, 0xf5, 0x81, 0xdd, 0x64, 0x01, 0x04, 0xeb, 0xc0, 0x1e}} ,
354 {{0xda, 0x2c, 0xa4, 0xd1, 0xa1, 0xc3, 0x5c, 0x6e, 0x32, 0x07, 0x1f, 0xb8, 0x0e, 0x19, 0x9e, 0x99, 0x29, 0x33, 0x9a, 0xae, 0x7a, 0xed, 0x68, 0x42, 0x69, 0x7c, 0x07, 0xb3, 0x38, 0x2c, 0xf6, 0x3d}}},
355{{{0x64, 0xaa, 0xb5, 0x88, 0x79, 0x65, 0x38, 0x8c, 0x94, 0xd6, 0x62, 0x37, 0x7d, 0x64, 0xcd, 0x3a, 0xeb, 0xff, 0xe8, 0x81, 0x09, 0xc7, 0x6a, 0x50, 0x09, 0x0d, 0x28, 0x03, 0x0d, 0x9a, 0x93, 0x0a}} ,
356 {{0x42, 0xa3, 0xf1, 0xc5, 0xb4, 0x0f, 0xd8, 0xc8, 0x8d, 0x15, 0x31, 0xbd, 0xf8, 0x07, 0x8b, 0xcd, 0x08, 0x8a, 0xfb, 0x18, 0x07, 0xfe, 0x8e, 0x52, 0x86, 0xef, 0xbe, 0xec, 0x49, 0x52, 0x99, 0x08}}},
357{{{0x0f, 0xa9, 0xd5, 0x01, 0xaa, 0x48, 0x4f, 0x28, 0x66, 0x32, 0x1a, 0xba, 0x7c, 0xea, 0x11, 0x80, 0x17, 0x18, 0x9b, 0x56, 0x88, 0x25, 0x06, 0x69, 0x12, 0x2c, 0xea, 0x56, 0x69, 0x41, 0x24, 0x19}} ,
358 {{0xde, 0x21, 0xf0, 0xda, 0x8a, 0xfb, 0xb1, 0xb8, 0xcd, 0xc8, 0x6a, 0x82, 0x19, 0x73, 0xdb, 0xc7, 0xcf, 0x88, 0xeb, 0x96, 0xee, 0x6f, 0xfb, 0x06, 0xd2, 0xcd, 0x7d, 0x7b, 0x12, 0x28, 0x8e, 0x0c}}},
359{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
360 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
361{{{0x93, 0x44, 0x97, 0xce, 0x28, 0xff, 0x3a, 0x40, 0xc4, 0xf5, 0xf6, 0x9b, 0xf4, 0x6b, 0x07, 0x84, 0xfb, 0x98, 0xd8, 0xec, 0x8c, 0x03, 0x57, 0xec, 0x49, 0xed, 0x63, 0xb6, 0xaa, 0xff, 0x98, 0x28}} ,
362 {{0x3d, 0x16, 0x35, 0xf3, 0x46, 0xbc, 0xb3, 0xf4, 0xc6, 0xb6, 0x4f, 0xfa, 0xf4, 0xa0, 0x13, 0xe6, 0x57, 0x45, 0x93, 0xb9, 0xbc, 0xd6, 0x59, 0xe7, 0x77, 0x94, 0x6c, 0xab, 0x96, 0x3b, 0x4f, 0x09}}},
363{{{0x5a, 0xf7, 0x6b, 0x01, 0x12, 0x4f, 0x51, 0xc1, 0x70, 0x84, 0x94, 0x47, 0xb2, 0x01, 0x6c, 0x71, 0xd7, 0xcc, 0x17, 0x66, 0x0f, 0x59, 0x5d, 0x5d, 0x10, 0x01, 0x57, 0x11, 0xf5, 0xdd, 0xe2, 0x34}} ,
364 {{0x26, 0xd9, 0x1f, 0x5c, 0x58, 0xac, 0x8b, 0x03, 0xd2, 0xc3, 0x85, 0x0f, 0x3a, 0xc3, 0x7f, 0x6d, 0x8e, 0x86, 0xcd, 0x52, 0x74, 0x8f, 0x55, 0x77, 0x17, 0xb7, 0x8e, 0xb7, 0x88, 0xea, 0xda, 0x1b}}},
365{{{0xb6, 0xea, 0x0e, 0x40, 0x93, 0x20, 0x79, 0x35, 0x6a, 0x61, 0x84, 0x5a, 0x07, 0x6d, 0xf9, 0x77, 0x6f, 0xed, 0x69, 0x1c, 0x0d, 0x25, 0x76, 0xcc, 0xf0, 0xdb, 0xbb, 0xc5, 0xad, 0xe2, 0x26, 0x57}} ,
366 {{0xcf, 0xe8, 0x0e, 0x6b, 0x96, 0x7d, 0xed, 0x27, 0xd1, 0x3c, 0xa9, 0xd9, 0x50, 0xa9, 0x98, 0x84, 0x5e, 0x86, 0xef, 0xd6, 0xf0, 0xf8, 0x0e, 0x89, 0x05, 0x2f, 0xd9, 0x5f, 0x15, 0x5f, 0x73, 0x79}}},
367{{{0xc8, 0x5c, 0x16, 0xfe, 0xed, 0x9f, 0x26, 0x56, 0xf6, 0x4b, 0x9f, 0xa7, 0x0a, 0x85, 0xfe, 0xa5, 0x8c, 0x87, 0xdd, 0x98, 0xce, 0x4e, 0xc3, 0x58, 0x55, 0xb2, 0x7b, 0x3d, 0xd8, 0x6b, 0xb5, 0x4c}} ,
368 {{0x65, 0x38, 0xa0, 0x15, 0xfa, 0xa7, 0xb4, 0x8f, 0xeb, 0xc4, 0x86, 0x9b, 0x30, 0xa5, 0x5e, 0x4d, 0xea, 0x8a, 0x9a, 0x9f, 0x1a, 0xd8, 0x5b, 0x53, 0x14, 0x19, 0x25, 0x63, 0xb4, 0x6f, 0x1f, 0x5d}}},
369{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
370 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
371{{{0xac, 0x8f, 0xbc, 0x1e, 0x7d, 0x8b, 0x5a, 0x0b, 0x8d, 0xaf, 0x76, 0x2e, 0x71, 0xe3, 0x3b, 0x6f, 0x53, 0x2f, 0x3e, 0x90, 0x95, 0xd4, 0x35, 0x14, 0x4f, 0x8c, 0x3c, 0xce, 0x57, 0x1c, 0x76, 0x49}} ,
372 {{0xa8, 0x50, 0xe1, 0x61, 0x6b, 0x57, 0x35, 0xeb, 0x44, 0x0b, 0x0c, 0x6e, 0xf9, 0x25, 0x80, 0x74, 0xf2, 0x8f, 0x6f, 0x7a, 0x3e, 0x7f, 0x2d, 0xf3, 0x4e, 0x09, 0x65, 0x10, 0x5e, 0x03, 0x25, 0x32}}},
373{{{0xa9, 0x60, 0xdc, 0x0f, 0x64, 0xe5, 0x1d, 0xe2, 0x8d, 0x4f, 0x79, 0x2f, 0x0e, 0x24, 0x02, 0x00, 0x05, 0x77, 0x43, 0x25, 0x3d, 0x6a, 0xc7, 0xb7, 0xbf, 0x04, 0x08, 0x65, 0xf4, 0x39, 0x4b, 0x65}} ,
374 {{0x96, 0x19, 0x12, 0x6b, 0x6a, 0xb7, 0xe3, 0xdc, 0x45, 0x9b, 0xdb, 0xb4, 0xa8, 0xae, 0xdc, 0xa8, 0x14, 0x44, 0x65, 0x62, 0xce, 0x34, 0x9a, 0x84, 0x18, 0x12, 0x01, 0xf1, 0xe2, 0x7b, 0xce, 0x50}}},
375{{{0x41, 0x21, 0x30, 0x53, 0x1b, 0x47, 0x01, 0xb7, 0x18, 0xd8, 0x82, 0x57, 0xbd, 0xa3, 0x60, 0xf0, 0x32, 0xf6, 0x5b, 0xf0, 0x30, 0x88, 0x91, 0x59, 0xfd, 0x90, 0xa2, 0xb9, 0x55, 0x93, 0x21, 0x34}} ,
376 {{0x97, 0x67, 0x9e, 0xeb, 0x6a, 0xf9, 0x6e, 0xd6, 0x73, 0xe8, 0x6b, 0x29, 0xec, 0x63, 0x82, 0x00, 0xa8, 0x99, 0x1c, 0x1d, 0x30, 0xc8, 0x90, 0x52, 0x90, 0xb6, 0x6a, 0x80, 0x4e, 0xff, 0x4b, 0x51}}},
377{{{0x0f, 0x7d, 0x63, 0x8c, 0x6e, 0x5c, 0xde, 0x30, 0xdf, 0x65, 0xfa, 0x2e, 0xb0, 0xa3, 0x25, 0x05, 0x54, 0xbd, 0x25, 0xba, 0x06, 0xae, 0xdf, 0x8b, 0xd9, 0x1b, 0xea, 0x38, 0xb3, 0x05, 0x16, 0x09}} ,
378 {{0xc7, 0x8c, 0xbf, 0x64, 0x28, 0xad, 0xf8, 0xa5, 0x5a, 0x6f, 0xc9, 0xba, 0xd5, 0x7f, 0xd5, 0xd6, 0xbd, 0x66, 0x2f, 0x3d, 0xaa, 0x54, 0xf6, 0xba, 0x32, 0x22, 0x9a, 0x1e, 0x52, 0x05, 0xf4, 0x1d}}},
379{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
380 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
381{{{0xaa, 0x1f, 0xbb, 0xeb, 0xfe, 0xe4, 0x87, 0xfc, 0xb1, 0x2c, 0xb7, 0x88, 0xf4, 0xc6, 0xb9, 0xf5, 0x24, 0x46, 0xf2, 0xa5, 0x9f, 0x8f, 0x8a, 0x93, 0x70, 0x69, 0xd4, 0x56, 0xec, 0xfd, 0x06, 0x46}} ,
382 {{0x4e, 0x66, 0xcf, 0x4e, 0x34, 0xce, 0x0c, 0xd9, 0xa6, 0x50, 0xd6, 0x5e, 0x95, 0xaf, 0xe9, 0x58, 0xfa, 0xee, 0x9b, 0xb8, 0xa5, 0x0f, 0x35, 0xe0, 0x43, 0x82, 0x6d, 0x65, 0xe6, 0xd9, 0x00, 0x0f}}},
383{{{0x7b, 0x75, 0x3a, 0xfc, 0x64, 0xd3, 0x29, 0x7e, 0xdd, 0x49, 0x9a, 0x59, 0x53, 0xbf, 0xb4, 0xa7, 0x52, 0xb3, 0x05, 0xab, 0xc3, 0xaf, 0x16, 0x1a, 0x85, 0x42, 0x32, 0xa2, 0x86, 0xfa, 0x39, 0x43}} ,
384 {{0x0e, 0x4b, 0xa3, 0x63, 0x8a, 0xfe, 0xa5, 0x58, 0xf1, 0x13, 0xbd, 0x9d, 0xaa, 0x7f, 0x76, 0x40, 0x70, 0x81, 0x10, 0x75, 0x99, 0xbb, 0xbe, 0x0b, 0x16, 0xe9, 0xba, 0x62, 0x34, 0xcc, 0x07, 0x6d}}},
385{{{0xc3, 0xf1, 0xc6, 0x93, 0x65, 0xee, 0x0b, 0xbc, 0xea, 0x14, 0xf0, 0xc1, 0xf8, 0x84, 0x89, 0xc2, 0xc9, 0xd7, 0xea, 0x34, 0xca, 0xa7, 0xc4, 0x99, 0xd5, 0x50, 0x69, 0xcb, 0xd6, 0x21, 0x63, 0x7c}} ,
386 {{0x99, 0xeb, 0x7c, 0x31, 0x73, 0x64, 0x67, 0x7f, 0x0c, 0x66, 0xaa, 0x8c, 0x69, 0x91, 0xe2, 0x26, 0xd3, 0x23, 0xe2, 0x76, 0x5d, 0x32, 0x52, 0xdf, 0x5d, 0xc5, 0x8f, 0xb7, 0x7c, 0x84, 0xb3, 0x70}}},
387{{{0xeb, 0x01, 0xc7, 0x36, 0x97, 0x4e, 0xb6, 0xab, 0x5f, 0x0d, 0x2c, 0xba, 0x67, 0x64, 0x55, 0xde, 0xbc, 0xff, 0xa6, 0xec, 0x04, 0xd3, 0x8d, 0x39, 0x56, 0x5e, 0xee, 0xf8, 0xe4, 0x2e, 0x33, 0x62}} ,
388 {{0x65, 0xef, 0xb8, 0x9f, 0xc8, 0x4b, 0xa7, 0xfd, 0x21, 0x49, 0x9b, 0x92, 0x35, 0x82, 0xd6, 0x0a, 0x9b, 0xf2, 0x79, 0xf1, 0x47, 0x2f, 0x6a, 0x7e, 0x9f, 0xcf, 0x18, 0x02, 0x3c, 0xfb, 0x1b, 0x3e}}},
389{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
390 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
391{{{0x2f, 0x8b, 0xc8, 0x40, 0x51, 0xd1, 0xac, 0x1a, 0x0b, 0xe4, 0xa9, 0xa2, 0x42, 0x21, 0x19, 0x2f, 0x7b, 0x97, 0xbf, 0xf7, 0x57, 0x6d, 0x3f, 0x3d, 0x4f, 0x0f, 0xe2, 0xb2, 0x81, 0x00, 0x9e, 0x7b}} ,
392 {{0x8c, 0x85, 0x2b, 0xc4, 0xfc, 0xf1, 0xab, 0xe8, 0x79, 0x22, 0xc4, 0x84, 0x17, 0x3a, 0xfa, 0x86, 0xa6, 0x7d, 0xf9, 0xf3, 0x6f, 0x03, 0x57, 0x20, 0x4d, 0x79, 0xf9, 0x6e, 0x71, 0x54, 0x38, 0x09}}},
393{{{0x40, 0x29, 0x74, 0xa8, 0x2f, 0x5e, 0xf9, 0x79, 0xa4, 0xf3, 0x3e, 0xb9, 0xfd, 0x33, 0x31, 0xac, 0x9a, 0x69, 0x88, 0x1e, 0x77, 0x21, 0x2d, 0xf3, 0x91, 0x52, 0x26, 0x15, 0xb2, 0xa6, 0xcf, 0x7e}} ,
394 {{0xc6, 0x20, 0x47, 0x6c, 0xa4, 0x7d, 0xcb, 0x63, 0xea, 0x5b, 0x03, 0xdf, 0x3e, 0x88, 0x81, 0x6d, 0xce, 0x07, 0x42, 0x18, 0x60, 0x7e, 0x7b, 0x55, 0xfe, 0x6a, 0xf3, 0xda, 0x5c, 0x8b, 0x95, 0x10}}},
395{{{0x62, 0xe4, 0x0d, 0x03, 0xb4, 0xd7, 0xcd, 0xfa, 0xbd, 0x46, 0xdf, 0x93, 0x71, 0x10, 0x2c, 0xa8, 0x3b, 0xb6, 0x09, 0x05, 0x70, 0x84, 0x43, 0x29, 0xa8, 0x59, 0xf5, 0x8e, 0x10, 0xe4, 0xd7, 0x20}} ,
396 {{0x57, 0x82, 0x1c, 0xab, 0xbf, 0x62, 0x70, 0xe8, 0xc4, 0xcf, 0xf0, 0x28, 0x6e, 0x16, 0x3c, 0x08, 0x78, 0x89, 0x85, 0x46, 0x0f, 0xf6, 0x7f, 0xcf, 0xcb, 0x7e, 0xb8, 0x25, 0xe9, 0x5a, 0xfa, 0x03}}},
397{{{0xfb, 0x95, 0x92, 0x63, 0x50, 0xfc, 0x62, 0xf0, 0xa4, 0x5e, 0x8c, 0x18, 0xc2, 0x17, 0x24, 0xb7, 0x78, 0xc2, 0xa9, 0xe7, 0x6a, 0x32, 0xd6, 0x29, 0x85, 0xaf, 0xcb, 0x8d, 0x91, 0x13, 0xda, 0x6b}} ,
398 {{0x36, 0x0a, 0xc2, 0xb6, 0x4b, 0xa5, 0x5d, 0x07, 0x17, 0x41, 0x31, 0x5f, 0x62, 0x46, 0xf8, 0x92, 0xf9, 0x66, 0x48, 0x73, 0xa6, 0x97, 0x0d, 0x7d, 0x88, 0xee, 0x62, 0xb1, 0x03, 0xa8, 0x3f, 0x2c}}},
399{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
400 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
401{{{0x4a, 0xb1, 0x70, 0x8a, 0xa9, 0xe8, 0x63, 0x79, 0x00, 0xe2, 0x25, 0x16, 0xca, 0x4b, 0x0f, 0xa4, 0x66, 0xad, 0x19, 0x9f, 0x88, 0x67, 0x0c, 0x8b, 0xc2, 0x4a, 0x5b, 0x2b, 0x6d, 0x95, 0xaf, 0x19}} ,
402 {{0x8b, 0x9d, 0xb6, 0xcc, 0x60, 0xb4, 0x72, 0x4f, 0x17, 0x69, 0x5a, 0x4a, 0x68, 0x34, 0xab, 0xa1, 0x45, 0x32, 0x3c, 0x83, 0x87, 0x72, 0x30, 0x54, 0x77, 0x68, 0xae, 0xfb, 0xb5, 0x8b, 0x22, 0x5e}}},
403{{{0xf1, 0xb9, 0x87, 0x35, 0xc5, 0xbb, 0xb9, 0xcf, 0xf5, 0xd6, 0xcd, 0xd5, 0x0c, 0x7c, 0x0e, 0xe6, 0x90, 0x34, 0xfb, 0x51, 0x42, 0x1e, 0x6d, 0xac, 0x9a, 0x46, 0xc4, 0x97, 0x29, 0x32, 0xbf, 0x45}} ,
404 {{0x66, 0x9e, 0xc6, 0x24, 0xc0, 0xed, 0xa5, 0x5d, 0x88, 0xd4, 0xf0, 0x73, 0x97, 0x7b, 0xea, 0x7f, 0x42, 0xff, 0x21, 0xa0, 0x9b, 0x2f, 0x9a, 0xfd, 0x53, 0x57, 0x07, 0x84, 0x48, 0x88, 0x9d, 0x52}}},
405{{{0xc6, 0x96, 0x48, 0x34, 0x2a, 0x06, 0xaf, 0x94, 0x3d, 0xf4, 0x1a, 0xcf, 0xf2, 0xc0, 0x21, 0xc2, 0x42, 0x5e, 0xc8, 0x2f, 0x35, 0xa2, 0x3e, 0x29, 0xfa, 0x0c, 0x84, 0xe5, 0x89, 0x72, 0x7c, 0x06}} ,
406 {{0x32, 0x65, 0x03, 0xe5, 0x89, 0xa6, 0x6e, 0xb3, 0x5b, 0x8e, 0xca, 0xeb, 0xfe, 0x22, 0x56, 0x8b, 0x5d, 0x14, 0x4b, 0x4d, 0xf9, 0xbe, 0xb5, 0xf5, 0xe6, 0x5c, 0x7b, 0x8b, 0xf4, 0x13, 0x11, 0x34}}},
407{{{0x07, 0xc6, 0x22, 0x15, 0xe2, 0x9c, 0x60, 0xa2, 0x19, 0xd9, 0x27, 0xae, 0x37, 0x4e, 0xa6, 0xc9, 0x80, 0xa6, 0x91, 0x8f, 0x12, 0x49, 0xe5, 0x00, 0x18, 0x47, 0xd1, 0xd7, 0x28, 0x22, 0x63, 0x39}} ,
408 {{0xe8, 0xe2, 0x00, 0x7e, 0xf2, 0x9e, 0x1e, 0x99, 0x39, 0x95, 0x04, 0xbd, 0x1e, 0x67, 0x7b, 0xb2, 0x26, 0xac, 0xe6, 0xaa, 0xe2, 0x46, 0xd5, 0xe4, 0xe8, 0x86, 0xbd, 0xab, 0x7c, 0x55, 0x59, 0x6f}}},
409{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
410 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
411{{{0x24, 0x64, 0x6e, 0x9b, 0x35, 0x71, 0x78, 0xce, 0x33, 0x03, 0x21, 0x33, 0x36, 0xf1, 0x73, 0x9b, 0xb9, 0x15, 0x8b, 0x2c, 0x69, 0xcf, 0x4d, 0xed, 0x4f, 0x4d, 0x57, 0x14, 0x13, 0x82, 0xa4, 0x4d}} ,
412 {{0x65, 0x6e, 0x0a, 0xa4, 0x59, 0x07, 0x17, 0xf2, 0x6b, 0x4a, 0x1f, 0x6e, 0xf6, 0xb5, 0xbc, 0x62, 0xe4, 0xb6, 0xda, 0xa2, 0x93, 0xbc, 0x29, 0x05, 0xd2, 0xd2, 0x73, 0x46, 0x03, 0x16, 0x40, 0x31}}},
413{{{0x4c, 0x73, 0x6d, 0x15, 0xbd, 0xa1, 0x4d, 0x5c, 0x13, 0x0b, 0x24, 0x06, 0x98, 0x78, 0x1c, 0x5b, 0xeb, 0x1f, 0x18, 0x54, 0x43, 0xd9, 0x55, 0x66, 0xda, 0x29, 0x21, 0xe8, 0xb8, 0x3c, 0x42, 0x22}} ,
414 {{0xb4, 0xcd, 0x08, 0x6f, 0x15, 0x23, 0x1a, 0x0b, 0x22, 0xed, 0xd1, 0xf1, 0xa7, 0xc7, 0x73, 0x45, 0xf3, 0x9e, 0xce, 0x76, 0xb7, 0xf6, 0x39, 0xb6, 0x8e, 0x79, 0xbe, 0xe9, 0x9b, 0xcf, 0x7d, 0x62}}},
415{{{0x92, 0x5b, 0xfc, 0x72, 0xfd, 0xba, 0xf1, 0xfd, 0xa6, 0x7c, 0x95, 0xe3, 0x61, 0x3f, 0xe9, 0x03, 0xd4, 0x2b, 0xd4, 0x20, 0xd9, 0xdb, 0x4d, 0x32, 0x3e, 0xf5, 0x11, 0x64, 0xe3, 0xb4, 0xbe, 0x32}} ,
416 {{0x86, 0x17, 0x90, 0xe7, 0xc9, 0x1f, 0x10, 0xa5, 0x6a, 0x2d, 0x39, 0xd0, 0x3b, 0xc4, 0xa6, 0xe9, 0x59, 0x13, 0xda, 0x1a, 0xe6, 0xa0, 0xb9, 0x3c, 0x50, 0xb8, 0x40, 0x7c, 0x15, 0x36, 0x5a, 0x42}}},
417{{{0xb4, 0x0b, 0x32, 0xab, 0xdc, 0x04, 0x51, 0x55, 0x21, 0x1e, 0x0b, 0x75, 0x99, 0x89, 0x73, 0x35, 0x3a, 0x91, 0x2b, 0xfe, 0xe7, 0x49, 0xea, 0x76, 0xc1, 0xf9, 0x46, 0xb9, 0x53, 0x02, 0x23, 0x04}} ,
418 {{0xfc, 0x5a, 0x1e, 0x1d, 0x74, 0x58, 0x95, 0xa6, 0x8f, 0x7b, 0x97, 0x3e, 0x17, 0x3b, 0x79, 0x2d, 0xa6, 0x57, 0xef, 0x45, 0x02, 0x0b, 0x4d, 0x6e, 0x9e, 0x93, 0x8d, 0x2f, 0xd9, 0x9d, 0xdb, 0x04}}},
419{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
420 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
421{{{0xc0, 0xd7, 0x56, 0x97, 0x58, 0x91, 0xde, 0x09, 0x4f, 0x9f, 0xbe, 0x63, 0xb0, 0x83, 0x86, 0x43, 0x5d, 0xbc, 0xe0, 0xf3, 0xc0, 0x75, 0xbf, 0x8b, 0x8e, 0xaa, 0xf7, 0x8b, 0x64, 0x6e, 0xb0, 0x63}} ,
422 {{0x16, 0xae, 0x8b, 0xe0, 0x9b, 0x24, 0x68, 0x5c, 0x44, 0xc2, 0xd0, 0x08, 0xb7, 0x7b, 0x62, 0xfd, 0x7f, 0xd8, 0xd4, 0xb7, 0x50, 0xfd, 0x2c, 0x1b, 0xbf, 0x41, 0x95, 0xd9, 0x8e, 0xd8, 0x17, 0x1b}}},
423{{{0x86, 0x55, 0x37, 0x8e, 0xc3, 0x38, 0x48, 0x14, 0xb5, 0x97, 0xd2, 0xa7, 0x54, 0x45, 0xf1, 0x35, 0x44, 0x38, 0x9e, 0xf1, 0x1b, 0xb6, 0x34, 0x00, 0x3c, 0x96, 0xee, 0x29, 0x00, 0xea, 0x2c, 0x0b}} ,
424 {{0xea, 0xda, 0x99, 0x9e, 0x19, 0x83, 0x66, 0x6d, 0xe9, 0x76, 0x87, 0x50, 0xd1, 0xfd, 0x3c, 0x60, 0x87, 0xc6, 0x41, 0xd9, 0x8e, 0xdb, 0x5e, 0xde, 0xaa, 0x9a, 0xd3, 0x28, 0xda, 0x95, 0xea, 0x47}}},
425{{{0xd0, 0x80, 0xba, 0x19, 0xae, 0x1d, 0xa9, 0x79, 0xf6, 0x3f, 0xac, 0x5d, 0x6f, 0x96, 0x1f, 0x2a, 0xce, 0x29, 0xb2, 0xff, 0x37, 0xf1, 0x94, 0x8f, 0x0c, 0xb5, 0x28, 0xba, 0x9a, 0x21, 0xf6, 0x66}} ,
426 {{0x02, 0xfb, 0x54, 0xb8, 0x05, 0xf3, 0x81, 0x52, 0x69, 0x34, 0x46, 0x9d, 0x86, 0x76, 0x8f, 0xd7, 0xf8, 0x6a, 0x66, 0xff, 0xe6, 0xa7, 0x90, 0xf7, 0x5e, 0xcd, 0x6a, 0x9b, 0x55, 0xfc, 0x9d, 0x48}}},
427{{{0xbd, 0xaa, 0x13, 0xe6, 0xcd, 0x45, 0x4a, 0xa4, 0x59, 0x0a, 0x64, 0xb1, 0x98, 0xd6, 0x34, 0x13, 0x04, 0xe6, 0x97, 0x94, 0x06, 0xcb, 0xd4, 0x4e, 0xbb, 0x96, 0xcd, 0xd1, 0x57, 0xd1, 0xe3, 0x06}} ,
428 {{0x7a, 0x6c, 0x45, 0x27, 0xc4, 0x93, 0x7f, 0x7d, 0x7c, 0x62, 0x50, 0x38, 0x3a, 0x6b, 0xb5, 0x88, 0xc6, 0xd9, 0xf1, 0x78, 0x19, 0xb9, 0x39, 0x93, 0x3d, 0xc9, 0xe0, 0x9c, 0x3c, 0xce, 0xf5, 0x72}}},
429{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
430 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
431{{{0x24, 0xea, 0x23, 0x7d, 0x56, 0x2c, 0xe2, 0x59, 0x0e, 0x85, 0x60, 0x04, 0x88, 0x5a, 0x74, 0x1e, 0x4b, 0xef, 0x13, 0xda, 0x4c, 0xff, 0x83, 0x45, 0x85, 0x3f, 0x08, 0x95, 0x2c, 0x20, 0x13, 0x1f}} ,
432 {{0x48, 0x5f, 0x27, 0x90, 0x5c, 0x02, 0x42, 0xad, 0x78, 0x47, 0x5c, 0xb5, 0x7e, 0x08, 0x85, 0x00, 0xfa, 0x7f, 0xfd, 0xfd, 0xe7, 0x09, 0x11, 0xf2, 0x7e, 0x1b, 0x38, 0x6c, 0x35, 0x6d, 0x33, 0x66}}},
433{{{0x93, 0x03, 0x36, 0x81, 0xac, 0xe4, 0x20, 0x09, 0x35, 0x4c, 0x45, 0xb2, 0x1e, 0x4c, 0x14, 0x21, 0xe6, 0xe9, 0x8a, 0x7b, 0x8d, 0xfe, 0x1e, 0xc6, 0x3e, 0xc1, 0x35, 0xfa, 0xe7, 0x70, 0x4e, 0x1d}} ,
434 {{0x61, 0x2e, 0xc2, 0xdd, 0x95, 0x57, 0xd1, 0xab, 0x80, 0xe8, 0x63, 0x17, 0xb5, 0x48, 0xe4, 0x8a, 0x11, 0x9e, 0x72, 0xbe, 0x85, 0x8d, 0x51, 0x0a, 0xf2, 0x9f, 0xe0, 0x1c, 0xa9, 0x07, 0x28, 0x7b}}},
435{{{0xbb, 0x71, 0x14, 0x5e, 0x26, 0x8c, 0x3d, 0xc8, 0xe9, 0x7c, 0xd3, 0xd6, 0xd1, 0x2f, 0x07, 0x6d, 0xe6, 0xdf, 0xfb, 0x79, 0xd6, 0x99, 0x59, 0x96, 0x48, 0x40, 0x0f, 0x3a, 0x7b, 0xb2, 0xa0, 0x72}} ,
436 {{0x4e, 0x3b, 0x69, 0xc8, 0x43, 0x75, 0x51, 0x6c, 0x79, 0x56, 0xe4, 0xcb, 0xf7, 0xa6, 0x51, 0xc2, 0x2c, 0x42, 0x0b, 0xd4, 0x82, 0x20, 0x1c, 0x01, 0x08, 0x66, 0xd7, 0xbf, 0x04, 0x56, 0xfc, 0x02}}},
437{{{0x24, 0xe8, 0xb7, 0x60, 0xae, 0x47, 0x80, 0xfc, 0xe5, 0x23, 0xe7, 0xc2, 0xc9, 0x85, 0xe6, 0x98, 0xa0, 0x29, 0x4e, 0xe1, 0x84, 0x39, 0x2d, 0x95, 0x2c, 0xf3, 0x45, 0x3c, 0xff, 0xaf, 0x27, 0x4c}} ,
438 {{0x6b, 0xa6, 0xf5, 0x4b, 0x11, 0xbd, 0xba, 0x5b, 0x9e, 0xc4, 0xa4, 0x51, 0x1e, 0xbe, 0xd0, 0x90, 0x3a, 0x9c, 0xc2, 0x26, 0xb6, 0x1e, 0xf1, 0x95, 0x7d, 0xc8, 0x6d, 0x52, 0xe6, 0x99, 0x2c, 0x5f}}},
439{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
440 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
441{{{0x85, 0xe0, 0x24, 0x32, 0xb4, 0xd1, 0xef, 0xfc, 0x69, 0xa2, 0xbf, 0x8f, 0x72, 0x2c, 0x95, 0xf6, 0xe4, 0x6e, 0x7d, 0x90, 0xf7, 0x57, 0x81, 0xa0, 0xf7, 0xda, 0xef, 0x33, 0x07, 0xe3, 0x6b, 0x78}} ,
442 {{0x36, 0x27, 0x3e, 0xc6, 0x12, 0x07, 0xab, 0x4e, 0xbe, 0x69, 0x9d, 0xb3, 0xbe, 0x08, 0x7c, 0x2a, 0x47, 0x08, 0xfd, 0xd4, 0xcd, 0x0e, 0x27, 0x34, 0x5b, 0x98, 0x34, 0x2f, 0x77, 0x5f, 0x3a, 0x65}}},
443{{{0x13, 0xaa, 0x2e, 0x4c, 0xf0, 0x22, 0xb8, 0x6c, 0xb3, 0x19, 0x4d, 0xeb, 0x6b, 0xd0, 0xa4, 0xc6, 0x9c, 0xdd, 0xc8, 0x5b, 0x81, 0x57, 0x89, 0xdf, 0x33, 0xa9, 0x68, 0x49, 0x80, 0xe4, 0xfe, 0x21}} ,
444 {{0x00, 0x17, 0x90, 0x30, 0xe9, 0xd3, 0x60, 0x30, 0x31, 0xc2, 0x72, 0x89, 0x7a, 0x36, 0xa5, 0xbd, 0x39, 0x83, 0x85, 0x50, 0xa1, 0x5d, 0x6c, 0x41, 0x1d, 0xb5, 0x2c, 0x07, 0x40, 0x77, 0x0b, 0x50}}},
445{{{0x64, 0x34, 0xec, 0xc0, 0x9e, 0x44, 0x41, 0xaf, 0xa0, 0x36, 0x05, 0x6d, 0xea, 0x30, 0x25, 0x46, 0x35, 0x24, 0x9d, 0x86, 0xbd, 0x95, 0xf1, 0x6a, 0x46, 0xd7, 0x94, 0x54, 0xf9, 0x3b, 0xbd, 0x5d}} ,
446 {{0x77, 0x5b, 0xe2, 0x37, 0xc7, 0xe1, 0x7c, 0x13, 0x8c, 0x9f, 0x7b, 0x7b, 0x2a, 0xce, 0x42, 0xa3, 0xb9, 0x2a, 0x99, 0xa8, 0xc0, 0xd8, 0x3c, 0x86, 0xb0, 0xfb, 0xe9, 0x76, 0x77, 0xf7, 0xf5, 0x56}}},
447{{{0xdf, 0xb3, 0x46, 0x11, 0x6e, 0x13, 0xb7, 0x28, 0x4e, 0x56, 0xdd, 0xf1, 0xac, 0xad, 0x58, 0xc3, 0xf8, 0x88, 0x94, 0x5e, 0x06, 0x98, 0xa1, 0xe4, 0x6a, 0xfb, 0x0a, 0x49, 0x5d, 0x8a, 0xfe, 0x77}} ,
448 {{0x46, 0x02, 0xf5, 0xa5, 0xaf, 0xc5, 0x75, 0x6d, 0xba, 0x45, 0x35, 0x0a, 0xfe, 0xc9, 0xac, 0x22, 0x91, 0x8d, 0x21, 0x95, 0x33, 0x03, 0xc0, 0x8a, 0x16, 0xf3, 0x39, 0xe0, 0x01, 0x0f, 0x53, 0x3c}}},
449{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
450 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
451{{{0x34, 0x75, 0x37, 0x1f, 0x34, 0x4e, 0xa9, 0x1d, 0x68, 0x67, 0xf8, 0x49, 0x98, 0x96, 0xfc, 0x4c, 0x65, 0x97, 0xf7, 0x02, 0x4a, 0x52, 0x6c, 0x01, 0xbd, 0x48, 0xbb, 0x1b, 0xed, 0xa4, 0xe2, 0x53}} ,
452 {{0x59, 0xd5, 0x9b, 0x5a, 0xa2, 0x90, 0xd3, 0xb8, 0x37, 0x4c, 0x55, 0x82, 0x28, 0x08, 0x0f, 0x7f, 0xaa, 0x81, 0x65, 0xe0, 0x0c, 0x52, 0xc9, 0xa3, 0x32, 0x27, 0x64, 0xda, 0xfd, 0x34, 0x23, 0x5a}}},
453{{{0xb5, 0xb0, 0x0c, 0x4d, 0xb3, 0x7b, 0x23, 0xc8, 0x1f, 0x8a, 0x39, 0x66, 0xe6, 0xba, 0x4c, 0x10, 0x37, 0xca, 0x9c, 0x7c, 0x05, 0x9e, 0xff, 0xc0, 0xf8, 0x8e, 0xb1, 0x8f, 0x6f, 0x67, 0x18, 0x26}} ,
454 {{0x4b, 0x41, 0x13, 0x54, 0x23, 0x1a, 0xa4, 0x4e, 0xa9, 0x8b, 0x1e, 0x4b, 0xfc, 0x15, 0x24, 0xbb, 0x7e, 0xcb, 0xb6, 0x1e, 0x1b, 0xf5, 0xf2, 0xc8, 0x56, 0xec, 0x32, 0xa2, 0x60, 0x5b, 0xa0, 0x2a}}},
455{{{0xa4, 0x29, 0x47, 0x86, 0x2e, 0x92, 0x4f, 0x11, 0x4f, 0xf3, 0xb2, 0x5c, 0xd5, 0x3e, 0xa6, 0xb9, 0xc8, 0xe2, 0x33, 0x11, 0x1f, 0x01, 0x8f, 0xb0, 0x9b, 0xc7, 0xa5, 0xff, 0x83, 0x0f, 0x1e, 0x28}} ,
456 {{0x1d, 0x29, 0x7a, 0xa1, 0xec, 0x8e, 0xb5, 0xad, 0xea, 0x02, 0x68, 0x60, 0x74, 0x29, 0x1c, 0xa5, 0xcf, 0xc8, 0x3b, 0x7d, 0x8b, 0x2b, 0x7c, 0xad, 0xa4, 0x40, 0x17, 0x51, 0x59, 0x7c, 0x2e, 0x5d}}},
457{{{0x0a, 0x6c, 0x4f, 0xbc, 0x3e, 0x32, 0xe7, 0x4a, 0x1a, 0x13, 0xc1, 0x49, 0x38, 0xbf, 0xf7, 0xc2, 0xd3, 0x8f, 0x6b, 0xad, 0x52, 0xf7, 0xcf, 0xbc, 0x27, 0xcb, 0x40, 0x67, 0x76, 0xcd, 0x6d, 0x56}} ,
458 {{0xe5, 0xb0, 0x27, 0xad, 0xbe, 0x9b, 0xf2, 0xb5, 0x63, 0xde, 0x3a, 0x23, 0x95, 0xb7, 0x0a, 0x7e, 0xf3, 0x9e, 0x45, 0x6f, 0x19, 0x39, 0x75, 0x8f, 0x39, 0x3d, 0x0f, 0xc0, 0x9f, 0xf1, 0xe9, 0x51}}},
459{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
460 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
461{{{0x88, 0xaa, 0x14, 0x24, 0x86, 0x94, 0x11, 0x12, 0x3e, 0x1a, 0xb5, 0xcc, 0xbb, 0xe0, 0x9c, 0xd5, 0x9c, 0x6d, 0xba, 0x58, 0x72, 0x8d, 0xfb, 0x22, 0x7b, 0x9f, 0x7c, 0x94, 0x30, 0xb3, 0x51, 0x21}} ,
462 {{0xf6, 0x74, 0x3d, 0xf2, 0xaf, 0xd0, 0x1e, 0x03, 0x7c, 0x23, 0x6b, 0xc9, 0xfc, 0x25, 0x70, 0x90, 0xdc, 0x9a, 0xa4, 0xfb, 0x49, 0xfc, 0x3d, 0x0a, 0x35, 0x38, 0x6f, 0xe4, 0x7e, 0x50, 0x01, 0x2a}}},
463{{{0xd6, 0xe3, 0x96, 0x61, 0x3a, 0xfd, 0xef, 0x9b, 0x1f, 0x90, 0xa4, 0x24, 0x14, 0x5b, 0xc8, 0xde, 0x50, 0xb1, 0x1d, 0xaf, 0xe8, 0x55, 0x8a, 0x87, 0x0d, 0xfe, 0xaa, 0x3b, 0x82, 0x2c, 0x8d, 0x7b}} ,
464 {{0x85, 0x0c, 0xaf, 0xf8, 0x83, 0x44, 0x49, 0xd9, 0x45, 0xcf, 0xf7, 0x48, 0xd9, 0x53, 0xb4, 0xf1, 0x65, 0xa0, 0xe1, 0xc3, 0xb3, 0x15, 0xed, 0x89, 0x9b, 0x4f, 0x62, 0xb3, 0x57, 0xa5, 0x45, 0x1c}}},
465{{{0x8f, 0x12, 0xea, 0xaf, 0xd1, 0x1f, 0x79, 0x10, 0x0b, 0xf6, 0xa3, 0x7b, 0xea, 0xac, 0x8b, 0x57, 0x32, 0x62, 0xe7, 0x06, 0x12, 0x51, 0xa0, 0x3b, 0x43, 0x5e, 0xa4, 0x20, 0x78, 0x31, 0xce, 0x0d}} ,
466 {{0x84, 0x7c, 0xc2, 0xa6, 0x91, 0x23, 0xce, 0xbd, 0xdc, 0xf9, 0xce, 0xd5, 0x75, 0x30, 0x22, 0xe6, 0xf9, 0x43, 0x62, 0x0d, 0xf7, 0x75, 0x9d, 0x7f, 0x8c, 0xff, 0x7d, 0xe4, 0x72, 0xac, 0x9f, 0x1c}}},
467{{{0x88, 0xc1, 0x99, 0xd0, 0x3c, 0x1c, 0x5d, 0xb4, 0xef, 0x13, 0x0f, 0x90, 0xb9, 0x36, 0x2f, 0x95, 0x95, 0xc6, 0xdc, 0xde, 0x0a, 0x51, 0xe2, 0x8d, 0xf3, 0xbc, 0x51, 0xec, 0xdf, 0xb1, 0xa2, 0x5f}} ,
468 {{0x2e, 0x68, 0xa1, 0x23, 0x7d, 0x9b, 0x40, 0x69, 0x85, 0x7b, 0x42, 0xbf, 0x90, 0x4b, 0xd6, 0x40, 0x2f, 0xd7, 0x52, 0x52, 0xb2, 0x21, 0xde, 0x64, 0xbd, 0x88, 0xc3, 0x6d, 0xa5, 0xfa, 0x81, 0x3f}}},
469{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
470 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
471{{{0xfb, 0xfd, 0x47, 0x7b, 0x8a, 0x66, 0x9e, 0x79, 0x2e, 0x64, 0x82, 0xef, 0xf7, 0x21, 0xec, 0xf6, 0xd8, 0x86, 0x09, 0x31, 0x7c, 0xdd, 0x03, 0x6a, 0x58, 0xa0, 0x77, 0xb7, 0x9b, 0x8c, 0x87, 0x1f}} ,
472 {{0x55, 0x47, 0xe4, 0xa8, 0x3d, 0x55, 0x21, 0x34, 0xab, 0x1d, 0xae, 0xe0, 0xf4, 0xea, 0xdb, 0xc5, 0xb9, 0x58, 0xbf, 0xc4, 0x2a, 0x89, 0x31, 0x1a, 0xf4, 0x2d, 0xe1, 0xca, 0x37, 0x99, 0x47, 0x59}}},
473{{{0xc7, 0xca, 0x63, 0xc1, 0x49, 0xa9, 0x35, 0x45, 0x55, 0x7e, 0xda, 0x64, 0x32, 0x07, 0x50, 0xf7, 0x32, 0xac, 0xde, 0x75, 0x58, 0x9b, 0x11, 0xb2, 0x3a, 0x1f, 0xf5, 0xf7, 0x79, 0x04, 0xe6, 0x08}} ,
474 {{0x46, 0xfa, 0x22, 0x4b, 0xfa, 0xe1, 0xfe, 0x96, 0xfc, 0x67, 0xba, 0x67, 0x97, 0xc4, 0xe7, 0x1b, 0x86, 0x90, 0x5f, 0xee, 0xf4, 0x5b, 0x11, 0xb2, 0xcd, 0xad, 0xee, 0xc2, 0x48, 0x6c, 0x2b, 0x1b}}},
475{{{0xe3, 0x39, 0x62, 0xb4, 0x4f, 0x31, 0x04, 0xc9, 0xda, 0xd5, 0x73, 0x51, 0x57, 0xc5, 0xb8, 0xf3, 0xa3, 0x43, 0x70, 0xe4, 0x61, 0x81, 0x84, 0xe2, 0xbb, 0xbf, 0x4f, 0x9e, 0xa4, 0x5e, 0x74, 0x06}} ,
476 {{0x29, 0xac, 0xff, 0x27, 0xe0, 0x59, 0xbe, 0x39, 0x9c, 0x0d, 0x83, 0xd7, 0x10, 0x0b, 0x15, 0xb7, 0xe1, 0xc2, 0x2c, 0x30, 0x73, 0x80, 0x3a, 0x7d, 0x5d, 0xab, 0x58, 0x6b, 0xc1, 0xf0, 0xf4, 0x22}}},
477{{{0xfe, 0x7f, 0xfb, 0x35, 0x7d, 0xc6, 0x01, 0x23, 0x28, 0xc4, 0x02, 0xac, 0x1f, 0x42, 0xb4, 0x9d, 0xfc, 0x00, 0x94, 0xa5, 0xee, 0xca, 0xda, 0x97, 0x09, 0x41, 0x77, 0x87, 0x5d, 0x7b, 0x87, 0x78}} ,
478 {{0xf5, 0xfb, 0x90, 0x2d, 0x81, 0x19, 0x9e, 0x2f, 0x6d, 0x85, 0x88, 0x8c, 0x40, 0x5c, 0x77, 0x41, 0x4d, 0x01, 0x19, 0x76, 0x60, 0xe8, 0x4c, 0x48, 0xe4, 0x33, 0x83, 0x32, 0x6c, 0xb4, 0x41, 0x03}}},
479{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
480 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
481{{{0xff, 0x10, 0xc2, 0x09, 0x4f, 0x6e, 0xf4, 0xd2, 0xdf, 0x7e, 0xca, 0x7b, 0x1c, 0x1d, 0xba, 0xa3, 0xb6, 0xda, 0x67, 0x33, 0xd4, 0x87, 0x36, 0x4b, 0x11, 0x20, 0x05, 0xa6, 0x29, 0xc1, 0x87, 0x17}} ,
482 {{0xf6, 0x96, 0xca, 0x2f, 0xda, 0x38, 0xa7, 0x1b, 0xfc, 0xca, 0x7d, 0xfe, 0x08, 0x89, 0xe2, 0x47, 0x2b, 0x6a, 0x5d, 0x4b, 0xfa, 0xa1, 0xb4, 0xde, 0xb6, 0xc2, 0x31, 0x51, 0xf5, 0xe0, 0xa4, 0x0b}}},
483{{{0x5c, 0xe5, 0xc6, 0x04, 0x8e, 0x2b, 0x57, 0xbe, 0x38, 0x85, 0x23, 0xcb, 0xb7, 0xbe, 0x4f, 0xa9, 0xd3, 0x6e, 0x12, 0xaa, 0xd5, 0xb2, 0x2e, 0x93, 0x29, 0x9a, 0x4a, 0x88, 0x18, 0x43, 0xf5, 0x01}} ,
484 {{0x50, 0xfc, 0xdb, 0xa2, 0x59, 0x21, 0x8d, 0xbd, 0x7e, 0x33, 0xae, 0x2f, 0x87, 0x1a, 0xd0, 0x97, 0xc7, 0x0d, 0x4d, 0x63, 0x01, 0xef, 0x05, 0x84, 0xec, 0x40, 0xdd, 0xa8, 0x0a, 0x4f, 0x70, 0x0b}}},
485{{{0x41, 0x69, 0x01, 0x67, 0x5c, 0xd3, 0x8a, 0xc5, 0xcf, 0x3f, 0xd1, 0x57, 0xd1, 0x67, 0x3e, 0x01, 0x39, 0xb5, 0xcb, 0x81, 0x56, 0x96, 0x26, 0xb6, 0xc2, 0xe7, 0x5c, 0xfb, 0x63, 0x97, 0x58, 0x06}} ,
486 {{0x0c, 0x0e, 0xf3, 0xba, 0xf0, 0xe5, 0xba, 0xb2, 0x57, 0x77, 0xc6, 0x20, 0x9b, 0x89, 0x24, 0xbe, 0xf2, 0x9c, 0x8a, 0xba, 0x69, 0xc1, 0xf1, 0xb0, 0x4f, 0x2a, 0x05, 0x9a, 0xee, 0x10, 0x7e, 0x36}}},
487{{{0x3f, 0x26, 0xe9, 0x40, 0xe9, 0x03, 0xad, 0x06, 0x69, 0x91, 0xe0, 0xd1, 0x89, 0x60, 0x84, 0x79, 0xde, 0x27, 0x6d, 0xe6, 0x76, 0xbd, 0xea, 0xe6, 0xae, 0x48, 0xc3, 0x67, 0xc0, 0x57, 0xcd, 0x2f}} ,
488 {{0x7f, 0xc1, 0xdc, 0xb9, 0xc7, 0xbc, 0x86, 0x3d, 0x55, 0x4b, 0x28, 0x7a, 0xfb, 0x4d, 0xc7, 0xf8, 0xbc, 0x67, 0x2a, 0x60, 0x4d, 0x8f, 0x07, 0x0b, 0x1a, 0x17, 0xbf, 0xfa, 0xac, 0xa7, 0x3d, 0x1a}}},
489{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
490 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
491{{{0x91, 0x3f, 0xed, 0x5e, 0x18, 0x78, 0x3f, 0x23, 0x2c, 0x0d, 0x8c, 0x44, 0x00, 0xe8, 0xfb, 0xe9, 0x8e, 0xd6, 0xd1, 0x36, 0x58, 0x57, 0x9e, 0xae, 0x4b, 0x5c, 0x0b, 0x07, 0xbc, 0x6b, 0x55, 0x2b}} ,
492 {{0x6f, 0x4d, 0x17, 0xd7, 0xe1, 0x84, 0xd9, 0x78, 0xb1, 0x90, 0xfd, 0x2e, 0xb3, 0xb5, 0x19, 0x3f, 0x1b, 0xfa, 0xc0, 0x68, 0xb3, 0xdd, 0x00, 0x2e, 0x89, 0xbd, 0x7e, 0x80, 0x32, 0x13, 0xa0, 0x7b}}},
493{{{0x1a, 0x6f, 0x40, 0xaf, 0x44, 0x44, 0xb0, 0x43, 0x8f, 0x0d, 0xd0, 0x1e, 0xc4, 0x0b, 0x19, 0x5d, 0x8e, 0xfe, 0xc1, 0xf3, 0xc5, 0x5c, 0x91, 0xf8, 0x04, 0x4e, 0xbe, 0x90, 0xb4, 0x47, 0x5c, 0x3f}} ,
494 {{0xb0, 0x3b, 0x2c, 0xf3, 0xfe, 0x32, 0x71, 0x07, 0x3f, 0xaa, 0xba, 0x45, 0x60, 0xa8, 0x8d, 0xea, 0x54, 0xcb, 0x39, 0x10, 0xb4, 0xf2, 0x8b, 0xd2, 0x14, 0x82, 0x42, 0x07, 0x8e, 0xe9, 0x7c, 0x53}}},
495{{{0xb0, 0xae, 0xc1, 0x8d, 0xc9, 0x8f, 0xb9, 0x7a, 0x77, 0xef, 0xba, 0x79, 0xa0, 0x3c, 0xa8, 0xf5, 0x6a, 0xe2, 0x3f, 0x5d, 0x00, 0xe3, 0x4b, 0x45, 0x24, 0x7b, 0x43, 0x78, 0x55, 0x1d, 0x2b, 0x1e}} ,
496 {{0x01, 0xb8, 0xd6, 0x16, 0x67, 0xa0, 0x15, 0xb9, 0xe1, 0x58, 0xa4, 0xa7, 0x31, 0x37, 0x77, 0x2f, 0x8b, 0x12, 0x9f, 0xf4, 0x3f, 0xc7, 0x36, 0x66, 0xd2, 0xa8, 0x56, 0xf7, 0x7f, 0x74, 0xc6, 0x41}}},
497{{{0x5d, 0xf8, 0xb4, 0xa8, 0x30, 0xdd, 0xcc, 0x38, 0xa5, 0xd3, 0xca, 0xd8, 0xd1, 0xf8, 0xb2, 0x31, 0x91, 0xd4, 0x72, 0x05, 0x57, 0x4a, 0x3b, 0x82, 0x4a, 0xc6, 0x68, 0x20, 0xe2, 0x18, 0x41, 0x61}} ,
498 {{0x19, 0xd4, 0x8d, 0x47, 0x29, 0x12, 0x65, 0xb0, 0x11, 0x78, 0x47, 0xb5, 0xcb, 0xa3, 0xa5, 0xfa, 0x05, 0x85, 0x54, 0xa9, 0x33, 0x97, 0x8d, 0x2b, 0xc2, 0xfe, 0x99, 0x35, 0x28, 0xe5, 0xeb, 0x63}}},
499{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
500 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
501{{{0xb1, 0x3f, 0x3f, 0xef, 0xd8, 0xf4, 0xfc, 0xb3, 0xa0, 0x60, 0x50, 0x06, 0x2b, 0x29, 0x52, 0x70, 0x15, 0x0b, 0x24, 0x24, 0xf8, 0x5f, 0x79, 0x18, 0xcc, 0xff, 0x89, 0x99, 0x84, 0xa1, 0xae, 0x13}} ,
502 {{0x44, 0x1f, 0xb8, 0xc2, 0x01, 0xc1, 0x30, 0x19, 0x55, 0x05, 0x60, 0x10, 0xa4, 0x6c, 0x2d, 0x67, 0x70, 0xe5, 0x25, 0x1b, 0xf2, 0xbf, 0xdd, 0xfb, 0x70, 0x2b, 0xa1, 0x8c, 0x9c, 0x94, 0x84, 0x08}}},
503{{{0xe7, 0xc4, 0x43, 0x4d, 0xc9, 0x2b, 0x69, 0x5d, 0x1d, 0x3c, 0xaf, 0xbb, 0x43, 0x38, 0x4e, 0x98, 0x3d, 0xed, 0x0d, 0x21, 0x03, 0xfd, 0xf0, 0x99, 0x47, 0x04, 0xb0, 0x98, 0x69, 0x55, 0x72, 0x0f}} ,
504 {{0x5e, 0xdf, 0x15, 0x53, 0x3b, 0x86, 0x80, 0xb0, 0xf1, 0x70, 0x68, 0x8f, 0x66, 0x7c, 0x0e, 0x49, 0x1a, 0xd8, 0x6b, 0xfe, 0x4e, 0xef, 0xca, 0x47, 0xd4, 0x03, 0xc1, 0x37, 0x50, 0x9c, 0xc1, 0x16}}},
505{{{0xcd, 0x24, 0xc6, 0x3e, 0x0c, 0x82, 0x9b, 0x91, 0x2b, 0x61, 0x4a, 0xb2, 0x0f, 0x88, 0x55, 0x5f, 0x5a, 0x57, 0xff, 0xe5, 0x74, 0x0b, 0x13, 0x43, 0x00, 0xd8, 0x6b, 0xcf, 0xd2, 0x15, 0x03, 0x2c}} ,
506 {{0xdc, 0xff, 0x15, 0x61, 0x2f, 0x4a, 0x2f, 0x62, 0xf2, 0x04, 0x2f, 0xb5, 0x0c, 0xb7, 0x1e, 0x3f, 0x74, 0x1a, 0x0f, 0xd7, 0xea, 0xcd, 0xd9, 0x7d, 0xf6, 0x12, 0x0e, 0x2f, 0xdb, 0x5a, 0x3b, 0x16}}},
507{{{0x1b, 0x37, 0x47, 0xe3, 0xf5, 0x9e, 0xea, 0x2c, 0x2a, 0xe7, 0x82, 0x36, 0xf4, 0x1f, 0x81, 0x47, 0x92, 0x4b, 0x69, 0x0e, 0x11, 0x8c, 0x5d, 0x53, 0x5b, 0x81, 0x27, 0x08, 0xbc, 0xa0, 0xae, 0x25}} ,
508 {{0x69, 0x32, 0xa1, 0x05, 0x11, 0x42, 0x00, 0xd2, 0x59, 0xac, 0x4d, 0x62, 0x8b, 0x13, 0xe2, 0x50, 0x5d, 0xa0, 0x9d, 0x9b, 0xfd, 0xbb, 0x12, 0x41, 0x75, 0x41, 0x9e, 0xcc, 0xdc, 0xc7, 0xdc, 0x5d}}},
509{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
510 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
511{{{0xd9, 0xe3, 0x38, 0x06, 0x46, 0x70, 0x82, 0x5e, 0x28, 0x49, 0x79, 0xff, 0x25, 0xd2, 0x4e, 0x29, 0x8d, 0x06, 0xb0, 0x23, 0xae, 0x9b, 0x66, 0xe4, 0x7d, 0xc0, 0x70, 0x91, 0xa3, 0xfc, 0xec, 0x4e}} ,
512 {{0x62, 0x12, 0x37, 0x6a, 0x30, 0xf6, 0x1e, 0xfb, 0x14, 0x5c, 0x0d, 0x0e, 0xb7, 0x81, 0x6a, 0xe7, 0x08, 0x05, 0xac, 0xaa, 0x38, 0x46, 0xe2, 0x73, 0xea, 0x4b, 0x07, 0x81, 0x43, 0x7c, 0x9e, 0x5e}}},
513{{{0xfc, 0xf9, 0x21, 0x4f, 0x2e, 0x76, 0x9b, 0x1f, 0x28, 0x60, 0x77, 0x43, 0x32, 0x9d, 0xbe, 0x17, 0x30, 0x2a, 0xc6, 0x18, 0x92, 0x66, 0x62, 0x30, 0x98, 0x40, 0x11, 0xa6, 0x7f, 0x18, 0x84, 0x28}} ,
514 {{0x3f, 0xab, 0xd3, 0xf4, 0x8a, 0x76, 0xa1, 0x3c, 0xca, 0x2d, 0x49, 0xc3, 0xea, 0x08, 0x0b, 0x85, 0x17, 0x2a, 0xc3, 0x6c, 0x08, 0xfd, 0x57, 0x9f, 0x3d, 0x5f, 0xdf, 0x67, 0x68, 0x42, 0x00, 0x32}}},
515{{{0x51, 0x60, 0x1b, 0x06, 0x4f, 0x8a, 0x21, 0xba, 0x38, 0xa8, 0xba, 0xd6, 0x40, 0xf6, 0xe9, 0x9b, 0x76, 0x4d, 0x56, 0x21, 0x5b, 0x0a, 0x9b, 0x2e, 0x4f, 0x3d, 0x81, 0x32, 0x08, 0x9f, 0x97, 0x5b}} ,
516 {{0xe5, 0x44, 0xec, 0x06, 0x9d, 0x90, 0x79, 0x9f, 0xd3, 0xe0, 0x79, 0xaf, 0x8f, 0x10, 0xfd, 0xdd, 0x04, 0xae, 0x27, 0x97, 0x46, 0x33, 0x79, 0xea, 0xb8, 0x4e, 0xca, 0x5a, 0x59, 0x57, 0xe1, 0x0e}}},
517{{{0x1a, 0xda, 0xf3, 0xa5, 0x41, 0x43, 0x28, 0xfc, 0x7e, 0xe7, 0x71, 0xea, 0xc6, 0x3b, 0x59, 0xcc, 0x2e, 0xd3, 0x40, 0xec, 0xb3, 0x13, 0x6f, 0x44, 0xcd, 0x13, 0xb2, 0x37, 0xf2, 0x6e, 0xd9, 0x1c}} ,
518 {{0xe3, 0xdb, 0x60, 0xcd, 0x5c, 0x4a, 0x18, 0x0f, 0xef, 0x73, 0x36, 0x71, 0x8c, 0xf6, 0x11, 0xb4, 0xd8, 0xce, 0x17, 0x5e, 0x4f, 0x26, 0x77, 0x97, 0x5f, 0xcb, 0xef, 0x91, 0xeb, 0x6a, 0x62, 0x7a}}},
519{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
520 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
521{{{0x18, 0x4a, 0xa2, 0x97, 0x08, 0x81, 0x2d, 0x83, 0xc4, 0xcc, 0xf0, 0x83, 0x7e, 0xec, 0x0d, 0x95, 0x4c, 0x5b, 0xfb, 0xfa, 0x98, 0x80, 0x4a, 0x66, 0x56, 0x0c, 0x51, 0xb3, 0xf2, 0x04, 0x5d, 0x27}} ,
522 {{0x3b, 0xb9, 0xb8, 0x06, 0x5a, 0x2e, 0xfe, 0xc3, 0x82, 0x37, 0x9c, 0xa3, 0x11, 0x1f, 0x9c, 0xa6, 0xda, 0x63, 0x48, 0x9b, 0xad, 0xde, 0x2d, 0xa6, 0xbc, 0x6e, 0x32, 0xda, 0x27, 0x65, 0xdd, 0x57}}},
523{{{0x84, 0x4f, 0x37, 0x31, 0x7d, 0x2e, 0xbc, 0xad, 0x87, 0x07, 0x2a, 0x6b, 0x37, 0xfc, 0x5f, 0xeb, 0x4e, 0x75, 0x35, 0xa6, 0xde, 0xab, 0x0a, 0x19, 0x3a, 0xb7, 0xb1, 0xef, 0x92, 0x6a, 0x3b, 0x3c}} ,
524 {{0x3b, 0xb2, 0x94, 0x6d, 0x39, 0x60, 0xac, 0xee, 0xe7, 0x81, 0x1a, 0x3b, 0x76, 0x87, 0x5c, 0x05, 0x94, 0x2a, 0x45, 0xb9, 0x80, 0xe9, 0x22, 0xb1, 0x07, 0xcb, 0x40, 0x9e, 0x70, 0x49, 0x6d, 0x12}}},
525{{{0xfd, 0x18, 0x78, 0x84, 0xa8, 0x4c, 0x7d, 0x6e, 0x59, 0xa6, 0xe5, 0x74, 0xf1, 0x19, 0xa6, 0x84, 0x2e, 0x51, 0xc1, 0x29, 0x13, 0xf2, 0x14, 0x6b, 0x5d, 0x53, 0x51, 0xf7, 0xef, 0xbf, 0x01, 0x22}} ,
526 {{0xa4, 0x4b, 0x62, 0x4c, 0xe6, 0xfd, 0x72, 0x07, 0xf2, 0x81, 0xfc, 0xf2, 0xbd, 0x12, 0x7c, 0x68, 0x76, 0x2a, 0xba, 0xf5, 0x65, 0xb1, 0x1f, 0x17, 0x0a, 0x38, 0xb0, 0xbf, 0xc0, 0xf8, 0xf4, 0x2a}}},
527{{{0x55, 0x60, 0x55, 0x5b, 0xe4, 0x1d, 0x71, 0x4c, 0x9d, 0x5b, 0x9f, 0x70, 0xa6, 0x85, 0x9a, 0x2c, 0xa0, 0xe2, 0x32, 0x48, 0xce, 0x9e, 0x2a, 0xa5, 0x07, 0x3b, 0xc7, 0x6c, 0x86, 0x77, 0xde, 0x3c}} ,
528 {{0xf7, 0x18, 0x7a, 0x96, 0x7e, 0x43, 0x57, 0xa9, 0x55, 0xfc, 0x4e, 0xb6, 0x72, 0x00, 0xf2, 0xe4, 0xd7, 0x52, 0xd3, 0xd3, 0xb6, 0x85, 0xf6, 0x71, 0xc7, 0x44, 0x3f, 0x7f, 0xd7, 0xb3, 0xf2, 0x79}}},
529{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
530 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
531{{{0x46, 0xca, 0xa7, 0x55, 0x7b, 0x79, 0xf3, 0xca, 0x5a, 0x65, 0xf6, 0xed, 0x50, 0x14, 0x7b, 0xe4, 0xc4, 0x2a, 0x65, 0x9e, 0xe2, 0xf9, 0xca, 0xa7, 0x22, 0x26, 0x53, 0xcb, 0x21, 0x5b, 0xa7, 0x31}} ,
532 {{0x90, 0xd7, 0xc5, 0x26, 0x08, 0xbd, 0xb0, 0x53, 0x63, 0x58, 0xc3, 0x31, 0x5e, 0x75, 0x46, 0x15, 0x91, 0xa6, 0xf8, 0x2f, 0x1a, 0x08, 0x65, 0x88, 0x2f, 0x98, 0x04, 0xf1, 0x7c, 0x6e, 0x00, 0x77}}},
533{{{0x81, 0x21, 0x61, 0x09, 0xf6, 0x4e, 0xf1, 0x92, 0xee, 0x63, 0x61, 0x73, 0x87, 0xc7, 0x54, 0x0e, 0x42, 0x4b, 0xc9, 0x47, 0xd1, 0xb8, 0x7e, 0x91, 0x75, 0x37, 0x99, 0x28, 0xb8, 0xdd, 0x7f, 0x50}} ,
534 {{0x89, 0x8f, 0xc0, 0xbe, 0x5d, 0xd6, 0x9f, 0xa0, 0xf0, 0x9d, 0x81, 0xce, 0x3a, 0x7b, 0x98, 0x58, 0xbb, 0xd7, 0x78, 0xc8, 0x3f, 0x13, 0xf1, 0x74, 0x19, 0xdf, 0xf8, 0x98, 0x89, 0x5d, 0xfa, 0x5f}}},
535{{{0x9e, 0x35, 0x85, 0x94, 0x47, 0x1f, 0x90, 0x15, 0x26, 0xd0, 0x84, 0xed, 0x8a, 0x80, 0xf7, 0x63, 0x42, 0x86, 0x27, 0xd7, 0xf4, 0x75, 0x58, 0xdc, 0x9c, 0xc0, 0x22, 0x7e, 0x20, 0x35, 0xfd, 0x1f}} ,
536 {{0x68, 0x0e, 0x6f, 0x97, 0xba, 0x70, 0xbb, 0xa3, 0x0e, 0xe5, 0x0b, 0x12, 0xf4, 0xa2, 0xdc, 0x47, 0xf8, 0xe6, 0xd0, 0x23, 0x6c, 0x33, 0xa8, 0x99, 0x46, 0x6e, 0x0f, 0x44, 0xba, 0x76, 0x48, 0x0f}}},
537{{{0xa3, 0x2a, 0x61, 0x37, 0xe2, 0x59, 0x12, 0x0e, 0x27, 0xba, 0x64, 0x43, 0xae, 0xc0, 0x42, 0x69, 0x79, 0xa4, 0x1e, 0x29, 0x8b, 0x15, 0xeb, 0xf8, 0xaf, 0xd4, 0xa2, 0x68, 0x33, 0xb5, 0x7a, 0x24}} ,
538 {{0x2c, 0x19, 0x33, 0xdd, 0x1b, 0xab, 0xec, 0x01, 0xb0, 0x23, 0xf8, 0x42, 0x2b, 0x06, 0x88, 0xea, 0x3d, 0x2d, 0x00, 0x2a, 0x78, 0x45, 0x4d, 0x38, 0xed, 0x2e, 0x2e, 0x44, 0x49, 0xed, 0xcb, 0x33}}},
539{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
540 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
541{{{0xa0, 0x68, 0xe8, 0x41, 0x8f, 0x91, 0xf8, 0x11, 0x13, 0x90, 0x2e, 0xa7, 0xab, 0x30, 0xef, 0xad, 0xa0, 0x61, 0x00, 0x88, 0xef, 0xdb, 0xce, 0x5b, 0x5c, 0xbb, 0x62, 0xc8, 0x56, 0xf9, 0x00, 0x73}} ,
542 {{0x3f, 0x60, 0xc1, 0x82, 0x2d, 0xa3, 0x28, 0x58, 0x24, 0x9e, 0x9f, 0xe3, 0x70, 0xcc, 0x09, 0x4e, 0x1a, 0x3f, 0x11, 0x11, 0x15, 0x07, 0x3c, 0xa4, 0x41, 0xe0, 0x65, 0xa3, 0x0a, 0x41, 0x6d, 0x11}}},
543{{{0x31, 0x40, 0x01, 0x52, 0x56, 0x94, 0x5b, 0x28, 0x8a, 0xaa, 0x52, 0xee, 0xd8, 0x0a, 0x05, 0x8d, 0xcd, 0xb5, 0xaa, 0x2e, 0x38, 0xaa, 0xb7, 0x87, 0xf7, 0x2b, 0xfb, 0x04, 0xcb, 0x84, 0x3d, 0x54}} ,
544 {{0x20, 0xef, 0x59, 0xde, 0xa4, 0x2b, 0x93, 0x6e, 0x2e, 0xec, 0x42, 0x9a, 0xd4, 0x2d, 0xf4, 0x46, 0x58, 0x27, 0x2b, 0x18, 0x8f, 0x83, 0x3d, 0x69, 0x9e, 0xd4, 0x3e, 0xb6, 0xc5, 0xfd, 0x58, 0x03}}},
545{{{0x33, 0x89, 0xc9, 0x63, 0x62, 0x1c, 0x17, 0xb4, 0x60, 0xc4, 0x26, 0x68, 0x09, 0xc3, 0x2e, 0x37, 0x0f, 0x7b, 0xb4, 0x9c, 0xb6, 0xf9, 0xfb, 0xd4, 0x51, 0x78, 0xc8, 0x63, 0xea, 0x77, 0x47, 0x07}} ,
546 {{0x32, 0xb4, 0x18, 0x47, 0x79, 0xcb, 0xd4, 0x5a, 0x07, 0x14, 0x0f, 0xa0, 0xd5, 0xac, 0xd0, 0x41, 0x40, 0xab, 0x61, 0x23, 0xe5, 0x2a, 0x2a, 0x6f, 0xf7, 0xa8, 0xd4, 0x76, 0xef, 0xe7, 0x45, 0x6c}}},
547{{{0xa1, 0x5e, 0x60, 0x4f, 0xfb, 0xe1, 0x70, 0x6a, 0x1f, 0x55, 0x4f, 0x09, 0xb4, 0x95, 0x33, 0x36, 0xc6, 0x81, 0x01, 0x18, 0x06, 0x25, 0x27, 0xa4, 0xb4, 0x24, 0xa4, 0x86, 0x03, 0x4c, 0xac, 0x02}} ,
548 {{0x77, 0x38, 0xde, 0xd7, 0x60, 0x48, 0x07, 0xf0, 0x74, 0xa8, 0xff, 0x54, 0xe5, 0x30, 0x43, 0xff, 0x77, 0xfb, 0x21, 0x07, 0xff, 0xb2, 0x07, 0x6b, 0xe4, 0xe5, 0x30, 0xfc, 0x19, 0x6c, 0xa3, 0x01}}},
549{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
550 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
551{{{0x13, 0xc5, 0x2c, 0xac, 0xd3, 0x83, 0x82, 0x7c, 0x29, 0xf7, 0x05, 0xa5, 0x00, 0xb6, 0x1f, 0x86, 0x55, 0xf4, 0xd6, 0x2f, 0x0c, 0x99, 0xd0, 0x65, 0x9b, 0x6b, 0x46, 0x0d, 0x43, 0xf8, 0x16, 0x28}} ,
552 {{0x1e, 0x7f, 0xb4, 0x74, 0x7e, 0xb1, 0x89, 0x4f, 0x18, 0x5a, 0xab, 0x64, 0x06, 0xdf, 0x45, 0x87, 0xe0, 0x6a, 0xc6, 0xf0, 0x0e, 0xc9, 0x24, 0x35, 0x38, 0xea, 0x30, 0x54, 0xb4, 0xc4, 0x52, 0x54}}},
553{{{0xe9, 0x9f, 0xdc, 0x3f, 0xc1, 0x89, 0x44, 0x74, 0x27, 0xe4, 0xc1, 0x90, 0xff, 0x4a, 0xa7, 0x3c, 0xee, 0xcd, 0xf4, 0x1d, 0x25, 0x94, 0x7f, 0x63, 0x16, 0x48, 0xbc, 0x64, 0xfe, 0x95, 0xc4, 0x0c}} ,
554 {{0x8b, 0x19, 0x75, 0x6e, 0x03, 0x06, 0x5e, 0x6a, 0x6f, 0x1a, 0x8c, 0xe3, 0xd3, 0x28, 0xf2, 0xe0, 0xb9, 0x7a, 0x43, 0x69, 0xe6, 0xd3, 0xc0, 0xfe, 0x7e, 0x97, 0xab, 0x6c, 0x7b, 0x8e, 0x13, 0x42}}},
555{{{0xd4, 0xca, 0x70, 0x3d, 0xab, 0xfb, 0x5f, 0x5e, 0x00, 0x0c, 0xcc, 0x77, 0x22, 0xf8, 0x78, 0x55, 0xae, 0x62, 0x35, 0xfb, 0x9a, 0xc6, 0x03, 0xe4, 0x0c, 0xee, 0xab, 0xc7, 0xc0, 0x89, 0x87, 0x54}} ,
556 {{0x32, 0xad, 0xae, 0x85, 0x58, 0x43, 0xb8, 0xb1, 0xe6, 0x3e, 0x00, 0x9c, 0x78, 0x88, 0x56, 0xdb, 0x9c, 0xfc, 0x79, 0xf6, 0xf9, 0x41, 0x5f, 0xb7, 0xbc, 0x11, 0xf9, 0x20, 0x36, 0x1c, 0x53, 0x2b}}},
557{{{0x5a, 0x20, 0x5b, 0xa1, 0xa5, 0x44, 0x91, 0x24, 0x02, 0x63, 0x12, 0x64, 0xb8, 0x55, 0xf6, 0xde, 0x2c, 0xdb, 0x47, 0xb8, 0xc6, 0x0a, 0xc3, 0x00, 0x78, 0x93, 0xd8, 0xf5, 0xf5, 0x18, 0x28, 0x0a}} ,
558 {{0xd6, 0x1b, 0x9a, 0x6c, 0xe5, 0x46, 0xea, 0x70, 0x96, 0x8d, 0x4e, 0x2a, 0x52, 0x21, 0x26, 0x4b, 0xb1, 0xbb, 0x0f, 0x7c, 0xa9, 0x9b, 0x04, 0xbb, 0x51, 0x08, 0xf1, 0x9a, 0xa4, 0x76, 0x7c, 0x18}}},
559{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
560 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
561{{{0xfa, 0x94, 0xf7, 0x40, 0xd0, 0xd7, 0xeb, 0xa9, 0x82, 0x36, 0xd5, 0x15, 0xb9, 0x33, 0x7a, 0xbf, 0x8a, 0xf2, 0x63, 0xaa, 0x37, 0xf5, 0x59, 0xac, 0xbd, 0xbb, 0x32, 0x36, 0xbe, 0x73, 0x99, 0x38}} ,
562 {{0x2c, 0xb3, 0xda, 0x7a, 0xd8, 0x3d, 0x99, 0xca, 0xd2, 0xf4, 0xda, 0x99, 0x8e, 0x4f, 0x98, 0xb7, 0xf4, 0xae, 0x3e, 0x9f, 0x8e, 0x35, 0x60, 0xa4, 0x33, 0x75, 0xa4, 0x04, 0x93, 0xb1, 0x6b, 0x4d}}},
563{{{0x97, 0x9d, 0xa8, 0xcd, 0x97, 0x7b, 0x9d, 0xb9, 0xe7, 0xa5, 0xef, 0xfd, 0xa8, 0x42, 0x6b, 0xc3, 0x62, 0x64, 0x7d, 0xa5, 0x1b, 0xc9, 0x9e, 0xd2, 0x45, 0xb9, 0xee, 0x03, 0xb0, 0xbf, 0xc0, 0x68}} ,
564 {{0xed, 0xb7, 0x84, 0x2c, 0xf6, 0xd3, 0xa1, 0x6b, 0x24, 0x6d, 0x87, 0x56, 0x97, 0x59, 0x79, 0x62, 0x9f, 0xac, 0xed, 0xf3, 0xc9, 0x89, 0x21, 0x2e, 0x04, 0xb3, 0xcc, 0x2f, 0xbe, 0xd6, 0x0a, 0x4b}}},
565{{{0x39, 0x61, 0x05, 0xed, 0x25, 0x89, 0x8b, 0x5d, 0x1b, 0xcb, 0x0c, 0x55, 0xf4, 0x6a, 0x00, 0x8a, 0x46, 0xe8, 0x1e, 0xc6, 0x83, 0xc8, 0x5a, 0x76, 0xdb, 0xcc, 0x19, 0x7a, 0xcc, 0x67, 0x46, 0x0b}} ,
566 {{0x53, 0xcf, 0xc2, 0xa1, 0xad, 0x6a, 0xf3, 0xcd, 0x8f, 0xc9, 0xde, 0x1c, 0xf8, 0x6c, 0x8f, 0xf8, 0x76, 0x42, 0xe7, 0xfe, 0xb2, 0x72, 0x21, 0x0a, 0x66, 0x74, 0x8f, 0xb7, 0xeb, 0xe4, 0x6f, 0x01}}},
567{{{0x22, 0x8c, 0x6b, 0xbe, 0xfc, 0x4d, 0x70, 0x62, 0x6e, 0x52, 0x77, 0x99, 0x88, 0x7e, 0x7b, 0x57, 0x7a, 0x0d, 0xfe, 0xdc, 0x72, 0x92, 0xf1, 0x68, 0x1d, 0x97, 0xd7, 0x7c, 0x8d, 0x53, 0x10, 0x37}} ,
568 {{0x53, 0x88, 0x77, 0x02, 0xca, 0x27, 0xa8, 0xe5, 0x45, 0xe2, 0xa8, 0x48, 0x2a, 0xab, 0x18, 0xca, 0xea, 0x2d, 0x2a, 0x54, 0x17, 0x37, 0x32, 0x09, 0xdc, 0xe0, 0x4a, 0xb7, 0x7d, 0x82, 0x10, 0x7d}}},
569{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
570 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
571{{{0x8a, 0x64, 0x1e, 0x14, 0x0a, 0x57, 0xd4, 0xda, 0x5c, 0x96, 0x9b, 0x01, 0x4c, 0x67, 0xbf, 0x8b, 0x30, 0xfe, 0x08, 0xdb, 0x0d, 0xd5, 0xa8, 0xd7, 0x09, 0x11, 0x85, 0xa2, 0xd3, 0x45, 0xfb, 0x7e}} ,
572 {{0xda, 0x8c, 0xc2, 0xd0, 0xac, 0x18, 0xe8, 0x52, 0x36, 0xd4, 0x21, 0xa3, 0xdd, 0x57, 0x22, 0x79, 0xb7, 0xf8, 0x71, 0x9d, 0xc6, 0x91, 0x70, 0x86, 0x56, 0xbf, 0xa1, 0x11, 0x8b, 0x19, 0xe1, 0x0f}}},
573{{{0x18, 0x32, 0x98, 0x2c, 0x8f, 0x91, 0xae, 0x12, 0xf0, 0x8c, 0xea, 0xf3, 0x3c, 0xb9, 0x5d, 0xe4, 0x69, 0xed, 0xb2, 0x47, 0x18, 0xbd, 0xce, 0x16, 0x52, 0x5c, 0x23, 0xe2, 0xa5, 0x25, 0x52, 0x5d}} ,
574 {{0xb9, 0xb1, 0xe7, 0x5d, 0x4e, 0xbc, 0xee, 0xbb, 0x40, 0x81, 0x77, 0x82, 0x19, 0xab, 0xb5, 0xc6, 0xee, 0xab, 0x5b, 0x6b, 0x63, 0x92, 0x8a, 0x34, 0x8d, 0xcd, 0xee, 0x4f, 0x49, 0xe5, 0xc9, 0x7e}}},
575{{{0x21, 0xac, 0x8b, 0x22, 0xcd, 0xc3, 0x9a, 0xe9, 0x5e, 0x78, 0xbd, 0xde, 0xba, 0xad, 0xab, 0xbf, 0x75, 0x41, 0x09, 0xc5, 0x58, 0xa4, 0x7d, 0x92, 0xb0, 0x7f, 0xf2, 0xa1, 0xd1, 0xc0, 0xb3, 0x6d}} ,
576 {{0x62, 0x4f, 0xd0, 0x75, 0x77, 0xba, 0x76, 0x77, 0xd7, 0xb8, 0xd8, 0x92, 0x6f, 0x98, 0x34, 0x3d, 0xd6, 0x4e, 0x1c, 0x0f, 0xf0, 0x8f, 0x2e, 0xf1, 0xb3, 0xbd, 0xb1, 0xb9, 0xec, 0x99, 0xb4, 0x07}}},
577{{{0x60, 0x57, 0x2e, 0x9a, 0x72, 0x1d, 0x6b, 0x6e, 0x58, 0x33, 0x24, 0x8c, 0x48, 0x39, 0x46, 0x8e, 0x89, 0x6a, 0x88, 0x51, 0x23, 0x62, 0xb5, 0x32, 0x09, 0x36, 0xe3, 0x57, 0xf5, 0x98, 0xde, 0x6f}} ,
578 {{0x8b, 0x2c, 0x00, 0x48, 0x4a, 0xf9, 0x5b, 0x87, 0x69, 0x52, 0xe5, 0x5b, 0xd1, 0xb1, 0xe5, 0x25, 0x25, 0xe0, 0x9c, 0xc2, 0x13, 0x44, 0xe8, 0xb9, 0x0a, 0x70, 0xad, 0xbd, 0x0f, 0x51, 0x94, 0x69}}},
579{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
580 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
581{{{0xa2, 0xdc, 0xab, 0xa9, 0x25, 0x2d, 0xac, 0x5f, 0x03, 0x33, 0x08, 0xe7, 0x7e, 0xfe, 0x95, 0x36, 0x3c, 0x5b, 0x3a, 0xd3, 0x05, 0x82, 0x1c, 0x95, 0x2d, 0xd8, 0x77, 0x7e, 0x02, 0xd9, 0x5b, 0x70}} ,
582 {{0xc2, 0xfe, 0x1b, 0x0c, 0x67, 0xcd, 0xd6, 0xe0, 0x51, 0x8e, 0x2c, 0xe0, 0x79, 0x88, 0xf0, 0xcf, 0x41, 0x4a, 0xad, 0x23, 0xd4, 0x46, 0xca, 0x94, 0xa1, 0xc3, 0xeb, 0x28, 0x06, 0xfa, 0x17, 0x14}}},
583{{{0x7b, 0xaa, 0x70, 0x0a, 0x4b, 0xfb, 0xf5, 0xbf, 0x80, 0xc5, 0xcf, 0x08, 0x7a, 0xdd, 0xa1, 0xf4, 0x9d, 0x54, 0x50, 0x53, 0x23, 0x77, 0x23, 0xf5, 0x34, 0xa5, 0x22, 0xd1, 0x0d, 0x96, 0x2e, 0x47}} ,
584 {{0xcc, 0xb7, 0x32, 0x89, 0x57, 0xd0, 0x98, 0x75, 0xe4, 0x37, 0x99, 0xa9, 0xe8, 0xba, 0xed, 0xba, 0xeb, 0xc7, 0x4f, 0x15, 0x76, 0x07, 0x0c, 0x4c, 0xef, 0x9f, 0x52, 0xfc, 0x04, 0x5d, 0x58, 0x10}}},
585{{{0xce, 0x82, 0xf0, 0x8f, 0x79, 0x02, 0xa8, 0xd1, 0xda, 0x14, 0x09, 0x48, 0xee, 0x8a, 0x40, 0x98, 0x76, 0x60, 0x54, 0x5a, 0xde, 0x03, 0x24, 0xf5, 0xe6, 0x2f, 0xe1, 0x03, 0xbf, 0x68, 0x82, 0x7f}} ,
586 {{0x64, 0xe9, 0x28, 0xc7, 0xa4, 0xcf, 0x2a, 0xf9, 0x90, 0x64, 0x72, 0x2c, 0x8b, 0xeb, 0xec, 0xa0, 0xf2, 0x7d, 0x35, 0xb5, 0x90, 0x4d, 0x7f, 0x5b, 0x4a, 0x49, 0xe4, 0xb8, 0x3b, 0xc8, 0xa1, 0x2f}}},
587{{{0x8b, 0xc5, 0xcc, 0x3d, 0x69, 0xa6, 0xa1, 0x18, 0x44, 0xbc, 0x4d, 0x77, 0x37, 0xc7, 0x86, 0xec, 0x0c, 0xc9, 0xd6, 0x44, 0xa9, 0x23, 0x27, 0xb9, 0x03, 0x34, 0xa7, 0x0a, 0xd5, 0xc7, 0x34, 0x37}} ,
588 {{0xf9, 0x7e, 0x3e, 0x66, 0xee, 0xf9, 0x99, 0x28, 0xff, 0xad, 0x11, 0xd8, 0xe2, 0x66, 0xc5, 0xcd, 0x0f, 0x0d, 0x0b, 0x6a, 0xfc, 0x7c, 0x24, 0xa8, 0x4f, 0xa8, 0x5e, 0x80, 0x45, 0x8b, 0x6c, 0x41}}},
589{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
590 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
591{{{0xef, 0x1e, 0xec, 0xf7, 0x8d, 0x77, 0xf2, 0xea, 0xdb, 0x60, 0x03, 0x21, 0xc0, 0xff, 0x5e, 0x67, 0xc3, 0x71, 0x0b, 0x21, 0xb4, 0x41, 0xa0, 0x68, 0x38, 0xc6, 0x01, 0xa3, 0xd3, 0x51, 0x3c, 0x3c}} ,
592 {{0x92, 0xf8, 0xd6, 0x4b, 0xef, 0x42, 0x13, 0xb2, 0x4a, 0xc4, 0x2e, 0x72, 0x3f, 0xc9, 0x11, 0xbd, 0x74, 0x02, 0x0e, 0xf5, 0x13, 0x9d, 0x83, 0x1a, 0x1b, 0xd5, 0x54, 0xde, 0xc4, 0x1e, 0x16, 0x6c}}},
593{{{0x27, 0x52, 0xe4, 0x63, 0xaa, 0x94, 0xe6, 0xc3, 0x28, 0x9c, 0xc6, 0x56, 0xac, 0xfa, 0xb6, 0xbd, 0xe2, 0xcc, 0x76, 0xc6, 0x27, 0x27, 0xa2, 0x8e, 0x78, 0x2b, 0x84, 0x72, 0x10, 0xbd, 0x4e, 0x2a}} ,
594 {{0xea, 0xa7, 0x23, 0xef, 0x04, 0x61, 0x80, 0x50, 0xc9, 0x6e, 0xa5, 0x96, 0xd1, 0xd1, 0xc8, 0xc3, 0x18, 0xd7, 0x2d, 0xfd, 0x26, 0xbd, 0xcb, 0x7b, 0x92, 0x51, 0x0e, 0x4a, 0x65, 0x57, 0xb8, 0x49}}},
595{{{0xab, 0x55, 0x36, 0xc3, 0xec, 0x63, 0x55, 0x11, 0x55, 0xf6, 0xa5, 0xc7, 0x01, 0x5f, 0xfe, 0x79, 0xd8, 0x0a, 0xf7, 0x03, 0xd8, 0x98, 0x99, 0xf5, 0xd0, 0x00, 0x54, 0x6b, 0x66, 0x28, 0xf5, 0x25}} ,
596 {{0x7a, 0x8d, 0xa1, 0x5d, 0x70, 0x5d, 0x51, 0x27, 0xee, 0x30, 0x65, 0x56, 0x95, 0x46, 0xde, 0xbd, 0x03, 0x75, 0xb4, 0x57, 0x59, 0x89, 0xeb, 0x02, 0x9e, 0xcc, 0x89, 0x19, 0xa7, 0xcb, 0x17, 0x67}}},
597{{{0x6a, 0xeb, 0xfc, 0x9a, 0x9a, 0x10, 0xce, 0xdb, 0x3a, 0x1c, 0x3c, 0x6a, 0x9d, 0xea, 0x46, 0xbc, 0x45, 0x49, 0xac, 0xe3, 0x41, 0x12, 0x7c, 0xf0, 0xf7, 0x4f, 0xf9, 0xf7, 0xff, 0x2c, 0x89, 0x04}} ,
598 {{0x30, 0x31, 0x54, 0x1a, 0x46, 0xca, 0xe6, 0xc6, 0xcb, 0xe2, 0xc3, 0xc1, 0x8b, 0x75, 0x81, 0xbe, 0xee, 0xf8, 0xa3, 0x11, 0x1c, 0x25, 0xa3, 0xa7, 0x35, 0x51, 0x55, 0xe2, 0x25, 0xaa, 0xe2, 0x3a}}},
599{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
600 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
601{{{0xb4, 0x48, 0x10, 0x9f, 0x8a, 0x09, 0x76, 0xfa, 0xf0, 0x7a, 0xb0, 0x70, 0xf7, 0x83, 0x80, 0x52, 0x84, 0x2b, 0x26, 0xa2, 0xc4, 0x5d, 0x4f, 0xba, 0xb1, 0xc8, 0x40, 0x0d, 0x78, 0x97, 0xc4, 0x60}} ,
602 {{0xd4, 0xb1, 0x6c, 0x08, 0xc7, 0x40, 0x38, 0x73, 0x5f, 0x0b, 0xf3, 0x76, 0x5d, 0xb2, 0xa5, 0x2f, 0x57, 0x57, 0x07, 0xed, 0x08, 0xa2, 0x6c, 0x4f, 0x08, 0x02, 0xb5, 0x0e, 0xee, 0x44, 0xfa, 0x22}}},
603{{{0x0f, 0x00, 0x3f, 0xa6, 0x04, 0x19, 0x56, 0x65, 0x31, 0x7f, 0x8b, 0xeb, 0x0d, 0xe1, 0x47, 0x89, 0x97, 0x16, 0x53, 0xfa, 0x81, 0xa7, 0xaa, 0xb2, 0xbf, 0x67, 0xeb, 0x72, 0x60, 0x81, 0x0d, 0x48}} ,
604 {{0x7e, 0x13, 0x33, 0xcd, 0xa8, 0x84, 0x56, 0x1e, 0x67, 0xaf, 0x6b, 0x43, 0xac, 0x17, 0xaf, 0x16, 0xc0, 0x52, 0x99, 0x49, 0x5b, 0x87, 0x73, 0x7e, 0xb5, 0x43, 0xda, 0x6b, 0x1d, 0x0f, 0x2d, 0x55}}},
605{{{0xe9, 0x58, 0x1f, 0xff, 0x84, 0x3f, 0x93, 0x1c, 0xcb, 0xe1, 0x30, 0x69, 0xa5, 0x75, 0x19, 0x7e, 0x14, 0x5f, 0xf8, 0xfc, 0x09, 0xdd, 0xa8, 0x78, 0x9d, 0xca, 0x59, 0x8b, 0xd1, 0x30, 0x01, 0x13}} ,
606 {{0xff, 0x76, 0x03, 0xc5, 0x4b, 0x89, 0x99, 0x70, 0x00, 0x59, 0x70, 0x9c, 0xd5, 0xd9, 0x11, 0x89, 0x5a, 0x46, 0xfe, 0xef, 0xdc, 0xd9, 0x55, 0x2b, 0x45, 0xa7, 0xb0, 0x2d, 0xfb, 0x24, 0xc2, 0x29}}},
607{{{0x38, 0x06, 0xf8, 0x0b, 0xac, 0x82, 0xc4, 0x97, 0x2b, 0x90, 0xe0, 0xf7, 0xa8, 0xab, 0x6c, 0x08, 0x80, 0x66, 0x90, 0x46, 0xf7, 0x26, 0x2d, 0xf8, 0xf1, 0xc4, 0x6b, 0x4a, 0x82, 0x98, 0x8e, 0x37}} ,
608 {{0x8e, 0xb4, 0xee, 0xb8, 0xd4, 0x3f, 0xb2, 0x1b, 0xe0, 0x0a, 0x3d, 0x75, 0x34, 0x28, 0xa2, 0x8e, 0xc4, 0x92, 0x7b, 0xfe, 0x60, 0x6e, 0x6d, 0xb8, 0x31, 0x1d, 0x62, 0x0d, 0x78, 0x14, 0x42, 0x11}}},
609{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
610 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
611{{{0x5e, 0xa8, 0xd8, 0x04, 0x9b, 0x73, 0xc9, 0xc9, 0xdc, 0x0d, 0x73, 0xbf, 0x0a, 0x0a, 0x73, 0xff, 0x18, 0x1f, 0x9c, 0x51, 0xaa, 0xc6, 0xf1, 0x83, 0x25, 0xfd, 0xab, 0xa3, 0x11, 0xd3, 0x01, 0x24}} ,
612 {{0x4d, 0xe3, 0x7e, 0x38, 0x62, 0x5e, 0x64, 0xbb, 0x2b, 0x53, 0xb5, 0x03, 0x68, 0xc4, 0xf2, 0x2b, 0x5a, 0x03, 0x32, 0x99, 0x4a, 0x41, 0x9a, 0xe1, 0x1a, 0xae, 0x8c, 0x48, 0xf3, 0x24, 0x32, 0x65}}},
613{{{0xe8, 0xdd, 0xad, 0x3a, 0x8c, 0xea, 0xf4, 0xb3, 0xb2, 0xe5, 0x73, 0xf2, 0xed, 0x8b, 0xbf, 0xed, 0xb1, 0x0c, 0x0c, 0xfb, 0x2b, 0xf1, 0x01, 0x48, 0xe8, 0x26, 0x03, 0x8e, 0x27, 0x4d, 0x96, 0x72}} ,
614 {{0xc8, 0x09, 0x3b, 0x60, 0xc9, 0x26, 0x4d, 0x7c, 0xf2, 0x9c, 0xd4, 0xa1, 0x3b, 0x26, 0xc2, 0x04, 0x33, 0x44, 0x76, 0x3c, 0x02, 0xbb, 0x11, 0x42, 0x0c, 0x22, 0xb7, 0xc6, 0xe1, 0xac, 0xb4, 0x0e}}},
615{{{0x6f, 0x85, 0xe7, 0xef, 0xde, 0x67, 0x30, 0xfc, 0xbf, 0x5a, 0xe0, 0x7b, 0x7a, 0x2a, 0x54, 0x6b, 0x5d, 0x62, 0x85, 0xa1, 0xf8, 0x16, 0x88, 0xec, 0x61, 0xb9, 0x96, 0xb5, 0xef, 0x2d, 0x43, 0x4d}} ,
616 {{0x7c, 0x31, 0x33, 0xcc, 0xe4, 0xcf, 0x6c, 0xff, 0x80, 0x47, 0x77, 0xd1, 0xd8, 0xe9, 0x69, 0x97, 0x98, 0x7f, 0x20, 0x57, 0x1d, 0x1d, 0x4f, 0x08, 0x27, 0xc8, 0x35, 0x57, 0x40, 0xc6, 0x21, 0x0c}}},
617{{{0xd2, 0x8e, 0x9b, 0xfa, 0x42, 0x8e, 0xdf, 0x8f, 0xc7, 0x86, 0xf9, 0xa4, 0xca, 0x70, 0x00, 0x9d, 0x21, 0xbf, 0xec, 0x57, 0x62, 0x30, 0x58, 0x8c, 0x0d, 0x35, 0xdb, 0x5d, 0x8b, 0x6a, 0xa0, 0x5a}} ,
618 {{0xc1, 0x58, 0x7c, 0x0d, 0x20, 0xdd, 0x11, 0x26, 0x5f, 0x89, 0x3b, 0x97, 0x58, 0xf8, 0x8b, 0xe3, 0xdf, 0x32, 0xe2, 0xfc, 0xd8, 0x67, 0xf2, 0xa5, 0x37, 0x1e, 0x6d, 0xec, 0x7c, 0x27, 0x20, 0x79}}},
619{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
620 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
621{{{0xd0, 0xe9, 0xc0, 0xfa, 0x95, 0x45, 0x23, 0x96, 0xf1, 0x2c, 0x79, 0x25, 0x14, 0xce, 0x40, 0x14, 0x44, 0x2c, 0x36, 0x50, 0xd9, 0x63, 0x56, 0xb7, 0x56, 0x3b, 0x9e, 0xa7, 0xef, 0x89, 0xbb, 0x0e}} ,
622 {{0xce, 0x7f, 0xdc, 0x0a, 0xcc, 0x82, 0x1c, 0x0a, 0x78, 0x71, 0xe8, 0x74, 0x8d, 0x01, 0x30, 0x0f, 0xa7, 0x11, 0x4c, 0xdf, 0x38, 0xd7, 0xa7, 0x0d, 0xf8, 0x48, 0x52, 0x00, 0x80, 0x7b, 0x5f, 0x0e}}},
623{{{0x25, 0x83, 0xe6, 0x94, 0x7b, 0x81, 0xb2, 0x91, 0xae, 0x0e, 0x05, 0xc9, 0xa3, 0x68, 0x2d, 0xd9, 0x88, 0x25, 0x19, 0x2a, 0x61, 0x61, 0x21, 0x97, 0x15, 0xa1, 0x35, 0xa5, 0x46, 0xc8, 0xa2, 0x0e}} ,
624 {{0x1b, 0x03, 0x0d, 0x8b, 0x5a, 0x1b, 0x97, 0x4b, 0xf2, 0x16, 0x31, 0x3d, 0x1f, 0x33, 0xa0, 0x50, 0x3a, 0x18, 0xbe, 0x13, 0xa1, 0x76, 0xc1, 0xba, 0x1b, 0xf1, 0x05, 0x7b, 0x33, 0xa8, 0x82, 0x3b}}},
625{{{0xba, 0x36, 0x7b, 0x6d, 0xa9, 0xea, 0x14, 0x12, 0xc5, 0xfa, 0x91, 0x00, 0xba, 0x9b, 0x99, 0xcc, 0x56, 0x02, 0xe9, 0xa0, 0x26, 0x40, 0x66, 0x8c, 0xc4, 0xf8, 0x85, 0x33, 0x68, 0xe7, 0x03, 0x20}} ,
626 {{0x50, 0x5b, 0xff, 0xa9, 0xb2, 0xf1, 0xf1, 0x78, 0xcf, 0x14, 0xa4, 0xa9, 0xfc, 0x09, 0x46, 0x94, 0x54, 0x65, 0x0d, 0x9c, 0x5f, 0x72, 0x21, 0xe2, 0x97, 0xa5, 0x2d, 0x81, 0xce, 0x4a, 0x5f, 0x79}}},
627{{{0x3d, 0x5f, 0x5c, 0xd2, 0xbc, 0x7d, 0x77, 0x0e, 0x2a, 0x6d, 0x22, 0x45, 0x84, 0x06, 0xc4, 0xdd, 0xc6, 0xa6, 0xc6, 0xd7, 0x49, 0xad, 0x6d, 0x87, 0x91, 0x0e, 0x3a, 0x67, 0x1d, 0x2c, 0x1d, 0x56}} ,
628 {{0xfe, 0x7a, 0x74, 0xcf, 0xd4, 0xd2, 0xe5, 0x19, 0xde, 0xd0, 0xdb, 0x70, 0x23, 0x69, 0xe6, 0x6d, 0xec, 0xec, 0xcc, 0x09, 0x33, 0x6a, 0x77, 0xdc, 0x6b, 0x22, 0x76, 0x5d, 0x92, 0x09, 0xac, 0x2d}}},
629{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
630 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
631{{{0x23, 0x15, 0x17, 0xeb, 0xd3, 0xdb, 0x12, 0x5e, 0x01, 0xf0, 0x91, 0xab, 0x2c, 0x41, 0xce, 0xac, 0xed, 0x1b, 0x4b, 0x2d, 0xbc, 0xdb, 0x17, 0x66, 0x89, 0x46, 0xad, 0x4b, 0x1e, 0x6f, 0x0b, 0x14}} ,
632 {{0x11, 0xce, 0xbf, 0xb6, 0x77, 0x2d, 0x48, 0x22, 0x18, 0x4f, 0xa3, 0x5d, 0x4a, 0xb0, 0x70, 0x12, 0x3e, 0x54, 0xd7, 0xd8, 0x0e, 0x2b, 0x27, 0xdc, 0x53, 0xff, 0xca, 0x8c, 0x59, 0xb3, 0x4e, 0x44}}},
633{{{0x07, 0x76, 0x61, 0x0f, 0x66, 0xb2, 0x21, 0x39, 0x7e, 0xc0, 0xec, 0x45, 0x28, 0x82, 0xa1, 0x29, 0x32, 0x44, 0x35, 0x13, 0x5e, 0x61, 0x5e, 0x54, 0xcb, 0x7c, 0xef, 0xf6, 0x41, 0xcf, 0x9f, 0x0a}} ,
634 {{0xdd, 0xf9, 0xda, 0x84, 0xc3, 0xe6, 0x8a, 0x9f, 0x24, 0xd2, 0x96, 0x5d, 0x39, 0x6f, 0x58, 0x8c, 0xc1, 0x56, 0x93, 0xab, 0xb5, 0x79, 0x3b, 0xd2, 0xa8, 0x73, 0x16, 0xed, 0xfa, 0xb4, 0x2f, 0x73}}},
635{{{0x8b, 0xb1, 0x95, 0xe5, 0x92, 0x50, 0x35, 0x11, 0x76, 0xac, 0xf4, 0x4d, 0x24, 0xc3, 0x32, 0xe6, 0xeb, 0xfe, 0x2c, 0x87, 0xc4, 0xf1, 0x56, 0xc4, 0x75, 0x24, 0x7a, 0x56, 0x85, 0x5a, 0x3a, 0x13}} ,
636 {{0x0d, 0x16, 0xac, 0x3c, 0x4a, 0x58, 0x86, 0x3a, 0x46, 0x7f, 0x6c, 0xa3, 0x52, 0x6e, 0x37, 0xe4, 0x96, 0x9c, 0xe9, 0x5c, 0x66, 0x41, 0x67, 0xe4, 0xfb, 0x79, 0x0c, 0x05, 0xf6, 0x64, 0xd5, 0x7c}}},
637{{{0x28, 0xc1, 0xe1, 0x54, 0x73, 0xf2, 0xbf, 0x76, 0x74, 0x19, 0x19, 0x1b, 0xe4, 0xb9, 0xa8, 0x46, 0x65, 0x73, 0xf3, 0x77, 0x9b, 0x29, 0x74, 0x5b, 0xc6, 0x89, 0x6c, 0x2c, 0x7c, 0xf8, 0xb3, 0x0f}} ,
638 {{0xf7, 0xd5, 0xe9, 0x74, 0x5d, 0xb8, 0x25, 0x16, 0xb5, 0x30, 0xbc, 0x84, 0xc5, 0xf0, 0xad, 0xca, 0x12, 0x28, 0xbc, 0x9d, 0xd4, 0xfa, 0x82, 0xe6, 0xe3, 0xbf, 0xa2, 0x15, 0x2c, 0xd4, 0x34, 0x10}}},
639{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
640 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
641{{{0x61, 0xb1, 0x46, 0xba, 0x0e, 0x31, 0xa5, 0x67, 0x6c, 0x7f, 0xd6, 0xd9, 0x27, 0x85, 0x0f, 0x79, 0x14, 0xc8, 0x6c, 0x2f, 0x5f, 0x5b, 0x9c, 0x35, 0x3d, 0x38, 0x86, 0x77, 0x65, 0x55, 0x6a, 0x7b}} ,
642 {{0xd3, 0xb0, 0x3a, 0x66, 0x60, 0x1b, 0x43, 0xf1, 0x26, 0x58, 0x99, 0x09, 0x8f, 0x2d, 0xa3, 0x14, 0x71, 0x85, 0xdb, 0xed, 0xf6, 0x26, 0xd5, 0x61, 0x9a, 0x73, 0xac, 0x0e, 0xea, 0xac, 0xb7, 0x0c}}},
643{{{0x5e, 0xf4, 0xe5, 0x17, 0x0e, 0x10, 0x9f, 0xe7, 0x43, 0x5f, 0x67, 0x5c, 0xac, 0x4b, 0xe5, 0x14, 0x41, 0xd2, 0xbf, 0x48, 0xf5, 0x14, 0xb0, 0x71, 0xc6, 0x61, 0xc1, 0xb2, 0x70, 0x58, 0xd2, 0x5a}} ,
644 {{0x2d, 0xba, 0x16, 0x07, 0x92, 0x94, 0xdc, 0xbd, 0x50, 0x2b, 0xc9, 0x7f, 0x42, 0x00, 0xba, 0x61, 0xed, 0xf8, 0x43, 0xed, 0xf5, 0xf9, 0x40, 0x60, 0xb2, 0xb0, 0x82, 0xcb, 0xed, 0x75, 0xc7, 0x65}}},
645{{{0x80, 0xba, 0x0d, 0x09, 0x40, 0xa7, 0x39, 0xa6, 0x67, 0x34, 0x7e, 0x66, 0xbe, 0x56, 0xfb, 0x53, 0x78, 0xc4, 0x46, 0xe8, 0xed, 0x68, 0x6c, 0x7f, 0xce, 0xe8, 0x9f, 0xce, 0xa2, 0x64, 0x58, 0x53}} ,
646 {{0xe8, 0xc1, 0xa9, 0xc2, 0x7b, 0x59, 0x21, 0x33, 0xe2, 0x43, 0x73, 0x2b, 0xac, 0x2d, 0xc1, 0x89, 0x3b, 0x15, 0xe2, 0xd5, 0xc0, 0x97, 0x8a, 0xfd, 0x6f, 0x36, 0x33, 0xb7, 0xb9, 0xc3, 0x88, 0x09}}},
647{{{0xd0, 0xb6, 0x56, 0x30, 0x5c, 0xae, 0xb3, 0x75, 0x44, 0xa4, 0x83, 0x51, 0x6e, 0x01, 0x65, 0xef, 0x45, 0x76, 0xe6, 0xf5, 0xa2, 0x0d, 0xd4, 0x16, 0x3b, 0x58, 0x2f, 0xf2, 0x2f, 0x36, 0x18, 0x3f}} ,
648 {{0xfd, 0x2f, 0xe0, 0x9b, 0x1e, 0x8c, 0xc5, 0x18, 0xa9, 0xca, 0xd4, 0x2b, 0x35, 0xb6, 0x95, 0x0a, 0x9f, 0x7e, 0xfb, 0xc4, 0xef, 0x88, 0x7b, 0x23, 0x43, 0xec, 0x2f, 0x0d, 0x0f, 0x7a, 0xfc, 0x5c}}},
649{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
650 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
651{{{0x8d, 0xd2, 0xda, 0xc7, 0x44, 0xd6, 0x7a, 0xdb, 0x26, 0x7d, 0x1d, 0xb8, 0xe1, 0xde, 0x9d, 0x7a, 0x7d, 0x17, 0x7e, 0x1c, 0x37, 0x04, 0x8d, 0x2d, 0x7c, 0x5e, 0x18, 0x38, 0x1e, 0xaf, 0xc7, 0x1b}} ,
652 {{0x33, 0x48, 0x31, 0x00, 0x59, 0xf6, 0xf2, 0xca, 0x0f, 0x27, 0x1b, 0x63, 0x12, 0x7e, 0x02, 0x1d, 0x49, 0xc0, 0x5d, 0x79, 0x87, 0xef, 0x5e, 0x7a, 0x2f, 0x1f, 0x66, 0x55, 0xd8, 0x09, 0xd9, 0x61}}},
653{{{0x54, 0x83, 0x02, 0x18, 0x82, 0x93, 0x99, 0x07, 0xd0, 0xa7, 0xda, 0xd8, 0x75, 0x89, 0xfa, 0xf2, 0xd9, 0xa3, 0xb8, 0x6b, 0x5a, 0x35, 0x28, 0xd2, 0x6b, 0x59, 0xc2, 0xf8, 0x45, 0xe2, 0xbc, 0x06}} ,
654 {{0x65, 0xc0, 0xa3, 0x88, 0x51, 0x95, 0xfc, 0x96, 0x94, 0x78, 0xe8, 0x0d, 0x8b, 0x41, 0xc9, 0xc2, 0x58, 0x48, 0x75, 0x10, 0x2f, 0xcd, 0x2a, 0xc9, 0xa0, 0x6d, 0x0f, 0xdd, 0x9c, 0x98, 0x26, 0x3d}}},
655{{{0x2f, 0x66, 0x29, 0x1b, 0x04, 0x89, 0xbd, 0x7e, 0xee, 0x6e, 0xdd, 0xb7, 0x0e, 0xef, 0xb0, 0x0c, 0xb4, 0xfc, 0x7f, 0xc2, 0xc9, 0x3a, 0x3c, 0x64, 0xef, 0x45, 0x44, 0xaf, 0x8a, 0x90, 0x65, 0x76}} ,
656 {{0xa1, 0x4c, 0x70, 0x4b, 0x0e, 0xa0, 0x83, 0x70, 0x13, 0xa4, 0xaf, 0xb8, 0x38, 0x19, 0x22, 0x65, 0x09, 0xb4, 0x02, 0x4f, 0x06, 0xf8, 0x17, 0xce, 0x46, 0x45, 0xda, 0x50, 0x7c, 0x8a, 0xd1, 0x4e}}},
657{{{0xf7, 0xd4, 0x16, 0x6c, 0x4e, 0x95, 0x9d, 0x5d, 0x0f, 0x91, 0x2b, 0x52, 0xfe, 0x5c, 0x34, 0xe5, 0x30, 0xe6, 0xa4, 0x3b, 0xf3, 0xf3, 0x34, 0x08, 0xa9, 0x4a, 0xa0, 0xb5, 0x6e, 0xb3, 0x09, 0x0a}} ,
658 {{0x26, 0xd9, 0x5e, 0xa3, 0x0f, 0xeb, 0xa2, 0xf3, 0x20, 0x3b, 0x37, 0xd4, 0xe4, 0x9e, 0xce, 0x06, 0x3d, 0x53, 0xed, 0xae, 0x2b, 0xeb, 0xb6, 0x24, 0x0a, 0x11, 0xa3, 0x0f, 0xd6, 0x7f, 0xa4, 0x3a}}},
659{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
660 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
661{{{0xdb, 0x9f, 0x2c, 0xfc, 0xd6, 0xb2, 0x1e, 0x2e, 0x52, 0x7a, 0x06, 0x87, 0x2d, 0x86, 0x72, 0x2b, 0x6d, 0x90, 0x77, 0x46, 0x43, 0xb5, 0x7a, 0xf8, 0x60, 0x7d, 0x91, 0x60, 0x5b, 0x9d, 0x9e, 0x07}} ,
662 {{0x97, 0x87, 0xc7, 0x04, 0x1c, 0x38, 0x01, 0x39, 0x58, 0xc7, 0x85, 0xa3, 0xfc, 0x64, 0x00, 0x64, 0x25, 0xa2, 0xbf, 0x50, 0x94, 0xca, 0x26, 0x31, 0x45, 0x0a, 0x24, 0xd2, 0x51, 0x29, 0x51, 0x16}}},
663{{{0x4d, 0x4a, 0xd7, 0x98, 0x71, 0x57, 0xac, 0x7d, 0x8b, 0x37, 0xbd, 0x63, 0xff, 0x87, 0xb1, 0x49, 0x95, 0x20, 0x7c, 0xcf, 0x7c, 0x59, 0xc4, 0x91, 0x9c, 0xef, 0xd0, 0xdb, 0x60, 0x09, 0x9d, 0x46}} ,
664 {{0xcb, 0x78, 0x94, 0x90, 0xe4, 0x45, 0xb3, 0xf6, 0xd9, 0xf6, 0x57, 0x74, 0xd5, 0xf8, 0x83, 0x4f, 0x39, 0xc9, 0xbd, 0x88, 0xc2, 0x57, 0x21, 0x1f, 0x24, 0x32, 0x68, 0xf8, 0xc7, 0x21, 0x5f, 0x0b}}},
665{{{0x2a, 0x36, 0x68, 0xfc, 0x5f, 0xb6, 0x4f, 0xa5, 0xe3, 0x9d, 0x24, 0x2f, 0xc0, 0x93, 0x61, 0xcf, 0xf8, 0x0a, 0xed, 0xe1, 0xdb, 0x27, 0xec, 0x0e, 0x14, 0x32, 0x5f, 0x8e, 0xa1, 0x62, 0x41, 0x16}} ,
666 {{0x95, 0x21, 0x01, 0xce, 0x95, 0x5b, 0x0e, 0x57, 0xc7, 0xb9, 0x62, 0xb5, 0x28, 0xca, 0x11, 0xec, 0xb4, 0x46, 0x06, 0x73, 0x26, 0xff, 0xfb, 0x66, 0x7d, 0xee, 0x5f, 0xb2, 0x56, 0xfd, 0x2a, 0x08}}},
667{{{0x92, 0x67, 0x77, 0x56, 0xa1, 0xff, 0xc4, 0xc5, 0x95, 0xf0, 0xe3, 0x3a, 0x0a, 0xca, 0x94, 0x4d, 0x9e, 0x7e, 0x3d, 0xb9, 0x6e, 0xb6, 0xb0, 0xce, 0xa4, 0x30, 0x89, 0x99, 0xe9, 0xad, 0x11, 0x59}} ,
668 {{0xf6, 0x48, 0x95, 0xa1, 0x6f, 0x5f, 0xb7, 0xa5, 0xbb, 0x30, 0x00, 0x1c, 0xd2, 0x8a, 0xd6, 0x25, 0x26, 0x1b, 0xb2, 0x0d, 0x37, 0x6a, 0x05, 0xf4, 0x9d, 0x3e, 0x17, 0x2a, 0x43, 0xd2, 0x3a, 0x06}}},
669{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
670 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
671{{{0x32, 0x99, 0x93, 0xd1, 0x9a, 0x72, 0xf3, 0xa9, 0x16, 0xbd, 0xb4, 0x4c, 0xdd, 0xf9, 0xd4, 0xb2, 0x64, 0x9a, 0xd3, 0x05, 0xe4, 0xa3, 0x73, 0x1c, 0xcb, 0x7e, 0x57, 0x67, 0xff, 0x04, 0xb3, 0x10}} ,
672 {{0xb9, 0x4b, 0xa4, 0xad, 0xd0, 0x6d, 0x61, 0x23, 0xb4, 0xaf, 0x34, 0xa9, 0xaa, 0x65, 0xec, 0xd9, 0x69, 0xe3, 0x85, 0xcd, 0xcc, 0xe7, 0xb0, 0x9b, 0x41, 0xc1, 0x1c, 0xf9, 0xa0, 0xfa, 0xb7, 0x13}}},
673{{{0x04, 0xfd, 0x88, 0x3c, 0x0c, 0xd0, 0x09, 0x52, 0x51, 0x4f, 0x06, 0x19, 0xcc, 0xc3, 0xbb, 0xde, 0x80, 0xc5, 0x33, 0xbc, 0xf9, 0xf3, 0x17, 0x36, 0xdd, 0xc6, 0xde, 0xe8, 0x9b, 0x5d, 0x79, 0x1b}} ,
674 {{0x65, 0x0a, 0xbe, 0x51, 0x57, 0xad, 0x50, 0x79, 0x08, 0x71, 0x9b, 0x07, 0x95, 0x8f, 0xfb, 0xae, 0x4b, 0x38, 0xba, 0xcf, 0x53, 0x2a, 0x86, 0x1e, 0xc0, 0x50, 0x5c, 0x67, 0x1b, 0xf6, 0x87, 0x6c}}},
675{{{0x4f, 0x00, 0xb2, 0x66, 0x55, 0xed, 0x4a, 0xed, 0x8d, 0xe1, 0x66, 0x18, 0xb2, 0x14, 0x74, 0x8d, 0xfd, 0x1a, 0x36, 0x0f, 0x26, 0x5c, 0x8b, 0x89, 0xf3, 0xab, 0xf2, 0xf3, 0x24, 0x67, 0xfd, 0x70}} ,
676 {{0xfd, 0x4e, 0x2a, 0xc1, 0x3a, 0xca, 0x8f, 0x00, 0xd8, 0xec, 0x74, 0x67, 0xef, 0x61, 0xe0, 0x28, 0xd0, 0x96, 0xf4, 0x48, 0xde, 0x81, 0xe3, 0xef, 0xdc, 0xaa, 0x7d, 0xf3, 0xb6, 0x55, 0xa6, 0x65}}},
677{{{0xeb, 0xcb, 0xc5, 0x70, 0x91, 0x31, 0x10, 0x93, 0x0d, 0xc8, 0xd0, 0xef, 0x62, 0xe8, 0x6f, 0x82, 0xe3, 0x69, 0x3d, 0x91, 0x7f, 0x31, 0xe1, 0x26, 0x35, 0x3c, 0x4a, 0x2f, 0xab, 0xc4, 0x9a, 0x5e}} ,
678 {{0xab, 0x1b, 0xb5, 0xe5, 0x2b, 0xc3, 0x0e, 0x29, 0xb0, 0xd0, 0x73, 0xe6, 0x4f, 0x64, 0xf2, 0xbc, 0xe4, 0xe4, 0xe1, 0x9a, 0x52, 0x33, 0x2f, 0xbd, 0xcc, 0x03, 0xee, 0x8a, 0xfa, 0x00, 0x5f, 0x50}}},
679{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
680 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
681{{{0xf6, 0xdb, 0x0d, 0x22, 0x3d, 0xb5, 0x14, 0x75, 0x31, 0xf0, 0x81, 0xe2, 0xb9, 0x37, 0xa2, 0xa9, 0x84, 0x11, 0x9a, 0x07, 0xb5, 0x53, 0x89, 0x78, 0xa9, 0x30, 0x27, 0xa1, 0xf1, 0x4e, 0x5c, 0x2e}} ,
682 {{0x8b, 0x00, 0x54, 0xfb, 0x4d, 0xdc, 0xcb, 0x17, 0x35, 0x40, 0xff, 0xb7, 0x8c, 0xfe, 0x4a, 0xe4, 0x4e, 0x99, 0x4e, 0xa8, 0x74, 0x54, 0x5d, 0x5c, 0x96, 0xa3, 0x12, 0x55, 0x36, 0x31, 0x17, 0x5c}}},
683{{{0xce, 0x24, 0xef, 0x7b, 0x86, 0xf2, 0x0f, 0x77, 0xe8, 0x5c, 0x7d, 0x87, 0x38, 0x2d, 0xef, 0xaf, 0xf2, 0x8c, 0x72, 0x2e, 0xeb, 0xb6, 0x55, 0x4b, 0x6e, 0xf1, 0x4e, 0x8a, 0x0e, 0x9a, 0x6c, 0x4c}} ,
684 {{0x25, 0xea, 0x86, 0xc2, 0xd1, 0x4f, 0xb7, 0x3e, 0xa8, 0x5c, 0x8d, 0x66, 0x81, 0x25, 0xed, 0xc5, 0x4c, 0x05, 0xb9, 0xd8, 0xd6, 0x70, 0xbe, 0x73, 0x82, 0xe8, 0xa1, 0xe5, 0x1e, 0x71, 0xd5, 0x26}}},
685{{{0x4e, 0x6d, 0xc3, 0xa7, 0x4f, 0x22, 0x45, 0x26, 0xa2, 0x7e, 0x16, 0xf7, 0xf7, 0x63, 0xdc, 0x86, 0x01, 0x2a, 0x71, 0x38, 0x5c, 0x33, 0xc3, 0xce, 0x30, 0xff, 0xf9, 0x2c, 0x91, 0x71, 0x8a, 0x72}} ,
686 {{0x8c, 0x44, 0x09, 0x28, 0xd5, 0x23, 0xc9, 0x8f, 0xf3, 0x84, 0x45, 0xc6, 0x9a, 0x5e, 0xff, 0xd2, 0xc7, 0x57, 0x93, 0xa3, 0xc1, 0x69, 0xdd, 0x62, 0x0f, 0xda, 0x5c, 0x30, 0x59, 0x5d, 0xe9, 0x4c}}},
687{{{0x92, 0x7e, 0x50, 0x27, 0x72, 0xd7, 0x0c, 0xd6, 0x69, 0x96, 0x81, 0x35, 0x84, 0x94, 0x35, 0x8b, 0x6c, 0xaa, 0x62, 0x86, 0x6e, 0x1c, 0x15, 0xf3, 0x6c, 0xb3, 0xff, 0x65, 0x1b, 0xa2, 0x9b, 0x59}} ,
688 {{0xe2, 0xa9, 0x65, 0x88, 0xc4, 0x50, 0xfa, 0xbb, 0x3b, 0x6e, 0x5f, 0x44, 0x01, 0xca, 0x97, 0xd4, 0xdd, 0xf6, 0xcd, 0x3f, 0x3f, 0xe5, 0x97, 0x67, 0x2b, 0x8c, 0x66, 0x0f, 0x35, 0x9b, 0xf5, 0x07}}},
689{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
690 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
691{{{0xf1, 0x59, 0x27, 0xd8, 0xdb, 0x5a, 0x11, 0x5e, 0x82, 0xf3, 0x38, 0xff, 0x1c, 0xed, 0xfe, 0x3f, 0x64, 0x54, 0x3f, 0x7f, 0xd1, 0x81, 0xed, 0xef, 0x65, 0xc5, 0xcb, 0xfd, 0xe1, 0x80, 0xcd, 0x11}} ,
692 {{0xe0, 0xdb, 0x22, 0x28, 0xe6, 0xff, 0x61, 0x9d, 0x41, 0x14, 0x2d, 0x3b, 0x26, 0x22, 0xdf, 0xf1, 0x34, 0x81, 0xe9, 0x45, 0xee, 0x0f, 0x98, 0x8b, 0xa6, 0x3f, 0xef, 0xf7, 0x43, 0x19, 0xf1, 0x43}}},
693{{{0xee, 0xf3, 0x00, 0xa1, 0x50, 0xde, 0xc0, 0xb6, 0x01, 0xe3, 0x8c, 0x3c, 0x4d, 0x31, 0xd2, 0xb0, 0x58, 0xcd, 0xed, 0x10, 0x4a, 0x7a, 0xef, 0x80, 0xa9, 0x19, 0x32, 0xf3, 0xd8, 0x33, 0x8c, 0x06}} ,
694 {{0xcb, 0x7d, 0x4f, 0xff, 0x30, 0xd8, 0x12, 0x3b, 0x39, 0x1c, 0x06, 0xf9, 0x4c, 0x34, 0x35, 0x71, 0xb5, 0x16, 0x94, 0x67, 0xdf, 0xee, 0x11, 0xde, 0xa4, 0x1d, 0x88, 0x93, 0x35, 0xa9, 0x32, 0x10}}},
695{{{0xe9, 0xc3, 0xbc, 0x7b, 0x5c, 0xfc, 0xb2, 0xf9, 0xc9, 0x2f, 0xe5, 0xba, 0x3a, 0x0b, 0xab, 0x64, 0x38, 0x6f, 0x5b, 0x4b, 0x93, 0xda, 0x64, 0xec, 0x4d, 0x3d, 0xa0, 0xf5, 0xbb, 0xba, 0x47, 0x48}} ,
696 {{0x60, 0xbc, 0x45, 0x1f, 0x23, 0xa2, 0x3b, 0x70, 0x76, 0xe6, 0x97, 0x99, 0x4f, 0x77, 0x54, 0x67, 0x30, 0x9a, 0xe7, 0x66, 0xd6, 0xcd, 0x2e, 0x51, 0x24, 0x2c, 0x42, 0x4a, 0x11, 0xfe, 0x6f, 0x7e}}},
697{{{0x87, 0xc0, 0xb1, 0xf0, 0xa3, 0x6f, 0x0c, 0x93, 0xa9, 0x0a, 0x72, 0xef, 0x5c, 0xbe, 0x65, 0x35, 0xa7, 0x6a, 0x4e, 0x2c, 0xbf, 0x21, 0x23, 0xe8, 0x2f, 0x97, 0xc7, 0x3e, 0xc8, 0x17, 0xac, 0x1e}} ,
698 {{0x7b, 0xef, 0x21, 0xe5, 0x40, 0xcc, 0x1e, 0xdc, 0xd6, 0xbd, 0x97, 0x7a, 0x7c, 0x75, 0x86, 0x7a, 0x25, 0x5a, 0x6e, 0x7c, 0xe5, 0x51, 0x3c, 0x1b, 0x5b, 0x82, 0x9a, 0x07, 0x60, 0xa1, 0x19, 0x04}}},
699{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
700 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
701{{{0x96, 0x88, 0xa6, 0xab, 0x8f, 0xe3, 0x3a, 0x49, 0xf8, 0xfe, 0x34, 0xe7, 0x6a, 0xb2, 0xfe, 0x40, 0x26, 0x74, 0x57, 0x4c, 0xf6, 0xd4, 0x99, 0xce, 0x5d, 0x7b, 0x2f, 0x67, 0xd6, 0x5a, 0xe4, 0x4e}} ,
702 {{0x5c, 0x82, 0xb3, 0xbd, 0x55, 0x25, 0xf6, 0x6a, 0x93, 0xa4, 0x02, 0xc6, 0x7d, 0x5c, 0xb1, 0x2b, 0x5b, 0xff, 0xfb, 0x56, 0xf8, 0x01, 0x41, 0x90, 0xc6, 0xb6, 0xac, 0x4f, 0xfe, 0xa7, 0x41, 0x70}}},
703{{{0xdb, 0xfa, 0x9b, 0x2c, 0xd4, 0x23, 0x67, 0x2c, 0x8a, 0x63, 0x6c, 0x07, 0x26, 0x48, 0x4f, 0xc2, 0x03, 0xd2, 0x53, 0x20, 0x28, 0xed, 0x65, 0x71, 0x47, 0xa9, 0x16, 0x16, 0x12, 0xbc, 0x28, 0x33}} ,
704 {{0x39, 0xc0, 0xfa, 0xfa, 0xcd, 0x33, 0x43, 0xc7, 0x97, 0x76, 0x9b, 0x93, 0x91, 0x72, 0xeb, 0xc5, 0x18, 0x67, 0x4c, 0x11, 0xf0, 0xf4, 0xe5, 0x73, 0xb2, 0x5c, 0x1b, 0xc2, 0x26, 0x3f, 0xbf, 0x2b}}},
705{{{0x86, 0xe6, 0x8c, 0x1d, 0xdf, 0xca, 0xfc, 0xd5, 0xf8, 0x3a, 0xc3, 0x44, 0x72, 0xe6, 0x78, 0x9d, 0x2b, 0x97, 0xf8, 0x28, 0x45, 0xb4, 0x20, 0xc9, 0x2a, 0x8c, 0x67, 0xaa, 0x11, 0xc5, 0x5b, 0x2f}} ,
706 {{0x17, 0x0f, 0x86, 0x52, 0xd7, 0x9d, 0xc3, 0x44, 0x51, 0x76, 0x32, 0x65, 0xb4, 0x37, 0x81, 0x99, 0x46, 0x37, 0x62, 0xed, 0xcf, 0x64, 0x9d, 0x72, 0x40, 0x7a, 0x4c, 0x0b, 0x76, 0x2a, 0xfb, 0x56}}},
707{{{0x33, 0xa7, 0x90, 0x7c, 0xc3, 0x6f, 0x17, 0xa5, 0xa0, 0x67, 0x72, 0x17, 0xea, 0x7e, 0x63, 0x14, 0x83, 0xde, 0xc1, 0x71, 0x2d, 0x41, 0x32, 0x7a, 0xf3, 0xd1, 0x2b, 0xd8, 0x2a, 0xa6, 0x46, 0x36}} ,
708 {{0xac, 0xcc, 0x6b, 0x7c, 0xf9, 0xb8, 0x8b, 0x08, 0x5c, 0xd0, 0x7d, 0x8f, 0x73, 0xea, 0x20, 0xda, 0x86, 0xca, 0x00, 0xc7, 0xad, 0x73, 0x4d, 0xe9, 0xe8, 0xa9, 0xda, 0x1f, 0x03, 0x06, 0xdd, 0x24}}},
709{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
710 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
711{{{0x9c, 0xb2, 0x61, 0x0a, 0x98, 0x2a, 0xa5, 0xd7, 0xee, 0xa9, 0xac, 0x65, 0xcb, 0x0a, 0x1e, 0xe2, 0xbe, 0xdc, 0x85, 0x59, 0x0f, 0x9c, 0xa6, 0x57, 0x34, 0xa5, 0x87, 0xeb, 0x7b, 0x1e, 0x0c, 0x3c}} ,
712 {{0x2f, 0xbd, 0x84, 0x63, 0x0d, 0xb5, 0xa0, 0xf0, 0x4b, 0x9e, 0x93, 0xc6, 0x34, 0x9a, 0x34, 0xff, 0x73, 0x19, 0x2f, 0x6e, 0x54, 0x45, 0x2c, 0x92, 0x31, 0x76, 0x34, 0xf1, 0xb2, 0x26, 0xe8, 0x74}}},
713{{{0x0a, 0x67, 0x90, 0x6d, 0x0c, 0x4c, 0xcc, 0xc0, 0xe6, 0xbd, 0xa7, 0x5e, 0x55, 0x8c, 0xcd, 0x58, 0x9b, 0x11, 0xa2, 0xbb, 0x4b, 0xb1, 0x43, 0x04, 0x3c, 0x55, 0xed, 0x23, 0xfe, 0xcd, 0xb1, 0x53}} ,
714 {{0x05, 0xfb, 0x75, 0xf5, 0x01, 0xaf, 0x38, 0x72, 0x58, 0xfc, 0x04, 0x29, 0x34, 0x7a, 0x67, 0xa2, 0x08, 0x50, 0x6e, 0xd0, 0x2b, 0x73, 0xd5, 0xb8, 0xe4, 0x30, 0x96, 0xad, 0x45, 0xdf, 0xa6, 0x5c}}},
715{{{0x0d, 0x88, 0x1a, 0x90, 0x7e, 0xdc, 0xd8, 0xfe, 0xc1, 0x2f, 0x5d, 0x67, 0xee, 0x67, 0x2f, 0xed, 0x6f, 0x55, 0x43, 0x5f, 0x87, 0x14, 0x35, 0x42, 0xd3, 0x75, 0xae, 0xd5, 0xd3, 0x85, 0x1a, 0x76}} ,
716 {{0x87, 0xc8, 0xa0, 0x6e, 0xe1, 0xb0, 0xad, 0x6a, 0x4a, 0x34, 0x71, 0xed, 0x7c, 0xd6, 0x44, 0x03, 0x65, 0x4a, 0x5c, 0x5c, 0x04, 0xf5, 0x24, 0x3f, 0xb0, 0x16, 0x5e, 0x8c, 0xb2, 0xd2, 0xc5, 0x20}}},
717{{{0x98, 0x83, 0xc2, 0x37, 0xa0, 0x41, 0xa8, 0x48, 0x5c, 0x5f, 0xbf, 0xc8, 0xfa, 0x24, 0xe0, 0x59, 0x2c, 0xbd, 0xf6, 0x81, 0x7e, 0x88, 0xe6, 0xca, 0x04, 0xd8, 0x5d, 0x60, 0xbb, 0x74, 0xa7, 0x0b}} ,
718 {{0x21, 0x13, 0x91, 0xbf, 0x77, 0x7a, 0x33, 0xbc, 0xe9, 0x07, 0x39, 0x0a, 0xdd, 0x7d, 0x06, 0x10, 0x9a, 0xee, 0x47, 0x73, 0x1b, 0x15, 0x5a, 0xfb, 0xcd, 0x4d, 0xd0, 0xd2, 0x3a, 0x01, 0xba, 0x54}}},
719{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
720 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
721{{{0x48, 0xd5, 0x39, 0x4a, 0x0b, 0x20, 0x6a, 0x43, 0xa0, 0x07, 0x82, 0x5e, 0x49, 0x7c, 0xc9, 0x47, 0xf1, 0x7c, 0x37, 0xb9, 0x23, 0xef, 0x6b, 0x46, 0x45, 0x8c, 0x45, 0x76, 0xdf, 0x14, 0x6b, 0x6e}} ,
722 {{0x42, 0xc9, 0xca, 0x29, 0x4c, 0x76, 0x37, 0xda, 0x8a, 0x2d, 0x7c, 0x3a, 0x58, 0xf2, 0x03, 0xb4, 0xb5, 0xb9, 0x1a, 0x13, 0x2d, 0xde, 0x5f, 0x6b, 0x9d, 0xba, 0x52, 0xc9, 0x5d, 0xb3, 0xf3, 0x30}}},
723{{{0x4c, 0x6f, 0xfe, 0x6b, 0x0c, 0x62, 0xd7, 0x48, 0x71, 0xef, 0xb1, 0x85, 0x79, 0xc0, 0xed, 0x24, 0xb1, 0x08, 0x93, 0x76, 0x8e, 0xf7, 0x38, 0x8e, 0xeb, 0xfe, 0x80, 0x40, 0xaf, 0x90, 0x64, 0x49}} ,
724 {{0x4a, 0x88, 0xda, 0xc1, 0x98, 0x44, 0x3c, 0x53, 0x4e, 0xdb, 0x4b, 0xb9, 0x12, 0x5f, 0xcd, 0x08, 0x04, 0xef, 0x75, 0xe7, 0xb1, 0x3a, 0xe5, 0x07, 0xfa, 0xca, 0x65, 0x7b, 0x72, 0x10, 0x64, 0x7f}}},
725{{{0x3d, 0x81, 0xf0, 0xeb, 0x16, 0xfd, 0x58, 0x33, 0x8d, 0x7c, 0x1a, 0xfb, 0x20, 0x2c, 0x8a, 0xee, 0x90, 0xbb, 0x33, 0x6d, 0x45, 0xe9, 0x8e, 0x99, 0x85, 0xe1, 0x08, 0x1f, 0xc5, 0xf1, 0xb5, 0x46}} ,
726 {{0xe4, 0xe7, 0x43, 0x4b, 0xa0, 0x3f, 0x2b, 0x06, 0xba, 0x17, 0xae, 0x3d, 0xe6, 0xce, 0xbd, 0xb8, 0xed, 0x74, 0x11, 0x35, 0xec, 0x96, 0xfe, 0x31, 0xe3, 0x0e, 0x7a, 0x4e, 0xc9, 0x1d, 0xcb, 0x20}}},
727{{{0xe0, 0x67, 0xe9, 0x7b, 0xdb, 0x96, 0x5c, 0xb0, 0x32, 0xd0, 0x59, 0x31, 0x90, 0xdc, 0x92, 0x97, 0xac, 0x09, 0x38, 0x31, 0x0f, 0x7e, 0xd6, 0x5d, 0xd0, 0x06, 0xb6, 0x1f, 0xea, 0xf0, 0x5b, 0x07}} ,
728 {{0x81, 0x9f, 0xc7, 0xde, 0x6b, 0x41, 0x22, 0x35, 0x14, 0x67, 0x77, 0x3e, 0x90, 0x81, 0xb0, 0xd9, 0x85, 0x4c, 0xca, 0x9b, 0x3f, 0x04, 0x59, 0xd6, 0xaa, 0x17, 0xc3, 0x88, 0x34, 0x37, 0xba, 0x43}}},
729{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
730 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
731{{{0x4c, 0xb6, 0x69, 0xc8, 0x81, 0x95, 0x94, 0x33, 0x92, 0x34, 0xe9, 0x3c, 0x84, 0x0d, 0x3d, 0x5a, 0x37, 0x9c, 0x22, 0xa0, 0xaa, 0x65, 0xce, 0xb4, 0xc2, 0x2d, 0x66, 0x67, 0x02, 0xff, 0x74, 0x10}} ,
732 {{0x22, 0xb0, 0xd5, 0xe6, 0xc7, 0xef, 0xb1, 0xa7, 0x13, 0xda, 0x60, 0xb4, 0x80, 0xc1, 0x42, 0x7d, 0x10, 0x70, 0x97, 0x04, 0x4d, 0xda, 0x23, 0x89, 0xc2, 0x0e, 0x68, 0xcb, 0xde, 0xe0, 0x9b, 0x29}}},
733{{{0x33, 0xfe, 0x42, 0x2a, 0x36, 0x2b, 0x2e, 0x36, 0x64, 0x5c, 0x8b, 0xcc, 0x81, 0x6a, 0x15, 0x08, 0xa1, 0x27, 0xe8, 0x57, 0xe5, 0x78, 0x8e, 0xf2, 0x58, 0x19, 0x12, 0x42, 0xae, 0xc4, 0x63, 0x3e}} ,
734 {{0x78, 0x96, 0x9c, 0xa7, 0xca, 0x80, 0xae, 0x02, 0x85, 0xb1, 0x7c, 0x04, 0x5c, 0xc1, 0x5b, 0x26, 0xc1, 0xba, 0xed, 0xa5, 0x59, 0x70, 0x85, 0x8c, 0x8c, 0xe8, 0x87, 0xac, 0x6a, 0x28, 0x99, 0x35}}},
735{{{0x9f, 0x04, 0x08, 0x28, 0xbe, 0x87, 0xda, 0x80, 0x28, 0x38, 0xde, 0x9f, 0xcd, 0xe4, 0xe3, 0x62, 0xfb, 0x2e, 0x46, 0x8d, 0x01, 0xb3, 0x06, 0x51, 0xd4, 0x19, 0x3b, 0x11, 0xfa, 0xe2, 0xad, 0x1e}} ,
736 {{0xa0, 0x20, 0x99, 0x69, 0x0a, 0xae, 0xa3, 0x70, 0x4e, 0x64, 0x80, 0xb7, 0x85, 0x9c, 0x87, 0x54, 0x43, 0x43, 0x55, 0x80, 0x6d, 0x8d, 0x7c, 0xa9, 0x64, 0xca, 0x6c, 0x2e, 0x21, 0xd8, 0xc8, 0x6c}}},
737{{{0x91, 0x4a, 0x07, 0xad, 0x08, 0x75, 0xc1, 0x4f, 0xa4, 0xb2, 0xc3, 0x6f, 0x46, 0x3e, 0xb1, 0xce, 0x52, 0xab, 0x67, 0x09, 0x54, 0x48, 0x6b, 0x6c, 0xd7, 0x1d, 0x71, 0x76, 0xcb, 0xff, 0xdd, 0x31}} ,
738 {{0x36, 0x88, 0xfa, 0xfd, 0xf0, 0x36, 0x6f, 0x07, 0x74, 0x88, 0x50, 0xd0, 0x95, 0x38, 0x4a, 0x48, 0x2e, 0x07, 0x64, 0x97, 0x11, 0x76, 0x01, 0x1a, 0x27, 0x4d, 0x8e, 0x25, 0x9a, 0x9b, 0x1c, 0x22}}},
739{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
740 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
741{{{0xbe, 0x57, 0xbd, 0x0e, 0x0f, 0xac, 0x5e, 0x76, 0xa3, 0x71, 0xad, 0x2b, 0x10, 0x45, 0x02, 0xec, 0x59, 0xd5, 0x5d, 0xa9, 0x44, 0xcc, 0x25, 0x4c, 0xb3, 0x3c, 0x5b, 0x69, 0x07, 0x55, 0x26, 0x6b}} ,
742 {{0x30, 0x6b, 0xd4, 0xa7, 0x51, 0x29, 0xe3, 0xf9, 0x7a, 0x75, 0x2a, 0x82, 0x2f, 0xd6, 0x1d, 0x99, 0x2b, 0x80, 0xd5, 0x67, 0x1e, 0x15, 0x9d, 0xca, 0xfd, 0xeb, 0xac, 0x97, 0x35, 0x09, 0x7f, 0x3f}}},
743{{{0x35, 0x0d, 0x34, 0x0a, 0xb8, 0x67, 0x56, 0x29, 0x20, 0xf3, 0x19, 0x5f, 0xe2, 0x83, 0x42, 0x73, 0x53, 0xa8, 0xc5, 0x02, 0x19, 0x33, 0xb4, 0x64, 0xbd, 0xc3, 0x87, 0x8c, 0xd7, 0x76, 0xed, 0x25}} ,
744 {{0x47, 0x39, 0x37, 0x76, 0x0d, 0x1d, 0x0c, 0xf5, 0x5a, 0x6d, 0x43, 0x88, 0x99, 0x15, 0xb4, 0x52, 0x0f, 0x2a, 0xb3, 0xb0, 0x3f, 0xa6, 0xb3, 0x26, 0xb3, 0xc7, 0x45, 0xf5, 0x92, 0x5f, 0x9b, 0x17}}},
745{{{0x9d, 0x23, 0xbd, 0x15, 0xfe, 0x52, 0x52, 0x15, 0x26, 0x79, 0x86, 0xba, 0x06, 0x56, 0x66, 0xbb, 0x8c, 0x2e, 0x10, 0x11, 0xd5, 0x4a, 0x18, 0x52, 0xda, 0x84, 0x44, 0xf0, 0x3e, 0xe9, 0x8c, 0x35}} ,
746 {{0xad, 0xa0, 0x41, 0xec, 0xc8, 0x4d, 0xb9, 0xd2, 0x6e, 0x96, 0x4e, 0x5b, 0xc5, 0xc2, 0xa0, 0x1b, 0xcf, 0x0c, 0xbf, 0x17, 0x66, 0x57, 0xc1, 0x17, 0x90, 0x45, 0x71, 0xc2, 0xe1, 0x24, 0xeb, 0x27}}},
747{{{0x2c, 0xb9, 0x42, 0xa4, 0xaf, 0x3b, 0x42, 0x0e, 0xc2, 0x0f, 0xf2, 0xea, 0x83, 0xaf, 0x9a, 0x13, 0x17, 0xb0, 0xbd, 0x89, 0x17, 0xe3, 0x72, 0xcb, 0x0e, 0x76, 0x7e, 0x41, 0x63, 0x04, 0x88, 0x71}} ,
748 {{0x75, 0x78, 0x38, 0x86, 0x57, 0xdd, 0x9f, 0xee, 0x54, 0x70, 0x65, 0xbf, 0xf1, 0x2c, 0xe0, 0x39, 0x0d, 0xe3, 0x89, 0xfd, 0x8e, 0x93, 0x4f, 0x43, 0xdc, 0xd5, 0x5b, 0xde, 0xf9, 0x98, 0xe5, 0x7b}}},
749{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
750 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
751{{{0xe7, 0x3b, 0x65, 0x11, 0xdf, 0xb2, 0xf2, 0x63, 0x94, 0x12, 0x6f, 0x5c, 0x9e, 0x77, 0xc1, 0xb6, 0xd8, 0xab, 0x58, 0x7a, 0x1d, 0x95, 0x73, 0xdd, 0xe7, 0xe3, 0x6f, 0xf2, 0x03, 0x1d, 0xdb, 0x76}} ,
752 {{0xae, 0x06, 0x4e, 0x2c, 0x52, 0x1b, 0xbc, 0x5a, 0x5a, 0xa5, 0xbe, 0x27, 0xbd, 0xeb, 0xe1, 0x14, 0x17, 0x68, 0x26, 0x07, 0x03, 0xd1, 0x18, 0x0b, 0xdf, 0xf1, 0x06, 0x5c, 0xa6, 0x1b, 0xb9, 0x24}}},
753{{{0xc5, 0x66, 0x80, 0x13, 0x0e, 0x48, 0x8c, 0x87, 0x31, 0x84, 0xb4, 0x60, 0xed, 0xc5, 0xec, 0xb6, 0xc5, 0x05, 0x33, 0x5f, 0x2f, 0x7d, 0x40, 0xb6, 0x32, 0x1d, 0x38, 0x74, 0x1b, 0xf1, 0x09, 0x3d}} ,
754 {{0xd4, 0x69, 0x82, 0xbc, 0x8d, 0xf8, 0x34, 0x36, 0x75, 0x55, 0x18, 0x55, 0x58, 0x3c, 0x79, 0xaf, 0x26, 0x80, 0xab, 0x9b, 0x95, 0x00, 0xf1, 0xcb, 0xda, 0xc1, 0x9f, 0xf6, 0x2f, 0xa2, 0xf4, 0x45}}},
755{{{0x17, 0xbe, 0xeb, 0x85, 0xed, 0x9e, 0xcd, 0x56, 0xf5, 0x17, 0x45, 0x42, 0xb4, 0x1f, 0x44, 0x4c, 0x05, 0x74, 0x15, 0x47, 0x00, 0xc6, 0x6a, 0x3d, 0x24, 0x09, 0x0d, 0x58, 0xb1, 0x42, 0xd7, 0x04}} ,
756 {{0x8d, 0xbd, 0xa3, 0xc4, 0x06, 0x9b, 0x1f, 0x90, 0x58, 0x60, 0x74, 0xb2, 0x00, 0x3b, 0x3c, 0xd2, 0xda, 0x82, 0xbb, 0x10, 0x90, 0x69, 0x92, 0xa9, 0xb4, 0x30, 0x81, 0xe3, 0x7c, 0xa8, 0x89, 0x45}}},
757{{{0x3f, 0xdc, 0x05, 0xcb, 0x41, 0x3c, 0xc8, 0x23, 0x04, 0x2c, 0x38, 0x99, 0xe3, 0x68, 0x55, 0xf9, 0xd3, 0x32, 0xc7, 0xbf, 0xfa, 0xd4, 0x1b, 0x5d, 0xde, 0xdc, 0x10, 0x42, 0xc0, 0x42, 0xd9, 0x75}} ,
758 {{0x2d, 0xab, 0x35, 0x4e, 0x87, 0xc4, 0x65, 0x97, 0x67, 0x24, 0xa4, 0x47, 0xad, 0x3f, 0x8e, 0xf3, 0xcb, 0x31, 0x17, 0x77, 0xc5, 0xe2, 0xd7, 0x8f, 0x3c, 0xc1, 0xcd, 0x56, 0x48, 0xc1, 0x6c, 0x69}}},
759{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
760 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
761{{{0x14, 0xae, 0x5f, 0x88, 0x7b, 0xa5, 0x90, 0xdf, 0x10, 0xb2, 0x8b, 0x5e, 0x24, 0x17, 0xc3, 0xa3, 0xd4, 0x0f, 0x92, 0x61, 0x1a, 0x19, 0x5a, 0xad, 0x76, 0xbd, 0xd8, 0x1c, 0xdd, 0xe0, 0x12, 0x6d}} ,
762 {{0x8e, 0xbd, 0x70, 0x8f, 0x02, 0xa3, 0x24, 0x4d, 0x5a, 0x67, 0xc4, 0xda, 0xf7, 0x20, 0x0f, 0x81, 0x5b, 0x7a, 0x05, 0x24, 0x67, 0x83, 0x0b, 0x2a, 0x80, 0xe7, 0xfd, 0x74, 0x4b, 0x9e, 0x5c, 0x0d}}},
763{{{0x94, 0xd5, 0x5f, 0x1f, 0xa2, 0xfb, 0xeb, 0xe1, 0x07, 0x34, 0xf8, 0x20, 0xad, 0x81, 0x30, 0x06, 0x2d, 0xa1, 0x81, 0x95, 0x36, 0xcf, 0x11, 0x0b, 0xaf, 0xc1, 0x2b, 0x9a, 0x6c, 0x55, 0xc1, 0x16}} ,
764 {{0x36, 0x4f, 0xf1, 0x5e, 0x74, 0x35, 0x13, 0x28, 0xd7, 0x11, 0xcf, 0xb8, 0xde, 0x93, 0xb3, 0x05, 0xb8, 0xb5, 0x73, 0xe9, 0xeb, 0xad, 0x19, 0x1e, 0x89, 0x0f, 0x8b, 0x15, 0xd5, 0x8c, 0xe3, 0x23}}},
765{{{0x33, 0x79, 0xe7, 0x18, 0xe6, 0x0f, 0x57, 0x93, 0x15, 0xa0, 0xa7, 0xaa, 0xc4, 0xbf, 0x4f, 0x30, 0x74, 0x95, 0x5e, 0x69, 0x4a, 0x5b, 0x45, 0xe4, 0x00, 0xeb, 0x23, 0x74, 0x4c, 0xdf, 0x6b, 0x45}} ,
766 {{0x97, 0x29, 0x6c, 0xc4, 0x42, 0x0b, 0xdd, 0xc0, 0x29, 0x5c, 0x9b, 0x34, 0x97, 0xd0, 0xc7, 0x79, 0x80, 0x63, 0x74, 0xe4, 0x8e, 0x37, 0xb0, 0x2b, 0x7c, 0xe8, 0x68, 0x6c, 0xc3, 0x82, 0x97, 0x57}}},
767{{{0x22, 0xbe, 0x83, 0xb6, 0x4b, 0x80, 0x6b, 0x43, 0x24, 0x5e, 0xef, 0x99, 0x9b, 0xa8, 0xfc, 0x25, 0x8d, 0x3b, 0x03, 0x94, 0x2b, 0x3e, 0xe7, 0x95, 0x76, 0x9b, 0xcc, 0x15, 0xdb, 0x32, 0xe6, 0x66}} ,
768 {{0x84, 0xf0, 0x4a, 0x13, 0xa6, 0xd6, 0xfa, 0x93, 0x46, 0x07, 0xf6, 0x7e, 0x5c, 0x6d, 0x5e, 0xf6, 0xa6, 0xe7, 0x48, 0xf0, 0x06, 0xea, 0xff, 0x90, 0xc1, 0xcc, 0x4c, 0x19, 0x9c, 0x3c, 0x4e, 0x53}}},
769{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
770 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
771{{{0x2a, 0x50, 0xe3, 0x07, 0x15, 0x59, 0xf2, 0x8b, 0x81, 0xf2, 0xf3, 0xd3, 0x6c, 0x99, 0x8c, 0x70, 0x67, 0xec, 0xcc, 0xee, 0x9e, 0x59, 0x45, 0x59, 0x7d, 0x47, 0x75, 0x69, 0xf5, 0x24, 0x93, 0x5d}} ,
772 {{0x6a, 0x4f, 0x1b, 0xbe, 0x6b, 0x30, 0xcf, 0x75, 0x46, 0xe3, 0x7b, 0x9d, 0xfc, 0xcd, 0xd8, 0x5c, 0x1f, 0xb4, 0xc8, 0xe2, 0x24, 0xec, 0x1a, 0x28, 0x05, 0x32, 0x57, 0xfd, 0x3c, 0x5a, 0x98, 0x10}}},
773{{{0xa3, 0xdb, 0xf7, 0x30, 0xd8, 0xc2, 0x9a, 0xe1, 0xd3, 0xce, 0x22, 0xe5, 0x80, 0x1e, 0xd9, 0xe4, 0x1f, 0xab, 0xc0, 0x71, 0x1a, 0x86, 0x0e, 0x27, 0x99, 0x5b, 0xfa, 0x76, 0x99, 0xb0, 0x08, 0x3c}} ,
774 {{0x2a, 0x93, 0xd2, 0x85, 0x1b, 0x6a, 0x5d, 0xa6, 0xee, 0xd1, 0xd1, 0x33, 0xbd, 0x6a, 0x36, 0x73, 0x37, 0x3a, 0x44, 0xb4, 0xec, 0xa9, 0x7a, 0xde, 0x83, 0x40, 0xd7, 0xdf, 0x28, 0xba, 0xa2, 0x30}}},
775{{{0xd3, 0xb5, 0x6d, 0x05, 0x3f, 0x9f, 0xf3, 0x15, 0x8d, 0x7c, 0xca, 0xc9, 0xfc, 0x8a, 0x7c, 0x94, 0xb0, 0x63, 0x36, 0x9b, 0x78, 0xd1, 0x91, 0x1f, 0x93, 0xd8, 0x57, 0x43, 0xde, 0x76, 0xa3, 0x43}} ,
776 {{0x9b, 0x35, 0xe2, 0xa9, 0x3d, 0x32, 0x1e, 0xbb, 0x16, 0x28, 0x70, 0xe9, 0x45, 0x2f, 0x8f, 0x70, 0x7f, 0x08, 0x7e, 0x53, 0xc4, 0x7a, 0xbf, 0xf7, 0xe1, 0xa4, 0x6a, 0xd8, 0xac, 0x64, 0x1b, 0x11}}},
777{{{0xb2, 0xeb, 0x47, 0x46, 0x18, 0x3e, 0x1f, 0x99, 0x0c, 0xcc, 0xf1, 0x2c, 0xe0, 0xe7, 0x8f, 0xe0, 0x01, 0x7e, 0x65, 0xb8, 0x0c, 0xd0, 0xfb, 0xc8, 0xb9, 0x90, 0x98, 0x33, 0x61, 0x3b, 0xd8, 0x27}} ,
778 {{0xa0, 0xbe, 0x72, 0x3a, 0x50, 0x4b, 0x74, 0xab, 0x01, 0xc8, 0x93, 0xc5, 0xe4, 0xc7, 0x08, 0x6c, 0xb4, 0xca, 0xee, 0xeb, 0x8e, 0xd7, 0x4e, 0x26, 0xc6, 0x1d, 0xe2, 0x71, 0xaf, 0x89, 0xa0, 0x2a}}},
779{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
780 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
781{{{0x98, 0x0b, 0xe4, 0xde, 0xdb, 0xa8, 0xfa, 0x82, 0x74, 0x06, 0x52, 0x6d, 0x08, 0x52, 0x8a, 0xff, 0x62, 0xc5, 0x6a, 0x44, 0x0f, 0x51, 0x8c, 0x1f, 0x6e, 0xb6, 0xc6, 0x2c, 0x81, 0xd3, 0x76, 0x46}} ,
782 {{0xf4, 0x29, 0x74, 0x2e, 0x80, 0xa7, 0x1a, 0x8f, 0xf6, 0xbd, 0xd6, 0x8e, 0xbf, 0xc1, 0x95, 0x2a, 0xeb, 0xa0, 0x7f, 0x45, 0xa0, 0x50, 0x14, 0x05, 0xb1, 0x57, 0x4c, 0x74, 0xb7, 0xe2, 0x89, 0x7d}}},
783{{{0x07, 0xee, 0xa7, 0xad, 0xb7, 0x09, 0x0b, 0x49, 0x4e, 0xbf, 0xca, 0xe5, 0x21, 0xe6, 0xe6, 0xaf, 0xd5, 0x67, 0xf3, 0xce, 0x7e, 0x7c, 0x93, 0x7b, 0x5a, 0x10, 0x12, 0x0e, 0x6c, 0x06, 0x11, 0x75}} ,
784 {{0xd5, 0xfc, 0x86, 0xa3, 0x3b, 0xa3, 0x3e, 0x0a, 0xfb, 0x0b, 0xf7, 0x36, 0xb1, 0x5b, 0xda, 0x70, 0xb7, 0x00, 0xa7, 0xda, 0x88, 0x8f, 0x84, 0xa8, 0xbc, 0x1c, 0x39, 0xb8, 0x65, 0xf3, 0x4d, 0x60}}},
785{{{0x96, 0x9d, 0x31, 0xf4, 0xa2, 0xbe, 0x81, 0xb9, 0xa5, 0x59, 0x9e, 0xba, 0x07, 0xbe, 0x74, 0x58, 0xd8, 0xeb, 0xc5, 0x9f, 0x3d, 0xd1, 0xf4, 0xae, 0xce, 0x53, 0xdf, 0x4f, 0xc7, 0x2a, 0x89, 0x4d}} ,
786 {{0x29, 0xd8, 0xf2, 0xaa, 0xe9, 0x0e, 0xf7, 0x2e, 0x5f, 0x9d, 0x8a, 0x5b, 0x09, 0xed, 0xc9, 0x24, 0x22, 0xf4, 0x0f, 0x25, 0x8f, 0x1c, 0x84, 0x6e, 0x34, 0x14, 0x6c, 0xea, 0xb3, 0x86, 0x5d, 0x04}}},
787{{{0x07, 0x98, 0x61, 0xe8, 0x6a, 0xd2, 0x81, 0x49, 0x25, 0xd5, 0x5b, 0x18, 0xc7, 0x35, 0x52, 0x51, 0xa4, 0x46, 0xad, 0x18, 0x0d, 0xc9, 0x5f, 0x18, 0x91, 0x3b, 0xb4, 0xc0, 0x60, 0x59, 0x8d, 0x66}} ,
788 {{0x03, 0x1b, 0x79, 0x53, 0x6e, 0x24, 0xae, 0x57, 0xd9, 0x58, 0x09, 0x85, 0x48, 0xa2, 0xd3, 0xb5, 0xe2, 0x4d, 0x11, 0x82, 0xe6, 0x86, 0x3c, 0xe9, 0xb1, 0x00, 0x19, 0xc2, 0x57, 0xf7, 0x66, 0x7a}}},
789{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
790 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
791{{{0x0f, 0xe3, 0x89, 0x03, 0xd7, 0x22, 0x95, 0x9f, 0xca, 0xb4, 0x8d, 0x9e, 0x6d, 0x97, 0xff, 0x8d, 0x21, 0x59, 0x07, 0xef, 0x03, 0x2d, 0x5e, 0xf8, 0x44, 0x46, 0xe7, 0x85, 0x80, 0xc5, 0x89, 0x50}} ,
792 {{0x8b, 0xd8, 0x53, 0x86, 0x24, 0x86, 0x29, 0x52, 0x01, 0xfa, 0x20, 0xc3, 0x4e, 0x95, 0xcb, 0xad, 0x7b, 0x34, 0x94, 0x30, 0xb7, 0x7a, 0xfa, 0x96, 0x41, 0x60, 0x2b, 0xcb, 0x59, 0xb9, 0xca, 0x50}}},
793{{{0xc2, 0x5b, 0x9b, 0x78, 0x23, 0x1b, 0x3a, 0x88, 0x94, 0x5f, 0x0a, 0x9b, 0x98, 0x2b, 0x6e, 0x53, 0x11, 0xf6, 0xff, 0xc6, 0x7d, 0x42, 0xcc, 0x02, 0x80, 0x40, 0x0d, 0x1e, 0xfb, 0xaf, 0x61, 0x07}} ,
794 {{0xb0, 0xe6, 0x2f, 0x81, 0x70, 0xa1, 0x2e, 0x39, 0x04, 0x7c, 0xc4, 0x2c, 0x87, 0x45, 0x4a, 0x5b, 0x69, 0x97, 0xac, 0x6d, 0x2c, 0x10, 0x42, 0x7c, 0x3b, 0x15, 0x70, 0x60, 0x0e, 0x11, 0x6d, 0x3a}}},
795{{{0x9b, 0x18, 0x80, 0x5e, 0xdb, 0x05, 0xbd, 0xc6, 0xb7, 0x3c, 0xc2, 0x40, 0x4d, 0x5d, 0xce, 0x97, 0x8a, 0x34, 0x15, 0xab, 0x28, 0x5d, 0x10, 0xf0, 0x37, 0x0c, 0xcc, 0x16, 0xfa, 0x1f, 0x33, 0x0d}} ,
796 {{0x19, 0xf9, 0x35, 0xaa, 0x59, 0x1a, 0x0c, 0x5c, 0x06, 0xfc, 0x6a, 0x0b, 0x97, 0x53, 0x36, 0xfc, 0x2a, 0xa5, 0x5a, 0x9b, 0x30, 0xef, 0x23, 0xaf, 0x39, 0x5d, 0x9a, 0x6b, 0x75, 0x57, 0x48, 0x0b}}},
797{{{0x26, 0xdc, 0x76, 0x3b, 0xfc, 0xf9, 0x9c, 0x3f, 0x89, 0x0b, 0x62, 0x53, 0xaf, 0x83, 0x01, 0x2e, 0xbc, 0x6a, 0xc6, 0x03, 0x0d, 0x75, 0x2a, 0x0d, 0xe6, 0x94, 0x54, 0xcf, 0xb3, 0xe5, 0x96, 0x25}} ,
798 {{0xfe, 0x82, 0xb1, 0x74, 0x31, 0x8a, 0xa7, 0x6f, 0x56, 0xbd, 0x8d, 0xf4, 0xe0, 0x94, 0x51, 0x59, 0xde, 0x2c, 0x5a, 0xf4, 0x84, 0x6b, 0x4a, 0x88, 0x93, 0xc0, 0x0c, 0x9a, 0xac, 0xa7, 0xa0, 0x68}}},
799{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
800 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
801{{{0x25, 0x0d, 0xd6, 0xc7, 0x23, 0x47, 0x10, 0xad, 0xc7, 0x08, 0x5c, 0x87, 0x87, 0x93, 0x98, 0x18, 0xb8, 0xd3, 0x9c, 0xac, 0x5a, 0x3d, 0xc5, 0x75, 0xf8, 0x49, 0x32, 0x14, 0xcc, 0x51, 0x96, 0x24}} ,
802 {{0x65, 0x9c, 0x5d, 0xf0, 0x37, 0x04, 0xf0, 0x34, 0x69, 0x2a, 0xf0, 0xa5, 0x64, 0xca, 0xde, 0x2b, 0x5b, 0x15, 0x10, 0xd2, 0xab, 0x06, 0xdd, 0xc4, 0xb0, 0xb6, 0x5b, 0xc1, 0x17, 0xdf, 0x8f, 0x02}}},
803{{{0xbd, 0x59, 0x3d, 0xbf, 0x5c, 0x31, 0x44, 0x2c, 0x32, 0x94, 0x04, 0x60, 0x84, 0x0f, 0xad, 0x00, 0xb6, 0x8f, 0xc9, 0x1d, 0xcc, 0x5c, 0xa2, 0x49, 0x0e, 0x50, 0x91, 0x08, 0x9a, 0x43, 0x55, 0x05}} ,
804 {{0x5d, 0x93, 0x55, 0xdf, 0x9b, 0x12, 0x19, 0xec, 0x93, 0x85, 0x42, 0x9e, 0x66, 0x0f, 0x9d, 0xaf, 0x99, 0xaf, 0x26, 0x89, 0xbc, 0x61, 0xfd, 0xff, 0xce, 0x4b, 0xf4, 0x33, 0x95, 0xc9, 0x35, 0x58}}},
805{{{0x12, 0x55, 0xf9, 0xda, 0xcb, 0x44, 0xa7, 0xdc, 0x57, 0xe2, 0xf9, 0x9a, 0xe6, 0x07, 0x23, 0x60, 0x54, 0xa7, 0x39, 0xa5, 0x9b, 0x84, 0x56, 0x6e, 0xaa, 0x8b, 0x8f, 0xb0, 0x2c, 0x87, 0xaf, 0x67}} ,
806 {{0x00, 0xa9, 0x4c, 0xb2, 0x12, 0xf8, 0x32, 0xa8, 0x7a, 0x00, 0x4b, 0x49, 0x32, 0xba, 0x1f, 0x5d, 0x44, 0x8e, 0x44, 0x7a, 0xdc, 0x11, 0xfb, 0x39, 0x08, 0x57, 0x87, 0xa5, 0x12, 0x42, 0x93, 0x0e}}},
807{{{0x17, 0xb4, 0xae, 0x72, 0x59, 0xd0, 0xaa, 0xa8, 0x16, 0x8b, 0x63, 0x11, 0xb3, 0x43, 0x04, 0xda, 0x0c, 0xa8, 0xb7, 0x68, 0xdd, 0x4e, 0x54, 0xe7, 0xaf, 0x5d, 0x5d, 0x05, 0x76, 0x36, 0xec, 0x0d}} ,
808 {{0x6d, 0x7c, 0x82, 0x32, 0x38, 0x55, 0x57, 0x74, 0x5b, 0x7d, 0xc3, 0xc4, 0xfb, 0x06, 0x29, 0xf0, 0x13, 0x55, 0x54, 0xc6, 0xa7, 0xdc, 0x4c, 0x9f, 0x98, 0x49, 0x20, 0xa8, 0xc3, 0x8d, 0xfa, 0x48}}},
809{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
810 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
811{{{0x87, 0x47, 0x9d, 0xe9, 0x25, 0xd5, 0xe3, 0x47, 0x78, 0xdf, 0x85, 0xa7, 0x85, 0x5e, 0x7a, 0x4c, 0x5f, 0x79, 0x1a, 0xf3, 0xa2, 0xb2, 0x28, 0xa0, 0x9c, 0xdd, 0x30, 0x40, 0xd4, 0x38, 0xbd, 0x28}} ,
812 {{0xfc, 0xbb, 0xd5, 0x78, 0x6d, 0x1d, 0xd4, 0x99, 0xb4, 0xaa, 0x44, 0x44, 0x7a, 0x1b, 0xd8, 0xfe, 0xb4, 0x99, 0xb9, 0xcc, 0xe7, 0xc4, 0xd3, 0x3a, 0x73, 0x83, 0x41, 0x5c, 0x40, 0xd7, 0x2d, 0x55}}},
813{{{0x26, 0xe1, 0x7b, 0x5f, 0xe5, 0xdc, 0x3f, 0x7d, 0xa1, 0xa7, 0x26, 0x44, 0x22, 0x23, 0xc0, 0x8f, 0x7d, 0xf1, 0xb5, 0x11, 0x47, 0x7b, 0x19, 0xd4, 0x75, 0x6f, 0x1e, 0xa5, 0x27, 0xfe, 0xc8, 0x0e}} ,
814 {{0xd3, 0x11, 0x3d, 0xab, 0xef, 0x2c, 0xed, 0xb1, 0x3d, 0x7c, 0x32, 0x81, 0x6b, 0xfe, 0xf8, 0x1c, 0x3c, 0x7b, 0xc0, 0x61, 0xdf, 0xb8, 0x75, 0x76, 0x7f, 0xaa, 0xd8, 0x93, 0xaf, 0x3d, 0xe8, 0x3d}}},
815{{{0xfd, 0x5b, 0x4e, 0x8d, 0xb6, 0x7e, 0x82, 0x9b, 0xef, 0xce, 0x04, 0x69, 0x51, 0x52, 0xff, 0xef, 0xa0, 0x52, 0xb5, 0x79, 0x17, 0x5e, 0x2f, 0xde, 0xd6, 0x3c, 0x2d, 0xa0, 0x43, 0xb4, 0x0b, 0x19}} ,
816 {{0xc0, 0x61, 0x48, 0x48, 0x17, 0xf4, 0x9e, 0x18, 0x51, 0x2d, 0xea, 0x2f, 0xf2, 0xf2, 0xe0, 0xa3, 0x14, 0xb7, 0x8b, 0x3a, 0x30, 0xf5, 0x81, 0xc1, 0x5d, 0x71, 0x39, 0x62, 0x55, 0x1f, 0x60, 0x5a}}},
817{{{0xe5, 0x89, 0x8a, 0x76, 0x6c, 0xdb, 0x4d, 0x0a, 0x5b, 0x72, 0x9d, 0x59, 0x6e, 0x63, 0x63, 0x18, 0x7c, 0xe3, 0xfa, 0xe2, 0xdb, 0xa1, 0x8d, 0xf4, 0xa5, 0xd7, 0x16, 0xb2, 0xd0, 0xb3, 0x3f, 0x39}} ,
818 {{0xce, 0x60, 0x09, 0x6c, 0xf5, 0x76, 0x17, 0x24, 0x80, 0x3a, 0x96, 0xc7, 0x94, 0x2e, 0xf7, 0x6b, 0xef, 0xb5, 0x05, 0x96, 0xef, 0xd3, 0x7b, 0x51, 0xda, 0x05, 0x44, 0x67, 0xbc, 0x07, 0x21, 0x4e}}},
819{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
820 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
821{{{0xe9, 0x73, 0x6f, 0x21, 0xb9, 0xde, 0x22, 0x7d, 0xeb, 0x97, 0x31, 0x10, 0xa3, 0xea, 0xe1, 0xc6, 0x37, 0xeb, 0x8f, 0x43, 0x58, 0xde, 0x41, 0x64, 0x0e, 0x3e, 0x07, 0x99, 0x3d, 0xf1, 0xdf, 0x1e}} ,
822 {{0xf8, 0xad, 0x43, 0xc2, 0x17, 0x06, 0xe2, 0xe4, 0xa9, 0x86, 0xcd, 0x18, 0xd7, 0x78, 0xc8, 0x74, 0x66, 0xd2, 0x09, 0x18, 0xa5, 0xf1, 0xca, 0xa6, 0x62, 0x92, 0xc1, 0xcb, 0x00, 0xeb, 0x42, 0x2e}}},
823{{{0x7b, 0x34, 0x24, 0x4c, 0xcf, 0x38, 0xe5, 0x6c, 0x0a, 0x01, 0x2c, 0x22, 0x0b, 0x24, 0x38, 0xad, 0x24, 0x7e, 0x19, 0xf0, 0x6c, 0xf9, 0x31, 0xf4, 0x35, 0x11, 0xf6, 0x46, 0x33, 0x3a, 0x23, 0x59}} ,
824 {{0x20, 0x0b, 0xa1, 0x08, 0x19, 0xad, 0x39, 0x54, 0xea, 0x3e, 0x23, 0x09, 0xb6, 0xe2, 0xd2, 0xbc, 0x4d, 0xfc, 0x9c, 0xf0, 0x13, 0x16, 0x22, 0x3f, 0xb9, 0xd2, 0x11, 0x86, 0x90, 0x55, 0xce, 0x3c}}},
825{{{0xc4, 0x0b, 0x4b, 0x62, 0x99, 0x37, 0x84, 0x3f, 0x74, 0xa2, 0xf9, 0xce, 0xe2, 0x0b, 0x0f, 0x2a, 0x3d, 0xa3, 0xe3, 0xdb, 0x5a, 0x9d, 0x93, 0xcc, 0xa5, 0xef, 0x82, 0x91, 0x1d, 0xe6, 0x6c, 0x68}} ,
826 {{0xa3, 0x64, 0x17, 0x9b, 0x8b, 0xc8, 0x3a, 0x61, 0xe6, 0x9d, 0xc6, 0xed, 0x7b, 0x03, 0x52, 0x26, 0x9d, 0x3a, 0xb3, 0x13, 0xcc, 0x8a, 0xfd, 0x2c, 0x1a, 0x1d, 0xed, 0x13, 0xd0, 0x55, 0x57, 0x0e}}},
827{{{0x1a, 0xea, 0xbf, 0xfd, 0x4a, 0x3c, 0x8e, 0xec, 0x29, 0x7e, 0x77, 0x77, 0x12, 0x99, 0xd7, 0x84, 0xf9, 0x55, 0x7f, 0xf1, 0x8b, 0xb4, 0xd2, 0x95, 0xa3, 0x8d, 0xf0, 0x8a, 0xa7, 0xeb, 0x82, 0x4b}} ,
828 {{0x2c, 0x28, 0xf4, 0x3a, 0xf6, 0xde, 0x0a, 0xe0, 0x41, 0x44, 0x23, 0xf8, 0x3f, 0x03, 0x64, 0x9f, 0xc3, 0x55, 0x4c, 0xc6, 0xc1, 0x94, 0x1c, 0x24, 0x5d, 0x5f, 0x92, 0x45, 0x96, 0x57, 0x37, 0x14}}},
829{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
830 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
831{{{0xc1, 0xcd, 0x90, 0x66, 0xb9, 0x76, 0xa0, 0x5b, 0xa5, 0x85, 0x75, 0x23, 0xf9, 0x89, 0xa5, 0x82, 0xb2, 0x6f, 0xb1, 0xeb, 0xc4, 0x69, 0x6f, 0x18, 0x5a, 0xed, 0x94, 0x3d, 0x9d, 0xd9, 0x2c, 0x1a}} ,
832 {{0x35, 0xb0, 0xe6, 0x73, 0x06, 0xb7, 0x37, 0xe0, 0xf8, 0xb0, 0x22, 0xe8, 0xd2, 0xed, 0x0b, 0xef, 0xe6, 0xc6, 0x5a, 0x99, 0x9e, 0x1a, 0x9f, 0x04, 0x97, 0xe4, 0x4d, 0x0b, 0xbe, 0xba, 0x44, 0x40}}},
833{{{0xc1, 0x56, 0x96, 0x91, 0x5f, 0x1f, 0xbb, 0x54, 0x6f, 0x88, 0x89, 0x0a, 0xb2, 0xd6, 0x41, 0x42, 0x6a, 0x82, 0xee, 0x14, 0xaa, 0x76, 0x30, 0x65, 0x0f, 0x67, 0x39, 0xa6, 0x51, 0x7c, 0x49, 0x24}} ,
834 {{0x35, 0xa3, 0x78, 0xd1, 0x11, 0x0f, 0x75, 0xd3, 0x70, 0x46, 0xdb, 0x20, 0x51, 0xcb, 0x92, 0x80, 0x54, 0x10, 0x74, 0x36, 0x86, 0xa9, 0xd7, 0xa3, 0x08, 0x78, 0xf1, 0x01, 0x29, 0xf8, 0x80, 0x3b}}},
835{{{0xdb, 0xa7, 0x9d, 0x9d, 0xbf, 0xa0, 0xcc, 0xed, 0x53, 0xa2, 0xa2, 0x19, 0x39, 0x48, 0x83, 0x19, 0x37, 0x58, 0xd1, 0x04, 0x28, 0x40, 0xf7, 0x8a, 0xc2, 0x08, 0xb7, 0xa5, 0x42, 0xcf, 0x53, 0x4c}} ,
836 {{0xa7, 0xbb, 0xf6, 0x8e, 0xad, 0xdd, 0xf7, 0x90, 0xdd, 0x5f, 0x93, 0x89, 0xae, 0x04, 0x37, 0xe6, 0x9a, 0xb7, 0xe8, 0xc0, 0xdf, 0x16, 0x2a, 0xbf, 0xc4, 0x3a, 0x3c, 0x41, 0xd5, 0x89, 0x72, 0x5a}}},
837{{{0x1f, 0x96, 0xff, 0x34, 0x2c, 0x13, 0x21, 0xcb, 0x0a, 0x89, 0x85, 0xbe, 0xb3, 0x70, 0x9e, 0x1e, 0xde, 0x97, 0xaf, 0x96, 0x30, 0xf7, 0x48, 0x89, 0x40, 0x8d, 0x07, 0xf1, 0x25, 0xf0, 0x30, 0x58}} ,
838 {{0x1e, 0xd4, 0x93, 0x57, 0xe2, 0x17, 0xe7, 0x9d, 0xab, 0x3c, 0x55, 0x03, 0x82, 0x2f, 0x2b, 0xdb, 0x56, 0x1e, 0x30, 0x2e, 0x24, 0x47, 0x6e, 0xe6, 0xff, 0x33, 0x24, 0x2c, 0x75, 0x51, 0xd4, 0x67}}},
839{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
840 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
841{{{0x2b, 0x06, 0xd9, 0xa1, 0x5d, 0xe1, 0xf4, 0xd1, 0x1e, 0x3c, 0x9a, 0xc6, 0x29, 0x2b, 0x13, 0x13, 0x78, 0xc0, 0xd8, 0x16, 0x17, 0x2d, 0x9e, 0xa9, 0xc9, 0x79, 0x57, 0xab, 0x24, 0x91, 0x92, 0x19}} ,
842 {{0x69, 0xfb, 0xa1, 0x9c, 0xa6, 0x75, 0x49, 0x7d, 0x60, 0x73, 0x40, 0x42, 0xc4, 0x13, 0x0a, 0x95, 0x79, 0x1e, 0x04, 0x83, 0x94, 0x99, 0x9b, 0x1e, 0x0c, 0xe8, 0x1f, 0x54, 0xef, 0xcb, 0xc0, 0x52}}},
843{{{0x14, 0x89, 0x73, 0xa1, 0x37, 0x87, 0x6a, 0x7a, 0xcf, 0x1d, 0xd9, 0x2e, 0x1a, 0x67, 0xed, 0x74, 0xc0, 0xf0, 0x9c, 0x33, 0xdd, 0xdf, 0x08, 0xbf, 0x7b, 0xd1, 0x66, 0xda, 0xe6, 0xc9, 0x49, 0x08}} ,
844 {{0xe9, 0xdd, 0x5e, 0x55, 0xb0, 0x0a, 0xde, 0x21, 0x4c, 0x5a, 0x2e, 0xd4, 0x80, 0x3a, 0x57, 0x92, 0x7a, 0xf1, 0xc4, 0x2c, 0x40, 0xaf, 0x2f, 0xc9, 0x92, 0x03, 0xe5, 0x5a, 0xbc, 0xdc, 0xf4, 0x09}}},
845{{{0xf3, 0xe1, 0x2b, 0x7c, 0x05, 0x86, 0x80, 0x93, 0x4a, 0xad, 0xb4, 0x8f, 0x7e, 0x99, 0x0c, 0xfd, 0xcd, 0xef, 0xd1, 0xff, 0x2c, 0x69, 0x34, 0x13, 0x41, 0x64, 0xcf, 0x3b, 0xd0, 0x90, 0x09, 0x1e}} ,
846 {{0x9d, 0x45, 0xd6, 0x80, 0xe6, 0x45, 0xaa, 0xf4, 0x15, 0xaa, 0x5c, 0x34, 0x87, 0x99, 0xa2, 0x8c, 0x26, 0x84, 0x62, 0x7d, 0xb6, 0x29, 0xc0, 0x52, 0xea, 0xf5, 0x81, 0x18, 0x0f, 0x35, 0xa9, 0x0e}}},
847{{{0xe7, 0x20, 0x72, 0x7c, 0x6d, 0x94, 0x5f, 0x52, 0x44, 0x54, 0xe3, 0xf1, 0xb2, 0xb0, 0x36, 0x46, 0x0f, 0xae, 0x92, 0xe8, 0x70, 0x9d, 0x6e, 0x79, 0xb1, 0xad, 0x37, 0xa9, 0x5f, 0xc0, 0xde, 0x03}} ,
848 {{0x15, 0x55, 0x37, 0xc6, 0x1c, 0x27, 0x1c, 0x6d, 0x14, 0x4f, 0xca, 0xa4, 0xc4, 0x88, 0x25, 0x46, 0x39, 0xfc, 0x5a, 0xe5, 0xfe, 0x29, 0x11, 0x69, 0xf5, 0x72, 0x84, 0x4d, 0x78, 0x9f, 0x94, 0x15}}},
849{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
850 {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
851{{{0xec, 0xd3, 0xff, 0x57, 0x0b, 0xb0, 0xb2, 0xdc, 0xf8, 0x4f, 0xe2, 0x12, 0xd5, 0x36, 0xbe, 0x6b, 0x09, 0x43, 0x6d, 0xa3, 0x4d, 0x90, 0x2d, 0xb8, 0x74, 0xe8, 0x71, 0x45, 0x19, 0x8b, 0x0c, 0x6a}} ,
852 {{0xb8, 0x42, 0x1c, 0x03, 0xad, 0x2c, 0x03, 0x8e, 0xac, 0xd7, 0x98, 0x29, 0x13, 0xc6, 0x02, 0x29, 0xb5, 0xd4, 0xe7, 0xcf, 0xcc, 0x8b, 0x83, 0xec, 0x35, 0xc7, 0x9c, 0x74, 0xb7, 0xad, 0x85, 0x5f}}},
853{{{0x78, 0x84, 0xe1, 0x56, 0x45, 0x69, 0x68, 0x5a, 0x4f, 0xb8, 0xb1, 0x29, 0xff, 0x33, 0x03, 0x31, 0xb7, 0xcb, 0x96, 0x25, 0xe6, 0xe6, 0x41, 0x98, 0x1a, 0xbb, 0x03, 0x56, 0xf2, 0xb2, 0x91, 0x34}} ,
854 {{0x2c, 0x6c, 0xf7, 0x66, 0xa4, 0x62, 0x6b, 0x39, 0xb3, 0xba, 0x65, 0xd3, 0x1c, 0xf8, 0x11, 0xaa, 0xbe, 0xdc, 0x80, 0x59, 0x87, 0xf5, 0x7b, 0xe5, 0xe3, 0xb3, 0x3e, 0x39, 0xda, 0xbe, 0x88, 0x09}}},
855{{{0x8b, 0xf1, 0xa0, 0xf5, 0xdc, 0x29, 0xb4, 0xe2, 0x07, 0xc6, 0x7a, 0x00, 0xd0, 0x89, 0x17, 0x51, 0xd4, 0xbb, 0xd4, 0x22, 0xea, 0x7e, 0x7d, 0x7c, 0x24, 0xea, 0xf2, 0xe8, 0x22, 0x12, 0x95, 0x06}} ,
856 {{0xda, 0x7c, 0xa4, 0x0c, 0xf4, 0xba, 0x6e, 0xe1, 0x89, 0xb5, 0x59, 0xca, 0xf1, 0xc0, 0x29, 0x36, 0x09, 0x44, 0xe2, 0x7f, 0xd1, 0x63, 0x15, 0x99, 0xea, 0x25, 0xcf, 0x0c, 0x9d, 0xc0, 0x44, 0x6f}}},
857{{{0x1d, 0x86, 0x4e, 0xcf, 0xf7, 0x37, 0x10, 0x25, 0x8f, 0x12, 0xfb, 0x19, 0xfb, 0xe0, 0xed, 0x10, 0xc8, 0xe2, 0xf5, 0x75, 0xb1, 0x33, 0xc0, 0x96, 0x0d, 0xfb, 0x15, 0x6c, 0x0d, 0x07, 0x5f, 0x05}} ,
858 {{0x69, 0x3e, 0x47, 0x97, 0x2c, 0xaf, 0x52, 0x7c, 0x78, 0x83, 0xad, 0x1b, 0x39, 0x82, 0x2f, 0x02, 0x6f, 0x47, 0xdb, 0x2a, 0xb0, 0xe1, 0x91, 0x99, 0x55, 0xb8, 0x99, 0x3a, 0xa0, 0x44, 0x11, 0x51}}}
diff --git a/gss-serv-krb5.c b/gss-serv-krb5.c
index 87f26831a..759fa104f 100644
--- a/gss-serv-krb5.c
+++ b/gss-serv-krb5.c
@@ -132,10 +132,16 @@ ssh_gssapi_krb5_storecreds(ssh_gssapi_client *client)
132 return; 132 return;
133 133
134#ifdef HEIMDAL 134#ifdef HEIMDAL
135# ifdef HAVE_KRB5_CC_NEW_UNIQUE
135 if ((problem = krb5_cc_new_unique(krb_context, krb5_fcc_ops.prefix, 136 if ((problem = krb5_cc_new_unique(krb_context, krb5_fcc_ops.prefix,
136 NULL, &ccache)) != 0) { 137 NULL, &ccache)) != 0) {
137 errmsg = krb5_get_error_message(krb_context, problem); 138 errmsg = krb5_get_error_message(krb_context, problem);
138 logit("krb5_cc_new_unique(): %.100s", errmsg); 139 logit("krb5_cc_new_unique(): %.100s", errmsg);
140# else
141 if ((problem = krb5_cc_gen_new(krb_context, &krb5_fcc_ops, &ccache))) {
142 logit("krb5_cc_gen_new(): %.100s",
143 krb5_get_err_text(krb_context, problem));
144# endif
139 krb5_free_error_message(krb_context, errmsg); 145 krb5_free_error_message(krb_context, errmsg);
140 return; 146 return;
141 } 147 }
diff --git a/hash.c b/hash.c
new file mode 100644
index 000000000..734c6bee2
--- /dev/null
+++ b/hash.c
@@ -0,0 +1,76 @@
1/* $OpenBSD: hash.c,v 1.3 2013/12/09 11:03:45 markus Exp $ */
2
3/* Copied from nacl-20110221/crypto_hash/sha512/ref/hash.c */
4
5/*
620080913
7D. J. Bernstein
8Public domain.
9*/
10
11#include "includes.h"
12
13#include "crypto_api.h"
14
15#define blocks crypto_hashblocks_sha512
16
17static const unsigned char iv[64] = {
18 0x6a,0x09,0xe6,0x67,0xf3,0xbc,0xc9,0x08,
19 0xbb,0x67,0xae,0x85,0x84,0xca,0xa7,0x3b,
20 0x3c,0x6e,0xf3,0x72,0xfe,0x94,0xf8,0x2b,
21 0xa5,0x4f,0xf5,0x3a,0x5f,0x1d,0x36,0xf1,
22 0x51,0x0e,0x52,0x7f,0xad,0xe6,0x82,0xd1,
23 0x9b,0x05,0x68,0x8c,0x2b,0x3e,0x6c,0x1f,
24 0x1f,0x83,0xd9,0xab,0xfb,0x41,0xbd,0x6b,
25 0x5b,0xe0,0xcd,0x19,0x13,0x7e,0x21,0x79
26} ;
27
28typedef unsigned long long uint64;
29
30int crypto_hash_sha512(unsigned char *out,const unsigned char *in,unsigned long long inlen)
31{
32 unsigned char h[64];
33 unsigned char padded[256];
34 unsigned int i;
35 unsigned long long bytes = inlen;
36
37 for (i = 0;i < 64;++i) h[i] = iv[i];
38
39 blocks(h,in,inlen);
40 in += inlen;
41 inlen &= 127;
42 in -= inlen;
43
44 for (i = 0;i < inlen;++i) padded[i] = in[i];
45 padded[inlen] = 0x80;
46
47 if (inlen < 112) {
48 for (i = inlen + 1;i < 119;++i) padded[i] = 0;
49 padded[119] = bytes >> 61;
50 padded[120] = bytes >> 53;
51 padded[121] = bytes >> 45;
52 padded[122] = bytes >> 37;
53 padded[123] = bytes >> 29;
54 padded[124] = bytes >> 21;
55 padded[125] = bytes >> 13;
56 padded[126] = bytes >> 5;
57 padded[127] = bytes << 3;
58 blocks(h,padded,128);
59 } else {
60 for (i = inlen + 1;i < 247;++i) padded[i] = 0;
61 padded[247] = bytes >> 61;
62 padded[248] = bytes >> 53;
63 padded[249] = bytes >> 45;
64 padded[250] = bytes >> 37;
65 padded[251] = bytes >> 29;
66 padded[252] = bytes >> 21;
67 padded[253] = bytes >> 13;
68 padded[254] = bytes >> 5;
69 padded[255] = bytes << 3;
70 blocks(h,padded,256);
71 }
72
73 for (i = 0;i < 64;++i) out[i] = h[i];
74
75 return 0;
76}
diff --git a/hostfile.c b/hostfile.c
index 2ff4c48b4..2778fb5df 100644
--- a/hostfile.c
+++ b/hostfile.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: hostfile.c,v 1.52 2013/07/12 00:19:58 djm Exp $ */ 1/* $OpenBSD: hostfile.c,v 1.53 2014/01/09 23:20:00 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
@@ -57,6 +57,7 @@
57#include "hostfile.h" 57#include "hostfile.h"
58#include "log.h" 58#include "log.h"
59#include "misc.h" 59#include "misc.h"
60#include "digest.h"
60 61
61struct hostkeys { 62struct hostkeys {
62 struct hostkey_entry *entries; 63 struct hostkey_entry *entries;
diff --git a/kex.c b/kex.c
index 54bd1a438..616484b85 100644
--- a/kex.c
+++ b/kex.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kex.c,v 1.91 2013/05/17 00:13:13 djm Exp $ */ 1/* $OpenBSD: kex.c,v 1.97 2014/01/25 20:35:37 markus 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 *
@@ -49,6 +49,7 @@
49#include "dispatch.h" 49#include "dispatch.h"
50#include "monitor.h" 50#include "monitor.h"
51#include "roaming.h" 51#include "roaming.h"
52#include "digest.h"
52 53
53#if OPENSSL_VERSION_NUMBER >= 0x00907000L 54#if OPENSSL_VERSION_NUMBER >= 0x00907000L
54# if defined(HAVE_EVP_SHA256) 55# if defined(HAVE_EVP_SHA256)
@@ -66,25 +67,34 @@ struct kexalg {
66 char *name; 67 char *name;
67 int type; 68 int type;
68 int ec_nid; 69 int ec_nid;
69 const EVP_MD *(*mdfunc)(void); 70 int hash_alg;
70}; 71};
71static const struct kexalg kexalgs[] = { 72static const struct kexalg kexalgs[] = {
72 { KEX_DH1, KEX_DH_GRP1_SHA1, 0, EVP_sha1 }, 73 { KEX_DH1, KEX_DH_GRP1_SHA1, 0, SSH_DIGEST_SHA1 },
73 { KEX_DH14, KEX_DH_GRP14_SHA1, 0, EVP_sha1 }, 74 { KEX_DH14, KEX_DH_GRP14_SHA1, 0, SSH_DIGEST_SHA1 },
74 { KEX_DHGEX_SHA1, KEX_DH_GEX_SHA1, 0, EVP_sha1 }, 75 { KEX_DHGEX_SHA1, KEX_DH_GEX_SHA1, 0, SSH_DIGEST_SHA1 },
75#ifdef HAVE_EVP_SHA256 76#ifdef HAVE_EVP_SHA256
76 { KEX_DHGEX_SHA256, KEX_DH_GEX_SHA256, 0, EVP_sha256 }, 77 { KEX_DHGEX_SHA256, KEX_DH_GEX_SHA256, 0, SSH_DIGEST_SHA256 },
77#endif 78#endif
78#ifdef OPENSSL_HAS_ECC 79#ifdef OPENSSL_HAS_ECC
79 { KEX_ECDH_SHA2_NISTP256, KEX_ECDH_SHA2, NID_X9_62_prime256v1, EVP_sha256 }, 80 { KEX_ECDH_SHA2_NISTP256, KEX_ECDH_SHA2,
80 { KEX_ECDH_SHA2_NISTP384, KEX_ECDH_SHA2, NID_secp384r1, EVP_sha384 }, 81 NID_X9_62_prime256v1, SSH_DIGEST_SHA256 },
81 { KEX_ECDH_SHA2_NISTP521, KEX_ECDH_SHA2, NID_secp521r1, EVP_sha512 }, 82 { KEX_ECDH_SHA2_NISTP384, KEX_ECDH_SHA2, NID_secp384r1,
83 SSH_DIGEST_SHA384 },
84# ifdef OPENSSL_HAS_NISTP521
85 { KEX_ECDH_SHA2_NISTP521, KEX_ECDH_SHA2, NID_secp521r1,
86 SSH_DIGEST_SHA512 },
87# endif
88#endif
89 { KEX_DH1, KEX_DH_GRP1_SHA1, 0, SSH_DIGEST_SHA1 },
90#ifdef HAVE_EVP_SHA256
91 { KEX_CURVE25519_SHA256, KEX_C25519_SHA256, 0, SSH_DIGEST_SHA256 },
82#endif 92#endif
83 { NULL, -1, -1, NULL}, 93 { NULL, -1, -1, -1},
84}; 94};
85 95
86char * 96char *
87kex_alg_list(void) 97kex_alg_list(char sep)
88{ 98{
89 char *ret = NULL; 99 char *ret = NULL;
90 size_t nlen, rlen = 0; 100 size_t nlen, rlen = 0;
@@ -92,7 +102,7 @@ kex_alg_list(void)
92 102
93 for (k = kexalgs; k->name != NULL; k++) { 103 for (k = kexalgs; k->name != NULL; k++) {
94 if (ret != NULL) 104 if (ret != NULL)
95 ret[rlen++] = '\n'; 105 ret[rlen++] = sep;
96 nlen = strlen(k->name); 106 nlen = strlen(k->name);
97 ret = xrealloc(ret, 1, rlen + nlen + 2); 107 ret = xrealloc(ret, 1, rlen + nlen + 2);
98 memcpy(ret + rlen, k->name, nlen + 1); 108 memcpy(ret + rlen, k->name, nlen + 1);
@@ -401,7 +411,7 @@ choose_kex(Kex *k, char *client, char *server)
401 if ((kexalg = kex_alg_by_name(k->name)) == NULL) 411 if ((kexalg = kex_alg_by_name(k->name)) == NULL)
402 fatal("unsupported kex alg %s", k->name); 412 fatal("unsupported kex alg %s", k->name);
403 k->kex_type = kexalg->type; 413 k->kex_type = kexalg->type;
404 k->evp_md = kexalg->mdfunc(); 414 k->hash_alg = kexalg->hash_alg;
405 k->ec_nid = kexalg->ec_nid; 415 k->ec_nid = kexalg->ec_nid;
406} 416}
407 417
@@ -448,7 +458,7 @@ kex_choose_conf(Kex *kex)
448 char **my, **peer; 458 char **my, **peer;
449 char **cprop, **sprop; 459 char **cprop, **sprop;
450 int nenc, nmac, ncomp; 460 int nenc, nmac, ncomp;
451 u_int mode, ctos, need, authlen; 461 u_int mode, ctos, need, dh_need, authlen;
452 int first_kex_follows, type; 462 int first_kex_follows, type;
453 463
454 my = kex_buf2prop(&kex->my, NULL); 464 my = kex_buf2prop(&kex->my, NULL);
@@ -496,20 +506,21 @@ kex_choose_conf(Kex *kex)
496 choose_kex(kex, cprop[PROPOSAL_KEX_ALGS], sprop[PROPOSAL_KEX_ALGS]); 506 choose_kex(kex, cprop[PROPOSAL_KEX_ALGS], sprop[PROPOSAL_KEX_ALGS]);
497 choose_hostkeyalg(kex, cprop[PROPOSAL_SERVER_HOST_KEY_ALGS], 507 choose_hostkeyalg(kex, cprop[PROPOSAL_SERVER_HOST_KEY_ALGS],
498 sprop[PROPOSAL_SERVER_HOST_KEY_ALGS]); 508 sprop[PROPOSAL_SERVER_HOST_KEY_ALGS]);
499 need = 0; 509 need = dh_need = 0;
500 for (mode = 0; mode < MODE_MAX; mode++) { 510 for (mode = 0; mode < MODE_MAX; mode++) {
501 newkeys = kex->newkeys[mode]; 511 newkeys = kex->newkeys[mode];
502 if (need < newkeys->enc.key_len) 512 need = MAX(need, newkeys->enc.key_len);
503 need = newkeys->enc.key_len; 513 need = MAX(need, newkeys->enc.block_size);
504 if (need < newkeys->enc.block_size) 514 need = MAX(need, newkeys->enc.iv_len);
505 need = newkeys->enc.block_size; 515 need = MAX(need, newkeys->mac.key_len);
506 if (need < newkeys->enc.iv_len) 516 dh_need = MAX(dh_need, cipher_seclen(newkeys->enc.cipher));
507 need = newkeys->enc.iv_len; 517 dh_need = MAX(dh_need, newkeys->enc.block_size);
508 if (need < newkeys->mac.key_len) 518 dh_need = MAX(dh_need, newkeys->enc.iv_len);
509 need = newkeys->mac.key_len; 519 dh_need = MAX(dh_need, newkeys->mac.key_len);
510 } 520 }
511 /* XXX need runden? */ 521 /* XXX need runden? */
512 kex->we_need = need; 522 kex->we_need = need;
523 kex->dh_need = dh_need;
513 524
514 /* ignore the next message if the proposals do not match */ 525 /* ignore the next message if the proposals do not match */
515 if (first_kex_follows && !proposals_match(my, peer) && 526 if (first_kex_follows && !proposals_match(my, peer) &&
@@ -524,30 +535,34 @@ kex_choose_conf(Kex *kex)
524 535
525static u_char * 536static u_char *
526derive_key(Kex *kex, int id, u_int need, u_char *hash, u_int hashlen, 537derive_key(Kex *kex, int id, u_int need, u_char *hash, u_int hashlen,
527 BIGNUM *shared_secret) 538 const u_char *shared_secret, u_int slen)
528{ 539{
529 Buffer b; 540 Buffer b;
530 EVP_MD_CTX md; 541 struct ssh_digest_ctx *hashctx;
531 char c = id; 542 char c = id;
532 u_int have; 543 u_int have;
533 int mdsz; 544 size_t mdsz;
534 u_char *digest; 545 u_char *digest;
535 546
536 if ((mdsz = EVP_MD_size(kex->evp_md)) <= 0) 547 if ((mdsz = ssh_digest_bytes(kex->hash_alg)) == 0)
537 fatal("bad kex md size %d", mdsz); 548 fatal("bad kex md size %zu", mdsz);
538 digest = xmalloc(roundup(need, mdsz)); 549 digest = xmalloc(roundup(need, mdsz));
539 550
540 buffer_init(&b); 551 buffer_init(&b);
541 buffer_put_bignum2(&b, shared_secret); 552 buffer_append(&b, shared_secret, slen);
542 553
543 /* K1 = HASH(K || H || "A" || session_id) */ 554 /* K1 = HASH(K || H || "A" || session_id) */
544 EVP_DigestInit(&md, kex->evp_md); 555 if ((hashctx = ssh_digest_start(kex->hash_alg)) == NULL)
545 if (!(datafellows & SSH_BUG_DERIVEKEY)) 556 fatal("%s: ssh_digest_start failed", __func__);
546 EVP_DigestUpdate(&md, buffer_ptr(&b), buffer_len(&b)); 557 if (ssh_digest_update_buffer(hashctx, &b) != 0 ||
547 EVP_DigestUpdate(&md, hash, hashlen); 558 ssh_digest_update(hashctx, hash, hashlen) != 0 ||
548 EVP_DigestUpdate(&md, &c, 1); 559 ssh_digest_update(hashctx, &c, 1) != 0 ||
549 EVP_DigestUpdate(&md, kex->session_id, kex->session_id_len); 560 ssh_digest_update(hashctx, kex->session_id,
550 EVP_DigestFinal(&md, digest, NULL); 561 kex->session_id_len) != 0)
562 fatal("%s: ssh_digest_update failed", __func__);
563 if (ssh_digest_final(hashctx, digest, mdsz) != 0)
564 fatal("%s: ssh_digest_final failed", __func__);
565 ssh_digest_free(hashctx);
551 566
552 /* 567 /*
553 * expand key: 568 * expand key:
@@ -555,12 +570,15 @@ derive_key(Kex *kex, int id, u_int need, u_char *hash, u_int hashlen,
555 * Key = K1 || K2 || ... || Kn 570 * Key = K1 || K2 || ... || Kn
556 */ 571 */
557 for (have = mdsz; need > have; have += mdsz) { 572 for (have = mdsz; need > have; have += mdsz) {
558 EVP_DigestInit(&md, kex->evp_md); 573 if ((hashctx = ssh_digest_start(kex->hash_alg)) == NULL)
559 if (!(datafellows & SSH_BUG_DERIVEKEY)) 574 fatal("%s: ssh_digest_start failed", __func__);
560 EVP_DigestUpdate(&md, buffer_ptr(&b), buffer_len(&b)); 575 if (ssh_digest_update_buffer(hashctx, &b) != 0 ||
561 EVP_DigestUpdate(&md, hash, hashlen); 576 ssh_digest_update(hashctx, hash, hashlen) != 0 ||
562 EVP_DigestUpdate(&md, digest, have); 577 ssh_digest_update(hashctx, digest, have) != 0)
563 EVP_DigestFinal(&md, digest + have, NULL); 578 fatal("%s: ssh_digest_update failed", __func__);
579 if (ssh_digest_final(hashctx, digest + have, mdsz) != 0)
580 fatal("%s: ssh_digest_final failed", __func__);
581 ssh_digest_free(hashctx);
564 } 582 }
565 buffer_free(&b); 583 buffer_free(&b);
566#ifdef DEBUG_KEX 584#ifdef DEBUG_KEX
@@ -574,14 +592,15 @@ Newkeys *current_keys[MODE_MAX];
574 592
575#define NKEYS 6 593#define NKEYS 6
576void 594void
577kex_derive_keys(Kex *kex, u_char *hash, u_int hashlen, BIGNUM *shared_secret) 595kex_derive_keys(Kex *kex, u_char *hash, u_int hashlen,
596 const u_char *shared_secret, u_int slen)
578{ 597{
579 u_char *keys[NKEYS]; 598 u_char *keys[NKEYS];
580 u_int i, mode, ctos; 599 u_int i, mode, ctos;
581 600
582 for (i = 0; i < NKEYS; i++) { 601 for (i = 0; i < NKEYS; i++) {
583 keys[i] = derive_key(kex, 'A'+i, kex->we_need, hash, hashlen, 602 keys[i] = derive_key(kex, 'A'+i, kex->we_need, hash, hashlen,
584 shared_secret); 603 shared_secret, slen);
585 } 604 }
586 605
587 debug2("kex_derive_keys"); 606 debug2("kex_derive_keys");
@@ -596,6 +615,18 @@ kex_derive_keys(Kex *kex, u_char *hash, u_int hashlen, BIGNUM *shared_secret)
596 } 615 }
597} 616}
598 617
618void
619kex_derive_keys_bn(Kex *kex, u_char *hash, u_int hashlen, const BIGNUM *secret)
620{
621 Buffer shared_secret;
622
623 buffer_init(&shared_secret);
624 buffer_put_bignum2(&shared_secret, secret);
625 kex_derive_keys(kex, hash, hashlen,
626 buffer_ptr(&shared_secret), buffer_len(&shared_secret));
627 buffer_free(&shared_secret);
628}
629
599Newkeys * 630Newkeys *
600kex_get_newkeys(int mode) 631kex_get_newkeys(int mode)
601{ 632{
@@ -610,33 +641,33 @@ void
610derive_ssh1_session_id(BIGNUM *host_modulus, BIGNUM *server_modulus, 641derive_ssh1_session_id(BIGNUM *host_modulus, BIGNUM *server_modulus,
611 u_int8_t cookie[8], u_int8_t id[16]) 642 u_int8_t cookie[8], u_int8_t id[16])
612{ 643{
613 const EVP_MD *evp_md = EVP_md5(); 644 u_int8_t nbuf[2048], obuf[SSH_DIGEST_MAX_LENGTH];
614 EVP_MD_CTX md;
615 u_int8_t nbuf[2048], obuf[EVP_MAX_MD_SIZE];
616 int len; 645 int len;
646 struct ssh_digest_ctx *hashctx;
617 647
618 EVP_DigestInit(&md, evp_md); 648 if ((hashctx = ssh_digest_start(SSH_DIGEST_MD5)) == NULL)
649 fatal("%s: ssh_digest_start", __func__);
619 650
620 len = BN_num_bytes(host_modulus); 651 len = BN_num_bytes(host_modulus);
621 if (len < (512 / 8) || (u_int)len > sizeof(nbuf)) 652 if (len < (512 / 8) || (u_int)len > sizeof(nbuf))
622 fatal("%s: bad host modulus (len %d)", __func__, len); 653 fatal("%s: bad host modulus (len %d)", __func__, len);
623 BN_bn2bin(host_modulus, nbuf); 654 BN_bn2bin(host_modulus, nbuf);
624 EVP_DigestUpdate(&md, nbuf, len); 655 if (ssh_digest_update(hashctx, nbuf, len) != 0)
656 fatal("%s: ssh_digest_update failed", __func__);
625 657
626 len = BN_num_bytes(server_modulus); 658 len = BN_num_bytes(server_modulus);
627 if (len < (512 / 8) || (u_int)len > sizeof(nbuf)) 659 if (len < (512 / 8) || (u_int)len > sizeof(nbuf))
628 fatal("%s: bad server modulus (len %d)", __func__, len); 660 fatal("%s: bad server modulus (len %d)", __func__, len);
629 BN_bn2bin(server_modulus, nbuf); 661 BN_bn2bin(server_modulus, nbuf);
630 EVP_DigestUpdate(&md, nbuf, len); 662 if (ssh_digest_update(hashctx, nbuf, len) != 0 ||
631 663 ssh_digest_update(hashctx, cookie, 8) != 0)
632 EVP_DigestUpdate(&md, cookie, 8); 664 fatal("%s: ssh_digest_update failed", __func__);
633 665 if (ssh_digest_final(hashctx, obuf, sizeof(obuf)) != 0)
634 EVP_DigestFinal(&md, obuf, NULL); 666 fatal("%s: ssh_digest_final failed", __func__);
635 memcpy(id, obuf, 16); 667 memcpy(id, obuf, ssh_digest_bytes(SSH_DIGEST_MD5));
636 668
637 memset(nbuf, 0, sizeof(nbuf)); 669 memset(nbuf, 0, sizeof(nbuf));
638 memset(obuf, 0, sizeof(obuf)); 670 memset(obuf, 0, sizeof(obuf));
639 memset(&md, 0, sizeof(md));
640} 671}
641 672
642#if defined(DEBUG_KEX) || defined(DEBUG_KEXDH) || defined(DEBUG_KEXECDH) 673#if defined(DEBUG_KEX) || defined(DEBUG_KEXDH) || defined(DEBUG_KEXECDH)
diff --git a/kex.h b/kex.h
index 9f1e1adb3..1aa3ec26a 100644
--- a/kex.h
+++ b/kex.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: kex.h,v 1.56 2013/07/19 07:37:48 markus Exp $ */ 1/* $OpenBSD: kex.h,v 1.61 2014/01/25 10:12:50 dtucker 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.
@@ -43,6 +43,7 @@
43#define KEX_ECDH_SHA2_NISTP256 "ecdh-sha2-nistp256" 43#define KEX_ECDH_SHA2_NISTP256 "ecdh-sha2-nistp256"
44#define KEX_ECDH_SHA2_NISTP384 "ecdh-sha2-nistp384" 44#define KEX_ECDH_SHA2_NISTP384 "ecdh-sha2-nistp384"
45#define KEX_ECDH_SHA2_NISTP521 "ecdh-sha2-nistp521" 45#define KEX_ECDH_SHA2_NISTP521 "ecdh-sha2-nistp521"
46#define KEX_CURVE25519_SHA256 "curve25519-sha256@libssh.org"
46 47
47#define COMP_NONE 0 48#define COMP_NONE 0
48#define COMP_ZLIB 1 49#define COMP_ZLIB 1
@@ -74,6 +75,7 @@ enum kex_exchange {
74 KEX_DH_GEX_SHA1, 75 KEX_DH_GEX_SHA1,
75 KEX_DH_GEX_SHA256, 76 KEX_DH_GEX_SHA256,
76 KEX_ECDH_SHA2, 77 KEX_ECDH_SHA2,
78 KEX_C25519_SHA256,
77 KEX_MAX 79 KEX_MAX
78}; 80};
79 81
@@ -122,6 +124,7 @@ struct Kex {
122 u_int session_id_len; 124 u_int session_id_len;
123 Newkeys *newkeys[MODE_MAX]; 125 Newkeys *newkeys[MODE_MAX];
124 u_int we_need; 126 u_int we_need;
127 u_int dh_need;
125 int server; 128 int server;
126 char *name; 129 char *name;
127 int hostkey_type; 130 int hostkey_type;
@@ -131,7 +134,7 @@ struct Kex {
131 Buffer peer; 134 Buffer peer;
132 sig_atomic_t done; 135 sig_atomic_t done;
133 int flags; 136 int flags;
134 const EVP_MD *evp_md; 137 int hash_alg;
135 int ec_nid; 138 int ec_nid;
136 char *client_version_string; 139 char *client_version_string;
137 char *server_version_string; 140 char *server_version_string;
@@ -144,14 +147,15 @@ struct Kex {
144}; 147};
145 148
146int kex_names_valid(const char *); 149int kex_names_valid(const char *);
147char *kex_alg_list(void); 150char *kex_alg_list(char);
148 151
149Kex *kex_setup(char *[PROPOSAL_MAX]); 152Kex *kex_setup(char *[PROPOSAL_MAX]);
150void kex_finish(Kex *); 153void kex_finish(Kex *);
151 154
152void kex_send_kexinit(Kex *); 155void kex_send_kexinit(Kex *);
153void kex_input_kexinit(int, u_int32_t, void *); 156void kex_input_kexinit(int, u_int32_t, void *);
154void kex_derive_keys(Kex *, u_char *, u_int, BIGNUM *); 157void kex_derive_keys(Kex *, u_char *, u_int, const u_char *, u_int);
158void kex_derive_keys_bn(Kex *, u_char *, u_int, const BIGNUM *);
155 159
156Newkeys *kex_get_newkeys(int); 160Newkeys *kex_get_newkeys(int);
157 161
@@ -161,20 +165,35 @@ void kexgex_client(Kex *);
161void kexgex_server(Kex *); 165void kexgex_server(Kex *);
162void kexecdh_client(Kex *); 166void kexecdh_client(Kex *);
163void kexecdh_server(Kex *); 167void kexecdh_server(Kex *);
168void kexc25519_client(Kex *);
169void kexc25519_server(Kex *);
164 170
165void 171void
166kex_dh_hash(char *, char *, char *, int, char *, int, u_char *, int, 172kex_dh_hash(char *, char *, char *, int, char *, int, u_char *, int,
167 BIGNUM *, BIGNUM *, BIGNUM *, u_char **, u_int *); 173 BIGNUM *, BIGNUM *, BIGNUM *, u_char **, u_int *);
168void 174void
169kexgex_hash(const EVP_MD *, char *, char *, char *, int, char *, 175kexgex_hash(int, char *, char *, char *, int, char *,
170 int, u_char *, int, int, int, int, BIGNUM *, BIGNUM *, BIGNUM *, 176 int, u_char *, int, int, int, int, BIGNUM *, BIGNUM *, BIGNUM *,
171 BIGNUM *, BIGNUM *, u_char **, u_int *); 177 BIGNUM *, BIGNUM *, u_char **, u_int *);
172#ifdef OPENSSL_HAS_ECC 178#ifdef OPENSSL_HAS_ECC
173void 179void
174kex_ecdh_hash(const EVP_MD *, const EC_GROUP *, char *, char *, char *, int, 180kex_ecdh_hash(int, const EC_GROUP *, char *, char *, char *, int,
175 char *, int, u_char *, int, const EC_POINT *, const EC_POINT *, 181 char *, int, u_char *, int, const EC_POINT *, const EC_POINT *,
176 const BIGNUM *, u_char **, u_int *); 182 const BIGNUM *, u_char **, u_int *);
177#endif 183#endif
184void
185kex_c25519_hash(int, char *, char *, char *, int,
186 char *, int, u_char *, int, const u_char *, const u_char *,
187 const u_char *, u_int, u_char **, u_int *);
188
189#define CURVE25519_SIZE 32
190void kexc25519_keygen(u_char[CURVE25519_SIZE], u_char[CURVE25519_SIZE])
191 __attribute__((__bounded__(__minbytes__, 1, CURVE25519_SIZE)))
192 __attribute__((__bounded__(__minbytes__, 2, CURVE25519_SIZE)));
193void kexc25519_shared_key(const u_char key[CURVE25519_SIZE],
194 const u_char pub[CURVE25519_SIZE], Buffer *out)
195 __attribute__((__bounded__(__minbytes__, 1, CURVE25519_SIZE)))
196 __attribute__((__bounded__(__minbytes__, 2, CURVE25519_SIZE)));
178 197
179void 198void
180derive_ssh1_session_id(BIGNUM *, BIGNUM *, u_int8_t[8], u_int8_t[16]); 199derive_ssh1_session_id(BIGNUM *, BIGNUM *, u_int8_t[8], u_int8_t[16]);
diff --git a/kexc25519.c b/kexc25519.c
new file mode 100644
index 000000000..48ca4aaa2
--- /dev/null
+++ b/kexc25519.c
@@ -0,0 +1,122 @@
1/* $OpenBSD: kexc25519.c,v 1.4 2014/01/12 08:13:13 djm Exp $ */
2/*
3 * Copyright (c) 2001, 2013 Markus Friedl. All rights reserved.
4 * Copyright (c) 2010 Damien Miller. All rights reserved.
5 * Copyright (c) 2013 Aris Adamantiadis. All rights reserved.
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
28#include "includes.h"
29
30#include <sys/types.h>
31
32#include <signal.h>
33#include <string.h>
34
35#include <openssl/bn.h>
36#include <openssl/evp.h>
37
38#include "buffer.h"
39#include "ssh2.h"
40#include "key.h"
41#include "cipher.h"
42#include "kex.h"
43#include "log.h"
44#include "digest.h"
45
46extern int crypto_scalarmult_curve25519(u_char a[CURVE25519_SIZE],
47 const u_char b[CURVE25519_SIZE], const u_char c[CURVE25519_SIZE])
48 __attribute__((__bounded__(__minbytes__, 1, CURVE25519_SIZE)))
49 __attribute__((__bounded__(__minbytes__, 2, CURVE25519_SIZE)))
50 __attribute__((__bounded__(__minbytes__, 3, CURVE25519_SIZE)));
51
52void
53kexc25519_keygen(u_char key[CURVE25519_SIZE], u_char pub[CURVE25519_SIZE])
54{
55 static const u_char basepoint[CURVE25519_SIZE] = {9};
56
57 arc4random_buf(key, CURVE25519_SIZE);
58 crypto_scalarmult_curve25519(pub, key, basepoint);
59}
60
61void
62kexc25519_shared_key(const u_char key[CURVE25519_SIZE],
63 const u_char pub[CURVE25519_SIZE], Buffer *out)
64{
65 u_char shared_key[CURVE25519_SIZE];
66
67 crypto_scalarmult_curve25519(shared_key, key, pub);
68#ifdef DEBUG_KEXECDH
69 dump_digest("shared secret", shared_key, CURVE25519_SIZE);
70#endif
71 buffer_clear(out);
72 buffer_put_bignum2_from_string(out, shared_key, CURVE25519_SIZE);
73 memset(shared_key, 0, CURVE25519_SIZE); /* XXX explicit_bzero() */
74}
75
76void
77kex_c25519_hash(
78 int hash_alg,
79 char *client_version_string,
80 char *server_version_string,
81 char *ckexinit, int ckexinitlen,
82 char *skexinit, int skexinitlen,
83 u_char *serverhostkeyblob, int sbloblen,
84 const u_char client_dh_pub[CURVE25519_SIZE],
85 const u_char server_dh_pub[CURVE25519_SIZE],
86 const u_char *shared_secret, u_int secretlen,
87 u_char **hash, u_int *hashlen)
88{
89 Buffer b;
90 static u_char digest[SSH_DIGEST_MAX_LENGTH];
91
92 buffer_init(&b);
93 buffer_put_cstring(&b, client_version_string);
94 buffer_put_cstring(&b, server_version_string);
95
96 /* kexinit messages: fake header: len+SSH2_MSG_KEXINIT */
97 buffer_put_int(&b, ckexinitlen+1);
98 buffer_put_char(&b, SSH2_MSG_KEXINIT);
99 buffer_append(&b, ckexinit, ckexinitlen);
100 buffer_put_int(&b, skexinitlen+1);
101 buffer_put_char(&b, SSH2_MSG_KEXINIT);
102 buffer_append(&b, skexinit, skexinitlen);
103
104 buffer_put_string(&b, serverhostkeyblob, sbloblen);
105 buffer_put_string(&b, client_dh_pub, CURVE25519_SIZE);
106 buffer_put_string(&b, server_dh_pub, CURVE25519_SIZE);
107 buffer_append(&b, shared_secret, secretlen);
108
109#ifdef DEBUG_KEX
110 buffer_dump(&b);
111#endif
112 if (ssh_digest_buffer(hash_alg, &b, digest, sizeof(digest)) != 0)
113 fatal("%s: digest_buffer failed", __func__);
114
115 buffer_free(&b);
116
117#ifdef DEBUG_KEX
118 dump_digest("hash", digest, ssh_digest_bytes(hash_alg));
119#endif
120 *hash = digest;
121 *hashlen = ssh_digest_bytes(hash_alg);
122}
diff --git a/kexc25519c.c b/kexc25519c.c
new file mode 100644
index 000000000..a80678af6
--- /dev/null
+++ b/kexc25519c.c
@@ -0,0 +1,129 @@
1/* $OpenBSD: kexc25519c.c,v 1.4 2014/01/12 08:13:13 djm Exp $ */
2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2010 Damien Miller. All rights reserved.
5 * Copyright (c) 2013 Aris Adamantiadis. All rights reserved.
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
28#include "includes.h"
29
30#include <sys/types.h>
31
32#include <stdio.h>
33#include <string.h>
34#include <signal.h>
35
36#include "xmalloc.h"
37#include "buffer.h"
38#include "key.h"
39#include "cipher.h"
40#include "kex.h"
41#include "log.h"
42#include "packet.h"
43#include "ssh2.h"
44
45void
46kexc25519_client(Kex *kex)
47{
48 Key *server_host_key;
49 u_char client_key[CURVE25519_SIZE];
50 u_char client_pubkey[CURVE25519_SIZE];
51 u_char *server_pubkey = NULL;
52 u_char *server_host_key_blob = NULL, *signature = NULL;
53 u_char *hash;
54 u_int slen, sbloblen, hashlen;
55 Buffer shared_secret;
56
57 kexc25519_keygen(client_key, client_pubkey);
58
59 packet_start(SSH2_MSG_KEX_ECDH_INIT);
60 packet_put_string(client_pubkey, sizeof(client_pubkey));
61 packet_send();
62 debug("sending SSH2_MSG_KEX_ECDH_INIT");
63
64#ifdef DEBUG_KEXECDH
65 dump_digest("client private key:", client_key, sizeof(client_key));
66#endif
67
68 debug("expecting SSH2_MSG_KEX_ECDH_REPLY");
69 packet_read_expect(SSH2_MSG_KEX_ECDH_REPLY);
70
71 /* hostkey */
72 server_host_key_blob = packet_get_string(&sbloblen);
73 server_host_key = key_from_blob(server_host_key_blob, sbloblen);
74 if (server_host_key == NULL)
75 fatal("cannot decode server_host_key_blob");
76 if (server_host_key->type != kex->hostkey_type)
77 fatal("type mismatch for decoded server_host_key_blob");
78 if (kex->verify_host_key == NULL)
79 fatal("cannot verify server_host_key");
80 if (kex->verify_host_key(server_host_key) == -1)
81 fatal("server_host_key verification failed");
82
83 /* Q_S, server public key */
84 server_pubkey = packet_get_string(&slen);
85 if (slen != CURVE25519_SIZE)
86 fatal("Incorrect size for server Curve25519 pubkey: %d", slen);
87
88#ifdef DEBUG_KEXECDH
89 dump_digest("server public key:", server_pubkey, CURVE25519_SIZE);
90#endif
91
92 /* signed H */
93 signature = packet_get_string(&slen);
94 packet_check_eom();
95
96 buffer_init(&shared_secret);
97 kexc25519_shared_key(client_key, server_pubkey, &shared_secret);
98
99 /* calc and verify H */
100 kex_c25519_hash(
101 kex->hash_alg,
102 kex->client_version_string,
103 kex->server_version_string,
104 buffer_ptr(&kex->my), buffer_len(&kex->my),
105 buffer_ptr(&kex->peer), buffer_len(&kex->peer),
106 server_host_key_blob, sbloblen,
107 client_pubkey,
108 server_pubkey,
109 buffer_ptr(&shared_secret), buffer_len(&shared_secret),
110 &hash, &hashlen
111 );
112 free(server_host_key_blob);
113 free(server_pubkey);
114 if (key_verify(server_host_key, signature, slen, hash, hashlen) != 1)
115 fatal("key_verify failed for server_host_key");
116 key_free(server_host_key);
117 free(signature);
118
119 /* save session id */
120 if (kex->session_id == NULL) {
121 kex->session_id_len = hashlen;
122 kex->session_id = xmalloc(kex->session_id_len);
123 memcpy(kex->session_id, hash, kex->session_id_len);
124 }
125 kex_derive_keys(kex, hash, hashlen,
126 buffer_ptr(&shared_secret), buffer_len(&shared_secret));
127 buffer_free(&shared_secret);
128 kex_finish(kex);
129}
diff --git a/kexc25519s.c b/kexc25519s.c
new file mode 100644
index 000000000..2b8e8efa1
--- /dev/null
+++ b/kexc25519s.c
@@ -0,0 +1,126 @@
1/* $OpenBSD: kexc25519s.c,v 1.4 2014/01/12 08:13:13 djm Exp $ */
2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2010 Damien Miller. All rights reserved.
5 * Copyright (c) 2013 Aris Adamantiadis. All rights reserved.
6 *
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 "ssh2.h"
41
42void
43kexc25519_server(Kex *kex)
44{
45 Key *server_host_private, *server_host_public;
46 u_char *server_host_key_blob = NULL, *signature = NULL;
47 u_char server_key[CURVE25519_SIZE];
48 u_char *client_pubkey = NULL;
49 u_char server_pubkey[CURVE25519_SIZE];
50 u_char *hash;
51 u_int slen, sbloblen, hashlen;
52 Buffer shared_secret;
53
54 /* generate private key */
55 kexc25519_keygen(server_key, server_pubkey);
56#ifdef DEBUG_KEXECDH
57 dump_digest("server private key:", server_key, sizeof(server_key));
58#endif
59
60 if (kex->load_host_public_key == NULL ||
61 kex->load_host_private_key == NULL)
62 fatal("Cannot load hostkey");
63 server_host_public = kex->load_host_public_key(kex->hostkey_type);
64 if (server_host_public == NULL)
65 fatal("Unsupported hostkey type %d", kex->hostkey_type);
66 server_host_private = kex->load_host_private_key(kex->hostkey_type);
67
68 debug("expecting SSH2_MSG_KEX_ECDH_INIT");
69 packet_read_expect(SSH2_MSG_KEX_ECDH_INIT);
70 client_pubkey = packet_get_string(&slen);
71 if (slen != CURVE25519_SIZE)
72 fatal("Incorrect size for server Curve25519 pubkey: %d", slen);
73 packet_check_eom();
74
75#ifdef DEBUG_KEXECDH
76 dump_digest("client public key:", client_pubkey, CURVE25519_SIZE);
77#endif
78
79 buffer_init(&shared_secret);
80 kexc25519_shared_key(server_key, client_pubkey, &shared_secret);
81
82 /* calc H */
83 key_to_blob(server_host_public, &server_host_key_blob, &sbloblen);
84 kex_c25519_hash(
85 kex->hash_alg,
86 kex->client_version_string,
87 kex->server_version_string,
88 buffer_ptr(&kex->peer), buffer_len(&kex->peer),
89 buffer_ptr(&kex->my), buffer_len(&kex->my),
90 server_host_key_blob, sbloblen,
91 client_pubkey,
92 server_pubkey,
93 buffer_ptr(&shared_secret), buffer_len(&shared_secret),
94 &hash, &hashlen
95 );
96
97 /* save session id := H */
98 if (kex->session_id == NULL) {
99 kex->session_id_len = hashlen;
100 kex->session_id = xmalloc(kex->session_id_len);
101 memcpy(kex->session_id, hash, kex->session_id_len);
102 }
103
104 /* sign H */
105 kex->sign(server_host_private, server_host_public, &signature, &slen,
106 hash, hashlen);
107
108 /* destroy_sensitive_data(); */
109
110 /* send server hostkey, ECDH pubkey 'Q_S' and signed H */
111 packet_start(SSH2_MSG_KEX_ECDH_REPLY);
112 packet_put_string(server_host_key_blob, sbloblen);
113 packet_put_string(server_pubkey, sizeof(server_pubkey));
114 packet_put_string(signature, slen);
115 packet_send();
116
117 free(signature);
118 free(server_host_key_blob);
119 /* have keys, free server key */
120 free(client_pubkey);
121
122 kex_derive_keys(kex, hash, hashlen,
123 buffer_ptr(&shared_secret), buffer_len(&shared_secret));
124 buffer_free(&shared_secret);
125 kex_finish(kex);
126}
diff --git a/kexdh.c b/kexdh.c
index 56e22f5bc..e7cdadc90 100644
--- a/kexdh.c
+++ b/kexdh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexdh.c,v 1.23 2006/08/03 03:34:42 deraadt Exp $ */ 1/* $OpenBSD: kexdh.c,v 1.24 2014/01/09 23:20:00 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -36,6 +36,8 @@
36#include "key.h" 36#include "key.h"
37#include "cipher.h" 37#include "cipher.h"
38#include "kex.h" 38#include "kex.h"
39#include "digest.h"
40#include "log.h"
39 41
40void 42void
41kex_dh_hash( 43kex_dh_hash(
@@ -50,9 +52,7 @@ kex_dh_hash(
50 u_char **hash, u_int *hashlen) 52 u_char **hash, u_int *hashlen)
51{ 53{
52 Buffer b; 54 Buffer b;
53 static u_char digest[EVP_MAX_MD_SIZE]; 55 static u_char digest[SSH_DIGEST_MAX_LENGTH];
54 const EVP_MD *evp_md = EVP_sha1();
55 EVP_MD_CTX md;
56 56
57 buffer_init(&b); 57 buffer_init(&b);
58 buffer_put_cstring(&b, client_version_string); 58 buffer_put_cstring(&b, client_version_string);
@@ -74,15 +74,14 @@ kex_dh_hash(
74#ifdef DEBUG_KEX 74#ifdef DEBUG_KEX
75 buffer_dump(&b); 75 buffer_dump(&b);
76#endif 76#endif
77 EVP_DigestInit(&md, evp_md); 77 if (ssh_digest_buffer(SSH_DIGEST_SHA1, &b, digest, sizeof(digest)) != 0)
78 EVP_DigestUpdate(&md, buffer_ptr(&b), buffer_len(&b)); 78 fatal("%s: ssh_digest_buffer failed", __func__);
79 EVP_DigestFinal(&md, digest, NULL);
80 79
81 buffer_free(&b); 80 buffer_free(&b);
82 81
83#ifdef DEBUG_KEX 82#ifdef DEBUG_KEX
84 dump_digest("hash", digest, EVP_MD_size(evp_md)); 83 dump_digest("hash", digest, ssh_digest_bytes(SSH_DIGEST_SHA1));
85#endif 84#endif
86 *hash = digest; 85 *hash = digest;
87 *hashlen = EVP_MD_size(evp_md); 86 *hashlen = ssh_digest_bytes(SSH_DIGEST_SHA1);
88} 87}
diff --git a/kexdhc.c b/kexdhc.c
index ccd137cac..78509af21 100644
--- a/kexdhc.c
+++ b/kexdhc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexdhc.c,v 1.13 2013/05/17 00:13:13 djm Exp $ */ 1/* $OpenBSD: kexdhc.c,v 1.14 2014/01/12 08:13:13 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -155,7 +155,7 @@ kexdh_client(Kex *kex)
155 memcpy(kex->session_id, hash, kex->session_id_len); 155 memcpy(kex->session_id, hash, kex->session_id_len);
156 } 156 }
157 157
158 kex_derive_keys(kex, hash, hashlen, shared_secret); 158 kex_derive_keys_bn(kex, hash, hashlen, shared_secret);
159 BN_clear_free(shared_secret); 159 BN_clear_free(shared_secret);
160 kex_finish(kex); 160 kex_finish(kex);
161} 161}
diff --git a/kexdhs.c b/kexdhs.c
index 269d80900..d2c7adc96 100644
--- a/kexdhs.c
+++ b/kexdhs.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexdhs.c,v 1.14 2013/07/19 07:37:48 markus Exp $ */ 1/* $OpenBSD: kexdhs.c,v 1.17 2014/01/12 08:13:13 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -42,10 +42,6 @@
42#include "packet.h" 42#include "packet.h"
43#include "dh.h" 43#include "dh.h"
44#include "ssh2.h" 44#include "ssh2.h"
45#ifdef GSSAPI
46#include "ssh-gss.h"
47#endif
48#include "monitor_wrap.h"
49 45
50void 46void
51kexdh_server(Kex *kex) 47kexdh_server(Kex *kex)
@@ -158,7 +154,7 @@ kexdh_server(Kex *kex)
158 /* have keys, free DH */ 154 /* have keys, free DH */
159 DH_free(dh); 155 DH_free(dh);
160 156
161 kex_derive_keys(kex, hash, hashlen, shared_secret); 157 kex_derive_keys_bn(kex, hash, hashlen, shared_secret);
162 BN_clear_free(shared_secret); 158 BN_clear_free(shared_secret);
163 kex_finish(kex); 159 kex_finish(kex);
164} 160}
diff --git a/kexecdh.c b/kexecdh.c
index c948fe20a..c52c5e234 100644
--- a/kexecdh.c
+++ b/kexecdh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexecdh.c,v 1.4 2013/04/19 01:06:50 djm Exp $ */ 1/* $OpenBSD: kexecdh.c,v 1.5 2014/01/09 23:20:00 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2010 Damien Miller. All rights reserved. 4 * Copyright (c) 2010 Damien Miller. All rights reserved.
@@ -44,10 +44,11 @@
44#include "cipher.h" 44#include "cipher.h"
45#include "kex.h" 45#include "kex.h"
46#include "log.h" 46#include "log.h"
47#include "digest.h"
47 48
48void 49void
49kex_ecdh_hash( 50kex_ecdh_hash(
50 const EVP_MD *evp_md, 51 int hash_alg,
51 const EC_GROUP *ec_group, 52 const EC_GROUP *ec_group,
52 char *client_version_string, 53 char *client_version_string,
53 char *server_version_string, 54 char *server_version_string,
@@ -60,8 +61,7 @@ kex_ecdh_hash(
60 u_char **hash, u_int *hashlen) 61 u_char **hash, u_int *hashlen)
61{ 62{
62 Buffer b; 63 Buffer b;
63 EVP_MD_CTX md; 64 static u_char digest[SSH_DIGEST_MAX_LENGTH];
64 static u_char digest[EVP_MAX_MD_SIZE];
65 65
66 buffer_init(&b); 66 buffer_init(&b);
67 buffer_put_cstring(&b, client_version_string); 67 buffer_put_cstring(&b, client_version_string);
@@ -83,17 +83,15 @@ kex_ecdh_hash(
83#ifdef DEBUG_KEX 83#ifdef DEBUG_KEX
84 buffer_dump(&b); 84 buffer_dump(&b);
85#endif 85#endif
86 EVP_DigestInit(&md, evp_md); 86 if (ssh_digest_buffer(hash_alg, &b, digest, sizeof(digest)) != 0)
87 EVP_DigestUpdate(&md, buffer_ptr(&b), buffer_len(&b)); 87 fatal("%s: ssh_digest_buffer failed", __func__);
88 EVP_DigestFinal(&md, digest, NULL);
89 88
90 buffer_free(&b); 89 buffer_free(&b);
91 90
92#ifdef DEBUG_KEX 91#ifdef DEBUG_KEX
93 dump_digest("hash", digest, EVP_MD_size(evp_md)); 92 dump_digest("hash", digest, ssh_digest_bytes(hash_alg));
94#endif 93#endif
95 *hash = digest; 94 *hash = digest;
96 *hashlen = EVP_MD_size(evp_md); 95 *hashlen = ssh_digest_bytes(hash_alg);
97} 96}
98
99#endif /* OPENSSL_HAS_ECC */ 97#endif /* OPENSSL_HAS_ECC */
diff --git a/kexecdhc.c b/kexecdhc.c
index 6193836c7..e3d1cf5f9 100644
--- a/kexecdhc.c
+++ b/kexecdhc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexecdhc.c,v 1.4 2013/05/17 00:13:13 djm Exp $ */ 1/* $OpenBSD: kexecdhc.c,v 1.6 2014/01/12 08:13:13 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2010 Damien Miller. All rights reserved. 4 * Copyright (c) 2010 Damien Miller. All rights reserved.
@@ -124,7 +124,7 @@ kexecdh_client(Kex *kex)
124 124
125 /* calc and verify H */ 125 /* calc and verify H */
126 kex_ecdh_hash( 126 kex_ecdh_hash(
127 kex->evp_md, 127 kex->hash_alg,
128 group, 128 group,
129 kex->client_version_string, 129 kex->client_version_string,
130 kex->server_version_string, 130 kex->server_version_string,
@@ -152,7 +152,7 @@ kexecdh_client(Kex *kex)
152 memcpy(kex->session_id, hash, kex->session_id_len); 152 memcpy(kex->session_id, hash, kex->session_id_len);
153 } 153 }
154 154
155 kex_derive_keys(kex, hash, hashlen, shared_secret); 155 kex_derive_keys_bn(kex, hash, hashlen, shared_secret);
156 BN_clear_free(shared_secret); 156 BN_clear_free(shared_secret);
157 kex_finish(kex); 157 kex_finish(kex);
158} 158}
diff --git a/kexecdhs.c b/kexecdhs.c
index 3a580aacf..6fbb79c9d 100644
--- a/kexecdhs.c
+++ b/kexecdhs.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexecdhs.c,v 1.5 2013/07/19 07:37:48 markus Exp $ */ 1/* $OpenBSD: kexecdhs.c,v 1.9 2014/01/12 08:13:13 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2010 Damien Miller. All rights reserved. 4 * Copyright (c) 2010 Damien Miller. All rights reserved.
@@ -37,12 +37,7 @@
37#include "kex.h" 37#include "kex.h"
38#include "log.h" 38#include "log.h"
39#include "packet.h" 39#include "packet.h"
40#include "dh.h"
41#include "ssh2.h" 40#include "ssh2.h"
42#ifdef GSSAPI
43#include "ssh-gss.h"
44#endif
45#include "monitor_wrap.h"
46 41
47#ifdef OPENSSL_HAS_ECC 42#ifdef OPENSSL_HAS_ECC
48 43
@@ -114,7 +109,7 @@ kexecdh_server(Kex *kex)
114 /* calc H */ 109 /* calc H */
115 key_to_blob(server_host_public, &server_host_key_blob, &sbloblen); 110 key_to_blob(server_host_public, &server_host_key_blob, &sbloblen);
116 kex_ecdh_hash( 111 kex_ecdh_hash(
117 kex->evp_md, 112 kex->hash_alg,
118 group, 113 group,
119 kex->client_version_string, 114 kex->client_version_string,
120 kex->server_version_string, 115 kex->server_version_string,
@@ -153,7 +148,7 @@ kexecdh_server(Kex *kex)
153 /* have keys, free server key */ 148 /* have keys, free server key */
154 EC_KEY_free(server_key); 149 EC_KEY_free(server_key);
155 150
156 kex_derive_keys(kex, hash, hashlen, shared_secret); 151 kex_derive_keys_bn(kex, hash, hashlen, shared_secret);
157 BN_clear_free(shared_secret); 152 BN_clear_free(shared_secret);
158 kex_finish(kex); 153 kex_finish(kex);
159} 154}
diff --git a/kexgex.c b/kexgex.c
index b60ab5c53..c2e6bc16d 100644
--- a/kexgex.c
+++ b/kexgex.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexgex.c,v 1.27 2006/08/03 03:34:42 deraadt Exp $ */ 1/* $OpenBSD: kexgex.c,v 1.28 2014/01/09 23:20:00 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.
@@ -36,10 +36,12 @@
36#include "cipher.h" 36#include "cipher.h"
37#include "kex.h" 37#include "kex.h"
38#include "ssh2.h" 38#include "ssh2.h"
39#include "digest.h"
40#include "log.h"
39 41
40void 42void
41kexgex_hash( 43kexgex_hash(
42 const EVP_MD *evp_md, 44 int hash_alg,
43 char *client_version_string, 45 char *client_version_string,
44 char *server_version_string, 46 char *server_version_string,
45 char *ckexinit, int ckexinitlen, 47 char *ckexinit, int ckexinitlen,
@@ -52,8 +54,7 @@ kexgex_hash(
52 u_char **hash, u_int *hashlen) 54 u_char **hash, u_int *hashlen)
53{ 55{
54 Buffer b; 56 Buffer b;
55 static u_char digest[EVP_MAX_MD_SIZE]; 57 static u_char digest[SSH_DIGEST_MAX_LENGTH];
56 EVP_MD_CTX md;
57 58
58 buffer_init(&b); 59 buffer_init(&b);
59 buffer_put_cstring(&b, client_version_string); 60 buffer_put_cstring(&b, client_version_string);
@@ -84,15 +85,14 @@ kexgex_hash(
84#ifdef DEBUG_KEXDH 85#ifdef DEBUG_KEXDH
85 buffer_dump(&b); 86 buffer_dump(&b);
86#endif 87#endif
87 88 if (ssh_digest_buffer(hash_alg, &b, digest, sizeof(digest)) != 0)
88 EVP_DigestInit(&md, evp_md); 89 fatal("%s: ssh_digest_buffer failed", __func__);
89 EVP_DigestUpdate(&md, buffer_ptr(&b), buffer_len(&b));
90 EVP_DigestFinal(&md, digest, NULL);
91 90
92 buffer_free(&b); 91 buffer_free(&b);
93 *hash = digest; 92
94 *hashlen = EVP_MD_size(evp_md); 93#ifdef DEBUG_KEX
95#ifdef DEBUG_KEXDH 94 dump_digest("hash", digest, ssh_digest_bytes(hash_alg));
96 dump_digest("hash", digest, *hashlen);
97#endif 95#endif
96 *hash = digest;
97 *hashlen = ssh_digest_bytes(hash_alg);
98} 98}
diff --git a/kexgexc.c b/kexgexc.c
index 5a3be2005..629b5fbbc 100644
--- a/kexgexc.c
+++ b/kexgexc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexgexc.c,v 1.13 2013/05/17 00:13:13 djm Exp $ */ 1/* $OpenBSD: kexgexc.c,v 1.16 2014/01/25 10:12:50 dtucker 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.
@@ -58,7 +58,7 @@ kexgex_client(Kex *kex)
58 int min, max, nbits; 58 int min, max, nbits;
59 DH *dh; 59 DH *dh;
60 60
61 nbits = dh_estimate(kex->we_need * 8); 61 nbits = dh_estimate(kex->dh_need * 8);
62 62
63 if (datafellows & SSH_OLD_DHGEX) { 63 if (datafellows & SSH_OLD_DHGEX) {
64 /* Old GEX request */ 64 /* Old GEX request */
@@ -170,7 +170,7 @@ kexgex_client(Kex *kex)
170 170
171 /* calc and verify H */ 171 /* calc and verify H */
172 kexgex_hash( 172 kexgex_hash(
173 kex->evp_md, 173 kex->hash_alg,
174 kex->client_version_string, 174 kex->client_version_string,
175 kex->server_version_string, 175 kex->server_version_string,
176 buffer_ptr(&kex->my), buffer_len(&kex->my), 176 buffer_ptr(&kex->my), buffer_len(&kex->my),
@@ -200,7 +200,7 @@ kexgex_client(Kex *kex)
200 kex->session_id = xmalloc(kex->session_id_len); 200 kex->session_id = xmalloc(kex->session_id_len);
201 memcpy(kex->session_id, hash, kex->session_id_len); 201 memcpy(kex->session_id, hash, kex->session_id_len);
202 } 202 }
203 kex_derive_keys(kex, hash, hashlen, shared_secret); 203 kex_derive_keys_bn(kex, hash, hashlen, shared_secret);
204 BN_clear_free(shared_secret); 204 BN_clear_free(shared_secret);
205 205
206 kex_finish(kex); 206 kex_finish(kex);
diff --git a/kexgexs.c b/kexgexs.c
index 4e473fc73..8773778ed 100644
--- a/kexgexs.c
+++ b/kexgexs.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexgexs.c,v 1.16 2013/07/19 07:37:48 markus Exp $ */ 1/* $OpenBSD: kexgexs.c,v 1.18 2014/01/12 08:13:13 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.
@@ -160,7 +160,7 @@ kexgex_server(Kex *kex)
160 160
161 /* calc H */ 161 /* calc H */
162 kexgex_hash( 162 kexgex_hash(
163 kex->evp_md, 163 kex->hash_alg,
164 kex->client_version_string, 164 kex->client_version_string,
165 kex->server_version_string, 165 kex->server_version_string,
166 buffer_ptr(&kex->peer), buffer_len(&kex->peer), 166 buffer_ptr(&kex->peer), buffer_len(&kex->peer),
@@ -201,7 +201,7 @@ kexgex_server(Kex *kex)
201 /* have keys, free DH */ 201 /* have keys, free DH */
202 DH_free(dh); 202 DH_free(dh);
203 203
204 kex_derive_keys(kex, hash, hashlen, shared_secret); 204 kex_derive_keys_bn(kex, hash, hashlen, shared_secret);
205 BN_clear_free(shared_secret); 205 BN_clear_free(shared_secret);
206 206
207 kex_finish(kex); 207 kex_finish(kex);
diff --git a/key.c b/key.c
index 55ee78998..914233808 100644
--- a/key.c
+++ b/key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: key.c,v 1.104 2013/05/19 02:42:42 djm Exp $ */ 1/* $OpenBSD: key.c,v 1.115 2014/01/09 23:20:00 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
@@ -39,6 +39,8 @@
39#include <sys/param.h> 39#include <sys/param.h>
40#include <sys/types.h> 40#include <sys/types.h>
41 41
42#include "crypto_api.h"
43
42#include <openssl/evp.h> 44#include <openssl/evp.h>
43#include <openbsd-compat/openssl-compat.h> 45#include <openbsd-compat/openssl-compat.h>
44 46
@@ -54,8 +56,10 @@
54#include "log.h" 56#include "log.h"
55#include "misc.h" 57#include "misc.h"
56#include "ssh2.h" 58#include "ssh2.h"
59#include "digest.h"
57 60
58static int to_blob(const Key *, u_char **, u_int *, int); 61static int to_blob(const Key *, u_char **, u_int *, int);
62static Key *key_from_blob2(const u_char *, u_int, int);
59 63
60static struct KeyCert * 64static struct KeyCert *
61cert_new(void) 65cert_new(void)
@@ -85,6 +89,8 @@ key_new(int type)
85 k->dsa = NULL; 89 k->dsa = NULL;
86 k->rsa = NULL; 90 k->rsa = NULL;
87 k->cert = NULL; 91 k->cert = NULL;
92 k->ed25519_sk = NULL;
93 k->ed25519_pk = NULL;
88 switch (k->type) { 94 switch (k->type) {
89 case KEY_RSA1: 95 case KEY_RSA1:
90 case KEY_RSA: 96 case KEY_RSA:
@@ -119,6 +125,10 @@ key_new(int type)
119 /* Cannot do anything until we know the group */ 125 /* Cannot do anything until we know the group */
120 break; 126 break;
121#endif 127#endif
128 case KEY_ED25519:
129 case KEY_ED25519_CERT:
130 /* no need to prealloc */
131 break;
122 case KEY_UNSPEC: 132 case KEY_UNSPEC:
123 break; 133 break;
124 default: 134 default:
@@ -163,6 +173,10 @@ key_add_private(Key *k)
163 case KEY_ECDSA_CERT: 173 case KEY_ECDSA_CERT:
164 /* Cannot do anything until we know the group */ 174 /* Cannot do anything until we know the group */
165 break; 175 break;
176 case KEY_ED25519:
177 case KEY_ED25519_CERT:
178 /* no need to prealloc */
179 break;
166 case KEY_UNSPEC: 180 case KEY_UNSPEC:
167 break; 181 break;
168 default: 182 default:
@@ -225,6 +239,19 @@ key_free(Key *k)
225 k->ecdsa = NULL; 239 k->ecdsa = NULL;
226 break; 240 break;
227#endif 241#endif
242 case KEY_ED25519:
243 case KEY_ED25519_CERT:
244 if (k->ed25519_pk) {
245 memset(k->ed25519_pk, 0, ED25519_PK_SZ);
246 free(k->ed25519_pk);
247 k->ed25519_pk = NULL;
248 }
249 if (k->ed25519_sk) {
250 memset(k->ed25519_sk, 0, ED25519_SK_SZ);
251 free(k->ed25519_sk);
252 k->ed25519_sk = NULL;
253 }
254 break;
228 case KEY_UNSPEC: 255 case KEY_UNSPEC:
229 break; 256 break;
230 default: 257 default:
@@ -306,6 +333,10 @@ key_equal_public(const Key *a, const Key *b)
306 BN_CTX_free(bnctx); 333 BN_CTX_free(bnctx);
307 return 1; 334 return 1;
308#endif /* OPENSSL_HAS_ECC */ 335#endif /* OPENSSL_HAS_ECC */
336 case KEY_ED25519:
337 case KEY_ED25519_CERT:
338 return a->ed25519_pk != NULL && b->ed25519_pk != NULL &&
339 memcmp(a->ed25519_pk, b->ed25519_pk, ED25519_PK_SZ) == 0;
309 default: 340 default:
310 fatal("key_equal: bad key type %d", a->type); 341 fatal("key_equal: bad key type %d", a->type);
311 } 342 }
@@ -328,30 +359,26 @@ u_char*
328key_fingerprint_raw(const Key *k, enum fp_type dgst_type, 359key_fingerprint_raw(const Key *k, enum fp_type dgst_type,
329 u_int *dgst_raw_length) 360 u_int *dgst_raw_length)
330{ 361{
331 const EVP_MD *md = NULL;
332 EVP_MD_CTX ctx;
333 u_char *blob = NULL; 362 u_char *blob = NULL;
334 u_char *retval = NULL; 363 u_char *retval = NULL;
335 u_int len = 0; 364 u_int len = 0;
336 int nlen, elen; 365 int nlen, elen, hash_alg = -1;
337 366
338 *dgst_raw_length = 0; 367 *dgst_raw_length = 0;
339 368
369 /* XXX switch to DIGEST_* directly? */
340 switch (dgst_type) { 370 switch (dgst_type) {
341 case SSH_FP_MD5: 371 case SSH_FP_MD5:
342 md = EVP_md5(); 372 hash_alg = SSH_DIGEST_MD5;
343 break; 373 break;
344 case SSH_FP_SHA1: 374 case SSH_FP_SHA1:
345 md = EVP_sha1(); 375 hash_alg = SSH_DIGEST_SHA1;
346 break; 376 break;
347#ifdef HAVE_EVP_SHA256
348 case SSH_FP_SHA256: 377 case SSH_FP_SHA256:
349 md = EVP_sha256(); 378 hash_alg = SSH_DIGEST_SHA256;
350 break; 379 break;
351#endif
352 default: 380 default:
353 fatal("key_fingerprint_raw: bad digest type %d", 381 fatal("%s: bad digest type %d", __func__, dgst_type);
354 dgst_type);
355 } 382 }
356 switch (k->type) { 383 switch (k->type) {
357 case KEY_RSA1: 384 case KEY_RSA1:
@@ -365,6 +392,7 @@ key_fingerprint_raw(const Key *k, enum fp_type dgst_type,
365 case KEY_DSA: 392 case KEY_DSA:
366 case KEY_ECDSA: 393 case KEY_ECDSA:
367 case KEY_RSA: 394 case KEY_RSA:
395 case KEY_ED25519:
368 key_to_blob(k, &blob, &len); 396 key_to_blob(k, &blob, &len);
369 break; 397 break;
370 case KEY_DSA_CERT_V00: 398 case KEY_DSA_CERT_V00:
@@ -372,24 +400,26 @@ key_fingerprint_raw(const Key *k, enum fp_type dgst_type,
372 case KEY_DSA_CERT: 400 case KEY_DSA_CERT:
373 case KEY_ECDSA_CERT: 401 case KEY_ECDSA_CERT:
374 case KEY_RSA_CERT: 402 case KEY_RSA_CERT:
403 case KEY_ED25519_CERT:
375 /* We want a fingerprint of the _key_ not of the cert */ 404 /* We want a fingerprint of the _key_ not of the cert */
376 to_blob(k, &blob, &len, 1); 405 to_blob(k, &blob, &len, 1);
377 break; 406 break;
378 case KEY_UNSPEC: 407 case KEY_UNSPEC:
379 return retval; 408 return retval;
380 default: 409 default:
381 fatal("key_fingerprint_raw: bad key type %d", k->type); 410 fatal("%s: bad key type %d", __func__, k->type);
382 break; 411 break;
383 } 412 }
384 if (blob != NULL) { 413 if (blob != NULL) {
385 retval = xmalloc(EVP_MAX_MD_SIZE); 414 retval = xmalloc(SSH_DIGEST_MAX_LENGTH);
386 EVP_DigestInit(&ctx, md); 415 if ((ssh_digest_memory(hash_alg, blob, len,
387 EVP_DigestUpdate(&ctx, blob, len); 416 retval, SSH_DIGEST_MAX_LENGTH)) != 0)
388 EVP_DigestFinal(&ctx, retval, dgst_raw_length); 417 fatal("%s: digest_memory failed", __func__);
389 memset(blob, 0, len); 418 memset(blob, 0, len);
390 free(blob); 419 free(blob);
420 *dgst_raw_length = ssh_digest_bytes(hash_alg);
391 } else { 421 } else {
392 fatal("key_fingerprint_raw: blob is null"); 422 fatal("%s: blob is null", __func__);
393 } 423 }
394 return retval; 424 return retval;
395} 425}
@@ -698,11 +728,13 @@ key_read(Key *ret, char **cpp)
698 case KEY_RSA: 728 case KEY_RSA:
699 case KEY_DSA: 729 case KEY_DSA:
700 case KEY_ECDSA: 730 case KEY_ECDSA:
731 case KEY_ED25519:
701 case KEY_DSA_CERT_V00: 732 case KEY_DSA_CERT_V00:
702 case KEY_RSA_CERT_V00: 733 case KEY_RSA_CERT_V00:
703 case KEY_DSA_CERT: 734 case KEY_DSA_CERT:
704 case KEY_ECDSA_CERT: 735 case KEY_ECDSA_CERT:
705 case KEY_RSA_CERT: 736 case KEY_RSA_CERT:
737 case KEY_ED25519_CERT:
706 space = strchr(cp, ' '); 738 space = strchr(cp, ' ');
707 if (space == NULL) { 739 if (space == NULL) {
708 debug3("key_read: missing whitespace"); 740 debug3("key_read: missing whitespace");
@@ -804,6 +836,14 @@ key_read(Key *ret, char **cpp)
804#endif 836#endif
805 } 837 }
806#endif 838#endif
839 if (key_type_plain(ret->type) == KEY_ED25519) {
840 free(ret->ed25519_pk);
841 ret->ed25519_pk = k->ed25519_pk;
842 k->ed25519_pk = NULL;
843#ifdef DEBUG_PK
844 /* XXX */
845#endif
846 }
807 success = 1; 847 success = 1;
808/*XXXX*/ 848/*XXXX*/
809 key_free(k); 849 key_free(k);
@@ -867,6 +907,11 @@ key_write(const Key *key, FILE *f)
867 return 0; 907 return 0;
868 break; 908 break;
869#endif 909#endif
910 case KEY_ED25519:
911 case KEY_ED25519_CERT:
912 if (key->ed25519_pk == NULL)
913 return 0;
914 break;
870 case KEY_RSA: 915 case KEY_RSA:
871 case KEY_RSA_CERT_V00: 916 case KEY_RSA_CERT_V00:
872 case KEY_RSA_CERT: 917 case KEY_RSA_CERT:
@@ -914,10 +959,13 @@ static const struct keytype keytypes[] = {
914 { NULL, "RSA1", KEY_RSA1, 0, 0 }, 959 { NULL, "RSA1", KEY_RSA1, 0, 0 },
915 { "ssh-rsa", "RSA", KEY_RSA, 0, 0 }, 960 { "ssh-rsa", "RSA", KEY_RSA, 0, 0 },
916 { "ssh-dss", "DSA", KEY_DSA, 0, 0 }, 961 { "ssh-dss", "DSA", KEY_DSA, 0, 0 },
962 { "ssh-ed25519", "ED25519", KEY_ED25519, 0, 0 },
917#ifdef OPENSSL_HAS_ECC 963#ifdef OPENSSL_HAS_ECC
918 { "ecdsa-sha2-nistp256", "ECDSA", KEY_ECDSA, NID_X9_62_prime256v1, 0 }, 964 { "ecdsa-sha2-nistp256", "ECDSA", KEY_ECDSA, NID_X9_62_prime256v1, 0 },
919 { "ecdsa-sha2-nistp384", "ECDSA", KEY_ECDSA, NID_secp384r1, 0 }, 965 { "ecdsa-sha2-nistp384", "ECDSA", KEY_ECDSA, NID_secp384r1, 0 },
966# ifdef OPENSSL_HAS_NISTP521
920 { "ecdsa-sha2-nistp521", "ECDSA", KEY_ECDSA, NID_secp521r1, 0 }, 967 { "ecdsa-sha2-nistp521", "ECDSA", KEY_ECDSA, NID_secp521r1, 0 },
968# endif
921#endif /* OPENSSL_HAS_ECC */ 969#endif /* OPENSSL_HAS_ECC */
922 { "ssh-rsa-cert-v01@openssh.com", "RSA-CERT", KEY_RSA_CERT, 0, 1 }, 970 { "ssh-rsa-cert-v01@openssh.com", "RSA-CERT", KEY_RSA_CERT, 0, 1 },
923 { "ssh-dss-cert-v01@openssh.com", "DSA-CERT", KEY_DSA_CERT, 0, 1 }, 971 { "ssh-dss-cert-v01@openssh.com", "DSA-CERT", KEY_DSA_CERT, 0, 1 },
@@ -926,13 +974,17 @@ static const struct keytype keytypes[] = {
926 KEY_ECDSA_CERT, NID_X9_62_prime256v1, 1 }, 974 KEY_ECDSA_CERT, NID_X9_62_prime256v1, 1 },
927 { "ecdsa-sha2-nistp384-cert-v01@openssh.com", "ECDSA-CERT", 975 { "ecdsa-sha2-nistp384-cert-v01@openssh.com", "ECDSA-CERT",
928 KEY_ECDSA_CERT, NID_secp384r1, 1 }, 976 KEY_ECDSA_CERT, NID_secp384r1, 1 },
977# ifdef OPENSSL_HAS_NISTP521
929 { "ecdsa-sha2-nistp521-cert-v01@openssh.com", "ECDSA-CERT", 978 { "ecdsa-sha2-nistp521-cert-v01@openssh.com", "ECDSA-CERT",
930 KEY_ECDSA_CERT, NID_secp521r1, 1 }, 979 KEY_ECDSA_CERT, NID_secp521r1, 1 },
980# endif
931#endif /* OPENSSL_HAS_ECC */ 981#endif /* OPENSSL_HAS_ECC */
932 { "ssh-rsa-cert-v00@openssh.com", "RSA-CERT-V00", 982 { "ssh-rsa-cert-v00@openssh.com", "RSA-CERT-V00",
933 KEY_RSA_CERT_V00, 0, 1 }, 983 KEY_RSA_CERT_V00, 0, 1 },
934 { "ssh-dss-cert-v00@openssh.com", "DSA-CERT-V00", 984 { "ssh-dss-cert-v00@openssh.com", "DSA-CERT-V00",
935 KEY_DSA_CERT_V00, 0, 1 }, 985 KEY_DSA_CERT_V00, 0, 1 },
986 { "ssh-ed25519-cert-v01@openssh.com", "ED25519-CERT",
987 KEY_ED25519_CERT, 0, 1 },
936 { NULL, NULL, -1, -1, 0 } 988 { NULL, NULL, -1, -1, 0 }
937}; 989};
938 990
@@ -1004,7 +1056,7 @@ key_ecdsa_nid_from_name(const char *name)
1004} 1056}
1005 1057
1006char * 1058char *
1007key_alg_list(void) 1059key_alg_list(int certs_only, int plain_only)
1008{ 1060{
1009 char *ret = NULL; 1061 char *ret = NULL;
1010 size_t nlen, rlen = 0; 1062 size_t nlen, rlen = 0;
@@ -1013,6 +1065,8 @@ key_alg_list(void)
1013 for (kt = keytypes; kt->type != -1; kt++) { 1065 for (kt = keytypes; kt->type != -1; kt++) {
1014 if (kt->name == NULL) 1066 if (kt->name == NULL)
1015 continue; 1067 continue;
1068 if ((certs_only && !kt->cert) || (plain_only && kt->cert))
1069 continue;
1016 if (ret != NULL) 1070 if (ret != NULL)
1017 ret[rlen++] = '\n'; 1071 ret[rlen++] = '\n';
1018 nlen = strlen(kt->name); 1072 nlen = strlen(kt->name);
@@ -1023,6 +1077,32 @@ key_alg_list(void)
1023 return ret; 1077 return ret;
1024} 1078}
1025 1079
1080int
1081key_type_is_cert(int type)
1082{
1083 const struct keytype *kt;
1084
1085 for (kt = keytypes; kt->type != -1; kt++) {
1086 if (kt->type == type)
1087 return kt->cert;
1088 }
1089 return 0;
1090}
1091
1092static int
1093key_type_is_valid_ca(int type)
1094{
1095 switch (type) {
1096 case KEY_RSA:
1097 case KEY_DSA:
1098 case KEY_ECDSA:
1099 case KEY_ED25519:
1100 return 1;
1101 default:
1102 return 0;
1103 }
1104}
1105
1026u_int 1106u_int
1027key_size(const Key *k) 1107key_size(const Key *k)
1028{ 1108{
@@ -1036,6 +1116,8 @@ key_size(const Key *k)
1036 case KEY_DSA_CERT_V00: 1116 case KEY_DSA_CERT_V00:
1037 case KEY_DSA_CERT: 1117 case KEY_DSA_CERT:
1038 return BN_num_bits(k->dsa->p); 1118 return BN_num_bits(k->dsa->p);
1119 case KEY_ED25519:
1120 return 256; /* XXX */
1039#ifdef OPENSSL_HAS_ECC 1121#ifdef OPENSSL_HAS_ECC
1040 case KEY_ECDSA: 1122 case KEY_ECDSA:
1041 case KEY_ECDSA_CERT: 1123 case KEY_ECDSA_CERT:
@@ -1087,8 +1169,10 @@ key_ecdsa_bits_to_nid(int bits)
1087 return NID_X9_62_prime256v1; 1169 return NID_X9_62_prime256v1;
1088 case 384: 1170 case 384:
1089 return NID_secp384r1; 1171 return NID_secp384r1;
1172# ifdef OPENSSL_HAS_NISTP521
1090 case 521: 1173 case 521:
1091 return NID_secp521r1; 1174 return NID_secp521r1;
1175# endif
1092#endif 1176#endif
1093 default: 1177 default:
1094 return -1; 1178 return -1;
@@ -1103,7 +1187,9 @@ key_ecdsa_key_to_nid(EC_KEY *k)
1103 int nids[] = { 1187 int nids[] = {
1104 NID_X9_62_prime256v1, 1188 NID_X9_62_prime256v1,
1105 NID_secp384r1, 1189 NID_secp384r1,
1190# ifdef OPENSSL_HAS_NISTP521
1106 NID_secp521r1, 1191 NID_secp521r1,
1192# endif
1107 -1 1193 -1
1108 }; 1194 };
1109 int nid; 1195 int nid;
@@ -1175,6 +1261,11 @@ key_generate(int type, u_int bits)
1175 case KEY_RSA1: 1261 case KEY_RSA1:
1176 k->rsa = rsa_generate_private_key(bits); 1262 k->rsa = rsa_generate_private_key(bits);
1177 break; 1263 break;
1264 case KEY_ED25519:
1265 k->ed25519_pk = xmalloc(ED25519_PK_SZ);
1266 k->ed25519_sk = xmalloc(ED25519_SK_SZ);
1267 crypto_sign_ed25519_keypair(k->ed25519_pk, k->ed25519_sk);
1268 break;
1178 case KEY_RSA_CERT_V00: 1269 case KEY_RSA_CERT_V00:
1179 case KEY_DSA_CERT_V00: 1270 case KEY_DSA_CERT_V00:
1180 case KEY_RSA_CERT: 1271 case KEY_RSA_CERT:
@@ -1268,6 +1359,14 @@ key_from_private(const Key *k)
1268 (BN_copy(n->rsa->e, k->rsa->e) == NULL)) 1359 (BN_copy(n->rsa->e, k->rsa->e) == NULL))
1269 fatal("key_from_private: BN_copy failed"); 1360 fatal("key_from_private: BN_copy failed");
1270 break; 1361 break;
1362 case KEY_ED25519:
1363 case KEY_ED25519_CERT:
1364 n = key_new(k->type);
1365 if (k->ed25519_pk != NULL) {
1366 n->ed25519_pk = xmalloc(ED25519_PK_SZ);
1367 memcpy(n->ed25519_pk, k->ed25519_pk, ED25519_PK_SZ);
1368 }
1369 break;
1271 default: 1370 default:
1272 fatal("key_from_private: unknown type %d", k->type); 1371 fatal("key_from_private: unknown type %d", k->type);
1273 break; 1372 break;
@@ -1387,14 +1486,12 @@ cert_parse(Buffer *b, Key *key, const u_char *blob, u_int blen)
1387 } 1486 }
1388 buffer_clear(&tmp); 1487 buffer_clear(&tmp);
1389 1488
1390 if ((key->cert->signature_key = key_from_blob(sig_key, 1489 if ((key->cert->signature_key = key_from_blob2(sig_key, sklen, 0))
1391 sklen)) == NULL) { 1490 == NULL) {
1392 error("%s: Signature key invalid", __func__); 1491 error("%s: Signature key invalid", __func__);
1393 goto out; 1492 goto out;
1394 } 1493 }
1395 if (key->cert->signature_key->type != KEY_RSA && 1494 if (!key_type_is_valid_ca(key->cert->signature_key->type)) {
1396 key->cert->signature_key->type != KEY_DSA &&
1397 key->cert->signature_key->type != KEY_ECDSA) {
1398 error("%s: Invalid signature key type %s (%d)", __func__, 1495 error("%s: Invalid signature key type %s (%d)", __func__,
1399 key_type(key->cert->signature_key), 1496 key_type(key->cert->signature_key),
1400 key->cert->signature_key->type); 1497 key->cert->signature_key->type);
@@ -1425,12 +1522,14 @@ cert_parse(Buffer *b, Key *key, const u_char *blob, u_int blen)
1425 return ret; 1522 return ret;
1426} 1523}
1427 1524
1428Key * 1525static Key *
1429key_from_blob(const u_char *blob, u_int blen) 1526key_from_blob2(const u_char *blob, u_int blen, int allow_cert)
1430{ 1527{
1431 Buffer b; 1528 Buffer b;
1432 int rlen, type; 1529 int rlen, type;
1530 u_int len;
1433 char *ktype = NULL, *curve = NULL; 1531 char *ktype = NULL, *curve = NULL;
1532 u_char *pk = NULL;
1434 Key *key = NULL; 1533 Key *key = NULL;
1435#ifdef OPENSSL_HAS_ECC 1534#ifdef OPENSSL_HAS_ECC
1436 EC_POINT *q = NULL; 1535 EC_POINT *q = NULL;
@@ -1452,7 +1551,10 @@ key_from_blob(const u_char *blob, u_int blen)
1452 if (key_type_plain(type) == KEY_ECDSA) 1551 if (key_type_plain(type) == KEY_ECDSA)
1453 nid = key_ecdsa_nid_from_name(ktype); 1552 nid = key_ecdsa_nid_from_name(ktype);
1454#endif 1553#endif
1455 1554 if (!allow_cert && key_type_is_cert(type)) {
1555 error("key_from_blob: certificate not allowed in this context");
1556 goto out;
1557 }
1456 switch (type) { 1558 switch (type) {
1457 case KEY_RSA_CERT: 1559 case KEY_RSA_CERT:
1458 (void)buffer_get_string_ptr_ret(&b, NULL); /* Skip nonce */ 1560 (void)buffer_get_string_ptr_ret(&b, NULL); /* Skip nonce */
@@ -1526,6 +1628,23 @@ key_from_blob(const u_char *blob, u_int blen)
1526#endif 1628#endif
1527 break; 1629 break;
1528#endif /* OPENSSL_HAS_ECC */ 1630#endif /* OPENSSL_HAS_ECC */
1631 case KEY_ED25519_CERT:
1632 (void)buffer_get_string_ptr_ret(&b, NULL); /* Skip nonce */
1633 /* FALLTHROUGH */
1634 case KEY_ED25519:
1635 if ((pk = buffer_get_string_ret(&b, &len)) == NULL) {
1636 error("key_from_blob: can't read ed25519 key");
1637 goto badkey;
1638 }
1639 if (len != ED25519_PK_SZ) {
1640 error("key_from_blob: ed25519 len %d != %d",
1641 len, ED25519_PK_SZ);
1642 goto badkey;
1643 }
1644 key = key_new(type);
1645 key->ed25519_pk = pk;
1646 pk = NULL;
1647 break;
1529 case KEY_UNSPEC: 1648 case KEY_UNSPEC:
1530 key = key_new(type); 1649 key = key_new(type);
1531 break; 1650 break;
@@ -1543,6 +1662,7 @@ key_from_blob(const u_char *blob, u_int blen)
1543 out: 1662 out:
1544 free(ktype); 1663 free(ktype);
1545 free(curve); 1664 free(curve);
1665 free(pk);
1546#ifdef OPENSSL_HAS_ECC 1666#ifdef OPENSSL_HAS_ECC
1547 if (q != NULL) 1667 if (q != NULL)
1548 EC_POINT_free(q); 1668 EC_POINT_free(q);
@@ -1551,12 +1671,22 @@ key_from_blob(const u_char *blob, u_int blen)
1551 return key; 1671 return key;
1552} 1672}
1553 1673
1674Key *
1675key_from_blob(const u_char *blob, u_int blen)
1676{
1677 return key_from_blob2(blob, blen, 1);
1678}
1679
1554static int 1680static int
1555to_blob(const Key *key, u_char **blobp, u_int *lenp, int force_plain) 1681to_blob(const Key *key, u_char **blobp, u_int *lenp, int force_plain)
1556{ 1682{
1557 Buffer b; 1683 Buffer b;
1558 int len, type; 1684 int len, type;
1559 1685
1686 if (blobp != NULL)
1687 *blobp = NULL;
1688 if (lenp != NULL)
1689 *lenp = 0;
1560 if (key == NULL) { 1690 if (key == NULL) {
1561 error("key_to_blob: key == NULL"); 1691 error("key_to_blob: key == NULL");
1562 return 0; 1692 return 0;
@@ -1569,6 +1699,7 @@ to_blob(const Key *key, u_char **blobp, u_int *lenp, int force_plain)
1569 case KEY_DSA_CERT: 1699 case KEY_DSA_CERT:
1570 case KEY_ECDSA_CERT: 1700 case KEY_ECDSA_CERT:
1571 case KEY_RSA_CERT: 1701 case KEY_RSA_CERT:
1702 case KEY_ED25519_CERT:
1572 /* Use the existing blob */ 1703 /* Use the existing blob */
1573 buffer_append(&b, buffer_ptr(&key->cert->certblob), 1704 buffer_append(&b, buffer_ptr(&key->cert->certblob),
1574 buffer_len(&key->cert->certblob)); 1705 buffer_len(&key->cert->certblob));
@@ -1596,6 +1727,11 @@ to_blob(const Key *key, u_char **blobp, u_int *lenp, int force_plain)
1596 buffer_put_bignum2(&b, key->rsa->e); 1727 buffer_put_bignum2(&b, key->rsa->e);
1597 buffer_put_bignum2(&b, key->rsa->n); 1728 buffer_put_bignum2(&b, key->rsa->n);
1598 break; 1729 break;
1730 case KEY_ED25519:
1731 buffer_put_cstring(&b,
1732 key_ssh_name_from_type_nid(type, key->ecdsa_nid));
1733 buffer_put_string(&b, key->ed25519_pk, ED25519_PK_SZ);
1734 break;
1599 default: 1735 default:
1600 error("key_to_blob: unsupported key type %d", key->type); 1736 error("key_to_blob: unsupported key type %d", key->type);
1601 buffer_free(&b); 1737 buffer_free(&b);
@@ -1639,6 +1775,9 @@ key_sign(
1639 case KEY_RSA_CERT: 1775 case KEY_RSA_CERT:
1640 case KEY_RSA: 1776 case KEY_RSA:
1641 return ssh_rsa_sign(key, sigp, lenp, data, datalen); 1777 return ssh_rsa_sign(key, sigp, lenp, data, datalen);
1778 case KEY_ED25519:
1779 case KEY_ED25519_CERT:
1780 return ssh_ed25519_sign(key, sigp, lenp, data, datalen);
1642 default: 1781 default:
1643 error("key_sign: invalid key type %d", key->type); 1782 error("key_sign: invalid key type %d", key->type);
1644 return -1; 1783 return -1;
@@ -1672,6 +1811,9 @@ key_verify(
1672 case KEY_RSA_CERT: 1811 case KEY_RSA_CERT:
1673 case KEY_RSA: 1812 case KEY_RSA:
1674 return ssh_rsa_verify(key, signature, signaturelen, data, datalen); 1813 return ssh_rsa_verify(key, signature, signaturelen, data, datalen);
1814 case KEY_ED25519:
1815 case KEY_ED25519_CERT:
1816 return ssh_ed25519_verify(key, signature, signaturelen, data, datalen);
1675 default: 1817 default:
1676 error("key_verify: invalid key type %d", key->type); 1818 error("key_verify: invalid key type %d", key->type);
1677 return -1; 1819 return -1;
@@ -1691,6 +1833,8 @@ key_demote(const Key *k)
1691 pk->dsa = NULL; 1833 pk->dsa = NULL;
1692 pk->ecdsa = NULL; 1834 pk->ecdsa = NULL;
1693 pk->rsa = NULL; 1835 pk->rsa = NULL;
1836 pk->ed25519_pk = NULL;
1837 pk->ed25519_sk = NULL;
1694 1838
1695 switch (k->type) { 1839 switch (k->type) {
1696 case KEY_RSA_CERT_V00: 1840 case KEY_RSA_CERT_V00:
@@ -1734,8 +1878,17 @@ key_demote(const Key *k)
1734 fatal("key_demote: EC_KEY_set_public_key failed"); 1878 fatal("key_demote: EC_KEY_set_public_key failed");
1735 break; 1879 break;
1736#endif 1880#endif
1881 case KEY_ED25519_CERT:
1882 key_cert_copy(k, pk);
1883 /* FALLTHROUGH */
1884 case KEY_ED25519:
1885 if (k->ed25519_pk != NULL) {
1886 pk->ed25519_pk = xmalloc(ED25519_PK_SZ);
1887 memcpy(pk->ed25519_pk, k->ed25519_pk, ED25519_PK_SZ);
1888 }
1889 break;
1737 default: 1890 default:
1738 fatal("key_free: bad key type %d", k->type); 1891 fatal("key_demote: bad key type %d", k->type);
1739 break; 1892 break;
1740 } 1893 }
1741 1894
@@ -1747,16 +1900,7 @@ key_is_cert(const Key *k)
1747{ 1900{
1748 if (k == NULL) 1901 if (k == NULL)
1749 return 0; 1902 return 0;
1750 switch (k->type) { 1903 return key_type_is_cert(k->type);
1751 case KEY_RSA_CERT_V00:
1752 case KEY_DSA_CERT_V00:
1753 case KEY_RSA_CERT:
1754 case KEY_DSA_CERT:
1755 case KEY_ECDSA_CERT:
1756 return 1;
1757 default:
1758 return 0;
1759 }
1760} 1904}
1761 1905
1762/* Return the cert-less equivalent to a certified key type */ 1906/* Return the cert-less equivalent to a certified key type */
@@ -1772,12 +1916,14 @@ key_type_plain(int type)
1772 return KEY_DSA; 1916 return KEY_DSA;
1773 case KEY_ECDSA_CERT: 1917 case KEY_ECDSA_CERT:
1774 return KEY_ECDSA; 1918 return KEY_ECDSA;
1919 case KEY_ED25519_CERT:
1920 return KEY_ED25519;
1775 default: 1921 default:
1776 return type; 1922 return type;
1777 } 1923 }
1778} 1924}
1779 1925
1780/* Convert a KEY_RSA or KEY_DSA to their _CERT equivalent */ 1926/* Convert a plain key to their _CERT equivalent */
1781int 1927int
1782key_to_certified(Key *k, int legacy) 1928key_to_certified(Key *k, int legacy)
1783{ 1929{
@@ -1797,41 +1943,34 @@ key_to_certified(Key *k, int legacy)
1797 k->cert = cert_new(); 1943 k->cert = cert_new();
1798 k->type = KEY_ECDSA_CERT; 1944 k->type = KEY_ECDSA_CERT;
1799 return 0; 1945 return 0;
1946 case KEY_ED25519:
1947 if (legacy)
1948 fatal("%s: legacy ED25519 certificates are not "
1949 "supported", __func__);
1950 k->cert = cert_new();
1951 k->type = KEY_ED25519_CERT;
1952 return 0;
1800 default: 1953 default:
1801 error("%s: key has incorrect type %s", __func__, key_type(k)); 1954 error("%s: key has incorrect type %s", __func__, key_type(k));
1802 return -1; 1955 return -1;
1803 } 1956 }
1804} 1957}
1805 1958
1806/* Convert a KEY_RSA_CERT or KEY_DSA_CERT to their raw key equivalent */ 1959/* Convert a certificate to its raw key equivalent */
1807int 1960int
1808key_drop_cert(Key *k) 1961key_drop_cert(Key *k)
1809{ 1962{
1810 switch (k->type) { 1963 if (!key_type_is_cert(k->type)) {
1811 case KEY_RSA_CERT_V00:
1812 case KEY_RSA_CERT:
1813 cert_free(k->cert);
1814 k->type = KEY_RSA;
1815 return 0;
1816 case KEY_DSA_CERT_V00:
1817 case KEY_DSA_CERT:
1818 cert_free(k->cert);
1819 k->type = KEY_DSA;
1820 return 0;
1821 case KEY_ECDSA_CERT:
1822 cert_free(k->cert);
1823 k->type = KEY_ECDSA;
1824 return 0;
1825 default:
1826 error("%s: key has incorrect type %s", __func__, key_type(k)); 1964 error("%s: key has incorrect type %s", __func__, key_type(k));
1827 return -1; 1965 return -1;
1828 } 1966 }
1967 cert_free(k->cert);
1968 k->cert = NULL;
1969 k->type = key_type_plain(k->type);
1970 return 0;
1829} 1971}
1830 1972
1831/* 1973/* Sign a certified key, (re-)generating the signed certblob. */
1832 * Sign a KEY_RSA_CERT, KEY_DSA_CERT or KEY_ECDSA_CERT, (re-)generating
1833 * the signed certblob
1834 */
1835int 1974int
1836key_certify(Key *k, Key *ca) 1975key_certify(Key *k, Key *ca)
1837{ 1976{
@@ -1850,8 +1989,7 @@ key_certify(Key *k, Key *ca)
1850 return -1; 1989 return -1;
1851 } 1990 }
1852 1991
1853 if (ca->type != KEY_RSA && ca->type != KEY_DSA && 1992 if (!key_type_is_valid_ca(ca->type)) {
1854 ca->type != KEY_ECDSA) {
1855 error("%s: CA key has unsupported type %s", __func__, 1993 error("%s: CA key has unsupported type %s", __func__,
1856 key_type(ca)); 1994 key_type(ca));
1857 return -1; 1995 return -1;
@@ -1867,6 +2005,7 @@ key_certify(Key *k, Key *ca)
1867 if (!key_cert_is_legacy(k)) 2005 if (!key_cert_is_legacy(k))
1868 buffer_put_string(&k->cert->certblob, nonce, sizeof(nonce)); 2006 buffer_put_string(&k->cert->certblob, nonce, sizeof(nonce));
1869 2007
2008 /* XXX this substantially duplicates to_blob(); refactor */
1870 switch (k->type) { 2009 switch (k->type) {
1871 case KEY_DSA_CERT_V00: 2010 case KEY_DSA_CERT_V00:
1872 case KEY_DSA_CERT: 2011 case KEY_DSA_CERT:
@@ -1889,6 +2028,10 @@ key_certify(Key *k, Key *ca)
1889 buffer_put_bignum2(&k->cert->certblob, k->rsa->e); 2028 buffer_put_bignum2(&k->cert->certblob, k->rsa->e);
1890 buffer_put_bignum2(&k->cert->certblob, k->rsa->n); 2029 buffer_put_bignum2(&k->cert->certblob, k->rsa->n);
1891 break; 2030 break;
2031 case KEY_ED25519_CERT:
2032 buffer_put_string(&k->cert->certblob,
2033 k->ed25519_pk, ED25519_PK_SZ);
2034 break;
1892 default: 2035 default:
1893 error("%s: key has incorrect type %s", __func__, key_type(k)); 2036 error("%s: key has incorrect type %s", __func__, key_type(k));
1894 buffer_clear(&k->cert->certblob); 2037 buffer_clear(&k->cert->certblob);
@@ -2018,8 +2161,10 @@ key_curve_name_to_nid(const char *name)
2018 return NID_X9_62_prime256v1; 2161 return NID_X9_62_prime256v1;
2019 else if (strcmp(name, "nistp384") == 0) 2162 else if (strcmp(name, "nistp384") == 0)
2020 return NID_secp384r1; 2163 return NID_secp384r1;
2164# ifdef OPENSSL_HAS_NISTP521
2021 else if (strcmp(name, "nistp521") == 0) 2165 else if (strcmp(name, "nistp521") == 0)
2022 return NID_secp521r1; 2166 return NID_secp521r1;
2167# endif
2023#endif 2168#endif
2024 2169
2025 debug("%s: unsupported EC curve name \"%.100s\"", __func__, name); 2170 debug("%s: unsupported EC curve name \"%.100s\"", __func__, name);
@@ -2035,8 +2180,10 @@ key_curve_nid_to_bits(int nid)
2035 return 256; 2180 return 256;
2036 case NID_secp384r1: 2181 case NID_secp384r1:
2037 return 384; 2182 return 384;
2183# ifdef OPENSSL_HAS_NISTP521
2038 case NID_secp521r1: 2184 case NID_secp521r1:
2039 return 521; 2185 return 521;
2186# endif
2040#endif 2187#endif
2041 default: 2188 default:
2042 error("%s: unsupported EC curve nid %d", __func__, nid); 2189 error("%s: unsupported EC curve nid %d", __func__, nid);
@@ -2052,16 +2199,18 @@ key_curve_nid_to_name(int nid)
2052 return "nistp256"; 2199 return "nistp256";
2053 else if (nid == NID_secp384r1) 2200 else if (nid == NID_secp384r1)
2054 return "nistp384"; 2201 return "nistp384";
2202# ifdef OPENSSL_HAS_NISTP521
2055 else if (nid == NID_secp521r1) 2203 else if (nid == NID_secp521r1)
2056 return "nistp521"; 2204 return "nistp521";
2205# endif
2057#endif 2206#endif
2058 error("%s: unsupported EC curve nid %d", __func__, nid); 2207 error("%s: unsupported EC curve nid %d", __func__, nid);
2059 return NULL; 2208 return NULL;
2060} 2209}
2061 2210
2062#ifdef OPENSSL_HAS_ECC 2211#ifdef OPENSSL_HAS_ECC
2063const EVP_MD * 2212int
2064key_ec_nid_to_evpmd(int nid) 2213key_ec_nid_to_hash_alg(int nid)
2065{ 2214{
2066 int kbits = key_curve_nid_to_bits(nid); 2215 int kbits = key_curve_nid_to_bits(nid);
2067 2216
@@ -2069,11 +2218,11 @@ key_ec_nid_to_evpmd(int nid)
2069 fatal("%s: invalid nid %d", __func__, nid); 2218 fatal("%s: invalid nid %d", __func__, nid);
2070 /* RFC5656 section 6.2.1 */ 2219 /* RFC5656 section 6.2.1 */
2071 if (kbits <= 256) 2220 if (kbits <= 256)
2072 return EVP_sha256(); 2221 return SSH_DIGEST_SHA256;
2073 else if (kbits <= 384) 2222 else if (kbits <= 384)
2074 return EVP_sha384(); 2223 return SSH_DIGEST_SHA384;
2075 else 2224 else
2076 return EVP_sha512(); 2225 return SSH_DIGEST_SHA512;
2077} 2226}
2078 2227
2079int 2228int
@@ -2245,3 +2394,232 @@ key_dump_ec_key(const EC_KEY *key)
2245} 2394}
2246#endif /* defined(DEBUG_KEXECDH) || defined(DEBUG_PK) */ 2395#endif /* defined(DEBUG_KEXECDH) || defined(DEBUG_PK) */
2247#endif /* OPENSSL_HAS_ECC */ 2396#endif /* OPENSSL_HAS_ECC */
2397
2398void
2399key_private_serialize(const Key *key, Buffer *b)
2400{
2401 buffer_put_cstring(b, key_ssh_name(key));
2402 switch (key->type) {
2403 case KEY_RSA:
2404 buffer_put_bignum2(b, key->rsa->n);
2405 buffer_put_bignum2(b, key->rsa->e);
2406 buffer_put_bignum2(b, key->rsa->d);
2407 buffer_put_bignum2(b, key->rsa->iqmp);
2408 buffer_put_bignum2(b, key->rsa->p);
2409 buffer_put_bignum2(b, key->rsa->q);
2410 break;
2411 case KEY_RSA_CERT_V00:
2412 case KEY_RSA_CERT:
2413 if (key->cert == NULL || buffer_len(&key->cert->certblob) == 0)
2414 fatal("%s: no cert/certblob", __func__);
2415 buffer_put_string(b, buffer_ptr(&key->cert->certblob),
2416 buffer_len(&key->cert->certblob));
2417 buffer_put_bignum2(b, key->rsa->d);
2418 buffer_put_bignum2(b, key->rsa->iqmp);
2419 buffer_put_bignum2(b, key->rsa->p);
2420 buffer_put_bignum2(b, key->rsa->q);
2421 break;
2422 case KEY_DSA:
2423 buffer_put_bignum2(b, key->dsa->p);
2424 buffer_put_bignum2(b, key->dsa->q);
2425 buffer_put_bignum2(b, key->dsa->g);
2426 buffer_put_bignum2(b, key->dsa->pub_key);
2427 buffer_put_bignum2(b, key->dsa->priv_key);
2428 break;
2429 case KEY_DSA_CERT_V00:
2430 case KEY_DSA_CERT:
2431 if (key->cert == NULL || buffer_len(&key->cert->certblob) == 0)
2432 fatal("%s: no cert/certblob", __func__);
2433 buffer_put_string(b, buffer_ptr(&key->cert->certblob),
2434 buffer_len(&key->cert->certblob));
2435 buffer_put_bignum2(b, key->dsa->priv_key);
2436 break;
2437#ifdef OPENSSL_HAS_ECC
2438 case KEY_ECDSA:
2439 buffer_put_cstring(b, key_curve_nid_to_name(key->ecdsa_nid));
2440 buffer_put_ecpoint(b, EC_KEY_get0_group(key->ecdsa),
2441 EC_KEY_get0_public_key(key->ecdsa));
2442 buffer_put_bignum2(b, EC_KEY_get0_private_key(key->ecdsa));
2443 break;
2444 case KEY_ECDSA_CERT:
2445 if (key->cert == NULL || buffer_len(&key->cert->certblob) == 0)
2446 fatal("%s: no cert/certblob", __func__);
2447 buffer_put_string(b, buffer_ptr(&key->cert->certblob),
2448 buffer_len(&key->cert->certblob));
2449 buffer_put_bignum2(b, EC_KEY_get0_private_key(key->ecdsa));
2450 break;
2451#endif /* OPENSSL_HAS_ECC */
2452 case KEY_ED25519:
2453 buffer_put_string(b, key->ed25519_pk, ED25519_PK_SZ);
2454 buffer_put_string(b, key->ed25519_sk, ED25519_SK_SZ);
2455 break;
2456 case KEY_ED25519_CERT:
2457 if (key->cert == NULL || buffer_len(&key->cert->certblob) == 0)
2458 fatal("%s: no cert/certblob", __func__);
2459 buffer_put_string(b, buffer_ptr(&key->cert->certblob),
2460 buffer_len(&key->cert->certblob));
2461 buffer_put_string(b, key->ed25519_pk, ED25519_PK_SZ);
2462 buffer_put_string(b, key->ed25519_sk, ED25519_SK_SZ);
2463 break;
2464 }
2465}
2466
2467Key *
2468key_private_deserialize(Buffer *blob)
2469{
2470 char *type_name;
2471 Key *k = NULL;
2472 u_char *cert;
2473 u_int len, pklen, sklen;
2474 int type;
2475#ifdef OPENSSL_HAS_ECC
2476 char *curve;
2477 BIGNUM *exponent;
2478 EC_POINT *q;
2479#endif
2480
2481 type_name = buffer_get_string(blob, NULL);
2482 type = key_type_from_name(type_name);
2483 switch (type) {
2484 case KEY_DSA:
2485 k = key_new_private(type);
2486 buffer_get_bignum2(blob, k->dsa->p);
2487 buffer_get_bignum2(blob, k->dsa->q);
2488 buffer_get_bignum2(blob, k->dsa->g);
2489 buffer_get_bignum2(blob, k->dsa->pub_key);
2490 buffer_get_bignum2(blob, k->dsa->priv_key);
2491 break;
2492 case KEY_DSA_CERT_V00:
2493 case KEY_DSA_CERT:
2494 cert = buffer_get_string(blob, &len);
2495 if ((k = key_from_blob(cert, len)) == NULL)
2496 fatal("Certificate parse failed");
2497 free(cert);
2498 key_add_private(k);
2499 buffer_get_bignum2(blob, k->dsa->priv_key);
2500 break;
2501#ifdef OPENSSL_HAS_ECC
2502 case KEY_ECDSA:
2503 k = key_new_private(type);
2504 k->ecdsa_nid = key_ecdsa_nid_from_name(type_name);
2505 curve = buffer_get_string(blob, NULL);
2506 if (k->ecdsa_nid != key_curve_name_to_nid(curve))
2507 fatal("%s: curve names mismatch", __func__);
2508 free(curve);
2509 k->ecdsa = EC_KEY_new_by_curve_name(k->ecdsa_nid);
2510 if (k->ecdsa == NULL)
2511 fatal("%s: EC_KEY_new_by_curve_name failed",
2512 __func__);
2513 q = EC_POINT_new(EC_KEY_get0_group(k->ecdsa));
2514 if (q == NULL)
2515 fatal("%s: BN_new failed", __func__);
2516 if ((exponent = BN_new()) == NULL)
2517 fatal("%s: BN_new failed", __func__);
2518 buffer_get_ecpoint(blob,
2519 EC_KEY_get0_group(k->ecdsa), q);
2520 buffer_get_bignum2(blob, exponent);
2521 if (EC_KEY_set_public_key(k->ecdsa, q) != 1)
2522 fatal("%s: EC_KEY_set_public_key failed",
2523 __func__);
2524 if (EC_KEY_set_private_key(k->ecdsa, exponent) != 1)
2525 fatal("%s: EC_KEY_set_private_key failed",
2526 __func__);
2527 if (key_ec_validate_public(EC_KEY_get0_group(k->ecdsa),
2528 EC_KEY_get0_public_key(k->ecdsa)) != 0)
2529 fatal("%s: bad ECDSA public key", __func__);
2530 if (key_ec_validate_private(k->ecdsa) != 0)
2531 fatal("%s: bad ECDSA private key", __func__);
2532 BN_clear_free(exponent);
2533 EC_POINT_free(q);
2534 break;
2535 case KEY_ECDSA_CERT:
2536 cert = buffer_get_string(blob, &len);
2537 if ((k = key_from_blob(cert, len)) == NULL)
2538 fatal("Certificate parse failed");
2539 free(cert);
2540 key_add_private(k);
2541 if ((exponent = BN_new()) == NULL)
2542 fatal("%s: BN_new failed", __func__);
2543 buffer_get_bignum2(blob, exponent);
2544 if (EC_KEY_set_private_key(k->ecdsa, exponent) != 1)
2545 fatal("%s: EC_KEY_set_private_key failed",
2546 __func__);
2547 if (key_ec_validate_public(EC_KEY_get0_group(k->ecdsa),
2548 EC_KEY_get0_public_key(k->ecdsa)) != 0 ||
2549 key_ec_validate_private(k->ecdsa) != 0)
2550 fatal("%s: bad ECDSA key", __func__);
2551 BN_clear_free(exponent);
2552 break;
2553#endif
2554 case KEY_RSA:
2555 k = key_new_private(type);
2556 buffer_get_bignum2(blob, k->rsa->n);
2557 buffer_get_bignum2(blob, k->rsa->e);
2558 buffer_get_bignum2(blob, k->rsa->d);
2559 buffer_get_bignum2(blob, k->rsa->iqmp);
2560 buffer_get_bignum2(blob, k->rsa->p);
2561 buffer_get_bignum2(blob, k->rsa->q);
2562
2563 /* Generate additional parameters */
2564 rsa_generate_additional_parameters(k->rsa);
2565 break;
2566 case KEY_RSA_CERT_V00:
2567 case KEY_RSA_CERT:
2568 cert = buffer_get_string(blob, &len);
2569 if ((k = key_from_blob(cert, len)) == NULL)
2570 fatal("Certificate parse failed");
2571 free(cert);
2572 key_add_private(k);
2573 buffer_get_bignum2(blob, k->rsa->d);
2574 buffer_get_bignum2(blob, k->rsa->iqmp);
2575 buffer_get_bignum2(blob, k->rsa->p);
2576 buffer_get_bignum2(blob, k->rsa->q);
2577 break;
2578 case KEY_ED25519:
2579 k = key_new_private(type);
2580 k->ed25519_pk = buffer_get_string(blob, &pklen);
2581 k->ed25519_sk = buffer_get_string(blob, &sklen);
2582 if (pklen != ED25519_PK_SZ)
2583 fatal("%s: ed25519 pklen %d != %d",
2584 __func__, pklen, ED25519_PK_SZ);
2585 if (sklen != ED25519_SK_SZ)
2586 fatal("%s: ed25519 sklen %d != %d",
2587 __func__, sklen, ED25519_SK_SZ);
2588 break;
2589 case KEY_ED25519_CERT:
2590 cert = buffer_get_string(blob, &len);
2591 if ((k = key_from_blob(cert, len)) == NULL)
2592 fatal("Certificate parse failed");
2593 free(cert);
2594 key_add_private(k);
2595 k->ed25519_pk = buffer_get_string(blob, &pklen);
2596 k->ed25519_sk = buffer_get_string(blob, &sklen);
2597 if (pklen != ED25519_PK_SZ)
2598 fatal("%s: ed25519 pklen %d != %d",
2599 __func__, pklen, ED25519_PK_SZ);
2600 if (sklen != ED25519_SK_SZ)
2601 fatal("%s: ed25519 sklen %d != %d",
2602 __func__, sklen, ED25519_SK_SZ);
2603 break;
2604 default:
2605 free(type_name);
2606 buffer_clear(blob);
2607 return NULL;
2608 }
2609 free(type_name);
2610
2611 /* enable blinding */
2612 switch (k->type) {
2613 case KEY_RSA:
2614 case KEY_RSA_CERT_V00:
2615 case KEY_RSA_CERT:
2616 case KEY_RSA1:
2617 if (RSA_blinding_on(k->rsa, NULL) != 1) {
2618 error("%s: RSA_blinding_on failed", __func__);
2619 key_free(k);
2620 return NULL;
2621 }
2622 break;
2623 }
2624 return k;
2625}
diff --git a/key.h b/key.h
index 17358ae1f..d8ad13d08 100644
--- a/key.h
+++ b/key.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: key.h,v 1.37 2013/05/19 02:42:42 djm Exp $ */ 1/* $OpenBSD: key.h,v 1.41 2014/01/09 23:20:00 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.
@@ -39,9 +39,11 @@ enum types {
39 KEY_RSA, 39 KEY_RSA,
40 KEY_DSA, 40 KEY_DSA,
41 KEY_ECDSA, 41 KEY_ECDSA,
42 KEY_ED25519,
42 KEY_RSA_CERT, 43 KEY_RSA_CERT,
43 KEY_DSA_CERT, 44 KEY_DSA_CERT,
44 KEY_ECDSA_CERT, 45 KEY_ECDSA_CERT,
46 KEY_ED25519_CERT,
45 KEY_RSA_CERT_V00, 47 KEY_RSA_CERT_V00,
46 KEY_DSA_CERT_V00, 48 KEY_DSA_CERT_V00,
47 KEY_UNSPEC 49 KEY_UNSPEC
@@ -86,8 +88,13 @@ struct Key {
86 void *ecdsa; 88 void *ecdsa;
87#endif 89#endif
88 struct KeyCert *cert; 90 struct KeyCert *cert;
91 u_char *ed25519_sk;
92 u_char *ed25519_pk;
89}; 93};
90 94
95#define ED25519_SK_SZ crypto_sign_ed25519_SECRETKEYBYTES
96#define ED25519_PK_SZ crypto_sign_ed25519_PUBLICKEYBYTES
97
91Key *key_new(int); 98Key *key_new(int);
92void key_add_private(Key *); 99void key_add_private(Key *);
93Key *key_new_private(int); 100Key *key_new_private(int);
@@ -107,6 +114,7 @@ Key *key_generate(int, u_int);
107Key *key_from_private(const Key *); 114Key *key_from_private(const Key *);
108int key_type_from_name(char *); 115int key_type_from_name(char *);
109int key_is_cert(const Key *); 116int key_is_cert(const Key *);
117int key_type_is_cert(int);
110int key_type_plain(int); 118int key_type_plain(int);
111int key_to_certified(Key *, int); 119int key_to_certified(Key *, int);
112int key_drop_cert(Key *); 120int key_drop_cert(Key *);
@@ -123,11 +131,11 @@ u_int key_curve_nid_to_bits(int);
123int key_ecdsa_bits_to_nid(int); 131int key_ecdsa_bits_to_nid(int);
124#ifdef OPENSSL_HAS_ECC 132#ifdef OPENSSL_HAS_ECC
125int key_ecdsa_key_to_nid(EC_KEY *); 133int key_ecdsa_key_to_nid(EC_KEY *);
126const EVP_MD *key_ec_nid_to_evpmd(int nid); 134int key_ec_nid_to_hash_alg(int nid);
127int key_ec_validate_public(const EC_GROUP *, const EC_POINT *); 135int key_ec_validate_public(const EC_GROUP *, const EC_POINT *);
128int key_ec_validate_private(const EC_KEY *); 136int key_ec_validate_private(const EC_KEY *);
129#endif 137#endif
130char *key_alg_list(void); 138char *key_alg_list(int, int);
131 139
132Key *key_from_blob(const u_char *, u_int); 140Key *key_from_blob(const u_char *, u_int);
133int key_to_blob(const Key *, u_char **, u_int *); 141int key_to_blob(const Key *, u_char **, u_int *);
@@ -144,10 +152,15 @@ int ssh_ecdsa_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
144int ssh_ecdsa_verify(const Key *, const u_char *, u_int, const u_char *, u_int); 152int ssh_ecdsa_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
145int ssh_rsa_sign(const Key *, u_char **, u_int *, const u_char *, u_int); 153int ssh_rsa_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
146int ssh_rsa_verify(const Key *, const u_char *, u_int, const u_char *, u_int); 154int ssh_rsa_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
155int ssh_ed25519_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
156int ssh_ed25519_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
147 157
148#if defined(OPENSSL_HAS_ECC) && (defined(DEBUG_KEXECDH) || defined(DEBUG_PK)) 158#if defined(OPENSSL_HAS_ECC) && (defined(DEBUG_KEXECDH) || defined(DEBUG_PK))
149void key_dump_ec_point(const EC_GROUP *, const EC_POINT *); 159void key_dump_ec_point(const EC_GROUP *, const EC_POINT *);
150void key_dump_ec_key(const EC_KEY *); 160void key_dump_ec_key(const EC_KEY *);
151#endif 161#endif
152 162
163void key_private_serialize(const Key *, Buffer *);
164Key *key_private_deserialize(Buffer *);
165
153#endif 166#endif
diff --git a/loginrec.c b/loginrec.c
index 59e8a44ee..4219b9aef 100644
--- a/loginrec.c
+++ b/loginrec.c
@@ -310,9 +310,13 @@ login_get_lastlog(struct logininfo *li, const uid_t uid)
310 fatal("%s: Cannot find account for uid %ld", __func__, 310 fatal("%s: Cannot find account for uid %ld", __func__,
311 (long)uid); 311 (long)uid);
312 312
313 /* No MIN_SIZEOF here - we absolutely *must not* truncate the 313 if (strlcpy(li->username, pw->pw_name, sizeof(li->username)) >=
314 * username (XXX - so check for trunc!) */ 314 sizeof(li->username)) {
315 strlcpy(li->username, pw->pw_name, sizeof(li->username)); 315 error("%s: username too long (%lu > max %lu)", __func__,
316 (unsigned long)strlen(pw->pw_name),
317 (unsigned long)sizeof(li->username) - 1);
318 return NULL;
319 }
316 320
317 if (getlast_entry(li)) 321 if (getlast_entry(li))
318 return (li); 322 return (li);
@@ -320,7 +324,6 @@ login_get_lastlog(struct logininfo *li, const uid_t uid)
320 return (NULL); 324 return (NULL);
321} 325}
322 326
323
324/* 327/*
325 * login_alloc_entry(int, char*, char*, char*) - Allocate and initialise 328 * login_alloc_entry(int, char*, char*, char*) - Allocate and initialise
326 * a logininfo structure 329 * a logininfo structure
diff --git a/mac.c b/mac.c
index c4dfb501d..d3a0b935f 100644
--- a/mac.c
+++ b/mac.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mac.c,v 1.24 2013/06/03 00:03:18 dtucker Exp $ */ 1/* $OpenBSD: mac.c,v 1.26 2014/01/04 17:50:55 tedu Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -91,9 +91,9 @@ static const struct macalg macs[] = {
91 { NULL, 0, NULL, 0, 0, 0, 0 } 91 { NULL, 0, NULL, 0, 0, 0, 0 }
92}; 92};
93 93
94/* Returns a comma-separated list of supported MACs. */ 94/* Returns a list of supported MACs separated by the specified char. */
95char * 95char *
96mac_alg_list(void) 96mac_alg_list(char sep)
97{ 97{
98 char *ret = NULL; 98 char *ret = NULL;
99 size_t nlen, rlen = 0; 99 size_t nlen, rlen = 0;
@@ -101,7 +101,7 @@ mac_alg_list(void)
101 101
102 for (m = macs; m->name != NULL; m++) { 102 for (m = macs; m->name != NULL; m++) {
103 if (ret != NULL) 103 if (ret != NULL)
104 ret[rlen++] = '\n'; 104 ret[rlen++] = sep;
105 nlen = strlen(m->name); 105 nlen = strlen(m->name);
106 ret = xrealloc(ret, 1, rlen + nlen + 2); 106 ret = xrealloc(ret, 1, rlen + nlen + 2);
107 memcpy(ret + rlen, m->name, nlen + 1); 107 memcpy(ret + rlen, m->name, nlen + 1);
@@ -181,8 +181,8 @@ mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen)
181 u_char b[4], nonce[8]; 181 u_char b[4], nonce[8];
182 182
183 if (mac->mac_len > sizeof(u)) 183 if (mac->mac_len > sizeof(u))
184 fatal("mac_compute: mac too long %u %lu", 184 fatal("mac_compute: mac too long %u %zu",
185 mac->mac_len, (u_long)sizeof(u)); 185 mac->mac_len, sizeof(u));
186 186
187 switch (mac->type) { 187 switch (mac->type) {
188 case SSH_EVP: 188 case SSH_EVP:
diff --git a/mac.h b/mac.h
index 260798ab3..fbe18c463 100644
--- a/mac.h
+++ b/mac.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: mac.h,v 1.7 2013/04/19 01:06:50 djm Exp $ */ 1/* $OpenBSD: mac.h,v 1.8 2013/11/07 11:58:27 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -24,7 +24,7 @@
24 */ 24 */
25 25
26int mac_valid(const char *); 26int mac_valid(const char *);
27char *mac_alg_list(void); 27char *mac_alg_list(char);
28int mac_setup(Mac *, char *); 28int mac_setup(Mac *, char *);
29int mac_init(Mac *); 29int mac_init(Mac *);
30u_char *mac_compute(Mac *, u_int32_t, u_char *, int); 30u_char *mac_compute(Mac *, u_int32_t, u_char *, int);
diff --git a/match.c b/match.c
index 7be7d2c5c..c35e32896 100644
--- a/match.c
+++ b/match.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: match.c,v 1.28 2013/05/17 00:13:13 djm Exp $ */ 1/* $OpenBSD: match.c,v 1.29 2013/11/20 20:54:10 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
@@ -141,8 +141,8 @@ match_pattern_list(const char *string, const char *pattern, u_int len,
141 for (subi = 0; 141 for (subi = 0;
142 i < len && subi < sizeof(sub) - 1 && pattern[i] != ','; 142 i < len && subi < sizeof(sub) - 1 && pattern[i] != ',';
143 subi++, i++) 143 subi++, i++)
144 sub[subi] = dolower && isupper(pattern[i]) ? 144 sub[subi] = dolower && isupper((u_char)pattern[i]) ?
145 (char)tolower(pattern[i]) : pattern[i]; 145 tolower((u_char)pattern[i]) : pattern[i];
146 /* If subpattern too long, return failure (no match). */ 146 /* If subpattern too long, return failure (no match). */
147 if (subi >= sizeof(sub) - 1) 147 if (subi >= sizeof(sub) - 1)
148 return 0; 148 return 0;
diff --git a/misc.c b/misc.c
index c3c809943..e4c8c3238 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.91 2013/07/12 00:43:50 djm Exp $ */ 1/* $OpenBSD: misc.c,v 1.92 2013/10/14 23:28:23 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.
@@ -43,6 +43,7 @@
43#include <netinet/ip.h> 43#include <netinet/ip.h>
44#include <netinet/tcp.h> 44#include <netinet/tcp.h>
45 45
46#include <ctype.h>
46#include <errno.h> 47#include <errno.h>
47#include <fcntl.h> 48#include <fcntl.h>
48#include <netdb.h> 49#include <netdb.h>
@@ -1017,6 +1018,13 @@ iptos2str(int iptos)
1017 snprintf(iptos_str, sizeof iptos_str, "0x%02x", iptos); 1018 snprintf(iptos_str, sizeof iptos_str, "0x%02x", iptos);
1018 return iptos_str; 1019 return iptos_str;
1019} 1020}
1021
1022void
1023lowercase(char *s)
1024{
1025 for (; *s; s++)
1026 *s = tolower((u_char)*s);
1027}
1020void 1028void
1021sock_set_v6only(int s) 1029sock_set_v6only(int s)
1022{ 1030{
diff --git a/misc.h b/misc.h
index fceb30655..d4df619cd 100644
--- a/misc.h
+++ b/misc.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.h,v 1.49 2013/06/01 13:15:52 dtucker Exp $ */ 1/* $OpenBSD: misc.h,v 1.50 2013/10/14 23:28:23 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -36,6 +36,8 @@ 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);
38time_t monotime(void); 38time_t monotime(void);
39void lowercase(char *s);
40
39void sock_set_v6only(int); 41void sock_set_v6only(int);
40 42
41struct passwd *pwcopy(struct passwd *); 43struct passwd *pwcopy(struct passwd *);
diff --git a/moduli.c b/moduli.c
index 294ff8fde..bb4dd7beb 100644
--- a/moduli.c
+++ b/moduli.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: moduli.c,v 1.27 2013/05/17 00:13:13 djm Exp $ */ 1/* $OpenBSD: moduli.c,v 1.28 2013/10/24 00:49:49 dtucker 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>
@@ -56,6 +56,7 @@
56#include "xmalloc.h" 56#include "xmalloc.h"
57#include "dh.h" 57#include "dh.h"
58#include "log.h" 58#include "log.h"
59#include "misc.h"
59 60
60#include "openbsd-compat/openssl-compat.h" 61#include "openbsd-compat/openssl-compat.h"
61 62
@@ -488,6 +489,79 @@ read_checkpoint(char *cpfile)
488 return lineno; 489 return lineno;
489} 490}
490 491
492static unsigned long
493count_lines(FILE *f)
494{
495 unsigned long count = 0;
496 char lp[QLINESIZE + 1];
497
498 if (fseek(f, 0, SEEK_SET) != 0) {
499 debug("input file is not seekable");
500 return ULONG_MAX;
501 }
502 while (fgets(lp, QLINESIZE + 1, f) != NULL)
503 count++;
504 rewind(f);
505 debug("input file has %lu lines", count);
506 return count;
507}
508
509static char *
510fmt_time(time_t seconds)
511{
512 int day, hr, min;
513 static char buf[128];
514
515 min = (seconds / 60) % 60;
516 hr = (seconds / 60 / 60) % 24;
517 day = seconds / 60 / 60 / 24;
518 if (day > 0)
519 snprintf(buf, sizeof buf, "%dd %d:%02d", day, hr, min);
520 else
521 snprintf(buf, sizeof buf, "%d:%02d", hr, min);
522 return buf;
523}
524
525static void
526print_progress(unsigned long start_lineno, unsigned long current_lineno,
527 unsigned long end_lineno)
528{
529 static time_t time_start, time_prev;
530 time_t time_now, elapsed;
531 unsigned long num_to_process, processed, remaining, percent, eta;
532 double time_per_line;
533 char *eta_str;
534
535 time_now = monotime();
536 if (time_start == 0) {
537 time_start = time_prev = time_now;
538 return;
539 }
540 /* print progress after 1m then once per 5m */
541 if (time_now - time_prev < 5 * 60)
542 return;
543 time_prev = time_now;
544 elapsed = time_now - time_start;
545 processed = current_lineno - start_lineno;
546 remaining = end_lineno - current_lineno;
547 num_to_process = end_lineno - start_lineno;
548 time_per_line = (double)elapsed / processed;
549 /* if we don't know how many we're processing just report count+time */
550 time(&time_now);
551 if (end_lineno == ULONG_MAX) {
552 logit("%.24s processed %lu in %s", ctime(&time_now),
553 processed, fmt_time(elapsed));
554 return;
555 }
556 percent = 100 * processed / num_to_process;
557 eta = time_per_line * remaining;
558 eta_str = xstrdup(fmt_time(eta));
559 logit("%.24s processed %lu of %lu (%lu%%) in %s, ETA %s",
560 ctime(&time_now), processed, num_to_process, percent,
561 fmt_time(elapsed), eta_str);
562 free(eta_str);
563}
564
491/* 565/*
492 * perform a Miller-Rabin primality test 566 * perform a Miller-Rabin primality test
493 * on the list of candidates 567 * on the list of candidates
@@ -512,6 +586,11 @@ prime_test(FILE *in, FILE *out, u_int32_t trials, u_int32_t generator_wanted,
512 return (-1); 586 return (-1);
513 } 587 }
514 588
589 if (num_lines == 0)
590 end_lineno = count_lines(in);
591 else
592 end_lineno = start_lineno + num_lines;
593
515 time(&time_start); 594 time(&time_start);
516 595
517 if ((p = BN_new()) == NULL) 596 if ((p = BN_new()) == NULL)
@@ -526,26 +605,25 @@ prime_test(FILE *in, FILE *out, u_int32_t trials, u_int32_t generator_wanted,
526 605
527 if (checkpoint_file != NULL) 606 if (checkpoint_file != NULL)
528 last_processed = read_checkpoint(checkpoint_file); 607 last_processed = read_checkpoint(checkpoint_file);
529 if (start_lineno > last_processed) 608 last_processed = start_lineno = MAX(last_processed, start_lineno);
530 last_processed = start_lineno; 609 if (end_lineno == ULONG_MAX)
531 if (num_lines == 0) 610 debug("process from line %lu from pipe", last_processed);
532 end_lineno = ULONG_MAX;
533 else 611 else
534 end_lineno = last_processed + num_lines; 612 debug("process from line %lu to line %lu", last_processed,
535 debug2("process line %lu to line %lu", last_processed, end_lineno); 613 end_lineno);
536 614
537 res = 0; 615 res = 0;
538 lp = xmalloc(QLINESIZE + 1); 616 lp = xmalloc(QLINESIZE + 1);
539 while (fgets(lp, QLINESIZE + 1, in) != NULL && count_in < end_lineno) { 617 while (fgets(lp, QLINESIZE + 1, in) != NULL && count_in < end_lineno) {
540 count_in++; 618 count_in++;
541 if (checkpoint_file != NULL) { 619 if (count_in <= last_processed) {
542 if (count_in <= last_processed) { 620 debug3("skipping line %u, before checkpoint or "
543 debug3("skipping line %u, before checkpoint", 621 "specified start line", count_in);
544 count_in); 622 continue;
545 continue;
546 }
547 write_checkpoint(checkpoint_file, count_in);
548 } 623 }
624 if (checkpoint_file != NULL)
625 write_checkpoint(checkpoint_file, count_in);
626 print_progress(start_lineno, count_in, end_lineno);
549 if (strlen(lp) < 14 || *lp == '!' || *lp == '#') { 627 if (strlen(lp) < 14 || *lp == '!' || *lp == '#') {
550 debug2("%10u: comment or short line", count_in); 628 debug2("%10u: comment or short line", count_in);
551 continue; 629 continue;
diff --git a/monitor.c b/monitor.c
index 44dff98c9..03baf1ea9 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor.c,v 1.127 2013/07/19 07:37:48 markus Exp $ */ 1/* $OpenBSD: monitor.c,v 1.128 2013/11/04 11:51:16 markus 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>
@@ -1855,6 +1855,7 @@ mm_get_kex(Buffer *m)
1855 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; 1855 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
1856 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; 1856 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
1857 kex->kex[KEX_ECDH_SHA2] = kexecdh_server; 1857 kex->kex[KEX_ECDH_SHA2] = kexecdh_server;
1858 kex->kex[KEX_C25519_SHA256] = kexc25519_server;
1858 kex->server = 1; 1859 kex->server = 1;
1859 kex->hostkey_type = buffer_get_int(m); 1860 kex->hostkey_type = buffer_get_int(m);
1860 kex->kex_type = buffer_get_int(m); 1861 kex->kex_type = buffer_get_int(m);
diff --git a/monitor_mm.c b/monitor_mm.c
index d3e6aeee5..0ba0658a1 100644
--- a/monitor_mm.c
+++ b/monitor_mm.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor_mm.c,v 1.18 2013/11/08 00:39:15 djm Exp $ */ 1/* $OpenBSD: monitor_mm.c,v 1.19 2014/01/04 17:50:55 tedu Exp $ */
2/* 2/*
3 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 3 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4 * All rights reserved. 4 * All rights reserved.
@@ -35,6 +35,7 @@
35 35
36#include <errno.h> 36#include <errno.h>
37#include <stdarg.h> 37#include <stdarg.h>
38#include <stddef.h>
38#include <stdlib.h> 39#include <stdlib.h>
39#include <string.h> 40#include <string.h>
40 41
@@ -46,7 +47,7 @@
46static int 47static int
47mm_compare(struct mm_share *a, struct mm_share *b) 48mm_compare(struct mm_share *a, struct mm_share *b)
48{ 49{
49 long diff = (char *)a->address - (char *)b->address; 50 ptrdiff_t diff = (char *)a->address - (char *)b->address;
50 51
51 if (diff == 0) 52 if (diff == 0)
52 return (0); 53 return (0);
@@ -73,8 +74,8 @@ mm_make_entry(struct mm_master *mm, struct mmtree *head,
73 74
74 tmp2 = RB_INSERT(mmtree, head, tmp); 75 tmp2 = RB_INSERT(mmtree, head, tmp);
75 if (tmp2 != NULL) 76 if (tmp2 != NULL)
76 fatal("mm_make_entry(%p): double address %p->%p(%lu)", 77 fatal("mm_make_entry(%p): double address %p->%p(%zu)",
77 mm, tmp2, address, (u_long)size); 78 mm, tmp2, address, size);
78 79
79 return (tmp); 80 return (tmp);
80} 81}
@@ -101,7 +102,7 @@ mm_create(struct mm_master *mmalloc, size_t size)
101 102
102 address = xmmap(size); 103 address = xmmap(size);
103 if (address == (void *)MAP_FAILED) 104 if (address == (void *)MAP_FAILED)
104 fatal("mmap(%lu): %s", (u_long)size, strerror(errno)); 105 fatal("mmap(%zu): %s", size, strerror(errno));
105 106
106 mm->address = address; 107 mm->address = address;
107 mm->size = size; 108 mm->size = size;
@@ -141,7 +142,7 @@ mm_destroy(struct mm_master *mm)
141 142
142#ifdef HAVE_MMAP 143#ifdef HAVE_MMAP
143 if (munmap(mm->address, mm->size) == -1) 144 if (munmap(mm->address, mm->size) == -1)
144 fatal("munmap(%p, %lu): %s", mm->address, (u_long)mm->size, 145 fatal("munmap(%p, %zu): %s", mm->address, mm->size,
145 strerror(errno)); 146 strerror(errno));
146#else 147#else
147 fatal("%s: UsePrivilegeSeparation=yes and Compression=yes not supported", 148 fatal("%s: UsePrivilegeSeparation=yes and Compression=yes not supported",
@@ -160,7 +161,7 @@ mm_xmalloc(struct mm_master *mm, size_t size)
160 161
161 address = mm_malloc(mm, size); 162 address = mm_malloc(mm, size);
162 if (address == NULL) 163 if (address == NULL)
163 fatal("%s: mm_malloc(%lu)", __func__, (u_long)size); 164 fatal("%s: mm_malloc(%zu)", __func__, size);
164 memset(address, 0, size); 165 memset(address, 0, size);
165 return (address); 166 return (address);
166} 167}
@@ -195,7 +196,7 @@ mm_malloc(struct mm_master *mm, size_t size)
195 196
196 /* Does not change order in RB tree */ 197 /* Does not change order in RB tree */
197 mms->size -= size; 198 mms->size -= size;
198 mms->address = (u_char *)mms->address + size; 199 mms->address = (char *)mms->address + size;
199 200
200 if (mms->size == 0) { 201 if (mms->size == 0) {
201 RB_REMOVE(mmtree, &mm->rb_free, mms); 202 RB_REMOVE(mmtree, &mm->rb_free, mms);
@@ -248,8 +249,8 @@ mm_free(struct mm_master *mm, void *address)
248 249
249 /* Check if range does not overlap */ 250 /* Check if range does not overlap */
250 if (prev != NULL && MM_ADDRESS_END(prev) > address) 251 if (prev != NULL && MM_ADDRESS_END(prev) > address)
251 fatal("mm_free: memory corruption: %p(%lu) > %p", 252 fatal("mm_free: memory corruption: %p(%zu) > %p",
252 prev->address, (u_long)prev->size, address); 253 prev->address, prev->size, address);
253 254
254 /* See if we can merge backwards */ 255 /* See if we can merge backwards */
255 if (prev != NULL && MM_ADDRESS_END(prev) == address) { 256 if (prev != NULL && MM_ADDRESS_END(prev) == address) {
@@ -271,8 +272,8 @@ mm_free(struct mm_master *mm, void *address)
271 return; 272 return;
272 273
273 if (MM_ADDRESS_END(prev) > mms->address) 274 if (MM_ADDRESS_END(prev) > mms->address)
274 fatal("mm_free: memory corruption: %p < %p(%lu)", 275 fatal("mm_free: memory corruption: %p < %p(%zu)",
275 mms->address, prev->address, (u_long)prev->size); 276 mms->address, prev->address, prev->size);
276 if (MM_ADDRESS_END(prev) != mms->address) 277 if (MM_ADDRESS_END(prev) != mms->address)
277 return; 278 return;
278 279
@@ -343,12 +344,12 @@ mm_share_sync(struct mm_master **pmm, struct mm_master **pmmalloc)
343void 344void
344mm_memvalid(struct mm_master *mm, void *address, size_t size) 345mm_memvalid(struct mm_master *mm, void *address, size_t size)
345{ 346{
346 void *end = (u_char *)address + size; 347 void *end = (char *)address + size;
347 348
348 if (address < mm->address) 349 if (address < mm->address)
349 fatal("mm_memvalid: address too small: %p", address); 350 fatal("mm_memvalid: address too small: %p", address);
350 if (end < address) 351 if (end < address)
351 fatal("mm_memvalid: end < address: %p < %p", end, address); 352 fatal("mm_memvalid: end < address: %p < %p", end, address);
352 if (end > (void *)((u_char *)mm->address + mm->size)) 353 if (end > MM_ADDRESS_END(mm))
353 fatal("mm_memvalid: address too large: %p", address); 354 fatal("mm_memvalid: address too large: %p", address);
354} 355}
diff --git a/monitor_mm.h b/monitor_mm.h
index c890f7709..f1fae7e3b 100644
--- a/monitor_mm.h
+++ b/monitor_mm.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor_mm.h,v 1.5 2008/04/29 11:20:31 otto Exp $ */ 1/* $OpenBSD: monitor_mm.h,v 1.6 2014/01/04 17:50:55 tedu Exp $ */
2 2
3/* 3/*
4 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 4 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
@@ -47,7 +47,7 @@ RB_PROTOTYPE(mmtree, mm_share, next, mm_compare)
47 47
48#define MM_MINSIZE 128 48#define MM_MINSIZE 128
49 49
50#define MM_ADDRESS_END(x) (void *)((u_char *)(x)->address + (x)->size) 50#define MM_ADDRESS_END(x) (void *)((char *)(x)->address + (x)->size)
51 51
52struct mm_master *mm_create(struct mm_master *, size_t); 52struct mm_master *mm_create(struct mm_master *, size_t);
53void mm_destroy(struct mm_master *); 53void mm_destroy(struct mm_master *);
diff --git a/myproposal.h b/myproposal.h
index 4e913e3ce..3a0f5aeab 100644
--- a/myproposal.h
+++ b/myproposal.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: myproposal.h,v 1.32 2013/01/08 18:49:04 markus Exp $ */ 1/* $OpenBSD: myproposal.h,v 1.35 2013/12/06 13:39:49 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -29,6 +29,7 @@
29/* conditional algorithm support */ 29/* conditional algorithm support */
30 30
31#ifdef OPENSSL_HAS_ECC 31#ifdef OPENSSL_HAS_ECC
32#ifdef OPENSSL_HAS_NISTP521
32# define KEX_ECDH_METHODS \ 33# define KEX_ECDH_METHODS \
33 "ecdh-sha2-nistp256," \ 34 "ecdh-sha2-nistp256," \
34 "ecdh-sha2-nistp384," \ 35 "ecdh-sha2-nistp384," \
@@ -42,6 +43,17 @@
42 "ecdsa-sha2-nistp384," \ 43 "ecdsa-sha2-nistp384," \
43 "ecdsa-sha2-nistp521," 44 "ecdsa-sha2-nistp521,"
44#else 45#else
46# define KEX_ECDH_METHODS \
47 "ecdh-sha2-nistp256," \
48 "ecdh-sha2-nistp384,"
49# define HOSTKEY_ECDSA_CERT_METHODS \
50 "ecdsa-sha2-nistp256-cert-v01@openssh.com," \
51 "ecdsa-sha2-nistp384-cert-v01@openssh.com,"
52# define HOSTKEY_ECDSA_METHODS \
53 "ecdsa-sha2-nistp256," \
54 "ecdsa-sha2-nistp384,"
55#endif
56#else
45# define KEX_ECDH_METHODS 57# define KEX_ECDH_METHODS
46# define HOSTKEY_ECDSA_CERT_METHODS 58# define HOSTKEY_ECDSA_CERT_METHODS
47# define HOSTKEY_ECDSA_METHODS 59# define HOSTKEY_ECDSA_METHODS
@@ -57,15 +69,19 @@
57#ifdef HAVE_EVP_SHA256 69#ifdef HAVE_EVP_SHA256
58# define KEX_SHA256_METHODS \ 70# define KEX_SHA256_METHODS \
59 "diffie-hellman-group-exchange-sha256," 71 "diffie-hellman-group-exchange-sha256,"
72#define KEX_CURVE25519_METHODS \
73 "curve25519-sha256@libssh.org,"
60#define SHA2_HMAC_MODES \ 74#define SHA2_HMAC_MODES \
61 "hmac-sha2-256," \ 75 "hmac-sha2-256," \
62 "hmac-sha2-512," 76 "hmac-sha2-512,"
63#else 77#else
64# define KEX_SHA256_METHODS 78# define KEX_SHA256_METHODS
79# define KEX_CURVE25519_METHODS
65# define SHA2_HMAC_MODES 80# define SHA2_HMAC_MODES
66#endif 81#endif
67 82
68# define KEX_DEFAULT_KEX \ 83# define KEX_DEFAULT_KEX \
84 KEX_CURVE25519_METHODS \
69 KEX_ECDH_METHODS \ 85 KEX_ECDH_METHODS \
70 KEX_SHA256_METHODS \ 86 KEX_SHA256_METHODS \
71 "diffie-hellman-group-exchange-sha1," \ 87 "diffie-hellman-group-exchange-sha1," \
@@ -74,11 +90,13 @@
74 90
75#define KEX_DEFAULT_PK_ALG \ 91#define KEX_DEFAULT_PK_ALG \
76 HOSTKEY_ECDSA_CERT_METHODS \ 92 HOSTKEY_ECDSA_CERT_METHODS \
93 "ssh-ed25519-cert-v01@openssh.com," \
77 "ssh-rsa-cert-v01@openssh.com," \ 94 "ssh-rsa-cert-v01@openssh.com," \
78 "ssh-dss-cert-v01@openssh.com," \ 95 "ssh-dss-cert-v01@openssh.com," \
79 "ssh-rsa-cert-v00@openssh.com," \ 96 "ssh-rsa-cert-v00@openssh.com," \
80 "ssh-dss-cert-v00@openssh.com," \ 97 "ssh-dss-cert-v00@openssh.com," \
81 HOSTKEY_ECDSA_METHODS \ 98 HOSTKEY_ECDSA_METHODS \
99 "ssh-ed25519," \
82 "ssh-rsa," \ 100 "ssh-rsa," \
83 "ssh-dss" 101 "ssh-dss"
84 102
@@ -88,6 +106,7 @@
88 "aes128-ctr,aes192-ctr,aes256-ctr," \ 106 "aes128-ctr,aes192-ctr,aes256-ctr," \
89 "arcfour256,arcfour128," \ 107 "arcfour256,arcfour128," \
90 AESGCM_CIPHER_MODES \ 108 AESGCM_CIPHER_MODES \
109 "chacha20-poly1305@openssh.com," \
91 "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc," \ 110 "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc," \
92 "aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se" 111 "aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se"
93 112
diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in
index 365cf006d..276646fa6 100644
--- a/openbsd-compat/Makefile.in
+++ b/openbsd-compat/Makefile.in
@@ -1,4 +1,4 @@
1# $Id: Makefile.in,v 1.51 2013/05/10 06:28:56 dtucker Exp $ 1# $Id: Makefile.in,v 1.54 2013/12/07 01:37:54 djm Exp $
2 2
3sysconfdir=@sysconfdir@ 3sysconfdir=@sysconfdir@
4piddir=@piddir@ 4piddir=@piddir@
@@ -16,9 +16,9 @@ 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_long.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 strnlen.o strptime.o strsep.o strtonum.o strtoll.o strtoul.o strtoull.o timingsafe_bcmp.o vis.o 19OPENBSD=base64.o basename.o bcrypt_pbkdf.o bindresvport.o blowfish.o daemon.o dirname.o fmt_scaled.o getcwd.o getgrouplist.o getopt_long.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 strnlen.o strptime.o strsep.o strtonum.o strtoll.o strtoul.o strtoull.o timingsafe_bcmp.o vis.o blowfish.o bcrypt_pbkdf.o
20 20
21COMPAT=bsd-arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o getrrsetbyname-ldns.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-setres_id.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o 21COMPAT=arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o getrrsetbyname-ldns.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-setres_id.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o
22 22
23PORTS=port-aix.o port-irix.o port-linux.o port-solaris.o port-tun.o port-uw.o 23PORTS=port-aix.o port-irix.o port-linux.o port-solaris.o port-tun.o port-uw.o
24 24
diff --git a/openbsd-compat/arc4random.c b/openbsd-compat/arc4random.c
new file mode 100644
index 000000000..eac073cc0
--- /dev/null
+++ b/openbsd-compat/arc4random.c
@@ -0,0 +1,294 @@
1/* OPENBSD ORIGINAL: lib/libc/crypto/arc4random.c */
2
3/* $OpenBSD: arc4random.c,v 1.25 2013/10/01 18:34:57 markus Exp $ */
4
5/*
6 * Copyright (c) 1996, David Mazieres <dm@uun.org>
7 * Copyright (c) 2008, Damien Miller <djm@openbsd.org>
8 * Copyright (c) 2013, Markus Friedl <markus@openbsd.org>
9 *
10 * Permission to use, copy, modify, and distribute this software for any
11 * purpose with or without fee is hereby granted, provided that the above
12 * copyright notice and this permission notice appear in all copies.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 */
22
23/*
24 * ChaCha based random number generator for OpenBSD.
25 */
26
27#include "includes.h"
28
29#include <stdlib.h>
30#include <string.h>
31#include <unistd.h>
32#include <sys/types.h>
33
34#ifndef HAVE_ARC4RANDOM
35
36#include <openssl/rand.h>
37#include <openssl/err.h>
38
39#include "log.h"
40
41#define KEYSTREAM_ONLY
42#include "chacha_private.h"
43
44#ifdef __GNUC__
45#define inline __inline
46#else /* !__GNUC__ */
47#define inline
48#endif /* !__GNUC__ */
49
50/* OpenSSH isn't multithreaded */
51#define _ARC4_LOCK()
52#define _ARC4_UNLOCK()
53
54#define KEYSZ 32
55#define IVSZ 8
56#define BLOCKSZ 64
57#define RSBUFSZ (16*BLOCKSZ)
58static int rs_initialized;
59static pid_t rs_stir_pid;
60static chacha_ctx rs; /* chacha context for random keystream */
61static u_char rs_buf[RSBUFSZ]; /* keystream blocks */
62static size_t rs_have; /* valid bytes at end of rs_buf */
63static size_t rs_count; /* bytes till reseed */
64
65static inline void _rs_rekey(u_char *dat, size_t datlen);
66
67static inline void
68_rs_init(u_char *buf, size_t n)
69{
70 if (n < KEYSZ + IVSZ)
71 return;
72 chacha_keysetup(&rs, buf, KEYSZ * 8, 0);
73 chacha_ivsetup(&rs, buf + KEYSZ);
74}
75
76static void
77_rs_stir(void)
78{
79 u_char rnd[KEYSZ + IVSZ];
80
81 if (RAND_bytes(rnd, sizeof(rnd)) <= 0)
82 fatal("Couldn't obtain random bytes (error %ld)",
83 ERR_get_error());
84
85 if (!rs_initialized) {
86 rs_initialized = 1;
87 _rs_init(rnd, sizeof(rnd));
88 } else
89 _rs_rekey(rnd, sizeof(rnd));
90 memset(rnd, 0, sizeof(rnd));
91
92 /* invalidate rs_buf */
93 rs_have = 0;
94 memset(rs_buf, 0, RSBUFSZ);
95
96 rs_count = 1600000;
97}
98
99static inline void
100_rs_stir_if_needed(size_t len)
101{
102 pid_t pid = getpid();
103
104 if (rs_count <= len || !rs_initialized || rs_stir_pid != pid) {
105 rs_stir_pid = pid;
106 _rs_stir();
107 } else
108 rs_count -= len;
109}
110
111static inline void
112_rs_rekey(u_char *dat, size_t datlen)
113{
114#ifndef KEYSTREAM_ONLY
115 memset(rs_buf, 0,RSBUFSZ);
116#endif
117 /* fill rs_buf with the keystream */
118 chacha_encrypt_bytes(&rs, rs_buf, rs_buf, RSBUFSZ);
119 /* mix in optional user provided data */
120 if (dat) {
121 size_t i, m;
122
123 m = MIN(datlen, KEYSZ + IVSZ);
124 for (i = 0; i < m; i++)
125 rs_buf[i] ^= dat[i];
126 }
127 /* immediately reinit for backtracking resistance */
128 _rs_init(rs_buf, KEYSZ + IVSZ);
129 memset(rs_buf, 0, KEYSZ + IVSZ);
130 rs_have = RSBUFSZ - KEYSZ - IVSZ;
131}
132
133static inline void
134_rs_random_buf(void *_buf, size_t n)
135{
136 u_char *buf = (u_char *)_buf;
137 size_t m;
138
139 _rs_stir_if_needed(n);
140 while (n > 0) {
141 if (rs_have > 0) {
142 m = MIN(n, rs_have);
143 memcpy(buf, rs_buf + RSBUFSZ - rs_have, m);
144 memset(rs_buf + RSBUFSZ - rs_have, 0, m);
145 buf += m;
146 n -= m;
147 rs_have -= m;
148 }
149 if (rs_have == 0)
150 _rs_rekey(NULL, 0);
151 }
152}
153
154static inline void
155_rs_random_u32(u_int32_t *val)
156{
157 _rs_stir_if_needed(sizeof(*val));
158 if (rs_have < sizeof(*val))
159 _rs_rekey(NULL, 0);
160 memcpy(val, rs_buf + RSBUFSZ - rs_have, sizeof(*val));
161 memset(rs_buf + RSBUFSZ - rs_have, 0, sizeof(*val));
162 rs_have -= sizeof(*val);
163 return;
164}
165
166void
167arc4random_stir(void)
168{
169 _ARC4_LOCK();
170 _rs_stir();
171 _ARC4_UNLOCK();
172}
173
174void
175arc4random_addrandom(u_char *dat, int datlen)
176{
177 int m;
178
179 _ARC4_LOCK();
180 if (!rs_initialized)
181 _rs_stir();
182 while (datlen > 0) {
183 m = MIN(datlen, KEYSZ + IVSZ);
184 _rs_rekey(dat, m);
185 dat += m;
186 datlen -= m;
187 }
188 _ARC4_UNLOCK();
189}
190
191u_int32_t
192arc4random(void)
193{
194 u_int32_t val;
195
196 _ARC4_LOCK();
197 _rs_random_u32(&val);
198 _ARC4_UNLOCK();
199 return val;
200}
201
202/*
203 * If we are providing arc4random, then we can provide a more efficient
204 * arc4random_buf().
205 */
206# ifndef HAVE_ARC4RANDOM_BUF
207void
208arc4random_buf(void *buf, size_t n)
209{
210 _ARC4_LOCK();
211 _rs_random_buf(buf, n);
212 _ARC4_UNLOCK();
213}
214# endif /* !HAVE_ARC4RANDOM_BUF */
215#endif /* !HAVE_ARC4RANDOM */
216
217/* arc4random_buf() that uses platform arc4random() */
218#if !defined(HAVE_ARC4RANDOM_BUF) && defined(HAVE_ARC4RANDOM)
219void
220arc4random_buf(void *_buf, size_t n)
221{
222 size_t i;
223 u_int32_t r = 0;
224 char *buf = (char *)_buf;
225
226 for (i = 0; i < n; i++) {
227 if (i % 4 == 0)
228 r = arc4random();
229 buf[i] = r & 0xff;
230 r >>= 8;
231 }
232 i = r = 0;
233}
234#endif /* !defined(HAVE_ARC4RANDOM_BUF) && defined(HAVE_ARC4RANDOM) */
235
236#ifndef HAVE_ARC4RANDOM_UNIFORM
237/*
238 * Calculate a uniformly distributed random number less than upper_bound
239 * avoiding "modulo bias".
240 *
241 * Uniformity is achieved by generating new random numbers until the one
242 * returned is outside the range [0, 2**32 % upper_bound). This
243 * guarantees the selected random number will be inside
244 * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound)
245 * after reduction modulo upper_bound.
246 */
247u_int32_t
248arc4random_uniform(u_int32_t upper_bound)
249{
250 u_int32_t r, min;
251
252 if (upper_bound < 2)
253 return 0;
254
255 /* 2**32 % x == (2**32 - x) % x */
256 min = -upper_bound % upper_bound;
257
258 /*
259 * This could theoretically loop forever but each retry has
260 * p > 0.5 (worst case, usually far better) of selecting a
261 * number inside the range we need, so it should rarely need
262 * to re-roll.
263 */
264 for (;;) {
265 r = arc4random();
266 if (r >= min)
267 break;
268 }
269
270 return r % upper_bound;
271}
272#endif /* !HAVE_ARC4RANDOM_UNIFORM */
273
274#if 0
275/*-------- Test code for i386 --------*/
276#include <stdio.h>
277#include <machine/pctr.h>
278int
279main(int argc, char **argv)
280{
281 const int iter = 1000000;
282 int i;
283 pctrval v;
284
285 v = rdtsc();
286 for (i = 0; i < iter; i++)
287 arc4random();
288 v = rdtsc() - v;
289 v /= iter;
290
291 printf("%qd cycles\n", v);
292 exit(0);
293}
294#endif
diff --git a/openbsd-compat/bcrypt_pbkdf.c b/openbsd-compat/bcrypt_pbkdf.c
new file mode 100644
index 000000000..91b6ba07b
--- /dev/null
+++ b/openbsd-compat/bcrypt_pbkdf.c
@@ -0,0 +1,170 @@
1/* $OpenBSD: bcrypt_pbkdf.c,v 1.4 2013/07/29 00:55:53 tedu Exp $ */
2/*
3 * Copyright (c) 2013 Ted Unangst <tedu@openbsd.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#ifndef HAVE_BCRYPT_PBKDF
21
22#include <sys/types.h>
23#include <sys/param.h>
24
25#ifdef HAVE_STDLIB_H
26# include <stdlib.h>
27#endif
28#include <string.h>
29
30#ifdef HAVE_BLF_H
31# include <blf.h>
32#endif
33
34#include "crypto_api.h"
35#define SHA512_DIGEST_LENGTH crypto_hash_sha512_BYTES
36
37/*
38 * pkcs #5 pbkdf2 implementation using the "bcrypt" hash
39 *
40 * The bcrypt hash function is derived from the bcrypt password hashing
41 * function with the following modifications:
42 * 1. The input password and salt are preprocessed with SHA512.
43 * 2. The output length is expanded to 256 bits.
44 * 3. Subsequently the magic string to be encrypted is lengthened and modifed
45 * to "OxychromaticBlowfishSwatDynamite"
46 * 4. The hash function is defined to perform 64 rounds of initial state
47 * expansion. (More rounds are performed by iterating the hash.)
48 *
49 * Note that this implementation pulls the SHA512 operations into the caller
50 * as a performance optimization.
51 *
52 * One modification from official pbkdf2. Instead of outputting key material
53 * linearly, we mix it. pbkdf2 has a known weakness where if one uses it to
54 * generate (i.e.) 512 bits of key material for use as two 256 bit keys, an
55 * attacker can merely run once through the outer loop below, but the user
56 * always runs it twice. Shuffling output bytes requires computing the
57 * entirety of the key material to assemble any subkey. This is something a
58 * wise caller could do; we just do it for you.
59 */
60
61#define BCRYPT_BLOCKS 8
62#define BCRYPT_HASHSIZE (BCRYPT_BLOCKS * 4)
63
64static void
65bcrypt_hash(u_int8_t *sha2pass, u_int8_t *sha2salt, u_int8_t *out)
66{
67 blf_ctx state;
68 u_int8_t ciphertext[BCRYPT_HASHSIZE] =
69 "OxychromaticBlowfishSwatDynamite";
70 uint32_t cdata[BCRYPT_BLOCKS];
71 int i;
72 uint16_t j;
73 size_t shalen = SHA512_DIGEST_LENGTH;
74
75 /* key expansion */
76 Blowfish_initstate(&state);
77 Blowfish_expandstate(&state, sha2salt, shalen, sha2pass, shalen);
78 for (i = 0; i < 64; i++) {
79 Blowfish_expand0state(&state, sha2salt, shalen);
80 Blowfish_expand0state(&state, sha2pass, shalen);
81 }
82
83 /* encryption */
84 j = 0;
85 for (i = 0; i < BCRYPT_BLOCKS; i++)
86 cdata[i] = Blowfish_stream2word(ciphertext, sizeof(ciphertext),
87 &j);
88 for (i = 0; i < 64; i++)
89 blf_enc(&state, cdata, sizeof(cdata) / sizeof(uint64_t));
90
91 /* copy out */
92 for (i = 0; i < BCRYPT_BLOCKS; i++) {
93 out[4 * i + 3] = (cdata[i] >> 24) & 0xff;
94 out[4 * i + 2] = (cdata[i] >> 16) & 0xff;
95 out[4 * i + 1] = (cdata[i] >> 8) & 0xff;
96 out[4 * i + 0] = cdata[i] & 0xff;
97 }
98
99 /* zap */
100 memset(ciphertext, 0, sizeof(ciphertext));
101 memset(cdata, 0, sizeof(cdata));
102 memset(&state, 0, sizeof(state));
103}
104
105int
106bcrypt_pbkdf(const char *pass, size_t passlen, const u_int8_t *salt, size_t saltlen,
107 u_int8_t *key, size_t keylen, unsigned int rounds)
108{
109 u_int8_t sha2pass[SHA512_DIGEST_LENGTH];
110 u_int8_t sha2salt[SHA512_DIGEST_LENGTH];
111 u_int8_t out[BCRYPT_HASHSIZE];
112 u_int8_t tmpout[BCRYPT_HASHSIZE];
113 u_int8_t *countsalt;
114 size_t i, j, amt, stride;
115 uint32_t count;
116
117 /* nothing crazy */
118 if (rounds < 1)
119 return -1;
120 if (passlen == 0 || saltlen == 0 || keylen == 0 ||
121 keylen > sizeof(out) * sizeof(out) || saltlen > 1<<20)
122 return -1;
123 if ((countsalt = calloc(1, saltlen + 4)) == NULL)
124 return -1;
125 stride = (keylen + sizeof(out) - 1) / sizeof(out);
126 amt = (keylen + stride - 1) / stride;
127
128 memcpy(countsalt, salt, saltlen);
129
130 /* collapse password */
131 crypto_hash_sha512(sha2pass, pass, passlen);
132
133 /* generate key, sizeof(out) at a time */
134 for (count = 1; keylen > 0; count++) {
135 countsalt[saltlen + 0] = (count >> 24) & 0xff;
136 countsalt[saltlen + 1] = (count >> 16) & 0xff;
137 countsalt[saltlen + 2] = (count >> 8) & 0xff;
138 countsalt[saltlen + 3] = count & 0xff;
139
140 /* first round, salt is salt */
141 crypto_hash_sha512(sha2salt, countsalt, saltlen + 4);
142
143 bcrypt_hash(sha2pass, sha2salt, tmpout);
144 memcpy(out, tmpout, sizeof(out));
145
146 for (i = 1; i < rounds; i++) {
147 /* subsequent rounds, salt is previous output */
148 crypto_hash_sha512(sha2salt, tmpout, sizeof(tmpout));
149 bcrypt_hash(sha2pass, sha2salt, tmpout);
150 for (j = 0; j < sizeof(out); j++)
151 out[j] ^= tmpout[j];
152 }
153
154 /*
155 * pbkdf2 deviation: ouput the key material non-linearly.
156 */
157 amt = MIN(amt, keylen);
158 for (i = 0; i < amt; i++)
159 key[i * stride + (count - 1)] = out[i];
160 keylen -= amt;
161 }
162
163 /* zap */
164 memset(out, 0, sizeof(out));
165 memset(countsalt, 0, saltlen + 4);
166 free(countsalt);
167
168 return 0;
169}
170#endif /* HAVE_BCRYPT_PBKDF */
diff --git a/openbsd-compat/blf.h b/openbsd-compat/blf.h
new file mode 100644
index 000000000..f1ac5a5c2
--- /dev/null
+++ b/openbsd-compat/blf.h
@@ -0,0 +1,88 @@
1/* $OpenBSD: blf.h,v 1.7 2007/03/14 17:59:41 grunk Exp $ */
2/*
3 * Blowfish - a fast block cipher designed by Bruce Schneier
4 *
5 * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Niels Provos.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef _BLF_H_
35#define _BLF_H_
36
37#include "includes.h"
38
39#if !defined(HAVE_BCRYPT_PBKDF) && !defined(HAVE_BLH_H)
40
41/* Schneier specifies a maximum key length of 56 bytes.
42 * This ensures that every key bit affects every cipher
43 * bit. However, the subkeys can hold up to 72 bytes.
44 * Warning: For normal blowfish encryption only 56 bytes
45 * of the key affect all cipherbits.
46 */
47
48#define BLF_N 16 /* Number of Subkeys */
49#define BLF_MAXKEYLEN ((BLF_N-2)*4) /* 448 bits */
50#define BLF_MAXUTILIZED ((BLF_N+2)*4) /* 576 bits */
51
52/* Blowfish context */
53typedef struct BlowfishContext {
54 u_int32_t S[4][256]; /* S-Boxes */
55 u_int32_t P[BLF_N + 2]; /* Subkeys */
56} blf_ctx;
57
58/* Raw access to customized Blowfish
59 * blf_key is just:
60 * Blowfish_initstate( state )
61 * Blowfish_expand0state( state, key, keylen )
62 */
63
64void Blowfish_encipher(blf_ctx *, u_int32_t *, u_int32_t *);
65void Blowfish_decipher(blf_ctx *, u_int32_t *, u_int32_t *);
66void Blowfish_initstate(blf_ctx *);
67void Blowfish_expand0state(blf_ctx *, const u_int8_t *, u_int16_t);
68void Blowfish_expandstate
69(blf_ctx *, const u_int8_t *, u_int16_t, const u_int8_t *, u_int16_t);
70
71/* Standard Blowfish */
72
73void blf_key(blf_ctx *, const u_int8_t *, u_int16_t);
74void blf_enc(blf_ctx *, u_int32_t *, u_int16_t);
75void blf_dec(blf_ctx *, u_int32_t *, u_int16_t);
76
77void blf_ecb_encrypt(blf_ctx *, u_int8_t *, u_int32_t);
78void blf_ecb_decrypt(blf_ctx *, u_int8_t *, u_int32_t);
79
80void blf_cbc_encrypt(blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t);
81void blf_cbc_decrypt(blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t);
82
83/* Converts u_int8_t to u_int32_t */
84u_int32_t Blowfish_stream2word(const u_int8_t *, u_int16_t , u_int16_t *);
85
86#endif /* !defined(HAVE_BCRYPT_PBKDF) && !defined(HAVE_BLH_H) */
87#endif /* _BLF_H */
88
diff --git a/openbsd-compat/blowfish.c b/openbsd-compat/blowfish.c
new file mode 100644
index 000000000..6c419549e
--- /dev/null
+++ b/openbsd-compat/blowfish.c
@@ -0,0 +1,694 @@
1/* $OpenBSD: blowfish.c,v 1.18 2004/11/02 17:23:26 hshoexer Exp $ */
2/*
3 * Blowfish block cipher for OpenBSD
4 * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
5 * All rights reserved.
6 *
7 * Implementation advice by David Mazieres <dm@lcs.mit.edu>.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by Niels Provos.
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35/*
36 * This code is derived from section 14.3 and the given source
37 * in section V of Applied Cryptography, second edition.
38 * Blowfish is an unpatented fast block cipher designed by
39 * Bruce Schneier.
40 */
41
42#include "includes.h"
43
44#if !defined(HAVE_BCRYPT_PBKDF) && (!defined(HAVE_BLOWFISH_INITSTATE) || \
45 !defined(HAVE_BLOWFISH_EXPAND0STATE) || !defined(HAVE_BLF_ENC))
46
47#if 0
48#include <stdio.h> /* used for debugging */
49#include <string.h>
50#endif
51
52#include <sys/types.h>
53#include <blf.h>
54
55#undef inline
56#ifdef __GNUC__
57#define inline __inline
58#else /* !__GNUC__ */
59#define inline
60#endif /* !__GNUC__ */
61
62/* Function for Feistel Networks */
63
64#define F(s, x) ((((s)[ (((x)>>24)&0xFF)] \
65 + (s)[0x100 + (((x)>>16)&0xFF)]) \
66 ^ (s)[0x200 + (((x)>> 8)&0xFF)]) \
67 + (s)[0x300 + ( (x) &0xFF)])
68
69#define BLFRND(s,p,i,j,n) (i ^= F(s,j) ^ (p)[n])
70
71void
72Blowfish_encipher(blf_ctx *c, u_int32_t *xl, u_int32_t *xr)
73{
74 u_int32_t Xl;
75 u_int32_t Xr;
76 u_int32_t *s = c->S[0];
77 u_int32_t *p = c->P;
78
79 Xl = *xl;
80 Xr = *xr;
81
82 Xl ^= p[0];
83 BLFRND(s, p, Xr, Xl, 1); BLFRND(s, p, Xl, Xr, 2);
84 BLFRND(s, p, Xr, Xl, 3); BLFRND(s, p, Xl, Xr, 4);
85 BLFRND(s, p, Xr, Xl, 5); BLFRND(s, p, Xl, Xr, 6);
86 BLFRND(s, p, Xr, Xl, 7); BLFRND(s, p, Xl, Xr, 8);
87 BLFRND(s, p, Xr, Xl, 9); BLFRND(s, p, Xl, Xr, 10);
88 BLFRND(s, p, Xr, Xl, 11); BLFRND(s, p, Xl, Xr, 12);
89 BLFRND(s, p, Xr, Xl, 13); BLFRND(s, p, Xl, Xr, 14);
90 BLFRND(s, p, Xr, Xl, 15); BLFRND(s, p, Xl, Xr, 16);
91
92 *xl = Xr ^ p[17];
93 *xr = Xl;
94}
95
96void
97Blowfish_decipher(blf_ctx *c, u_int32_t *xl, u_int32_t *xr)
98{
99 u_int32_t Xl;
100 u_int32_t Xr;
101 u_int32_t *s = c->S[0];
102 u_int32_t *p = c->P;
103
104 Xl = *xl;
105 Xr = *xr;
106
107 Xl ^= p[17];
108 BLFRND(s, p, Xr, Xl, 16); BLFRND(s, p, Xl, Xr, 15);
109 BLFRND(s, p, Xr, Xl, 14); BLFRND(s, p, Xl, Xr, 13);
110 BLFRND(s, p, Xr, Xl, 12); BLFRND(s, p, Xl, Xr, 11);
111 BLFRND(s, p, Xr, Xl, 10); BLFRND(s, p, Xl, Xr, 9);
112 BLFRND(s, p, Xr, Xl, 8); BLFRND(s, p, Xl, Xr, 7);
113 BLFRND(s, p, Xr, Xl, 6); BLFRND(s, p, Xl, Xr, 5);
114 BLFRND(s, p, Xr, Xl, 4); BLFRND(s, p, Xl, Xr, 3);
115 BLFRND(s, p, Xr, Xl, 2); BLFRND(s, p, Xl, Xr, 1);
116
117 *xl = Xr ^ p[0];
118 *xr = Xl;
119}
120
121void
122Blowfish_initstate(blf_ctx *c)
123{
124 /* P-box and S-box tables initialized with digits of Pi */
125
126 static const blf_ctx initstate =
127 { {
128 {
129 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
130 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
131 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
132 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
133 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
134 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
135 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
136 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
137 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
138 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
139 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
140 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
141 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
142 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
143 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
144 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
145 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
146 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
147 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
148 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
149 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
150 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
151 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
152 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
153 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
154 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
155 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
156 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
157 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
158 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
159 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
160 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
161 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
162 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
163 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
164 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
165 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
166 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
167 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
168 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
169 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
170 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
171 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
172 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
173 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
174 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
175 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
176 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
177 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
178 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
179 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
180 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
181 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
182 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
183 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
184 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
185 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
186 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
187 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
188 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
189 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
190 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
191 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
192 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a},
193 {
194 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,
195 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
196 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
197 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
198 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
199 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
200 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
201 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
202 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
203 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
204 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
205 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
206 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
207 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
208 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
209 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
210 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
211 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
212 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
213 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
214 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
215 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
216 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
217 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
218 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
219 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
220 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
221 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
222 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
223 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
224 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
225 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
226 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
227 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
228 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
229 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
230 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
231 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
232 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
233 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
234 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
235 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
236 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
237 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
238 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
239 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
240 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
241 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
242 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
243 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
244 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
245 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
246 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
247 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
248 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
249 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
250 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
251 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
252 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
253 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
254 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
255 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
256 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
257 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7},
258 {
259 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
260 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
261 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
262 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
263 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
264 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
265 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
266 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
267 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
268 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
269 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
270 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
271 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
272 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
273 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
274 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
275 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
276 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
277 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
278 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
279 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
280 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
281 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
282 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
283 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
284 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
285 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
286 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
287 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
288 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
289 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
290 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
291 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
292 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
293 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
294 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
295 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
296 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
297 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
298 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
299 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
300 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
301 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
302 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
303 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
304 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
305 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
306 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
307 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
308 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
309 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
310 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
311 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
312 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
313 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
314 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
315 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
316 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
317 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
318 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
319 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
320 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
321 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
322 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0},
323 {
324 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
325 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
326 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
327 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
328 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
329 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
330 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
331 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
332 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
333 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
334 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
335 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
336 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
337 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
338 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
339 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
340 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
341 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
342 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
343 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
344 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
345 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
346 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
347 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
348 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
349 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
350 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
351 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
352 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
353 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
354 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
355 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
356 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
357 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
358 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
359 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
360 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
361 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
362 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
363 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
364 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
365 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
366 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
367 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
368 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
369 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
370 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
371 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
372 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
373 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
374 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
375 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
376 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
377 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
378 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
379 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
380 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
381 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
382 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
383 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
384 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
385 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
386 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
387 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6}
388 },
389 {
390 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
391 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
392 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
393 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
394 0x9216d5d9, 0x8979fb1b
395 } };
396
397 *c = initstate;
398}
399
400u_int32_t
401Blowfish_stream2word(const u_int8_t *data, u_int16_t databytes,
402 u_int16_t *current)
403{
404 u_int8_t i;
405 u_int16_t j;
406 u_int32_t temp;
407
408 temp = 0x00000000;
409 j = *current;
410
411 for (i = 0; i < 4; i++, j++) {
412 if (j >= databytes)
413 j = 0;
414 temp = (temp << 8) | data[j];
415 }
416
417 *current = j;
418 return temp;
419}
420
421void
422Blowfish_expand0state(blf_ctx *c, const u_int8_t *key, u_int16_t keybytes)
423{
424 u_int16_t i;
425 u_int16_t j;
426 u_int16_t k;
427 u_int32_t temp;
428 u_int32_t datal;
429 u_int32_t datar;
430
431 j = 0;
432 for (i = 0; i < BLF_N + 2; i++) {
433 /* Extract 4 int8 to 1 int32 from keystream */
434 temp = Blowfish_stream2word(key, keybytes, &j);
435 c->P[i] = c->P[i] ^ temp;
436 }
437
438 j = 0;
439 datal = 0x00000000;
440 datar = 0x00000000;
441 for (i = 0; i < BLF_N + 2; i += 2) {
442 Blowfish_encipher(c, &datal, &datar);
443
444 c->P[i] = datal;
445 c->P[i + 1] = datar;
446 }
447
448 for (i = 0; i < 4; i++) {
449 for (k = 0; k < 256; k += 2) {
450 Blowfish_encipher(c, &datal, &datar);
451
452 c->S[i][k] = datal;
453 c->S[i][k + 1] = datar;
454 }
455 }
456}
457
458
459void
460Blowfish_expandstate(blf_ctx *c, const u_int8_t *data, u_int16_t databytes,
461 const u_int8_t *key, u_int16_t keybytes)
462{
463 u_int16_t i;
464 u_int16_t j;
465 u_int16_t k;
466 u_int32_t temp;
467 u_int32_t datal;
468 u_int32_t datar;
469
470 j = 0;
471 for (i = 0; i < BLF_N + 2; i++) {
472 /* Extract 4 int8 to 1 int32 from keystream */
473 temp = Blowfish_stream2word(key, keybytes, &j);
474 c->P[i] = c->P[i] ^ temp;
475 }
476
477 j = 0;
478 datal = 0x00000000;
479 datar = 0x00000000;
480 for (i = 0; i < BLF_N + 2; i += 2) {
481 datal ^= Blowfish_stream2word(data, databytes, &j);
482 datar ^= Blowfish_stream2word(data, databytes, &j);
483 Blowfish_encipher(c, &datal, &datar);
484
485 c->P[i] = datal;
486 c->P[i + 1] = datar;
487 }
488
489 for (i = 0; i < 4; i++) {
490 for (k = 0; k < 256; k += 2) {
491 datal ^= Blowfish_stream2word(data, databytes, &j);
492 datar ^= Blowfish_stream2word(data, databytes, &j);
493 Blowfish_encipher(c, &datal, &datar);
494
495 c->S[i][k] = datal;
496 c->S[i][k + 1] = datar;
497 }
498 }
499
500}
501
502void
503blf_key(blf_ctx *c, const u_int8_t *k, u_int16_t len)
504{
505 /* Initialize S-boxes and subkeys with Pi */
506 Blowfish_initstate(c);
507
508 /* Transform S-boxes and subkeys with key */
509 Blowfish_expand0state(c, k, len);
510}
511
512void
513blf_enc(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
514{
515 u_int32_t *d;
516 u_int16_t i;
517
518 d = data;
519 for (i = 0; i < blocks; i++) {
520 Blowfish_encipher(c, d, d + 1);
521 d += 2;
522 }
523}
524
525void
526blf_dec(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
527{
528 u_int32_t *d;
529 u_int16_t i;
530
531 d = data;
532 for (i = 0; i < blocks; i++) {
533 Blowfish_decipher(c, d, d + 1);
534 d += 2;
535 }
536}
537
538void
539blf_ecb_encrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
540{
541 u_int32_t l, r;
542 u_int32_t i;
543
544 for (i = 0; i < len; i += 8) {
545 l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
546 r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
547 Blowfish_encipher(c, &l, &r);
548 data[0] = l >> 24 & 0xff;
549 data[1] = l >> 16 & 0xff;
550 data[2] = l >> 8 & 0xff;
551 data[3] = l & 0xff;
552 data[4] = r >> 24 & 0xff;
553 data[5] = r >> 16 & 0xff;
554 data[6] = r >> 8 & 0xff;
555 data[7] = r & 0xff;
556 data += 8;
557 }
558}
559
560void
561blf_ecb_decrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
562{
563 u_int32_t l, r;
564 u_int32_t i;
565
566 for (i = 0; i < len; i += 8) {
567 l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
568 r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
569 Blowfish_decipher(c, &l, &r);
570 data[0] = l >> 24 & 0xff;
571 data[1] = l >> 16 & 0xff;
572 data[2] = l >> 8 & 0xff;
573 data[3] = l & 0xff;
574 data[4] = r >> 24 & 0xff;
575 data[5] = r >> 16 & 0xff;
576 data[6] = r >> 8 & 0xff;
577 data[7] = r & 0xff;
578 data += 8;
579 }
580}
581
582void
583blf_cbc_encrypt(blf_ctx *c, u_int8_t *iv, u_int8_t *data, u_int32_t len)
584{
585 u_int32_t l, r;
586 u_int32_t i, j;
587
588 for (i = 0; i < len; i += 8) {
589 for (j = 0; j < 8; j++)
590 data[j] ^= iv[j];
591 l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
592 r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
593 Blowfish_encipher(c, &l, &r);
594 data[0] = l >> 24 & 0xff;
595 data[1] = l >> 16 & 0xff;
596 data[2] = l >> 8 & 0xff;
597 data[3] = l & 0xff;
598 data[4] = r >> 24 & 0xff;
599 data[5] = r >> 16 & 0xff;
600 data[6] = r >> 8 & 0xff;
601 data[7] = r & 0xff;
602 iv = data;
603 data += 8;
604 }
605}
606
607void
608blf_cbc_decrypt(blf_ctx *c, u_int8_t *iva, u_int8_t *data, u_int32_t len)
609{
610 u_int32_t l, r;
611 u_int8_t *iv;
612 u_int32_t i, j;
613
614 iv = data + len - 16;
615 data = data + len - 8;
616 for (i = len - 8; i >= 8; i -= 8) {
617 l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
618 r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
619 Blowfish_decipher(c, &l, &r);
620 data[0] = l >> 24 & 0xff;
621 data[1] = l >> 16 & 0xff;
622 data[2] = l >> 8 & 0xff;
623 data[3] = l & 0xff;
624 data[4] = r >> 24 & 0xff;
625 data[5] = r >> 16 & 0xff;
626 data[6] = r >> 8 & 0xff;
627 data[7] = r & 0xff;
628 for (j = 0; j < 8; j++)
629 data[j] ^= iv[j];
630 iv -= 8;
631 data -= 8;
632 }
633 l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
634 r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
635 Blowfish_decipher(c, &l, &r);
636 data[0] = l >> 24 & 0xff;
637 data[1] = l >> 16 & 0xff;
638 data[2] = l >> 8 & 0xff;
639 data[3] = l & 0xff;
640 data[4] = r >> 24 & 0xff;
641 data[5] = r >> 16 & 0xff;
642 data[6] = r >> 8 & 0xff;
643 data[7] = r & 0xff;
644 for (j = 0; j < 8; j++)
645 data[j] ^= iva[j];
646}
647
648#if 0
649void
650report(u_int32_t data[], u_int16_t len)
651{
652 u_int16_t i;
653 for (i = 0; i < len; i += 2)
654 printf("Block %0hd: %08lx %08lx.\n",
655 i / 2, data[i], data[i + 1]);
656}
657void
658main(void)
659{
660
661 blf_ctx c;
662 char key[] = "AAAAA";
663 char key2[] = "abcdefghijklmnopqrstuvwxyz";
664
665 u_int32_t data[10];
666 u_int32_t data2[] =
667 {0x424c4f57l, 0x46495348l};
668
669 u_int16_t i;
670
671 /* First test */
672 for (i = 0; i < 10; i++)
673 data[i] = i;
674
675 blf_key(&c, (u_int8_t *) key, 5);
676 blf_enc(&c, data, 5);
677 blf_dec(&c, data, 1);
678 blf_dec(&c, data + 2, 4);
679 printf("Should read as 0 - 9.\n");
680 report(data, 10);
681
682 /* Second test */
683 blf_key(&c, (u_int8_t *) key2, strlen(key2));
684 blf_enc(&c, data2, 1);
685 printf("\nShould read as: 0x324ed0fe 0xf413a203.\n");
686 report(data2, 2);
687 blf_dec(&c, data2, 1);
688 report(data2, 2);
689}
690#endif
691
692#endif /* !defined(HAVE_BCRYPT_PBKDF) && (!defined(HAVE_BLOWFISH_INITSTATE) || \
693 !defined(HAVE_BLOWFISH_EXPAND0STATE) || !defined(HAVE_BLF_ENC)) */
694
diff --git a/openbsd-compat/bsd-arc4random.c b/openbsd-compat/bsd-arc4random.c
deleted file mode 100644
index d7c586253..000000000
--- a/openbsd-compat/bsd-arc4random.c
+++ /dev/null
@@ -1,150 +0,0 @@
1/*
2 * Copyright (c) 1999,2000,2004 Damien Miller <djm@mindrot.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include "includes.h"
18
19#include <sys/types.h>
20
21#include <string.h>
22#include <stdlib.h>
23#include <stdarg.h>
24
25#include "log.h"
26
27#ifndef HAVE_ARC4RANDOM
28
29#include <openssl/rand.h>
30#include <openssl/rc4.h>
31#include <openssl/err.h>
32
33/* Size of key to use */
34#define SEED_SIZE 20
35
36/* Number of bytes to reseed after */
37#define REKEY_BYTES (1 << 24)
38
39static int rc4_ready = 0;
40static RC4_KEY rc4;
41
42unsigned int
43arc4random(void)
44{
45 unsigned int r = 0;
46 static int first_time = 1;
47
48 if (rc4_ready <= 0) {
49 if (first_time)
50 seed_rng();
51 first_time = 0;
52 arc4random_stir();
53 }
54
55 RC4(&rc4, sizeof(r), (unsigned char *)&r, (unsigned char *)&r);
56
57 rc4_ready -= sizeof(r);
58
59 return(r);
60}
61
62void
63arc4random_stir(void)
64{
65 unsigned char rand_buf[SEED_SIZE];
66 int i;
67
68 memset(&rc4, 0, sizeof(rc4));
69 if (RAND_bytes(rand_buf, sizeof(rand_buf)) <= 0)
70 fatal("Couldn't obtain random bytes (error %ld)",
71 ERR_get_error());
72 RC4_set_key(&rc4, sizeof(rand_buf), rand_buf);
73
74 /*
75 * Discard early keystream, as per recommendations in:
76 * http://www.wisdom.weizmann.ac.il/~itsik/RC4/Papers/Rc4_ksa.ps
77 */
78 for(i = 0; i <= 256; i += sizeof(rand_buf))
79 RC4(&rc4, sizeof(rand_buf), rand_buf, rand_buf);
80
81 memset(rand_buf, 0, sizeof(rand_buf));
82
83 rc4_ready = REKEY_BYTES;
84}
85#endif /* !HAVE_ARC4RANDOM */
86
87#ifndef HAVE_ARC4RANDOM_BUF
88void
89arc4random_buf(void *_buf, size_t n)
90{
91 size_t i;
92 u_int32_t r = 0;
93 char *buf = (char *)_buf;
94
95 for (i = 0; i < n; i++) {
96 if (i % 4 == 0)
97 r = arc4random();
98 buf[i] = r & 0xff;
99 r >>= 8;
100 }
101 i = r = 0;
102}
103#endif /* !HAVE_ARC4RANDOM_BUF */
104
105#ifndef HAVE_ARC4RANDOM_UNIFORM
106/*
107 * Calculate a uniformly distributed random number less than upper_bound
108 * avoiding "modulo bias".
109 *
110 * Uniformity is achieved by generating new random numbers until the one
111 * returned is outside the range [0, 2**32 % upper_bound). This
112 * guarantees the selected random number will be inside
113 * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound)
114 * after reduction modulo upper_bound.
115 */
116u_int32_t
117arc4random_uniform(u_int32_t upper_bound)
118{
119 u_int32_t r, min;
120
121 if (upper_bound < 2)
122 return 0;
123
124#if (ULONG_MAX > 0xffffffffUL)
125 min = 0x100000000UL % upper_bound;
126#else
127 /* Calculate (2**32 % upper_bound) avoiding 64-bit math */
128 if (upper_bound > 0x80000000)
129 min = 1 + ~upper_bound; /* 2**32 - upper_bound */
130 else {
131 /* (2**32 - (x * 2)) % x == 2**32 % x when x <= 2**31 */
132 min = ((0xffffffff - (upper_bound * 2)) + 1) % upper_bound;
133 }
134#endif
135
136 /*
137 * This could theoretically loop forever but each retry has
138 * p > 0.5 (worst case, usually far better) of selecting a
139 * number inside the range we need, so it should rarely need
140 * to re-roll.
141 */
142 for (;;) {
143 r = arc4random();
144 if (r >= min)
145 break;
146 }
147
148 return r % upper_bound;
149}
150#endif /* !HAVE_ARC4RANDOM_UNIFORM */
diff --git a/openbsd-compat/bsd-cygwin_util.h b/openbsd-compat/bsd-cygwin_util.h
index 372e41955..1177366f1 100644
--- a/openbsd-compat/bsd-cygwin_util.h
+++ b/openbsd-compat/bsd-cygwin_util.h
@@ -1,4 +1,4 @@
1/* $Id: bsd-cygwin_util.h,v 1.16 2013/04/01 01:40:49 dtucker Exp $ */ 1/* $Id: bsd-cygwin_util.h,v 1.17 2014/01/18 10:04:00 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000, 2001, 2011, 2013 Corinna Vinschen <vinschen@redhat.com> 4 * Copyright (c) 2000, 2001, 2011, 2013 Corinna Vinschen <vinschen@redhat.com>
@@ -40,9 +40,15 @@
40typedef void *HANDLE; 40typedef void *HANDLE;
41#define INVALID_HANDLE_VALUE ((HANDLE) -1) 41#define INVALID_HANDLE_VALUE ((HANDLE) -1)
42 42
43/* Cygwin functions for which declarations are only available when including
44 windows headers, so we have to define them here explicitely. */
45extern HANDLE cygwin_logon_user (const struct passwd *, const char *);
46extern void cygwin_set_impersonation_token (const HANDLE);
47
43#include <sys/cygwin.h> 48#include <sys/cygwin.h>
44#include <io.h> 49#include <io.h>
45 50
51
46int binary_open(const char *, int , ...); 52int binary_open(const char *, int , ...);
47int check_ntsec(const char *); 53int check_ntsec(const char *);
48char **fetch_windows_environment(void); 54char **fetch_windows_environment(void);
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index d75854e83..65e800397 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -28,6 +28,7 @@
28#include <string.h> 28#include <string.h>
29#include <signal.h> 29#include <signal.h>
30#include <stdlib.h> 30#include <stdlib.h>
31#include <time.h>
31#include <unistd.h> 32#include <unistd.h>
32 33
33#include "xmalloc.h" 34#include "xmalloc.h"
diff --git a/openbsd-compat/bsd-poll.c b/openbsd-compat/bsd-poll.c
index f899d7a24..c7ef82776 100644
--- a/openbsd-compat/bsd-poll.c
+++ b/openbsd-compat/bsd-poll.c
@@ -1,4 +1,4 @@
1/* $Id: bsd-poll.c,v 1.4 2008/08/29 21:32:38 dtucker Exp $ */ 1/* $Id: bsd-poll.c,v 1.5 2013/11/08 10:12:58 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2004, 2005, 2007 Darren Tucker (dtucker at zip com au). 4 * Copyright (c) 2004, 2005, 2007 Darren Tucker (dtucker at zip com au).
@@ -19,12 +19,15 @@
19#include "includes.h" 19#include "includes.h"
20#if !defined(HAVE_POLL) 20#if !defined(HAVE_POLL)
21 21
22#include <sys/types.h>
23#include <sys/time.h>
22#ifdef HAVE_SYS_SELECT_H 24#ifdef HAVE_SYS_SELECT_H
23# include <sys/select.h> 25# include <sys/select.h>
24#endif 26#endif
25 27
26#include <stdlib.h>
27#include <errno.h> 28#include <errno.h>
29#include <stdlib.h>
30#include <unistd.h>
28#include "bsd-poll.h" 31#include "bsd-poll.h"
29 32
30/* 33/*
diff --git a/openbsd-compat/bsd-setres_id.c b/openbsd-compat/bsd-setres_id.c
index 020b214b8..018bde8c7 100644
--- a/openbsd-compat/bsd-setres_id.c
+++ b/openbsd-compat/bsd-setres_id.c
@@ -1,4 +1,4 @@
1/* $Id: bsd-setres_id.c,v 1.1 2012/11/05 06:04:37 dtucker Exp $ */ 1/* $Id: bsd-setres_id.c,v 1.2 2013/12/07 21:23:09 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2012 Darren Tucker (dtucker at zip com au). 4 * Copyright (c) 2012 Darren Tucker (dtucker at zip com au).
@@ -22,6 +22,7 @@
22 22
23#include <stdarg.h> 23#include <stdarg.h>
24#include <unistd.h> 24#include <unistd.h>
25#include <string.h>
25 26
26#include "log.h" 27#include "log.h"
27 28
diff --git a/openbsd-compat/bsd-snprintf.c b/openbsd-compat/bsd-snprintf.c
index 41d2be238..975991e7f 100644
--- a/openbsd-compat/bsd-snprintf.c
+++ b/openbsd-compat/bsd-snprintf.c
@@ -160,6 +160,8 @@
160#define DP_C_LONG 2 160#define DP_C_LONG 2
161#define DP_C_LDOUBLE 3 161#define DP_C_LDOUBLE 3
162#define DP_C_LLONG 4 162#define DP_C_LLONG 4
163#define DP_C_SIZE 5
164#define DP_C_INTMAX 6
163 165
164#define char_to_int(p) ((p)- '0') 166#define char_to_int(p) ((p)- '0')
165#ifndef MAX 167#ifndef MAX
@@ -182,7 +184,7 @@ static int dopr(char *buffer, size_t maxlen, const char *format,
182static int fmtstr(char *buffer, size_t *currlen, size_t maxlen, 184static int fmtstr(char *buffer, size_t *currlen, size_t maxlen,
183 char *value, int flags, int min, int max); 185 char *value, int flags, int min, int max);
184static int fmtint(char *buffer, size_t *currlen, size_t maxlen, 186static int fmtint(char *buffer, size_t *currlen, size_t maxlen,
185 LLONG value, int base, int min, int max, int flags); 187 intmax_t value, int base, int min, int max, int flags);
186static int fmtfp(char *buffer, size_t *currlen, size_t maxlen, 188static int fmtfp(char *buffer, size_t *currlen, size_t maxlen,
187 LDOUBLE fvalue, int min, int max, int flags); 189 LDOUBLE fvalue, int min, int max, int flags);
188 190
@@ -190,7 +192,7 @@ static int
190dopr(char *buffer, size_t maxlen, const char *format, va_list args_in) 192dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
191{ 193{
192 char ch; 194 char ch;
193 LLONG value; 195 intmax_t value;
194 LDOUBLE fvalue; 196 LDOUBLE fvalue;
195 char *strvalue; 197 char *strvalue;
196 int min; 198 int min;
@@ -287,6 +289,10 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
287 cflags = DP_C_SHORT; 289 cflags = DP_C_SHORT;
288 ch = *format++; 290 ch = *format++;
289 break; 291 break;
292 case 'j':
293 cflags = DP_C_INTMAX;
294 ch = *format++;
295 break;
290 case 'l': 296 case 'l':
291 cflags = DP_C_LONG; 297 cflags = DP_C_LONG;
292 ch = *format++; 298 ch = *format++;
@@ -299,6 +305,10 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
299 cflags = DP_C_LDOUBLE; 305 cflags = DP_C_LDOUBLE;
300 ch = *format++; 306 ch = *format++;
301 break; 307 break;
308 case 'z':
309 cflags = DP_C_SIZE;
310 ch = *format++;
311 break;
302 default: 312 default:
303 break; 313 break;
304 } 314 }
@@ -314,6 +324,10 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
314 value = va_arg (args, long int); 324 value = va_arg (args, long int);
315 else if (cflags == DP_C_LLONG) 325 else if (cflags == DP_C_LLONG)
316 value = va_arg (args, LLONG); 326 value = va_arg (args, LLONG);
327 else if (cflags == DP_C_SIZE)
328 value = va_arg (args, ssize_t);
329 else if (cflags == DP_C_INTMAX)
330 value = va_arg (args, intmax_t);
317 else 331 else
318 value = va_arg (args, int); 332 value = va_arg (args, int);
319 if (fmtint(buffer, &currlen, maxlen, 333 if (fmtint(buffer, &currlen, maxlen,
@@ -328,6 +342,12 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
328 value = (long)va_arg (args, unsigned long int); 342 value = (long)va_arg (args, unsigned long int);
329 else if (cflags == DP_C_LLONG) 343 else if (cflags == DP_C_LLONG)
330 value = (long)va_arg (args, unsigned LLONG); 344 value = (long)va_arg (args, unsigned LLONG);
345 else if (cflags == DP_C_SIZE)
346 value = va_arg (args, size_t);
347#ifdef notyet
348 else if (cflags == DP_C_INTMAX)
349 value = va_arg (args, uintmax_t);
350#endif
331 else 351 else
332 value = (long)va_arg (args, unsigned int); 352 value = (long)va_arg (args, unsigned int);
333 if (fmtint(buffer, &currlen, maxlen, value, 353 if (fmtint(buffer, &currlen, maxlen, value,
@@ -342,6 +362,12 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
342 value = (long)va_arg (args, unsigned long int); 362 value = (long)va_arg (args, unsigned long int);
343 else if (cflags == DP_C_LLONG) 363 else if (cflags == DP_C_LLONG)
344 value = (LLONG)va_arg (args, unsigned LLONG); 364 value = (LLONG)va_arg (args, unsigned LLONG);
365 else if (cflags == DP_C_SIZE)
366 value = va_arg (args, size_t);
367#ifdef notyet
368 else if (cflags == DP_C_INTMAX)
369 value = va_arg (args, uintmax_t);
370#endif
345 else 371 else
346 value = (long)va_arg (args, unsigned int); 372 value = (long)va_arg (args, unsigned int);
347 if (fmtint(buffer, &currlen, maxlen, value, 373 if (fmtint(buffer, &currlen, maxlen, value,
@@ -358,6 +384,12 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
358 value = (long)va_arg (args, unsigned long int); 384 value = (long)va_arg (args, unsigned long int);
359 else if (cflags == DP_C_LLONG) 385 else if (cflags == DP_C_LLONG)
360 value = (LLONG)va_arg (args, unsigned LLONG); 386 value = (LLONG)va_arg (args, unsigned LLONG);
387 else if (cflags == DP_C_SIZE)
388 value = va_arg (args, size_t);
389#ifdef notyet
390 else if (cflags == DP_C_INTMAX)
391 value = va_arg (args, uintmax_t);
392#endif
361 else 393 else
362 value = (long)va_arg (args, unsigned int); 394 value = (long)va_arg (args, unsigned int);
363 if (fmtint(buffer, &currlen, maxlen, value, 395 if (fmtint(buffer, &currlen, maxlen, value,
@@ -416,6 +448,7 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
416 (long) strvalue, 16, min, max, flags) == -1) 448 (long) strvalue, 16, min, max, flags) == -1)
417 return -1; 449 return -1;
418 break; 450 break;
451#if we_dont_want_this_in_openssh
419 case 'n': 452 case 'n':
420 if (cflags == DP_C_SHORT) { 453 if (cflags == DP_C_SHORT) {
421 short int *num; 454 short int *num;
@@ -429,12 +462,21 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
429 LLONG *num; 462 LLONG *num;
430 num = va_arg (args, LLONG *); 463 num = va_arg (args, LLONG *);
431 *num = (LLONG)currlen; 464 *num = (LLONG)currlen;
465 } else if (cflags == DP_C_SIZE) {
466 ssize_t *num;
467 num = va_arg (args, ssize_t *);
468 *num = (ssize_t)currlen;
469 } else if (cflags == DP_C_INTMAX) {
470 intmax_t *num;
471 num = va_arg (args, intmax_t *);
472 *num = (intmax_t)currlen;
432 } else { 473 } else {
433 int *num; 474 int *num;
434 num = va_arg (args, int *); 475 num = va_arg (args, int *);
435 *num = currlen; 476 *num = currlen;
436 } 477 }
437 break; 478 break;
479#endif
438 case '%': 480 case '%':
439 DOPR_OUTCH(buffer, currlen, maxlen, ch); 481 DOPR_OUTCH(buffer, currlen, maxlen, ch);
440 break; 482 break;
diff --git a/openbsd-compat/bsd-statvfs.c b/openbsd-compat/bsd-statvfs.c
index 844d5b464..2b1da80ec 100644
--- a/openbsd-compat/bsd-statvfs.c
+++ b/openbsd-compat/bsd-statvfs.c
@@ -1,7 +1,7 @@
1/* $Id: bsd-statvfs.c,v 1.1 2008/06/08 17:32:29 dtucker Exp $ */ 1/* $Id: bsd-statvfs.c,v 1.2 2014/01/17 07:10:59 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 Darren Tucker <dtucker@zip.com.au> 4 * Copyright (c) 2008,2014 Darren Tucker <dtucker@zip.com.au>
5 * 5 *
6 * Permission to use, copy, modify, and distribute this software for any 6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above 7 * purpose with or without fee is hereby granted, provided that the above
@@ -18,20 +18,65 @@
18 18
19#include "includes.h" 19#include "includes.h"
20 20
21#if !defined(HAVE_STATVFS) || !defined(HAVE_FSTATVFS)
22
23#include <sys/param.h>
24#ifdef HAVE_SYS_MOUNT_H
25# include <sys/mount.h>
26#endif
27
21#include <errno.h> 28#include <errno.h>
22 29
23#ifndef HAVE_STATVFS 30static void
31copy_statfs_to_statvfs(struct statvfs *to, struct statfs *from)
32{
33 to->f_bsize = from->f_bsize;
34 to->f_frsize = from->f_bsize; /* no exact equivalent */
35 to->f_blocks = from->f_blocks;
36 to->f_bfree = from->f_bfree;
37 to->f_bavail = from->f_bavail;
38 to->f_files = from->f_files;
39 to->f_ffree = from->f_ffree;
40 to->f_favail = from->f_ffree; /* no exact equivalent */
41 to->f_fsid = 0; /* XXX fix me */
42 to->f_flag = from->f_flags;
43 to->f_namemax = MNAMELEN;
44}
45
46# ifndef HAVE_STATVFS
24int statvfs(const char *path, struct statvfs *buf) 47int statvfs(const char *path, struct statvfs *buf)
25{ 48{
49# ifdef HAVE_STATFS
50 struct statfs fs;
51
52 memset(&fs, 0, sizeof(fs));
53 if (statfs(path, &fs) == -1)
54 return -1;
55 copy_statfs_to_statvfs(buf, &fs);
56 return 0;
57# else
26 errno = ENOSYS; 58 errno = ENOSYS;
27 return -1; 59 return -1;
60# endif
28} 61}
29#endif 62# endif
30 63
31#ifndef HAVE_FSTATVFS 64# ifndef HAVE_FSTATVFS
32int fstatvfs(int fd, struct statvfs *buf) 65int fstatvfs(int fd, struct statvfs *buf)
33{ 66{
67# ifdef HAVE_FSTATFS
68 struct statfs fs;
69
70 memset(&fs, 0, sizeof(fs));
71 if (fstatfs(fd, &fs) == -1)
72 return -1;
73 copy_statfs_to_statvfs(buf, &fs);
74 return 0;
75# else
34 errno = ENOSYS; 76 errno = ENOSYS;
35 return -1; 77 return -1;
78# endif
36} 79}
80# endif
81
37#endif 82#endif
diff --git a/openbsd-compat/bsd-statvfs.h b/openbsd-compat/bsd-statvfs.h
index da215ffc6..dfd609974 100644
--- a/openbsd-compat/bsd-statvfs.h
+++ b/openbsd-compat/bsd-statvfs.h
@@ -1,7 +1,7 @@
1/* $Id: bsd-statvfs.h,v 1.1 2008/06/08 17:32:29 dtucker Exp $ */ 1/* $Id: bsd-statvfs.h,v 1.3 2014/01/17 07:48:22 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 Darren Tucker <dtucker@zip.com.au> 4 * Copyright (c) 2008,2014 Darren Tucker <dtucker@zip.com.au>
5 * 5 *
6 * Permission to use, copy, modify, and distribute this software for any 6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above 7 * purpose with or without fee is hereby granted, provided that the above
@@ -18,14 +18,17 @@
18 18
19#include "includes.h" 19#include "includes.h"
20 20
21#if !defined(HAVE_STATVFS) || !defined(HAVE_FSTATVFS)
22
21#include <sys/types.h> 23#include <sys/types.h>
22 24
25#ifdef HAVE_SYS_MOUNT_H
26#include <sys/mount.h>
27#endif
23#ifdef HAVE_SYS_STATFS_H 28#ifdef HAVE_SYS_STATFS_H
24#include <sys/statfs.h> 29#include <sys/statfs.h>
25#endif 30#endif
26 31
27#ifndef HAVE_STATVFS
28
29#ifndef HAVE_FSBLKCNT_T 32#ifndef HAVE_FSBLKCNT_T
30typedef unsigned long fsblkcnt_t; 33typedef unsigned long fsblkcnt_t;
31#endif 34#endif
diff --git a/openbsd-compat/chacha_private.h b/openbsd-compat/chacha_private.h
new file mode 100644
index 000000000..7c3680fa6
--- /dev/null
+++ b/openbsd-compat/chacha_private.h
@@ -0,0 +1,222 @@
1/*
2chacha-merged.c version 20080118
3D. J. Bernstein
4Public domain.
5*/
6
7/* $OpenBSD: chacha_private.h,v 1.2 2013/10/04 07:02:27 djm Exp $ */
8
9typedef unsigned char u8;
10typedef unsigned int u32;
11
12typedef struct
13{
14 u32 input[16]; /* could be compressed */
15} chacha_ctx;
16
17#define U8C(v) (v##U)
18#define U32C(v) (v##U)
19
20#define U8V(v) ((u8)(v) & U8C(0xFF))
21#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
22
23#define ROTL32(v, n) \
24 (U32V((v) << (n)) | ((v) >> (32 - (n))))
25
26#define U8TO32_LITTLE(p) \
27 (((u32)((p)[0]) ) | \
28 ((u32)((p)[1]) << 8) | \
29 ((u32)((p)[2]) << 16) | \
30 ((u32)((p)[3]) << 24))
31
32#define U32TO8_LITTLE(p, v) \
33 do { \
34 (p)[0] = U8V((v) ); \
35 (p)[1] = U8V((v) >> 8); \
36 (p)[2] = U8V((v) >> 16); \
37 (p)[3] = U8V((v) >> 24); \
38 } while (0)
39
40#define ROTATE(v,c) (ROTL32(v,c))
41#define XOR(v,w) ((v) ^ (w))
42#define PLUS(v,w) (U32V((v) + (w)))
43#define PLUSONE(v) (PLUS((v),1))
44
45#define QUARTERROUND(a,b,c,d) \
46 a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
47 c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
48 a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
49 c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
50
51static const char sigma[16] = "expand 32-byte k";
52static const char tau[16] = "expand 16-byte k";
53
54static void
55chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits,u32 ivbits)
56{
57 const char *constants;
58
59 x->input[4] = U8TO32_LITTLE(k + 0);
60 x->input[5] = U8TO32_LITTLE(k + 4);
61 x->input[6] = U8TO32_LITTLE(k + 8);
62 x->input[7] = U8TO32_LITTLE(k + 12);
63 if (kbits == 256) { /* recommended */
64 k += 16;
65 constants = sigma;
66 } else { /* kbits == 128 */
67 constants = tau;
68 }
69 x->input[8] = U8TO32_LITTLE(k + 0);
70 x->input[9] = U8TO32_LITTLE(k + 4);
71 x->input[10] = U8TO32_LITTLE(k + 8);
72 x->input[11] = U8TO32_LITTLE(k + 12);
73 x->input[0] = U8TO32_LITTLE(constants + 0);
74 x->input[1] = U8TO32_LITTLE(constants + 4);
75 x->input[2] = U8TO32_LITTLE(constants + 8);
76 x->input[3] = U8TO32_LITTLE(constants + 12);
77}
78
79static void
80chacha_ivsetup(chacha_ctx *x,const u8 *iv)
81{
82 x->input[12] = 0;
83 x->input[13] = 0;
84 x->input[14] = U8TO32_LITTLE(iv + 0);
85 x->input[15] = U8TO32_LITTLE(iv + 4);
86}
87
88static void
89chacha_encrypt_bytes(chacha_ctx *x,const u8 *m,u8 *c,u32 bytes)
90{
91 u32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
92 u32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
93 u8 *ctarget = NULL;
94 u8 tmp[64];
95 u_int i;
96
97 if (!bytes) return;
98
99 j0 = x->input[0];
100 j1 = x->input[1];
101 j2 = x->input[2];
102 j3 = x->input[3];
103 j4 = x->input[4];
104 j5 = x->input[5];
105 j6 = x->input[6];
106 j7 = x->input[7];
107 j8 = x->input[8];
108 j9 = x->input[9];
109 j10 = x->input[10];
110 j11 = x->input[11];
111 j12 = x->input[12];
112 j13 = x->input[13];
113 j14 = x->input[14];
114 j15 = x->input[15];
115
116 for (;;) {
117 if (bytes < 64) {
118 for (i = 0;i < bytes;++i) tmp[i] = m[i];
119 m = tmp;
120 ctarget = c;
121 c = tmp;
122 }
123 x0 = j0;
124 x1 = j1;
125 x2 = j2;
126 x3 = j3;
127 x4 = j4;
128 x5 = j5;
129 x6 = j6;
130 x7 = j7;
131 x8 = j8;
132 x9 = j9;
133 x10 = j10;
134 x11 = j11;
135 x12 = j12;
136 x13 = j13;
137 x14 = j14;
138 x15 = j15;
139 for (i = 20;i > 0;i -= 2) {
140 QUARTERROUND( x0, x4, x8,x12)
141 QUARTERROUND( x1, x5, x9,x13)
142 QUARTERROUND( x2, x6,x10,x14)
143 QUARTERROUND( x3, x7,x11,x15)
144 QUARTERROUND( x0, x5,x10,x15)
145 QUARTERROUND( x1, x6,x11,x12)
146 QUARTERROUND( x2, x7, x8,x13)
147 QUARTERROUND( x3, x4, x9,x14)
148 }
149 x0 = PLUS(x0,j0);
150 x1 = PLUS(x1,j1);
151 x2 = PLUS(x2,j2);
152 x3 = PLUS(x3,j3);
153 x4 = PLUS(x4,j4);
154 x5 = PLUS(x5,j5);
155 x6 = PLUS(x6,j6);
156 x7 = PLUS(x7,j7);
157 x8 = PLUS(x8,j8);
158 x9 = PLUS(x9,j9);
159 x10 = PLUS(x10,j10);
160 x11 = PLUS(x11,j11);
161 x12 = PLUS(x12,j12);
162 x13 = PLUS(x13,j13);
163 x14 = PLUS(x14,j14);
164 x15 = PLUS(x15,j15);
165
166#ifndef KEYSTREAM_ONLY
167 x0 = XOR(x0,U8TO32_LITTLE(m + 0));
168 x1 = XOR(x1,U8TO32_LITTLE(m + 4));
169 x2 = XOR(x2,U8TO32_LITTLE(m + 8));
170 x3 = XOR(x3,U8TO32_LITTLE(m + 12));
171 x4 = XOR(x4,U8TO32_LITTLE(m + 16));
172 x5 = XOR(x5,U8TO32_LITTLE(m + 20));
173 x6 = XOR(x6,U8TO32_LITTLE(m + 24));
174 x7 = XOR(x7,U8TO32_LITTLE(m + 28));
175 x8 = XOR(x8,U8TO32_LITTLE(m + 32));
176 x9 = XOR(x9,U8TO32_LITTLE(m + 36));
177 x10 = XOR(x10,U8TO32_LITTLE(m + 40));
178 x11 = XOR(x11,U8TO32_LITTLE(m + 44));
179 x12 = XOR(x12,U8TO32_LITTLE(m + 48));
180 x13 = XOR(x13,U8TO32_LITTLE(m + 52));
181 x14 = XOR(x14,U8TO32_LITTLE(m + 56));
182 x15 = XOR(x15,U8TO32_LITTLE(m + 60));
183#endif
184
185 j12 = PLUSONE(j12);
186 if (!j12) {
187 j13 = PLUSONE(j13);
188 /* stopping at 2^70 bytes per nonce is user's responsibility */
189 }
190
191 U32TO8_LITTLE(c + 0,x0);
192 U32TO8_LITTLE(c + 4,x1);
193 U32TO8_LITTLE(c + 8,x2);
194 U32TO8_LITTLE(c + 12,x3);
195 U32TO8_LITTLE(c + 16,x4);
196 U32TO8_LITTLE(c + 20,x5);
197 U32TO8_LITTLE(c + 24,x6);
198 U32TO8_LITTLE(c + 28,x7);
199 U32TO8_LITTLE(c + 32,x8);
200 U32TO8_LITTLE(c + 36,x9);
201 U32TO8_LITTLE(c + 40,x10);
202 U32TO8_LITTLE(c + 44,x11);
203 U32TO8_LITTLE(c + 48,x12);
204 U32TO8_LITTLE(c + 52,x13);
205 U32TO8_LITTLE(c + 56,x14);
206 U32TO8_LITTLE(c + 60,x15);
207
208 if (bytes <= 64) {
209 if (bytes < 64) {
210 for (i = 0;i < bytes;++i) ctarget[i] = c[i];
211 }
212 x->input[12] = j12;
213 x->input[13] = j13;
214 return;
215 }
216 bytes -= 64;
217 c += 64;
218#ifndef KEYSTREAM_ONLY
219 m += 64;
220#endif
221 }
222}
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h
index 392fa38dc..f34619e4a 100644
--- a/openbsd-compat/openbsd-compat.h
+++ b/openbsd-compat/openbsd-compat.h
@@ -1,4 +1,4 @@
1/* $Id: openbsd-compat.h,v 1.58 2013/06/05 22:30:21 dtucker Exp $ */ 1/* $Id: openbsd-compat.h,v 1.60 2013/12/07 00:51:54 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.
@@ -44,6 +44,7 @@
44#include "vis.h" 44#include "vis.h"
45#include "getrrsetbyname.h" 45#include "getrrsetbyname.h"
46#include "sha2.h" 46#include "sha2.h"
47#include "blf.h"
47 48
48#ifndef HAVE_BASENAME 49#ifndef HAVE_BASENAME
49char *basename(const char *path); 50char *basename(const char *path);
@@ -161,9 +162,13 @@ int writev(int, struct iovec *, int);
161 162
162#ifndef HAVE_GETPEEREID 163#ifndef HAVE_GETPEEREID
163int getpeereid(int , uid_t *, gid_t *); 164int getpeereid(int , uid_t *, gid_t *);
164#endif 165#endif
165 166
166#ifndef HAVE_ARC4RANDOM 167#ifdef HAVE_ARC4RANDOM
168# ifndef HAVE_ARC4RANDOM_STIR
169# define arc4random_stir()
170# endif
171#else
167unsigned int arc4random(void); 172unsigned int arc4random(void);
168void arc4random_stir(void); 173void arc4random_stir(void);
169#endif /* !HAVE_ARC4RANDOM */ 174#endif /* !HAVE_ARC4RANDOM */
@@ -236,6 +241,11 @@ char *group_from_gid(gid_t, int);
236int timingsafe_bcmp(const void *, const void *, size_t); 241int timingsafe_bcmp(const void *, const void *, size_t);
237#endif 242#endif
238 243
244#ifndef HAVE_BCRYPT_PBKDF
245int bcrypt_pbkdf(const char *, size_t, const u_int8_t *, size_t,
246 u_int8_t *, size_t, unsigned int);
247#endif
248
239void *xmmap(size_t size); 249void *xmmap(size_t size);
240char *xcrypt(const char *password, const char *salt); 250char *xcrypt(const char *password, const char *salt);
241char *shadow_pw(struct passwd *pw); 251char *shadow_pw(struct passwd *pw);
diff --git a/openbsd-compat/openssl-compat.c b/openbsd-compat/openssl-compat.c
index 5189cab61..60eac4b17 100644
--- a/openbsd-compat/openssl-compat.c
+++ b/openbsd-compat/openssl-compat.c
@@ -1,4 +1,4 @@
1/* $Id: openssl-compat.c,v 1.14 2011/05/10 01:13:38 dtucker Exp $ */ 1/* $Id: openssl-compat.c,v 1.16 2014/01/17 07:00:41 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>
@@ -59,6 +59,34 @@ ssh_EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *evp)
59} 59}
60#endif 60#endif
61 61
62#ifndef HAVE_EVP_DIGESTINIT_EX
63int
64EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *md, void *engine)
65{
66 if (engine != NULL)
67 fatal("%s: ENGINE is not supported", __func__);
68# ifdef OPENSSL_EVP_DIGESTUPDATE_VOID
69 EVP_DigestInit(ctx, md);
70 return 1;
71# else
72 return EVP_DigestInit(ctx, md);
73# endif
74}
75#endif
76
77#ifndef HAVE_EVP_DIGESTFINAL_EX
78int
79EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s)
80{
81# ifdef OPENSSL_EVP_DIGESTUPDATE_VOID
82 EVP_DigestFinal(ctx, md, s);
83 return 1;
84# else
85 return EVP_DigestFinal(ctx, md, s);
86# endif
87}
88#endif
89
62#ifdef OPENSSL_EVP_DIGESTUPDATE_VOID 90#ifdef OPENSSL_EVP_DIGESTUPDATE_VOID
63int 91int
64ssh_EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt) 92ssh_EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt)
diff --git a/openbsd-compat/openssl-compat.h b/openbsd-compat/openssl-compat.h
index e7439b4e7..021ea98f5 100644
--- a/openbsd-compat/openssl-compat.h
+++ b/openbsd-compat/openssl-compat.h
@@ -1,4 +1,4 @@
1/* $Id: openssl-compat.h,v 1.24 2013/02/12 00:00:40 djm Exp $ */ 1/* $Id: openssl-compat.h,v 1.25 2014/01/17 06:32:31 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>
@@ -148,6 +148,14 @@ int DSA_generate_parameters_ex(DSA *, int, const unsigned char *, int, int *,
148int RSA_generate_key_ex(RSA *, int, BIGNUM *, void *); 148int RSA_generate_key_ex(RSA *, int, BIGNUM *, void *);
149# endif 149# endif
150 150
151# ifndef HAVE_EVP_DIGESTINIT_EX
152int EVP_DigestInit_ex(EVP_MD_CTX *, const EVP_MD *, void *);
153# endif
154
155# ifndef HAVE_EVP_DISESTFINAL_EX
156int EVP_DigestFinal_ex(EVP_MD_CTX *, unsigned char *, unsigned int *);
157# endif
158
151int ssh_EVP_CipherInit(EVP_CIPHER_CTX *, const EVP_CIPHER *, unsigned char *, 159int ssh_EVP_CipherInit(EVP_CIPHER_CTX *, const EVP_CIPHER *, unsigned char *,
152 unsigned char *, int); 160 unsigned char *, int);
153int ssh_EVP_Cipher(EVP_CIPHER_CTX *, char *, char *, int); 161int ssh_EVP_Cipher(EVP_CIPHER_CTX *, char *, char *, int);
@@ -158,5 +166,13 @@ void ssh_OpenSSL_add_all_algorithms(void);
158# define HMAC_CTX_init(a) 166# define HMAC_CTX_init(a)
159# endif 167# endif
160 168
169# ifndef HAVE_EVP_MD_CTX_INIT
170# define EVP_MD_CTX_init(a)
171# endif
172
173# ifndef HAVE_EVP_MD_CTX_CLEANUP
174# define EVP_MD_CTX_cleanup(a)
175# endif
176
161#endif /* SSH_DONT_OVERLOAD_OPENSSL_FUNCS */ 177#endif /* SSH_DONT_OVERLOAD_OPENSSL_FUNCS */
162 178
diff --git a/openbsd-compat/setproctitle.c b/openbsd-compat/setproctitle.c
index 2965f689e..9f7ca14c2 100644
--- a/openbsd-compat/setproctitle.c
+++ b/openbsd-compat/setproctitle.c
@@ -67,7 +67,8 @@ static size_t argv_env_len = 0;
67void 67void
68compat_init_setproctitle(int argc, char *argv[]) 68compat_init_setproctitle(int argc, char *argv[])
69{ 69{
70#if defined(SPT_TYPE) && SPT_TYPE == SPT_REUSEARGV 70#if !defined(HAVE_SETPROCTITLE) && \
71 defined(SPT_TYPE) && SPT_TYPE == SPT_REUSEARGV
71 extern char **environ; 72 extern char **environ;
72 char *lastargv = NULL; 73 char *lastargv = NULL;
73 char **envp = environ; 74 char **envp = environ;
@@ -125,6 +126,7 @@ setproctitle(const char *fmt, ...)
125 va_list ap; 126 va_list ap;
126 char buf[1024], ptitle[1024]; 127 char buf[1024], ptitle[1024];
127 size_t len; 128 size_t len;
129 int r;
128 extern char *__progname; 130 extern char *__progname;
129#if SPT_TYPE == SPT_PSTAT 131#if SPT_TYPE == SPT_PSTAT
130 union pstun pst; 132 union pstun pst;
@@ -137,13 +139,16 @@ setproctitle(const char *fmt, ...)
137 139
138 strlcpy(buf, __progname, sizeof(buf)); 140 strlcpy(buf, __progname, sizeof(buf));
139 141
142 r = -1;
140 va_start(ap, fmt); 143 va_start(ap, fmt);
141 if (fmt != NULL) { 144 if (fmt != NULL) {
142 len = strlcat(buf, ": ", sizeof(buf)); 145 len = strlcat(buf, ": ", sizeof(buf));
143 if (len < sizeof(buf)) 146 if (len < sizeof(buf))
144 vsnprintf(buf + len, sizeof(buf) - len , fmt, ap); 147 r = vsnprintf(buf + len, sizeof(buf) - len , fmt, ap);
145 } 148 }
146 va_end(ap); 149 va_end(ap);
150 if (r == -1 || (size_t)r >= sizeof(buf) - len)
151 return;
147 strnvis(ptitle, buf, sizeof(ptitle), 152 strnvis(ptitle, buf, sizeof(ptitle),
148 VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL); 153 VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL);
149 154
diff --git a/packet.c b/packet.c
index 90db33bdd..6cf7edbb8 100644
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: packet.c,v 1.189 2013/11/08 00:39:15 djm Exp $ */ 1/* $OpenBSD: packet.c,v 1.191 2013/12/06 13:34:54 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
@@ -713,9 +713,10 @@ packet_send1(void)
713 buffer_append(&active_state->output, buf, 4); 713 buffer_append(&active_state->output, buf, 4);
714 cp = buffer_append_space(&active_state->output, 714 cp = buffer_append_space(&active_state->output,
715 buffer_len(&active_state->outgoing_packet)); 715 buffer_len(&active_state->outgoing_packet));
716 cipher_crypt(&active_state->send_context, cp, 716 if (cipher_crypt(&active_state->send_context, 0, cp,
717 buffer_ptr(&active_state->outgoing_packet), 717 buffer_ptr(&active_state->outgoing_packet),
718 buffer_len(&active_state->outgoing_packet), 0, 0); 718 buffer_len(&active_state->outgoing_packet), 0, 0) != 0)
719 fatal("%s: cipher_crypt failed", __func__);
719 720
720#ifdef PACKET_DEBUG 721#ifdef PACKET_DEBUG
721 fprintf(stderr, "encrypted: "); 722 fprintf(stderr, "encrypted: ");
@@ -946,9 +947,10 @@ packet_send2_wrapped(void)
946 } 947 }
947 /* encrypt packet and append to output buffer. */ 948 /* encrypt packet and append to output buffer. */
948 cp = buffer_append_space(&active_state->output, len + authlen); 949 cp = buffer_append_space(&active_state->output, len + authlen);
949 cipher_crypt(&active_state->send_context, cp, 950 if (cipher_crypt(&active_state->send_context, active_state->p_send.seqnr,
950 buffer_ptr(&active_state->outgoing_packet), 951 cp, buffer_ptr(&active_state->outgoing_packet),
951 len - aadlen, aadlen, authlen); 952 len - aadlen, aadlen, authlen) != 0)
953 fatal("%s: cipher_crypt failed", __func__);
952 /* append unencrypted MAC */ 954 /* append unencrypted MAC */
953 if (mac && mac->enabled) { 955 if (mac && mac->enabled) {
954 if (mac->etm) { 956 if (mac->etm) {
@@ -1208,8 +1210,9 @@ packet_read_poll1(void)
1208 /* Decrypt data to incoming_packet. */ 1210 /* Decrypt data to incoming_packet. */
1209 buffer_clear(&active_state->incoming_packet); 1211 buffer_clear(&active_state->incoming_packet);
1210 cp = buffer_append_space(&active_state->incoming_packet, padded_len); 1212 cp = buffer_append_space(&active_state->incoming_packet, padded_len);
1211 cipher_crypt(&active_state->receive_context, cp, 1213 if (cipher_crypt(&active_state->receive_context, 0, cp,
1212 buffer_ptr(&active_state->input), padded_len, 0, 0); 1214 buffer_ptr(&active_state->input), padded_len, 0, 0) != 0)
1215 fatal("%s: cipher_crypt failed", __func__);
1213 1216
1214 buffer_consume(&active_state->input, padded_len); 1217 buffer_consume(&active_state->input, padded_len);
1215 1218
@@ -1279,10 +1282,12 @@ packet_read_poll2(u_int32_t *seqnr_p)
1279 aadlen = (mac && mac->enabled && mac->etm) || authlen ? 4 : 0; 1282 aadlen = (mac && mac->enabled && mac->etm) || authlen ? 4 : 0;
1280 1283
1281 if (aadlen && active_state->packlen == 0) { 1284 if (aadlen && active_state->packlen == 0) {
1282 if (buffer_len(&active_state->input) < 4) 1285 if (cipher_get_length(&active_state->receive_context,
1286 &active_state->packlen,
1287 active_state->p_read.seqnr,
1288 buffer_ptr(&active_state->input),
1289 buffer_len(&active_state->input)) != 0)
1283 return SSH_MSG_NONE; 1290 return SSH_MSG_NONE;
1284 cp = buffer_ptr(&active_state->input);
1285 active_state->packlen = get_u32(cp);
1286 if (active_state->packlen < 1 + 4 || 1291 if (active_state->packlen < 1 + 4 ||
1287 active_state->packlen > PACKET_MAX_SIZE) { 1292 active_state->packlen > PACKET_MAX_SIZE) {
1288#ifdef PACKET_DEBUG 1293#ifdef PACKET_DEBUG
@@ -1302,8 +1307,10 @@ packet_read_poll2(u_int32_t *seqnr_p)
1302 buffer_clear(&active_state->incoming_packet); 1307 buffer_clear(&active_state->incoming_packet);
1303 cp = buffer_append_space(&active_state->incoming_packet, 1308 cp = buffer_append_space(&active_state->incoming_packet,
1304 block_size); 1309 block_size);
1305 cipher_crypt(&active_state->receive_context, cp, 1310 if (cipher_crypt(&active_state->receive_context,
1306 buffer_ptr(&active_state->input), block_size, 0, 0); 1311 active_state->p_read.seqnr, cp,
1312 buffer_ptr(&active_state->input), block_size, 0, 0) != 0)
1313 fatal("Decryption integrity check failed");
1307 cp = buffer_ptr(&active_state->incoming_packet); 1314 cp = buffer_ptr(&active_state->incoming_packet);
1308 active_state->packlen = get_u32(cp); 1315 active_state->packlen = get_u32(cp);
1309 if (active_state->packlen < 1 + 4 || 1316 if (active_state->packlen < 1 + 4 ||
@@ -1357,8 +1364,10 @@ packet_read_poll2(u_int32_t *seqnr_p)
1357 macbuf = mac_compute(mac, active_state->p_read.seqnr, 1364 macbuf = mac_compute(mac, active_state->p_read.seqnr,
1358 buffer_ptr(&active_state->input), aadlen + need); 1365 buffer_ptr(&active_state->input), aadlen + need);
1359 cp = buffer_append_space(&active_state->incoming_packet, aadlen + need); 1366 cp = buffer_append_space(&active_state->incoming_packet, aadlen + need);
1360 cipher_crypt(&active_state->receive_context, cp, 1367 if (cipher_crypt(&active_state->receive_context,
1361 buffer_ptr(&active_state->input), need, aadlen, authlen); 1368 active_state->p_read.seqnr, cp,
1369 buffer_ptr(&active_state->input), need, aadlen, authlen) != 0)
1370 fatal("Decryption integrity check failed");
1362 buffer_consume(&active_state->input, aadlen + need + authlen); 1371 buffer_consume(&active_state->input, aadlen + need + authlen);
1363 /* 1372 /*
1364 * compute MAC over seqnr and packet, 1373 * compute MAC over seqnr and packet,
diff --git a/pathnames.h b/pathnames.h
index 5027fbaed..ec89fc666 100644
--- a/pathnames.h
+++ b/pathnames.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: pathnames.h,v 1.23 2013/04/05 00:31:49 djm Exp $ */ 1/* $OpenBSD: pathnames.h,v 1.24 2013/12/06 13:39:49 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -39,6 +39,7 @@
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_ECDSA_KEY_FILE SSHDIR "/ssh_host_ecdsa_key"
42#define _PATH_HOST_ED25519_KEY_FILE SSHDIR "/ssh_host_ed25519_key"
42#define _PATH_HOST_RSA_KEY_FILE SSHDIR "/ssh_host_rsa_key" 43#define _PATH_HOST_RSA_KEY_FILE SSHDIR "/ssh_host_rsa_key"
43#define _PATH_DH_MODULI SSHDIR "/moduli" 44#define _PATH_DH_MODULI SSHDIR "/moduli"
44/* Backwards compatibility */ 45/* Backwards compatibility */
@@ -77,6 +78,7 @@
77#define _PATH_SSH_CLIENT_ID_DSA _PATH_SSH_USER_DIR "/id_dsa" 78#define _PATH_SSH_CLIENT_ID_DSA _PATH_SSH_USER_DIR "/id_dsa"
78#define _PATH_SSH_CLIENT_ID_ECDSA _PATH_SSH_USER_DIR "/id_ecdsa" 79#define _PATH_SSH_CLIENT_ID_ECDSA _PATH_SSH_USER_DIR "/id_ecdsa"
79#define _PATH_SSH_CLIENT_ID_RSA _PATH_SSH_USER_DIR "/id_rsa" 80#define _PATH_SSH_CLIENT_ID_RSA _PATH_SSH_USER_DIR "/id_rsa"
81#define _PATH_SSH_CLIENT_ID_ED25519 _PATH_SSH_USER_DIR "/id_ed25519"
80 82
81/* 83/*
82 * Configuration file in user's home directory. This file need not be 84 * Configuration file in user's home directory. This file need not be
diff --git a/pkcs11.h b/pkcs11.h
index 2cde5b3f4..b01d58f94 100644
--- a/pkcs11.h
+++ b/pkcs11.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: pkcs11.h,v 1.2 2010/02/24 06:12:53 djm Exp $ */ 1/* $OpenBSD: pkcs11.h,v 1.3 2013/11/26 19:15:09 deraadt Exp $ */
2/* pkcs11.h 2/* pkcs11.h
3 Copyright 2006, 2007 g10 Code GmbH 3 Copyright 2006, 2007 g10 Code GmbH
4 Copyright 2006 Andreas Jellinghaus 4 Copyright 2006 Andreas Jellinghaus
@@ -319,7 +319,7 @@ typedef unsigned long ck_object_class_t;
319#define CKO_HW_FEATURE (5) 319#define CKO_HW_FEATURE (5)
320#define CKO_DOMAIN_PARAMETERS (6) 320#define CKO_DOMAIN_PARAMETERS (6)
321#define CKO_MECHANISM (7) 321#define CKO_MECHANISM (7)
322#define CKO_VENDOR_DEFINED ((unsigned long) (1 << 31)) 322#define CKO_VENDOR_DEFINED (1U << 31)
323 323
324 324
325typedef unsigned long ck_hw_feature_type_t; 325typedef unsigned long ck_hw_feature_type_t;
@@ -327,7 +327,7 @@ typedef unsigned long ck_hw_feature_type_t;
327#define CKH_MONOTONIC_COUNTER (1) 327#define CKH_MONOTONIC_COUNTER (1)
328#define CKH_CLOCK (2) 328#define CKH_CLOCK (2)
329#define CKH_USER_INTERFACE (3) 329#define CKH_USER_INTERFACE (3)
330#define CKH_VENDOR_DEFINED ((unsigned long) (1 << 31)) 330#define CKH_VENDOR_DEFINED (1U << 31)
331 331
332 332
333typedef unsigned long ck_key_type_t; 333typedef unsigned long ck_key_type_t;
@@ -357,14 +357,14 @@ typedef unsigned long ck_key_type_t;
357#define CKK_AES (0x1f) 357#define CKK_AES (0x1f)
358#define CKK_BLOWFISH (0x20) 358#define CKK_BLOWFISH (0x20)
359#define CKK_TWOFISH (0x21) 359#define CKK_TWOFISH (0x21)
360#define CKK_VENDOR_DEFINED ((unsigned long) (1 << 31)) 360#define CKK_VENDOR_DEFINED (1U << 31)
361 361
362typedef unsigned long ck_certificate_type_t; 362typedef unsigned long ck_certificate_type_t;
363 363
364#define CKC_X_509 (0) 364#define CKC_X_509 (0)
365#define CKC_X_509_ATTR_CERT (1) 365#define CKC_X_509_ATTR_CERT (1)
366#define CKC_WTLS (2) 366#define CKC_WTLS (2)
367#define CKC_VENDOR_DEFINED ((unsigned long) (1 << 31)) 367#define CKC_VENDOR_DEFINED (1U << 31)
368 368
369 369
370typedef unsigned long ck_attribute_type_t; 370typedef unsigned long ck_attribute_type_t;
@@ -453,7 +453,7 @@ typedef unsigned long ck_attribute_type_t;
453#define CKA_WRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x211) 453#define CKA_WRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x211)
454#define CKA_UNWRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x212) 454#define CKA_UNWRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE | 0x212)
455#define CKA_ALLOWED_MECHANISMS (CKF_ARRAY_ATTRIBUTE | 0x600) 455#define CKA_ALLOWED_MECHANISMS (CKF_ARRAY_ATTRIBUTE | 0x600)
456#define CKA_VENDOR_DEFINED ((unsigned long) (1 << 31)) 456#define CKA_VENDOR_DEFINED (1U << 31)
457 457
458 458
459struct ck_attribute 459struct ck_attribute
@@ -672,7 +672,7 @@ typedef unsigned long ck_mechanism_type_t;
672#define CKM_DSA_PARAMETER_GEN (0x2000) 672#define CKM_DSA_PARAMETER_GEN (0x2000)
673#define CKM_DH_PKCS_PARAMETER_GEN (0x2001) 673#define CKM_DH_PKCS_PARAMETER_GEN (0x2001)
674#define CKM_X9_42_DH_PARAMETER_GEN (0x2002) 674#define CKM_X9_42_DH_PARAMETER_GEN (0x2002)
675#define CKM_VENDOR_DEFINED ((unsigned long) (1 << 31)) 675#define CKM_VENDOR_DEFINED (1U << 31)
676 676
677 677
678struct ck_mechanism 678struct ck_mechanism
@@ -703,7 +703,7 @@ struct ck_mechanism_info
703#define CKF_WRAP (1 << 17) 703#define CKF_WRAP (1 << 17)
704#define CKF_UNWRAP (1 << 18) 704#define CKF_UNWRAP (1 << 18)
705#define CKF_DERIVE (1 << 19) 705#define CKF_DERIVE (1 << 19)
706#define CKF_EXTENSION ((unsigned long) (1 << 31)) 706#define CKF_EXTENSION (1U << 31)
707 707
708 708
709/* Flags for C_WaitForSlotEvent. */ 709/* Flags for C_WaitForSlotEvent. */
@@ -1179,7 +1179,7 @@ struct ck_c_initialize_args
1179#define CKR_MUTEX_BAD (0x1a0) 1179#define CKR_MUTEX_BAD (0x1a0)
1180#define CKR_MUTEX_NOT_LOCKED (0x1a1) 1180#define CKR_MUTEX_NOT_LOCKED (0x1a1)
1181#define CKR_FUNCTION_REJECTED (0x200) 1181#define CKR_FUNCTION_REJECTED (0x200)
1182#define CKR_VENDOR_DEFINED ((unsigned long) (1 << 31)) 1182#define CKR_VENDOR_DEFINED (1U << 31)
1183 1183
1184 1184
1185 1185
diff --git a/platform.c b/platform.c
index 3262b2478..30fc60909 100644
--- a/platform.c
+++ b/platform.c
@@ -1,4 +1,4 @@
1/* $Id: platform.c,v 1.19 2013/03/12 00:31:05 dtucker Exp $ */ 1/* $Id: platform.c,v 1.21 2014/01/21 01:59:29 tim Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006 Darren Tucker. All rights reserved. 4 * Copyright (c) 2006 Darren Tucker. All rights reserved.
@@ -55,6 +55,14 @@ platform_pre_fork(void)
55} 55}
56 56
57void 57void
58platform_pre_restart(void)
59{
60#ifdef LINUX_OOM_ADJUST
61 oom_adjust_restore();
62#endif
63}
64
65void
58platform_post_fork_parent(pid_t child_pid) 66platform_post_fork_parent(pid_t child_pid)
59{ 67{
60#ifdef USE_SOLARIS_PROCESS_CONTRACTS 68#ifdef USE_SOLARIS_PROCESS_CONTRACTS
@@ -156,12 +164,6 @@ platform_setusercontext_post_groups(struct passwd *pw)
156 aix_usrinfo(pw); 164 aix_usrinfo(pw);
157#endif /* _AIX */ 165#endif /* _AIX */
158 166
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 167#ifdef HAVE_SETPCRED
166 /* 168 /*
167 * If we have a chroot directory, we set all creds except real 169 * If we have a chroot directory, we set all creds except real
diff --git a/platform.h b/platform.h
index 19f6bfdd3..1c7a45d8f 100644
--- a/platform.h
+++ b/platform.h
@@ -1,4 +1,4 @@
1/* $Id: platform.h,v 1.8 2013/03/12 00:31:05 dtucker Exp $ */ 1/* $Id: platform.h,v 1.9 2013/09/22 09:02:40 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006 Darren Tucker. All rights reserved. 4 * Copyright (c) 2006 Darren Tucker. All rights reserved.
@@ -22,6 +22,7 @@
22 22
23void platform_pre_listen(void); 23void platform_pre_listen(void);
24void platform_pre_fork(void); 24void platform_pre_fork(void);
25void platform_pre_restart(void);
25void platform_post_fork_parent(pid_t child_pid); 26void platform_post_fork_parent(pid_t child_pid);
26void platform_post_fork_child(void); 27void platform_post_fork_child(void);
27int platform_privileged_uidswap(void); 28int platform_privileged_uidswap(void);
diff --git a/poly1305.c b/poly1305.c
new file mode 100644
index 000000000..6fd1fc8cd
--- /dev/null
+++ b/poly1305.c
@@ -0,0 +1,160 @@
1/*
2 * Public Domain poly1305 from Andrew Moon
3 * poly1305-donna-unrolled.c from https://github.com/floodyberry/poly1305-donna
4 */
5
6/* $OpenBSD: poly1305.c,v 1.3 2013/12/19 22:57:13 djm Exp $ */
7
8#include "includes.h"
9
10#include <sys/types.h>
11#ifdef HAVE_STDINT_H
12# include <stdint.h>
13#endif
14
15#include "poly1305.h"
16
17#define mul32x32_64(a,b) ((uint64_t)(a) * (b))
18
19#define U8TO32_LE(p) \
20 (((uint32_t)((p)[0])) | \
21 ((uint32_t)((p)[1]) << 8) | \
22 ((uint32_t)((p)[2]) << 16) | \
23 ((uint32_t)((p)[3]) << 24))
24
25#define U32TO8_LE(p, v) \
26 do { \
27 (p)[0] = (uint8_t)((v)); \
28 (p)[1] = (uint8_t)((v) >> 8); \
29 (p)[2] = (uint8_t)((v) >> 16); \
30 (p)[3] = (uint8_t)((v) >> 24); \
31 } while (0)
32
33void
34poly1305_auth(unsigned char out[POLY1305_TAGLEN], const unsigned char *m, size_t inlen, const unsigned char key[POLY1305_KEYLEN]) {
35 uint32_t t0,t1,t2,t3;
36 uint32_t h0,h1,h2,h3,h4;
37 uint32_t r0,r1,r2,r3,r4;
38 uint32_t s1,s2,s3,s4;
39 uint32_t b, nb;
40 size_t j;
41 uint64_t t[5];
42 uint64_t f0,f1,f2,f3;
43 uint32_t g0,g1,g2,g3,g4;
44 uint64_t c;
45 unsigned char mp[16];
46
47 /* clamp key */
48 t0 = U8TO32_LE(key+0);
49 t1 = U8TO32_LE(key+4);
50 t2 = U8TO32_LE(key+8);
51 t3 = U8TO32_LE(key+12);
52
53 /* precompute multipliers */
54 r0 = t0 & 0x3ffffff; t0 >>= 26; t0 |= t1 << 6;
55 r1 = t0 & 0x3ffff03; t1 >>= 20; t1 |= t2 << 12;
56 r2 = t1 & 0x3ffc0ff; t2 >>= 14; t2 |= t3 << 18;
57 r3 = t2 & 0x3f03fff; t3 >>= 8;
58 r4 = t3 & 0x00fffff;
59
60 s1 = r1 * 5;
61 s2 = r2 * 5;
62 s3 = r3 * 5;
63 s4 = r4 * 5;
64
65 /* init state */
66 h0 = 0;
67 h1 = 0;
68 h2 = 0;
69 h3 = 0;
70 h4 = 0;
71
72 /* full blocks */
73 if (inlen < 16) goto poly1305_donna_atmost15bytes;
74poly1305_donna_16bytes:
75 m += 16;
76 inlen -= 16;
77
78 t0 = U8TO32_LE(m-16);
79 t1 = U8TO32_LE(m-12);
80 t2 = U8TO32_LE(m-8);
81 t3 = U8TO32_LE(m-4);
82
83 h0 += t0 & 0x3ffffff;
84 h1 += ((((uint64_t)t1 << 32) | t0) >> 26) & 0x3ffffff;
85 h2 += ((((uint64_t)t2 << 32) | t1) >> 20) & 0x3ffffff;
86 h3 += ((((uint64_t)t3 << 32) | t2) >> 14) & 0x3ffffff;
87 h4 += (t3 >> 8) | (1 << 24);
88
89
90poly1305_donna_mul:
91 t[0] = mul32x32_64(h0,r0) + mul32x32_64(h1,s4) + mul32x32_64(h2,s3) + mul32x32_64(h3,s2) + mul32x32_64(h4,s1);
92 t[1] = mul32x32_64(h0,r1) + mul32x32_64(h1,r0) + mul32x32_64(h2,s4) + mul32x32_64(h3,s3) + mul32x32_64(h4,s2);
93 t[2] = mul32x32_64(h0,r2) + mul32x32_64(h1,r1) + mul32x32_64(h2,r0) + mul32x32_64(h3,s4) + mul32x32_64(h4,s3);
94 t[3] = mul32x32_64(h0,r3) + mul32x32_64(h1,r2) + mul32x32_64(h2,r1) + mul32x32_64(h3,r0) + mul32x32_64(h4,s4);
95 t[4] = mul32x32_64(h0,r4) + mul32x32_64(h1,r3) + mul32x32_64(h2,r2) + mul32x32_64(h3,r1) + mul32x32_64(h4,r0);
96
97 h0 = (uint32_t)t[0] & 0x3ffffff; c = (t[0] >> 26);
98 t[1] += c; h1 = (uint32_t)t[1] & 0x3ffffff; b = (uint32_t)(t[1] >> 26);
99 t[2] += b; h2 = (uint32_t)t[2] & 0x3ffffff; b = (uint32_t)(t[2] >> 26);
100 t[3] += b; h3 = (uint32_t)t[3] & 0x3ffffff; b = (uint32_t)(t[3] >> 26);
101 t[4] += b; h4 = (uint32_t)t[4] & 0x3ffffff; b = (uint32_t)(t[4] >> 26);
102 h0 += b * 5;
103
104 if (inlen >= 16) goto poly1305_donna_16bytes;
105
106 /* final bytes */
107poly1305_donna_atmost15bytes:
108 if (!inlen) goto poly1305_donna_finish;
109
110 for (j = 0; j < inlen; j++) mp[j] = m[j];
111 mp[j++] = 1;
112 for (; j < 16; j++) mp[j] = 0;
113 inlen = 0;
114
115 t0 = U8TO32_LE(mp+0);
116 t1 = U8TO32_LE(mp+4);
117 t2 = U8TO32_LE(mp+8);
118 t3 = U8TO32_LE(mp+12);
119
120 h0 += t0 & 0x3ffffff;
121 h1 += ((((uint64_t)t1 << 32) | t0) >> 26) & 0x3ffffff;
122 h2 += ((((uint64_t)t2 << 32) | t1) >> 20) & 0x3ffffff;
123 h3 += ((((uint64_t)t3 << 32) | t2) >> 14) & 0x3ffffff;
124 h4 += (t3 >> 8);
125
126 goto poly1305_donna_mul;
127
128poly1305_donna_finish:
129 b = h0 >> 26; h0 = h0 & 0x3ffffff;
130 h1 += b; b = h1 >> 26; h1 = h1 & 0x3ffffff;
131 h2 += b; b = h2 >> 26; h2 = h2 & 0x3ffffff;
132 h3 += b; b = h3 >> 26; h3 = h3 & 0x3ffffff;
133 h4 += b; b = h4 >> 26; h4 = h4 & 0x3ffffff;
134 h0 += b * 5; b = h0 >> 26; h0 = h0 & 0x3ffffff;
135 h1 += b;
136
137 g0 = h0 + 5; b = g0 >> 26; g0 &= 0x3ffffff;
138 g1 = h1 + b; b = g1 >> 26; g1 &= 0x3ffffff;
139 g2 = h2 + b; b = g2 >> 26; g2 &= 0x3ffffff;
140 g3 = h3 + b; b = g3 >> 26; g3 &= 0x3ffffff;
141 g4 = h4 + b - (1 << 26);
142
143 b = (g4 >> 31) - 1;
144 nb = ~b;
145 h0 = (h0 & nb) | (g0 & b);
146 h1 = (h1 & nb) | (g1 & b);
147 h2 = (h2 & nb) | (g2 & b);
148 h3 = (h3 & nb) | (g3 & b);
149 h4 = (h4 & nb) | (g4 & b);
150
151 f0 = ((h0 ) | (h1 << 26)) + (uint64_t)U8TO32_LE(&key[16]);
152 f1 = ((h1 >> 6) | (h2 << 20)) + (uint64_t)U8TO32_LE(&key[20]);
153 f2 = ((h2 >> 12) | (h3 << 14)) + (uint64_t)U8TO32_LE(&key[24]);
154 f3 = ((h3 >> 18) | (h4 << 8)) + (uint64_t)U8TO32_LE(&key[28]);
155
156 U32TO8_LE(&out[ 0], f0); f1 += (f0 >> 32);
157 U32TO8_LE(&out[ 4], f1); f2 += (f1 >> 32);
158 U32TO8_LE(&out[ 8], f2); f3 += (f2 >> 32);
159 U32TO8_LE(&out[12], f3);
160}
diff --git a/poly1305.h b/poly1305.h
new file mode 100644
index 000000000..221efc462
--- /dev/null
+++ b/poly1305.h
@@ -0,0 +1,22 @@
1/* $OpenBSD: poly1305.h,v 1.2 2013/12/19 22:57:13 djm Exp $ */
2
3/*
4 * Public Domain poly1305 from Andrew Moon
5 * poly1305-donna-unrolled.c from https://github.com/floodyberry/poly1305-donna
6 */
7
8#ifndef POLY1305_H
9#define POLY1305_H
10
11#include <sys/types.h>
12
13#define POLY1305_KEYLEN 32
14#define POLY1305_TAGLEN 16
15
16void poly1305_auth(u_char out[POLY1305_TAGLEN], const u_char *m, size_t inlen,
17 const u_char key[POLY1305_KEYLEN])
18 __attribute__((__bounded__(__minbytes__, 1, POLY1305_TAGLEN)))
19 __attribute__((__bounded__(__buffer__, 2, 3)))
20 __attribute__((__bounded__(__minbytes__, 4, POLY1305_KEYLEN)));
21
22#endif /* POLY1305_H */
diff --git a/progressmeter.c b/progressmeter.c
index 332bd3c99..bbbc7066b 100644
--- a/progressmeter.c
+++ b/progressmeter.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: progressmeter.c,v 1.39 2013/06/02 13:33:05 dtucker Exp $ */ 1/* $OpenBSD: progressmeter.c,v 1.40 2013/09/19 00:24:52 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2003 Nils Nordman. All rights reserved. 3 * Copyright (c) 2003 Nils Nordman. All rights reserved.
4 * 4 *
@@ -66,6 +66,7 @@ static void update_progress_meter(int);
66static time_t start; /* start progress */ 66static time_t start; /* start progress */
67static time_t last_update; /* last progress update */ 67static time_t last_update; /* last progress update */
68static char *file; /* name of the file being transferred */ 68static char *file; /* name of the file being transferred */
69static off_t start_pos; /* initial position of transfer */
69static off_t end_pos; /* ending position of transfer */ 70static off_t end_pos; /* ending position of transfer */
70static off_t cur_pos; /* transfer position as of last refresh */ 71static off_t cur_pos; /* transfer position as of last refresh */
71static volatile off_t *counter; /* progress counter */ 72static volatile off_t *counter; /* progress counter */
@@ -129,7 +130,7 @@ refresh_progress_meter(void)
129 int i, len; 130 int i, len;
130 int file_len; 131 int file_len;
131 132
132 transferred = *counter - cur_pos; 133 transferred = *counter - (cur_pos ? cur_pos : start_pos);
133 cur_pos = *counter; 134 cur_pos = *counter;
134 now = monotime(); 135 now = monotime();
135 bytes_left = end_pos - cur_pos; 136 bytes_left = end_pos - cur_pos;
@@ -139,7 +140,7 @@ refresh_progress_meter(void)
139 else { 140 else {
140 elapsed = now - start; 141 elapsed = now - start;
141 /* Calculate true total speed when done */ 142 /* Calculate true total speed when done */
142 transferred = end_pos; 143 transferred = end_pos - start_pos;
143 bytes_per_second = 0; 144 bytes_per_second = 0;
144 } 145 }
145 146
@@ -251,6 +252,7 @@ start_progress_meter(char *f, off_t filesize, off_t *ctr)
251{ 252{
252 start = last_update = monotime(); 253 start = last_update = monotime();
253 file = f; 254 file = f;
255 start_pos = *ctr;
254 end_pos = filesize; 256 end_pos = filesize;
255 cur_pos = 0; 257 cur_pos = 0;
256 counter = ctr; 258 counter = ctr;
diff --git a/readconf.c b/readconf.c
index 1464430a4..9c7e73d7d 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.204 2013/06/10 19:19:44 dtucker Exp $ */ 1/* $OpenBSD: readconf.c,v 1.215 2013/12/06 13:39:49 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
@@ -17,6 +17,7 @@
17#include <sys/types.h> 17#include <sys/types.h>
18#include <sys/stat.h> 18#include <sys/stat.h>
19#include <sys/socket.h> 19#include <sys/socket.h>
20#include <sys/wait.h>
20 21
21#include <netinet/in.h> 22#include <netinet/in.h>
22#include <netinet/in_systm.h> 23#include <netinet/in_systm.h>
@@ -24,7 +25,12 @@
24 25
25#include <ctype.h> 26#include <ctype.h>
26#include <errno.h> 27#include <errno.h>
28#include <fcntl.h>
27#include <netdb.h> 29#include <netdb.h>
30#ifdef HAVE_PATHS_H
31# include <paths.h>
32#endif
33#include <pwd.h>
28#include <signal.h> 34#include <signal.h>
29#include <stdarg.h> 35#include <stdarg.h>
30#include <stdio.h> 36#include <stdio.h>
@@ -47,6 +53,7 @@
47#include "buffer.h" 53#include "buffer.h"
48#include "kex.h" 54#include "kex.h"
49#include "mac.h" 55#include "mac.h"
56#include "uidswap.h"
50 57
51/* Format of the configuration file: 58/* Format of the configuration file:
52 59
@@ -115,12 +122,13 @@
115 122
116typedef enum { 123typedef enum {
117 oBadOption, 124 oBadOption,
125 oHost, oMatch,
118 oForwardAgent, oForwardX11, oForwardX11Trusted, oForwardX11Timeout, 126 oForwardAgent, oForwardX11, oForwardX11Trusted, oForwardX11Timeout,
119 oGatewayPorts, oExitOnForwardFailure, 127 oGatewayPorts, oExitOnForwardFailure,
120 oPasswordAuthentication, oRSAAuthentication, 128 oPasswordAuthentication, oRSAAuthentication,
121 oChallengeResponseAuthentication, oXAuthLocation, 129 oChallengeResponseAuthentication, oXAuthLocation,
122 oIdentityFile, oHostName, oPort, oCipher, oRemoteForward, oLocalForward, 130 oIdentityFile, oHostName, oPort, oCipher, oRemoteForward, oLocalForward,
123 oUser, oHost, oEscapeChar, oRhostsRSAAuthentication, oProxyCommand, 131 oUser, oEscapeChar, oRhostsRSAAuthentication, oProxyCommand,
124 oGlobalKnownHostsFile, oUserKnownHostsFile, oConnectionAttempts, 132 oGlobalKnownHostsFile, oUserKnownHostsFile, oConnectionAttempts,
125 oBatchMode, oCheckHostIP, oStrictHostKeyChecking, oCompression, 133 oBatchMode, oCheckHostIP, oStrictHostKeyChecking, oCompression,
126 oCompressionLevel, oTCPKeepAlive, oNumberOfPasswordPrompts, 134 oCompressionLevel, oTCPKeepAlive, oNumberOfPasswordPrompts,
@@ -137,7 +145,9 @@ typedef enum {
137 oHashKnownHosts, 145 oHashKnownHosts,
138 oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand, 146 oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand,
139 oVisualHostKey, oUseRoaming, oZeroKnowledgePasswordAuthentication, 147 oVisualHostKey, oUseRoaming, oZeroKnowledgePasswordAuthentication,
140 oKexAlgorithms, oIPQoS, oRequestTTY, oIgnoreUnknown, 148 oKexAlgorithms, oIPQoS, oRequestTTY, oIgnoreUnknown, oProxyUseFdpass,
149 oCanonicalDomains, oCanonicalizeHostname, oCanonicalizeMaxDots,
150 oCanonicalizeFallbackLocal, oCanonicalizePermittedCNAMEs,
141 oIgnoredUnknownOption, oDeprecated, oUnsupported 151 oIgnoredUnknownOption, oDeprecated, oUnsupported
142} OpCodes; 152} OpCodes;
143 153
@@ -194,6 +204,7 @@ static struct {
194 { "localforward", oLocalForward }, 204 { "localforward", oLocalForward },
195 { "user", oUser }, 205 { "user", oUser },
196 { "host", oHost }, 206 { "host", oHost },
207 { "match", oMatch },
197 { "escapechar", oEscapeChar }, 208 { "escapechar", oEscapeChar },
198 { "globalknownhostsfile", oGlobalKnownHostsFile }, 209 { "globalknownhostsfile", oGlobalKnownHostsFile },
199 { "globalknownhostsfile2", oDeprecated }, 210 { "globalknownhostsfile2", oDeprecated },
@@ -249,6 +260,12 @@ static struct {
249 { "kexalgorithms", oKexAlgorithms }, 260 { "kexalgorithms", oKexAlgorithms },
250 { "ipqos", oIPQoS }, 261 { "ipqos", oIPQoS },
251 { "requesttty", oRequestTTY }, 262 { "requesttty", oRequestTTY },
263 { "proxyusefdpass", oProxyUseFdpass },
264 { "canonicaldomains", oCanonicalDomains },
265 { "canonicalizefallbacklocal", oCanonicalizeFallbackLocal },
266 { "canonicalizehostname", oCanonicalizeHostname },
267 { "canonicalizemaxdots", oCanonicalizeMaxDots },
268 { "canonicalizepermittedcnames", oCanonicalizePermittedCNAMEs },
252 { "ignoreunknown", oIgnoreUnknown }, 269 { "ignoreunknown", oIgnoreUnknown },
253 270
254 { NULL, oBadOption } 271 { NULL, oBadOption }
@@ -348,10 +365,243 @@ add_identity_file(Options *options, const char *dir, const char *filename,
348 options->identity_files[options->num_identity_files++] = path; 365 options->identity_files[options->num_identity_files++] = path;
349} 366}
350 367
368int
369default_ssh_port(void)
370{
371 static int port;
372 struct servent *sp;
373
374 if (port == 0) {
375 sp = getservbyname(SSH_SERVICE_NAME, "tcp");
376 port = sp ? ntohs(sp->s_port) : SSH_DEFAULT_PORT;
377 }
378 return port;
379}
380
351/* 381/*
352 * Returns the number of the token pointed to by cp or oBadOption. 382 * Execute a command in a shell.
383 * Return its exit status or -1 on abnormal exit.
353 */ 384 */
385static int
386execute_in_shell(const char *cmd)
387{
388 char *shell, *command_string;
389 pid_t pid;
390 int devnull, status;
391 extern uid_t original_real_uid;
392
393 if ((shell = getenv("SHELL")) == NULL)
394 shell = _PATH_BSHELL;
395
396 /*
397 * Use "exec" to avoid "sh -c" processes on some platforms
398 * (e.g. Solaris)
399 */
400 xasprintf(&command_string, "exec %s", cmd);
401
402 /* Need this to redirect subprocess stdin/out */
403 if ((devnull = open(_PATH_DEVNULL, O_RDWR)) == -1)
404 fatal("open(/dev/null): %s", strerror(errno));
405
406 debug("Executing command: '%.500s'", cmd);
407
408 /* Fork and execute the command. */
409 if ((pid = fork()) == 0) {
410 char *argv[4];
411
412 /* Child. Permanently give up superuser privileges. */
413 permanently_drop_suid(original_real_uid);
414
415 /* Redirect child stdin and stdout. Leave stderr */
416 if (dup2(devnull, STDIN_FILENO) == -1)
417 fatal("dup2: %s", strerror(errno));
418 if (dup2(devnull, STDOUT_FILENO) == -1)
419 fatal("dup2: %s", strerror(errno));
420 if (devnull > STDERR_FILENO)
421 close(devnull);
422 closefrom(STDERR_FILENO + 1);
423
424 argv[0] = shell;
425 argv[1] = "-c";
426 argv[2] = command_string;
427 argv[3] = NULL;
428
429 execv(argv[0], argv);
430 error("Unable to execute '%.100s': %s", cmd, strerror(errno));
431 /* Die with signal to make this error apparent to parent. */
432 signal(SIGTERM, SIG_DFL);
433 kill(getpid(), SIGTERM);
434 _exit(1);
435 }
436 /* Parent. */
437 if (pid < 0)
438 fatal("%s: fork: %.100s", __func__, strerror(errno));
354 439
440 close(devnull);
441 free(command_string);
442
443 while (waitpid(pid, &status, 0) == -1) {
444 if (errno != EINTR && errno != EAGAIN)
445 fatal("%s: waitpid: %s", __func__, strerror(errno));
446 }
447 if (!WIFEXITED(status)) {
448 error("command '%.100s' exited abnormally", cmd);
449 return -1;
450 }
451 debug3("command returned status %d", WEXITSTATUS(status));
452 return WEXITSTATUS(status);
453}
454
455/*
456 * Parse and execute a Match directive.
457 */
458static int
459match_cfg_line(Options *options, char **condition, struct passwd *pw,
460 const char *host_arg, const char *filename, int linenum)
461{
462 char *arg, *attrib, *cmd, *cp = *condition, *host;
463 const char *ruser;
464 int r, port, result = 1, attributes = 0;
465 size_t len;
466 char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV];
467
468 /*
469 * Configuration is likely to be incomplete at this point so we
470 * must be prepared to use default values.
471 */
472 port = options->port <= 0 ? default_ssh_port() : options->port;
473 ruser = options->user == NULL ? pw->pw_name : options->user;
474 if (options->hostname != NULL) {
475 /* NB. Please keep in sync with ssh.c:main() */
476 host = percent_expand(options->hostname,
477 "h", host_arg, (char *)NULL);
478 } else
479 host = xstrdup(host_arg);
480
481 debug3("checking match for '%s' host %s", cp, host);
482 while ((attrib = strdelim(&cp)) && *attrib != '\0') {
483 attributes++;
484 if (strcasecmp(attrib, "all") == 0) {
485 if (attributes != 1 ||
486 ((arg = strdelim(&cp)) != NULL && *arg != '\0')) {
487 error("'all' cannot be combined with other "
488 "Match attributes");
489 result = -1;
490 goto out;
491 }
492 *condition = cp;
493 result = 1;
494 goto out;
495 }
496 if ((arg = strdelim(&cp)) == NULL || *arg == '\0') {
497 error("Missing Match criteria for %s", attrib);
498 result = -1;
499 goto out;
500 }
501 len = strlen(arg);
502 if (strcasecmp(attrib, "host") == 0) {
503 if (match_hostname(host, arg, len) != 1)
504 result = 0;
505 else
506 debug("%.200s line %d: matched 'Host %.100s' ",
507 filename, linenum, host);
508 } else if (strcasecmp(attrib, "originalhost") == 0) {
509 if (match_hostname(host_arg, arg, len) != 1)
510 result = 0;
511 else
512 debug("%.200s line %d: matched "
513 "'OriginalHost %.100s' ",
514 filename, linenum, host_arg);
515 } else if (strcasecmp(attrib, "user") == 0) {
516 if (match_pattern_list(ruser, arg, len, 0) != 1)
517 result = 0;
518 else
519 debug("%.200s line %d: matched 'User %.100s' ",
520 filename, linenum, ruser);
521 } else if (strcasecmp(attrib, "localuser") == 0) {
522 if (match_pattern_list(pw->pw_name, arg, len, 0) != 1)
523 result = 0;
524 else
525 debug("%.200s line %d: matched "
526 "'LocalUser %.100s' ",
527 filename, linenum, pw->pw_name);
528 } else if (strcasecmp(attrib, "exec") == 0) {
529 if (gethostname(thishost, sizeof(thishost)) == -1)
530 fatal("gethostname: %s", strerror(errno));
531 strlcpy(shorthost, thishost, sizeof(shorthost));
532 shorthost[strcspn(thishost, ".")] = '\0';
533 snprintf(portstr, sizeof(portstr), "%d", port);
534
535 cmd = percent_expand(arg,
536 "L", shorthost,
537 "d", pw->pw_dir,
538 "h", host,
539 "l", thishost,
540 "n", host_arg,
541 "p", portstr,
542 "r", ruser,
543 "u", pw->pw_name,
544 (char *)NULL);
545 r = execute_in_shell(cmd);
546 if (r == -1) {
547 fatal("%.200s line %d: match exec '%.100s' "
548 "error", filename, linenum, cmd);
549 } else if (r == 0) {
550 debug("%.200s line %d: matched "
551 "'exec \"%.100s\"' ",
552 filename, linenum, cmd);
553 } else
554 result = 0;
555 free(cmd);
556 } else {
557 error("Unsupported Match attribute %s", attrib);
558 result = -1;
559 goto out;
560 }
561 }
562 if (attributes == 0) {
563 error("One or more attributes required for Match");
564 result = -1;
565 goto out;
566 }
567 debug3("match %sfound", result ? "" : "not ");
568 *condition = cp;
569 out:
570 free(host);
571 return result;
572}
573
574/* Check and prepare a domain name: removes trailing '.' and lowercases */
575static void
576valid_domain(char *name, const char *filename, int linenum)
577{
578 size_t i, l = strlen(name);
579 u_char c, last = '\0';
580
581 if (l == 0)
582 fatal("%s line %d: empty hostname suffix", filename, linenum);
583 if (!isalpha((u_char)name[0]) && !isdigit((u_char)name[0]))
584 fatal("%s line %d: hostname suffix \"%.100s\" "
585 "starts with invalid character", filename, linenum, name);
586 for (i = 0; i < l; i++) {
587 c = tolower((u_char)name[i]);
588 name[i] = (char)c;
589 if (last == '.' && c == '.')
590 fatal("%s line %d: hostname suffix \"%.100s\" contains "
591 "consecutive separators", filename, linenum, name);
592 if (c != '.' && c != '-' && !isalnum(c) &&
593 c != '_') /* technically invalid, but common */
594 fatal("%s line %d: hostname suffix \"%.100s\" contains "
595 "invalid characters", filename, linenum, name);
596 last = c;
597 }
598 if (name[l - 1] == '.')
599 name[l - 1] = '\0';
600}
601
602/*
603 * Returns the number of the token pointed to by cp or oBadOption.
604 */
355static OpCodes 605static OpCodes
356parse_token(const char *cp, const char *filename, int linenum, 606parse_token(const char *cp, const char *filename, int linenum,
357 const char *ignored_unknown) 607 const char *ignored_unknown)
@@ -369,25 +619,93 @@ parse_token(const char *cp, const char *filename, int linenum,
369 return oBadOption; 619 return oBadOption;
370} 620}
371 621
622/* Multistate option parsing */
623struct multistate {
624 char *key;
625 int value;
626};
627static const struct multistate multistate_flag[] = {
628 { "true", 1 },
629 { "false", 0 },
630 { "yes", 1 },
631 { "no", 0 },
632 { NULL, -1 }
633};
634static const struct multistate multistate_yesnoask[] = {
635 { "true", 1 },
636 { "false", 0 },
637 { "yes", 1 },
638 { "no", 0 },
639 { "ask", 2 },
640 { NULL, -1 }
641};
642static const struct multistate multistate_addressfamily[] = {
643 { "inet", AF_INET },
644 { "inet6", AF_INET6 },
645 { "any", AF_UNSPEC },
646 { NULL, -1 }
647};
648static const struct multistate multistate_controlmaster[] = {
649 { "true", SSHCTL_MASTER_YES },
650 { "yes", SSHCTL_MASTER_YES },
651 { "false", SSHCTL_MASTER_NO },
652 { "no", SSHCTL_MASTER_NO },
653 { "auto", SSHCTL_MASTER_AUTO },
654 { "ask", SSHCTL_MASTER_ASK },
655 { "autoask", SSHCTL_MASTER_AUTO_ASK },
656 { NULL, -1 }
657};
658static const struct multistate multistate_tunnel[] = {
659 { "ethernet", SSH_TUNMODE_ETHERNET },
660 { "point-to-point", SSH_TUNMODE_POINTOPOINT },
661 { "true", SSH_TUNMODE_DEFAULT },
662 { "yes", SSH_TUNMODE_DEFAULT },
663 { "false", SSH_TUNMODE_NO },
664 { "no", SSH_TUNMODE_NO },
665 { NULL, -1 }
666};
667static const struct multistate multistate_requesttty[] = {
668 { "true", REQUEST_TTY_YES },
669 { "yes", REQUEST_TTY_YES },
670 { "false", REQUEST_TTY_NO },
671 { "no", REQUEST_TTY_NO },
672 { "force", REQUEST_TTY_FORCE },
673 { "auto", REQUEST_TTY_AUTO },
674 { NULL, -1 }
675};
676static const struct multistate multistate_canonicalizehostname[] = {
677 { "true", SSH_CANONICALISE_YES },
678 { "false", SSH_CANONICALISE_NO },
679 { "yes", SSH_CANONICALISE_YES },
680 { "no", SSH_CANONICALISE_NO },
681 { "always", SSH_CANONICALISE_ALWAYS },
682 { NULL, -1 }
683};
684
372/* 685/*
373 * Processes a single option line as used in the configuration files. This 686 * Processes a single option line as used in the configuration files. This
374 * only sets those values that have not already been set. 687 * only sets those values that have not already been set.
375 */ 688 */
376#define WHITESPACE " \t\r\n" 689#define WHITESPACE " \t\r\n"
377
378int 690int
379process_config_line(Options *options, const char *host, 691process_config_line(Options *options, struct passwd *pw, const char *host,
380 char *line, const char *filename, int linenum, 692 char *line, const char *filename, int linenum, int *activep, int userconfig)
381 int *activep, int userconfig)
382{ 693{
383 char *s, **charptr, *endofnumber, *keyword, *arg, *arg2; 694 char *s, **charptr, *endofnumber, *keyword, *arg, *arg2;
384 char **cpptr, fwdarg[256]; 695 char **cpptr, fwdarg[256];
385 u_int i, *uintptr, max_entries = 0; 696 u_int i, *uintptr, max_entries = 0;
386 int negated, opcode, *intptr, value, value2; 697 int negated, opcode, *intptr, value, value2, cmdline = 0;
387 LogLevel *log_level_ptr; 698 LogLevel *log_level_ptr;
388 long long val64; 699 long long val64;
389 size_t len; 700 size_t len;
390 Forward fwd; 701 Forward fwd;
702 const struct multistate *multistate_ptr;
703 struct allowed_cname *cname;
704
705 if (activep == NULL) { /* We are processing a command line directive */
706 cmdline = 1;
707 activep = &cmdline;
708 }
391 709
392 /* Strip trailing whitespace */ 710 /* Strip trailing whitespace */
393 for (len = strlen(line) - 1; len > 0; len--) { 711 for (len = strlen(line) - 1; len > 0; len--) {
@@ -406,8 +724,7 @@ process_config_line(Options *options, const char *host,
406 if (keyword == NULL || !*keyword || *keyword == '\n' || *keyword == '#') 724 if (keyword == NULL || !*keyword || *keyword == '\n' || *keyword == '#')
407 return 0; 725 return 0;
408 /* Match lowercase keyword */ 726 /* Match lowercase keyword */
409 for (i = 0; i < strlen(keyword); i++) 727 lowercase(keyword);
410 keyword[i] = tolower(keyword[i]);
411 728
412 opcode = parse_token(keyword, filename, linenum, 729 opcode = parse_token(keyword, filename, linenum,
413 options->ignored_unknown); 730 options->ignored_unknown);
@@ -437,17 +754,23 @@ parse_time:
437 754
438 case oForwardAgent: 755 case oForwardAgent:
439 intptr = &options->forward_agent; 756 intptr = &options->forward_agent;
440parse_flag: 757 parse_flag:
758 multistate_ptr = multistate_flag;
759 parse_multistate:
441 arg = strdelim(&s); 760 arg = strdelim(&s);
442 if (!arg || *arg == '\0') 761 if (!arg || *arg == '\0')
443 fatal("%.200s line %d: Missing yes/no argument.", filename, linenum); 762 fatal("%s line %d: missing argument.",
444 value = 0; /* To avoid compiler warning... */ 763 filename, linenum);
445 if (strcmp(arg, "yes") == 0 || strcmp(arg, "true") == 0) 764 value = -1;
446 value = 1; 765 for (i = 0; multistate_ptr[i].key != NULL; i++) {
447 else if (strcmp(arg, "no") == 0 || strcmp(arg, "false") == 0) 766 if (strcasecmp(arg, multistate_ptr[i].key) == 0) {
448 value = 0; 767 value = multistate_ptr[i].value;
449 else 768 break;
450 fatal("%.200s line %d: Bad yes/no argument.", filename, linenum); 769 }
770 }
771 if (value == -1)
772 fatal("%s line %d: unsupported option \"%s\".",
773 filename, linenum, arg);
451 if (*activep && *intptr == -1) 774 if (*activep && *intptr == -1)
452 *intptr = value; 775 *intptr = value;
453 break; 776 break;
@@ -530,27 +853,13 @@ parse_flag:
530 853
531 case oVerifyHostKeyDNS: 854 case oVerifyHostKeyDNS:
532 intptr = &options->verify_host_key_dns; 855 intptr = &options->verify_host_key_dns;
533 goto parse_yesnoask; 856 multistate_ptr = multistate_yesnoask;
857 goto parse_multistate;
534 858
535 case oStrictHostKeyChecking: 859 case oStrictHostKeyChecking:
536 intptr = &options->strict_host_key_checking; 860 intptr = &options->strict_host_key_checking;
537parse_yesnoask: 861 multistate_ptr = multistate_yesnoask;
538 arg = strdelim(&s); 862 goto parse_multistate;
539 if (!arg || *arg == '\0')
540 fatal("%.200s line %d: Missing yes/no/ask argument.",
541 filename, linenum);
542 value = 0; /* To avoid compiler warning... */
543 if (strcmp(arg, "yes") == 0 || strcmp(arg, "true") == 0)
544 value = 1;
545 else if (strcmp(arg, "no") == 0 || strcmp(arg, "false") == 0)
546 value = 0;
547 else if (strcmp(arg, "ask") == 0)
548 value = 2;
549 else
550 fatal("%.200s line %d: Bad yes/no/ask argument.", filename, linenum);
551 if (*activep && *intptr == -1)
552 *intptr = value;
553 break;
554 863
555 case oCompression: 864 case oCompression:
556 intptr = &options->compression; 865 intptr = &options->compression;
@@ -827,6 +1136,9 @@ parse_int:
827 goto parse_flag; 1136 goto parse_flag;
828 1137
829 case oHost: 1138 case oHost:
1139 if (cmdline)
1140 fatal("Host directive not supported as a command-line "
1141 "option");
830 *activep = 0; 1142 *activep = 0;
831 arg2 = NULL; 1143 arg2 = NULL;
832 while ((arg = strdelim(&s)) != NULL && *arg != '\0') { 1144 while ((arg = strdelim(&s)) != NULL && *arg != '\0') {
@@ -853,6 +1165,18 @@ parse_int:
853 /* Avoid garbage check below, as strdelim is done. */ 1165 /* Avoid garbage check below, as strdelim is done. */
854 return 0; 1166 return 0;
855 1167
1168 case oMatch:
1169 if (cmdline)
1170 fatal("Host directive not supported as a command-line "
1171 "option");
1172 value = match_cfg_line(options, &s, pw, host,
1173 filename, linenum);
1174 if (value < 0)
1175 fatal("%.200s line %d: Bad Match condition", filename,
1176 linenum);
1177 *activep = value;
1178 break;
1179
856 case oEscapeChar: 1180 case oEscapeChar:
857 intptr = &options->escape_char; 1181 intptr = &options->escape_char;
858 arg = strdelim(&s); 1182 arg = strdelim(&s);
@@ -876,22 +1200,9 @@ parse_int:
876 break; 1200 break;
877 1201
878 case oAddressFamily: 1202 case oAddressFamily:
879 arg = strdelim(&s);
880 if (!arg || *arg == '\0')
881 fatal("%s line %d: missing address family.",
882 filename, linenum);
883 intptr = &options->address_family; 1203 intptr = &options->address_family;
884 if (strcasecmp(arg, "inet") == 0) 1204 multistate_ptr = multistate_addressfamily;
885 value = AF_INET; 1205 goto parse_multistate;
886 else if (strcasecmp(arg, "inet6") == 0)
887 value = AF_INET6;
888 else if (strcasecmp(arg, "any") == 0)
889 value = AF_UNSPEC;
890 else
891 fatal("Unsupported AddressFamily \"%s\"", arg);
892 if (*activep && *intptr == -1)
893 *intptr = value;
894 break;
895 1206
896 case oEnableSSHKeysign: 1207 case oEnableSSHKeysign:
897 intptr = &options->enable_ssh_keysign; 1208 intptr = &options->enable_ssh_keysign;
@@ -930,27 +1241,8 @@ parse_int:
930 1241
931 case oControlMaster: 1242 case oControlMaster:
932 intptr = &options->control_master; 1243 intptr = &options->control_master;
933 arg = strdelim(&s); 1244 multistate_ptr = multistate_controlmaster;
934 if (!arg || *arg == '\0') 1245 goto parse_multistate;
935 fatal("%.200s line %d: Missing ControlMaster argument.",
936 filename, linenum);
937 value = 0; /* To avoid compiler warning... */
938 if (strcmp(arg, "yes") == 0 || strcmp(arg, "true") == 0)
939 value = SSHCTL_MASTER_YES;
940 else if (strcmp(arg, "no") == 0 || strcmp(arg, "false") == 0)
941 value = SSHCTL_MASTER_NO;
942 else if (strcmp(arg, "auto") == 0)
943 value = SSHCTL_MASTER_AUTO;
944 else if (strcmp(arg, "ask") == 0)
945 value = SSHCTL_MASTER_ASK;
946 else if (strcmp(arg, "autoask") == 0)
947 value = SSHCTL_MASTER_AUTO_ASK;
948 else
949 fatal("%.200s line %d: Bad ControlMaster argument.",
950 filename, linenum);
951 if (*activep && *intptr == -1)
952 *intptr = value;
953 break;
954 1246
955 case oControlPersist: 1247 case oControlPersist:
956 /* no/false/yes/true, or a time spec */ 1248 /* no/false/yes/true, or a time spec */
@@ -982,25 +1274,8 @@ parse_int:
982 1274
983 case oTunnel: 1275 case oTunnel:
984 intptr = &options->tun_open; 1276 intptr = &options->tun_open;
985 arg = strdelim(&s); 1277 multistate_ptr = multistate_tunnel;
986 if (!arg || *arg == '\0') 1278 goto parse_multistate;
987 fatal("%s line %d: Missing yes/point-to-point/"
988 "ethernet/no argument.", filename, linenum);
989 value = 0; /* silence compiler */
990 if (strcasecmp(arg, "ethernet") == 0)
991 value = SSH_TUNMODE_ETHERNET;
992 else if (strcasecmp(arg, "point-to-point") == 0)
993 value = SSH_TUNMODE_POINTOPOINT;
994 else if (strcasecmp(arg, "yes") == 0)
995 value = SSH_TUNMODE_DEFAULT;
996 else if (strcasecmp(arg, "no") == 0)
997 value = SSH_TUNMODE_NO;
998 else
999 fatal("%s line %d: Bad yes/point-to-point/ethernet/"
1000 "no argument: %s", filename, linenum, arg);
1001 if (*activep)
1002 *intptr = value;
1003 break;
1004 1279
1005 case oTunnelDevice: 1280 case oTunnelDevice:
1006 arg = strdelim(&s); 1281 arg = strdelim(&s);
@@ -1049,29 +1324,74 @@ parse_int:
1049 goto parse_flag; 1324 goto parse_flag;
1050 1325
1051 case oRequestTTY: 1326 case oRequestTTY:
1052 arg = strdelim(&s);
1053 if (!arg || *arg == '\0')
1054 fatal("%s line %d: missing argument.",
1055 filename, linenum);
1056 intptr = &options->request_tty; 1327 intptr = &options->request_tty;
1057 if (strcasecmp(arg, "yes") == 0) 1328 multistate_ptr = multistate_requesttty;
1058 value = REQUEST_TTY_YES; 1329 goto parse_multistate;
1059 else if (strcasecmp(arg, "no") == 0)
1060 value = REQUEST_TTY_NO;
1061 else if (strcasecmp(arg, "force") == 0)
1062 value = REQUEST_TTY_FORCE;
1063 else if (strcasecmp(arg, "auto") == 0)
1064 value = REQUEST_TTY_AUTO;
1065 else
1066 fatal("Unsupported RequestTTY \"%s\"", arg);
1067 if (*activep && *intptr == -1)
1068 *intptr = value;
1069 break;
1070 1330
1071 case oIgnoreUnknown: 1331 case oIgnoreUnknown:
1072 charptr = &options->ignored_unknown; 1332 charptr = &options->ignored_unknown;
1073 goto parse_string; 1333 goto parse_string;
1074 1334
1335 case oProxyUseFdpass:
1336 intptr = &options->proxy_use_fdpass;
1337 goto parse_flag;
1338
1339 case oCanonicalDomains:
1340 value = options->num_canonical_domains != 0;
1341 while ((arg = strdelim(&s)) != NULL && *arg != '\0') {
1342 valid_domain(arg, filename, linenum);
1343 if (!*activep || value)
1344 continue;
1345 if (options->num_canonical_domains >= MAX_CANON_DOMAINS)
1346 fatal("%s line %d: too many hostname suffixes.",
1347 filename, linenum);
1348 options->canonical_domains[
1349 options->num_canonical_domains++] = xstrdup(arg);
1350 }
1351 break;
1352
1353 case oCanonicalizePermittedCNAMEs:
1354 value = options->num_permitted_cnames != 0;
1355 while ((arg = strdelim(&s)) != NULL && *arg != '\0') {
1356 /* Either '*' for everything or 'list:list' */
1357 if (strcmp(arg, "*") == 0)
1358 arg2 = arg;
1359 else {
1360 lowercase(arg);
1361 if ((arg2 = strchr(arg, ':')) == NULL ||
1362 arg2[1] == '\0') {
1363 fatal("%s line %d: "
1364 "Invalid permitted CNAME \"%s\"",
1365 filename, linenum, arg);
1366 }
1367 *arg2 = '\0';
1368 arg2++;
1369 }
1370 if (!*activep || value)
1371 continue;
1372 if (options->num_permitted_cnames >= MAX_CANON_DOMAINS)
1373 fatal("%s line %d: too many permitted CNAMEs.",
1374 filename, linenum);
1375 cname = options->permitted_cnames +
1376 options->num_permitted_cnames++;
1377 cname->source_list = xstrdup(arg);
1378 cname->target_list = xstrdup(arg2);
1379 }
1380 break;
1381
1382 case oCanonicalizeHostname:
1383 intptr = &options->canonicalize_hostname;
1384 multistate_ptr = multistate_canonicalizehostname;
1385 goto parse_multistate;
1386
1387 case oCanonicalizeMaxDots:
1388 intptr = &options->canonicalize_max_dots;
1389 goto parse_int;
1390
1391 case oCanonicalizeFallbackLocal:
1392 intptr = &options->canonicalize_fallback_local;
1393 goto parse_flag;
1394
1075 case oDeprecated: 1395 case oDeprecated:
1076 debug("%s line %d: Deprecated option \"%s\"", 1396 debug("%s line %d: Deprecated option \"%s\"",
1077 filename, linenum, keyword); 1397 filename, linenum, keyword);
@@ -1102,8 +1422,8 @@ parse_int:
1102 */ 1422 */
1103 1423
1104int 1424int
1105read_config_file(const char *filename, const char *host, Options *options, 1425read_config_file(const char *filename, struct passwd *pw, const char *host,
1106 int flags) 1426 Options *options, int flags)
1107{ 1427{
1108 FILE *f; 1428 FILE *f;
1109 char line[1024]; 1429 char line[1024];
@@ -1134,8 +1454,8 @@ read_config_file(const char *filename, const char *host, Options *options,
1134 while (fgets(line, sizeof(line), f)) { 1454 while (fgets(line, sizeof(line), f)) {
1135 /* Update line number counter. */ 1455 /* Update line number counter. */
1136 linenum++; 1456 linenum++;
1137 if (process_config_line(options, host, line, filename, linenum, 1457 if (process_config_line(options, pw, host, line, filename,
1138 &active, flags & SSHCONF_USERCONF) != 0) 1458 linenum, &active, flags & SSHCONF_USERCONF) != 0)
1139 bad_options++; 1459 bad_options++;
1140 } 1460 }
1141 fclose(f); 1461 fclose(f);
@@ -1233,7 +1553,13 @@ initialize_options(Options * options)
1233 options->ip_qos_interactive = -1; 1553 options->ip_qos_interactive = -1;
1234 options->ip_qos_bulk = -1; 1554 options->ip_qos_bulk = -1;
1235 options->request_tty = -1; 1555 options->request_tty = -1;
1556 options->proxy_use_fdpass = -1;
1236 options->ignored_unknown = NULL; 1557 options->ignored_unknown = NULL;
1558 options->num_canonical_domains = 0;
1559 options->num_permitted_cnames = 0;
1560 options->canonicalize_max_dots = -1;
1561 options->canonicalize_fallback_local = -1;
1562 options->canonicalize_hostname = -1;
1237} 1563}
1238 1564
1239/* 1565/*
@@ -1321,6 +1647,8 @@ fill_default_options(Options * options)
1321 add_identity_file(options, "~/", 1647 add_identity_file(options, "~/",
1322 _PATH_SSH_CLIENT_ID_ECDSA, 0); 1648 _PATH_SSH_CLIENT_ID_ECDSA, 0);
1323#endif 1649#endif
1650 add_identity_file(options, "~/",
1651 _PATH_SSH_CLIENT_ID_ED25519, 0);
1324 } 1652 }
1325 } 1653 }
1326 if (options->escape_char == -1) 1654 if (options->escape_char == -1)
@@ -1385,8 +1713,24 @@ fill_default_options(Options * options)
1385 options->ip_qos_bulk = IPTOS_THROUGHPUT; 1713 options->ip_qos_bulk = IPTOS_THROUGHPUT;
1386 if (options->request_tty == -1) 1714 if (options->request_tty == -1)
1387 options->request_tty = REQUEST_TTY_AUTO; 1715 options->request_tty = REQUEST_TTY_AUTO;
1388 /* options->local_command should not be set by default */ 1716 if (options->proxy_use_fdpass == -1)
1389 /* options->proxy_command should not be set by default */ 1717 options->proxy_use_fdpass = 0;
1718 if (options->canonicalize_max_dots == -1)
1719 options->canonicalize_max_dots = 1;
1720 if (options->canonicalize_fallback_local == -1)
1721 options->canonicalize_fallback_local = 1;
1722 if (options->canonicalize_hostname == -1)
1723 options->canonicalize_hostname = SSH_CANONICALISE_NO;
1724#define CLEAR_ON_NONE(v) \
1725 do { \
1726 if (v != NULL && strcasecmp(v, "none") == 0) { \
1727 free(v); \
1728 v = NULL; \
1729 } \
1730 } while(0)
1731 CLEAR_ON_NONE(options->local_command);
1732 CLEAR_ON_NONE(options->proxy_command);
1733 CLEAR_ON_NONE(options->control_path);
1390 /* options->user will be set in the main program if appropriate */ 1734 /* options->user will be set in the main program if appropriate */
1391 /* options->hostname will be set in the main program if appropriate */ 1735 /* options->hostname will be set in the main program if appropriate */
1392 /* options->host_key_alias should not be set by default */ 1736 /* options->host_key_alias should not be set by default */
@@ -1413,7 +1757,7 @@ parse_forward(Forward *fwd, const char *fwdspec, int dynamicfwd, int remotefwd)
1413 cp = p = xstrdup(fwdspec); 1757 cp = p = xstrdup(fwdspec);
1414 1758
1415 /* skip leading spaces */ 1759 /* skip leading spaces */
1416 while (isspace(*cp)) 1760 while (isspace((u_char)*cp))
1417 cp++; 1761 cp++;
1418 1762
1419 for (i = 0; i < 4; ++i) 1763 for (i = 0; i < 4; ++i)
diff --git a/readconf.h b/readconf.h
index 23fc500da..2d7ea9fc4 100644
--- a/readconf.h
+++ b/readconf.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.h,v 1.95 2013/05/16 04:27:50 djm Exp $ */ 1/* $OpenBSD: readconf.h,v 1.99 2013/10/16 22:49:38 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -29,7 +29,13 @@ typedef struct {
29/* Data structure for representing option data. */ 29/* Data structure for representing option data. */
30 30
31#define MAX_SEND_ENV 256 31#define MAX_SEND_ENV 256
32#define SSH_MAX_HOSTS_FILES 256 32#define SSH_MAX_HOSTS_FILES 32
33#define MAX_CANON_DOMAINS 32
34
35struct allowed_cname {
36 char *source_list;
37 char *target_list;
38};
33 39
34typedef struct { 40typedef struct {
35 int forward_agent; /* Forward authentication agent. */ 41 int forward_agent; /* Forward authentication agent. */
@@ -138,9 +144,23 @@ typedef struct {
138 144
139 int request_tty; 145 int request_tty;
140 146
147 int proxy_use_fdpass;
148
149 int num_canonical_domains;
150 char *canonical_domains[MAX_CANON_DOMAINS];
151 int canonicalize_hostname;
152 int canonicalize_max_dots;
153 int canonicalize_fallback_local;
154 int num_permitted_cnames;
155 struct allowed_cname permitted_cnames[MAX_CANON_DOMAINS];
156
141 char *ignored_unknown; /* Pattern list of unknown tokens to ignore */ 157 char *ignored_unknown; /* Pattern list of unknown tokens to ignore */
142} Options; 158} Options;
143 159
160#define SSH_CANONICALISE_NO 0
161#define SSH_CANONICALISE_YES 1
162#define SSH_CANONICALISE_ALWAYS 2
163
144#define SSHCTL_MASTER_NO 0 164#define SSHCTL_MASTER_NO 0
145#define SSHCTL_MASTER_YES 1 165#define SSHCTL_MASTER_YES 1
146#define SSHCTL_MASTER_AUTO 2 166#define SSHCTL_MASTER_AUTO 2
@@ -157,12 +177,12 @@ typedef struct {
157 177
158void initialize_options(Options *); 178void initialize_options(Options *);
159void fill_default_options(Options *); 179void fill_default_options(Options *);
160int read_config_file(const char *, const char *, Options *, int); 180int process_config_line(Options *, struct passwd *, const char *, char *,
181 const char *, int, int *, int);
182int read_config_file(const char *, struct passwd *, const char *,
183 Options *, int);
161int parse_forward(Forward *, const char *, int, int); 184int parse_forward(Forward *, const char *, int, int);
162 185int default_ssh_port(void);
163int
164process_config_line(Options *, const char *, char *, const char *, int, int *,
165 int);
166 186
167void add_local_forward(Options *, const Forward *); 187void add_local_forward(Options *, const Forward *);
168void add_remote_forward(Options *, const Forward *); 188void add_remote_forward(Options *, const Forward *);
diff --git a/regress/Makefile b/regress/Makefile
index ab2a6ae7b..0c66b1774 100644
--- a/regress/Makefile
+++ b/regress/Makefile
@@ -1,6 +1,6 @@
1# $OpenBSD: Makefile,v 1.65 2013/04/18 02:46:12 djm Exp $ 1# $OpenBSD: Makefile,v 1.67 2013/12/06 13:52:46 markus Exp $
2 2
3REGRESS_TARGETS= t1 t2 t3 t4 t5 t6 t7 t8 t9 t-exec 3REGRESS_TARGETS= t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 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
@@ -44,6 +44,7 @@ LTESTS= connect \
44 sftp-badcmds \ 44 sftp-badcmds \
45 sftp-batch \ 45 sftp-batch \
46 sftp-glob \ 46 sftp-glob \
47 sftp-perm \
47 reconfigure \ 48 reconfigure \
48 dynamic-forward \ 49 dynamic-forward \
49 forwarding \ 50 forwarding \
@@ -72,7 +73,7 @@ INTEROP_TESTS= putty-transfer putty-ciphers putty-kex conch-ciphers
72 73
73USER!= id -un 74USER!= id -un
74CLEANFILES= t2.out t3.out t6.out1 t6.out2 t7.out t7.out.pub copy.1 copy.2 \ 75CLEANFILES= t2.out t3.out t6.out1 t6.out2 t7.out t7.out.pub copy.1 copy.2 \
75 t8.out t8.out.pub t9.out t9.out.pub \ 76 t8.out t8.out.pub t9.out t9.out.pub t10.out t10.out.pub \
76 authorized_keys_${USER} known_hosts pidfile testdata \ 77 authorized_keys_${USER} known_hosts pidfile testdata \
77 ssh_config sshd_config.orig ssh_proxy sshd_config sshd_proxy \ 78 ssh_config sshd_config.orig ssh_proxy sshd_config sshd_proxy \
78 rsa.pub rsa rsa1.pub rsa1 host.rsa host.rsa1 \ 79 rsa.pub rsa rsa1.pub rsa1 host.rsa host.rsa1 \
@@ -86,7 +87,10 @@ CLEANFILES= t2.out t3.out t6.out1 t6.out2 t7.out t7.out.pub copy.1 copy.2 \
86 authorized_principals_${USER} expect actual ready \ 87 authorized_principals_${USER} expect actual ready \
87 sshd_proxy.* authorized_keys_${USER}.* modpipe revoked-* krl-* \ 88 sshd_proxy.* authorized_keys_${USER}.* modpipe revoked-* krl-* \
88 ssh.log failed-ssh.log sshd.log failed-sshd.log \ 89 ssh.log failed-ssh.log sshd.log failed-sshd.log \
89 regress.log failed-regress.log ssh-log-wrapper.sh 90 regress.log failed-regress.log ssh-log-wrapper.sh \
91 sftp-server.sh sftp-server.log sftp.log setuid-allowed \
92 data ed25519-agent ed25519-agent.pub key.ed25519-512 \
93 key.ed25519-512.pub
90 94
91SUDO_CLEAN+= /var/run/testdata_${USER} /var/run/keycommand_${USER} 95SUDO_CLEAN+= /var/run/testdata_${USER} /var/run/keycommand_${USER}
92 96
@@ -151,6 +155,14 @@ t9: $(OBJ)/t9.out
151 test "${TEST_SSH_ECC}" != yes || \ 155 test "${TEST_SSH_ECC}" != yes || \
152 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t9.out > /dev/null 156 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t9.out > /dev/null
153 157
158
159$(OBJ)/t10.out:
160 ${TEST_SSH_SSHKEYGEN} -q -t ed25519 -N '' -f $@
161
162t10: $(OBJ)/t10.out
163 ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t10.out > /dev/null
164 ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t10.out > /dev/null
165
154t-exec: ${LTESTS:=.sh} 166t-exec: ${LTESTS:=.sh}
155 @if [ "x$?" = "x" ]; then exit 0; fi; \ 167 @if [ "x$?" = "x" ]; then exit 0; fi; \
156 for TEST in ""$?; do \ 168 for TEST in ""$?; do \
diff --git a/regress/agent-ptrace.sh b/regress/agent-ptrace.sh
index 9f29464c5..ae150641f 100644
--- a/regress/agent-ptrace.sh
+++ b/regress/agent-ptrace.sh
@@ -19,6 +19,13 @@ else
19 exit 0 19 exit 0
20fi 20fi
21 21
22if $OBJ/setuid-allowed ${SSHAGENT} ; then
23 : ok
24else
25 echo "skipped (${SSHAGENT} is mounted on a no-setuid filesystem)"
26 exit 0
27fi
28
22if test -z "$SUDO" ; then 29if test -z "$SUDO" ; then
23 echo "skipped (SUDO not set)" 30 echo "skipped (SUDO not set)"
24 exit 0 31 exit 0
@@ -38,8 +45,9 @@ else
38 gdb ${SSHAGENT} ${SSH_AGENT_PID} > ${OBJ}/gdb.out 2>&1 << EOF 45 gdb ${SSHAGENT} ${SSH_AGENT_PID} > ${OBJ}/gdb.out 2>&1 << EOF
39 quit 46 quit
40EOF 47EOF
41 if [ $? -ne 0 ]; then 48 r=$?
42 fail "gdb failed: exit code $?" 49 if [ $r -ne 0 ]; then
50 fail "gdb failed: exit code $r"
43 fi 51 fi
44 egrep 'ptrace: Operation not permitted.|procfs:.*Permission denied.|ttrace.*Permission denied.|procfs:.*: Invalid argument.|Unable to access task ' >/dev/null ${OBJ}/gdb.out 52 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=$? 53 r=$?
diff --git a/regress/agent.sh b/regress/agent.sh
index be7d91334..cf1a45fe0 100644
--- a/regress/agent.sh
+++ b/regress/agent.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: agent.sh,v 1.8 2013/05/17 00:37:40 dtucker Exp $ 1# $OpenBSD: agent.sh,v 1.9 2013/12/06 13:52:46 markus Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="simple agent test" 4tid="simple agent test"
@@ -20,7 +20,7 @@ else
20 fi 20 fi
21 trace "overwrite authorized keys" 21 trace "overwrite authorized keys"
22 printf '' > $OBJ/authorized_keys_$USER 22 printf '' > $OBJ/authorized_keys_$USER
23 for t in rsa rsa1; do 23 for t in ed25519 rsa rsa1; do
24 # generate user key for agent 24 # generate user key for agent
25 rm -f $OBJ/$t-agent 25 rm -f $OBJ/$t-agent
26 ${SSHKEYGEN} -q -N '' -t $t -f $OBJ/$t-agent ||\ 26 ${SSHKEYGEN} -q -N '' -t $t -f $OBJ/$t-agent ||\
@@ -34,40 +34,46 @@ else
34 fi 34 fi
35 done 35 done
36 ${SSHADD} -l > /dev/null 2>&1 36 ${SSHADD} -l > /dev/null 2>&1
37 if [ $? -ne 0 ]; then 37 r=$?
38 fail "ssh-add -l failed: exit code $?" 38 if [ $r -ne 0 ]; then
39 fail "ssh-add -l failed: exit code $r"
39 fi 40 fi
40 # the same for full pubkey output 41 # the same for full pubkey output
41 ${SSHADD} -L > /dev/null 2>&1 42 ${SSHADD} -L > /dev/null 2>&1
42 if [ $? -ne 0 ]; then 43 r=$?
43 fail "ssh-add -L failed: exit code $?" 44 if [ $r -ne 0 ]; then
45 fail "ssh-add -L failed: exit code $r"
44 fi 46 fi
45 47
46 trace "simple connect via agent" 48 trace "simple connect via agent"
47 for p in 1 2; do 49 for p in 1 2; do
48 ${SSH} -$p -F $OBJ/ssh_proxy somehost exit 5$p 50 ${SSH} -$p -F $OBJ/ssh_proxy somehost exit 5$p
49 if [ $? -ne 5$p ]; then 51 r=$?
50 fail "ssh connect with protocol $p failed (exit code $?)" 52 if [ $r -ne 5$p ]; then
53 fail "ssh connect with protocol $p failed (exit code $r)"
51 fi 54 fi
52 done 55 done
53 56
54 trace "agent forwarding" 57 trace "agent forwarding"
55 for p in 1 2; do 58 for p in 1 2; do
56 ${SSH} -A -$p -F $OBJ/ssh_proxy somehost ${SSHADD} -l > /dev/null 2>&1 59 ${SSH} -A -$p -F $OBJ/ssh_proxy somehost ${SSHADD} -l > /dev/null 2>&1
57 if [ $? -ne 0 ]; then 60 r=$?
58 fail "ssh-add -l via agent fwd proto $p failed (exit code $?)" 61 if [ $r -ne 0 ]; then
62 fail "ssh-add -l via agent fwd proto $p failed (exit code $r)"
59 fi 63 fi
60 ${SSH} -A -$p -F $OBJ/ssh_proxy somehost \ 64 ${SSH} -A -$p -F $OBJ/ssh_proxy somehost \
61 "${SSH} -$p -F $OBJ/ssh_proxy somehost exit 5$p" 65 "${SSH} -$p -F $OBJ/ssh_proxy somehost exit 5$p"
62 if [ $? -ne 5$p ]; then 66 r=$?
63 fail "agent fwd proto $p failed (exit code $?)" 67 if [ $r -ne 5$p ]; then
68 fail "agent fwd proto $p failed (exit code $r)"
64 fi 69 fi
65 done 70 done
66 71
67 trace "delete all agent keys" 72 trace "delete all agent keys"
68 ${SSHADD} -D > /dev/null 2>&1 73 ${SSHADD} -D > /dev/null 2>&1
69 if [ $? -ne 0 ]; then 74 r=$?
70 fail "ssh-add -D failed: exit code $?" 75 if [ $r -ne 0 ]; then
76 fail "ssh-add -D failed: exit code $r"
71 fi 77 fi
72 78
73 trace "kill agent" 79 trace "kill agent"
diff --git a/regress/cert-hostkey.sh b/regress/cert-hostkey.sh
index 35cd39293..a1318cd53 100644
--- a/regress/cert-hostkey.sh
+++ b/regress/cert-hostkey.sh
@@ -1,14 +1,8 @@
1# $OpenBSD: cert-hostkey.sh,v 1.7 2013/05/17 00:37:40 dtucker Exp $ 1# $OpenBSD: cert-hostkey.sh,v 1.8 2013/12/06 13:52:46 markus 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
12rm -f $OBJ/known_hosts-cert $OBJ/host_ca_key* $OBJ/cert_host_key* 6rm -f $OBJ/known_hosts-cert $OBJ/host_ca_key* $OBJ/cert_host_key*
13cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak 7cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
14 8
@@ -23,8 +17,17 @@ ${SSHKEYGEN} -q -N '' -t rsa -f $OBJ/host_ca_key ||\
23 cat $OBJ/host_ca_key.pub 17 cat $OBJ/host_ca_key.pub
24) > $OBJ/known_hosts-cert 18) > $OBJ/known_hosts-cert
25 19
20PLAIN_TYPES=`$SSH -Q key-plain | sed 's/^ssh-dss/ssh-dsa/g;s/^ssh-//'`
21
22type_has_legacy() {
23 case $1 in
24 ed25519*|ecdsa*) return 1 ;;
25 esac
26 return 0
27}
28
26# Generate and sign host keys 29# Generate and sign host keys
27for ktype in rsa dsa $ecdsa ; do 30for ktype in $PLAIN_TYPES ; do
28 verbose "$tid: sign host ${ktype} cert" 31 verbose "$tid: sign host ${ktype} cert"
29 # Generate and sign a host key 32 # Generate and sign a host key
30 ${SSHKEYGEN} -q -N '' -t ${ktype} \ 33 ${SSHKEYGEN} -q -N '' -t ${ktype} \
@@ -34,10 +37,10 @@ for ktype in rsa dsa $ecdsa ; do
34 -I "regress host key for $USER" \ 37 -I "regress host key for $USER" \
35 -n $HOSTS $OBJ/cert_host_key_${ktype} || 38 -n $HOSTS $OBJ/cert_host_key_${ktype} ||
36 fail "couldn't sign cert_host_key_${ktype}" 39 fail "couldn't sign cert_host_key_${ktype}"
37 # v00 ecdsa certs do not exist 40 type_has_legacy $ktype || continue
38 test "${ktype}" = "ecdsa" && continue
39 cp $OBJ/cert_host_key_${ktype} $OBJ/cert_host_key_${ktype}_v00 41 cp $OBJ/cert_host_key_${ktype} $OBJ/cert_host_key_${ktype}_v00
40 cp $OBJ/cert_host_key_${ktype}.pub $OBJ/cert_host_key_${ktype}_v00.pub 42 cp $OBJ/cert_host_key_${ktype}.pub $OBJ/cert_host_key_${ktype}_v00.pub
43 verbose "$tid: sign host ${ktype}_v00 cert"
41 ${SSHKEYGEN} -t v00 -h -q -s $OBJ/host_ca_key \ 44 ${SSHKEYGEN} -t v00 -h -q -s $OBJ/host_ca_key \
42 -I "regress host key for $USER" \ 45 -I "regress host key for $USER" \
43 -n $HOSTS $OBJ/cert_host_key_${ktype}_v00 || 46 -n $HOSTS $OBJ/cert_host_key_${ktype}_v00 ||
@@ -46,7 +49,7 @@ done
46 49
47# Basic connect tests 50# Basic connect tests
48for privsep in yes no ; do 51for privsep in yes no ; do
49 for ktype in rsa dsa $ecdsa rsa_v00 dsa_v00; do 52 for ktype in $PLAIN_TYPES rsa_v00 dsa_v00; do
50 verbose "$tid: host ${ktype} cert connect privsep $privsep" 53 verbose "$tid: host ${ktype} cert connect privsep $privsep"
51 ( 54 (
52 cat $OBJ/sshd_proxy_bak 55 cat $OBJ/sshd_proxy_bak
@@ -69,26 +72,13 @@ done
69 printf '@cert-authority ' 72 printf '@cert-authority '
70 printf "$HOSTS " 73 printf "$HOSTS "
71 cat $OBJ/host_ca_key.pub 74 cat $OBJ/host_ca_key.pub
72 printf '@revoked ' 75 for ktype in $PLAIN_TYPES rsa_v00 dsa_v00; do
73 printf "* " 76 test -f "$OBJ/cert_host_key_${ktype}.pub" || fatal "no pubkey"
74 cat $OBJ/cert_host_key_rsa.pub 77 printf "@revoked * `cat $OBJ/cert_host_key_${ktype}.pub`\n"
75 if test "x$TEST_SSH_ECC" = "xyes"; then 78 done
76 printf '@revoked '
77 printf "* "
78 cat $OBJ/cert_host_key_ecdsa.pub
79 fi
80 printf '@revoked '
81 printf "* "
82 cat $OBJ/cert_host_key_dsa.pub
83 printf '@revoked '
84 printf "* "
85 cat $OBJ/cert_host_key_rsa_v00.pub
86 printf '@revoked '
87 printf "* "
88 cat $OBJ/cert_host_key_dsa_v00.pub
89) > $OBJ/known_hosts-cert 79) > $OBJ/known_hosts-cert
90for privsep in yes no ; do 80for privsep in yes no ; do
91 for ktype in rsa dsa $ecdsa rsa_v00 dsa_v00; do 81 for ktype in $PLAIN_TYPES rsa_v00 dsa_v00; do
92 verbose "$tid: host ${ktype} revoked cert privsep $privsep" 82 verbose "$tid: host ${ktype} revoked cert privsep $privsep"
93 ( 83 (
94 cat $OBJ/sshd_proxy_bak 84 cat $OBJ/sshd_proxy_bak
@@ -115,7 +105,7 @@ done
115 printf "* " 105 printf "* "
116 cat $OBJ/host_ca_key.pub 106 cat $OBJ/host_ca_key.pub
117) > $OBJ/known_hosts-cert 107) > $OBJ/known_hosts-cert
118for ktype in rsa dsa $ecdsa rsa_v00 dsa_v00 ; do 108for ktype in $PLAIN_TYPES rsa_v00 dsa_v00 ; do
119 verbose "$tid: host ${ktype} revoked cert" 109 verbose "$tid: host ${ktype} revoked cert"
120 ( 110 (
121 cat $OBJ/sshd_proxy_bak 111 cat $OBJ/sshd_proxy_bak
@@ -186,9 +176,8 @@ test_one "cert has constraints" failure "-h -Oforce-command=false"
186 176
187# Check downgrade of cert to raw key when no CA found 177# Check downgrade of cert to raw key when no CA found
188for v in v01 v00 ; do 178for v in v01 v00 ; do
189 for ktype in rsa dsa $ecdsa ; do 179 for ktype in $PLAIN_TYPES ; do
190 # v00 ecdsa certs do not exist. 180 type_has_legacy $ktype || continue
191 test "${v}${ktype}" = "v00ecdsa" && continue
192 rm -f $OBJ/known_hosts-cert $OBJ/cert_host_key* 181 rm -f $OBJ/known_hosts-cert $OBJ/cert_host_key*
193 verbose "$tid: host ${ktype} ${v} cert downgrade to raw key" 182 verbose "$tid: host ${ktype} ${v} cert downgrade to raw key"
194 # Generate and sign a host key 183 # Generate and sign a host key
@@ -225,9 +214,8 @@ done
225 cat $OBJ/host_ca_key.pub 214 cat $OBJ/host_ca_key.pub
226) > $OBJ/known_hosts-cert 215) > $OBJ/known_hosts-cert
227for v in v01 v00 ; do 216for v in v01 v00 ; do
228 for kt in rsa dsa $ecdsa ; do 217 for kt in $PLAIN_TYPES ; do
229 # v00 ecdsa certs do not exist. 218 type_has_legacy $kt || continue
230 test "${v}${ktype}" = "v00ecdsa" && continue
231 rm -f $OBJ/cert_host_key* 219 rm -f $OBJ/cert_host_key*
232 # Self-sign key 220 # Self-sign key
233 ${SSHKEYGEN} -q -N '' -t ${kt} \ 221 ${SSHKEYGEN} -q -N '' -t ${kt} \
diff --git a/regress/cert-userkey.sh b/regress/cert-userkey.sh
index 6018b38f4..b093a9196 100644
--- a/regress/cert-userkey.sh
+++ b/regress/cert-userkey.sh
@@ -1,23 +1,26 @@
1# $OpenBSD: cert-userkey.sh,v 1.11 2013/05/17 00:37:40 dtucker Exp $ 1# $OpenBSD: cert-userkey.sh,v 1.12 2013/12/06 13:52:46 markus 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
12rm -f $OBJ/authorized_keys_$USER $OBJ/user_ca_key* $OBJ/cert_user_key* 6rm -f $OBJ/authorized_keys_$USER $OBJ/user_ca_key* $OBJ/cert_user_key*
13cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak 7cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
14 8
9PLAIN_TYPES=`$SSH -Q key-plain | sed 's/^ssh-dss/ssh-dsa/;s/^ssh-//'`
10
11type_has_legacy() {
12 case $1 in
13 ed25519*|ecdsa*) return 1 ;;
14 esac
15 return 0
16}
17
15# Create a CA key 18# Create a CA key
16${SSHKEYGEN} -q -N '' -t rsa -f $OBJ/user_ca_key ||\ 19${SSHKEYGEN} -q -N '' -t rsa -f $OBJ/user_ca_key ||\
17 fail "ssh-keygen of user_ca_key failed" 20 fail "ssh-keygen of user_ca_key failed"
18 21
19# Generate and sign user keys 22# Generate and sign user keys
20for ktype in rsa dsa $ecdsa ; do 23for ktype in $PLAIN_TYPES ; do
21 verbose "$tid: sign user ${ktype} cert" 24 verbose "$tid: sign user ${ktype} cert"
22 ${SSHKEYGEN} -q -N '' -t ${ktype} \ 25 ${SSHKEYGEN} -q -N '' -t ${ktype} \
23 -f $OBJ/cert_user_key_${ktype} || \ 26 -f $OBJ/cert_user_key_${ktype} || \
@@ -25,18 +28,18 @@ for ktype in rsa dsa $ecdsa ; do
25 ${SSHKEYGEN} -q -s $OBJ/user_ca_key -I "regress user key for $USER" \ 28 ${SSHKEYGEN} -q -s $OBJ/user_ca_key -I "regress user key for $USER" \
26 -z $$ -n ${USER},mekmitasdigoat $OBJ/cert_user_key_${ktype} || 29 -z $$ -n ${USER},mekmitasdigoat $OBJ/cert_user_key_${ktype} ||
27 fail "couldn't sign cert_user_key_${ktype}" 30 fail "couldn't sign cert_user_key_${ktype}"
28 # v00 ecdsa certs do not exist 31 type_has_legacy $ktype || continue
29 test "${ktype}" = "ecdsa" && continue
30 cp $OBJ/cert_user_key_${ktype} $OBJ/cert_user_key_${ktype}_v00 32 cp $OBJ/cert_user_key_${ktype} $OBJ/cert_user_key_${ktype}_v00
31 cp $OBJ/cert_user_key_${ktype}.pub $OBJ/cert_user_key_${ktype}_v00.pub 33 cp $OBJ/cert_user_key_${ktype}.pub $OBJ/cert_user_key_${ktype}_v00.pub
34 verbose "$tid: sign host ${ktype}_v00 cert"
32 ${SSHKEYGEN} -q -t v00 -s $OBJ/user_ca_key -I \ 35 ${SSHKEYGEN} -q -t v00 -s $OBJ/user_ca_key -I \
33 "regress user key for $USER" \ 36 "regress user key for $USER" \
34 -n ${USER},mekmitasdigoat $OBJ/cert_user_key_${ktype}_v00 || 37 -n ${USER},mekmitasdigoat $OBJ/cert_user_key_${ktype}_v00 ||
35 fail "couldn't sign cert_user_key_${ktype}_v00" 38 fatal "couldn't sign cert_user_key_${ktype}_v00"
36done 39done
37 40
38# Test explicitly-specified principals 41# Test explicitly-specified principals
39for ktype in rsa dsa $ecdsa rsa_v00 dsa_v00 ; do 42for ktype in $PLAIN_TYPES rsa_v00 dsa_v00 ; do
40 for privsep in yes no ; do 43 for privsep in yes no ; do
41 _prefix="${ktype} privsep $privsep" 44 _prefix="${ktype} privsep $privsep"
42 45
@@ -162,7 +165,7 @@ basic_tests() {
162 extra_sshd="TrustedUserCAKeys $OBJ/user_ca_key.pub" 165 extra_sshd="TrustedUserCAKeys $OBJ/user_ca_key.pub"
163 fi 166 fi
164 167
165 for ktype in rsa dsa $ecdsa rsa_v00 dsa_v00 ; do 168 for ktype in $PLAIN_TYPES rsa_v00 dsa_v00 ; do
166 for privsep in yes no ; do 169 for privsep in yes no ; do
167 _prefix="${ktype} privsep $privsep $auth" 170 _prefix="${ktype} privsep $privsep $auth"
168 # Simple connect 171 # Simple connect
@@ -332,7 +335,7 @@ test_one "principals key option no principals" failure "" \
332 335
333# Wrong certificate 336# Wrong certificate
334cat $OBJ/sshd_proxy_bak > $OBJ/sshd_proxy 337cat $OBJ/sshd_proxy_bak > $OBJ/sshd_proxy
335for ktype in rsa dsa $ecdsa rsa_v00 dsa_v00 ; do 338for ktype in $PLAIN_TYPES rsa_v00 dsa_v00 ; do
336 case $ktype in 339 case $ktype in
337 *_v00) args="-t v00" ;; 340 *_v00) args="-t v00" ;;
338 *) args="" ;; 341 *) args="" ;;
diff --git a/regress/cipher-speed.sh b/regress/cipher-speed.sh
index 489d9f5fa..a6d53a78d 100644
--- a/regress/cipher-speed.sh
+++ b/regress/cipher-speed.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: cipher-speed.sh,v 1.9 2013/05/17 04:29:14 dtucker Exp $ 1# $OpenBSD: cipher-speed.sh,v 1.11 2013/11/21 03:18:51 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="cipher speed" 4tid="cipher speed"
@@ -11,18 +11,7 @@ getbytes ()
11 11
12tries="1 2" 12tries="1 2"
13 13
14ciphers="aes128-cbc 3des-cbc blowfish-cbc cast128-cbc 14for c in `${SSH} -Q cipher`; do n=0; for m in `${SSH} -Q mac`; do
15 arcfour128 arcfour256 arcfour
16 aes192-cbc aes256-cbc rijndael-cbc@lysator.liu.se
17 aes128-ctr aes192-ctr aes256-ctr"
18config_defined OPENSSL_HAVE_EVPGCM && \
19 ciphers="$ciphers aes128-gcm@openssh.com aes256-gcm@openssh.com"
20macs="hmac-sha1 hmac-md5 umac-64@openssh.com umac-128@openssh.com
21 hmac-sha1-96 hmac-md5-96"
22config_defined HAVE_EVP_SHA256 && \
23 macs="$macs hmac-sha2-256 hmac-sha2-512"
24
25for c in $ciphers; do n=0; for m in $macs; do
26 trace "proto 2 cipher $c mac $m" 15 trace "proto 2 cipher $c mac $m"
27 for x in $tries; do 16 for x in $tries; do
28 printf "%-60s" "$c/$m:" 17 printf "%-60s" "$c/$m:"
@@ -35,10 +24,10 @@ for c in $ciphers; do n=0; for m in $macs; do
35 fail "ssh -2 failed with mac $m cipher $c" 24 fail "ssh -2 failed with mac $m cipher $c"
36 fi 25 fi
37 done 26 done
38 # No point trying all MACs for GCM since they are ignored. 27 # No point trying all MACs for AEAD ciphers since they are ignored.
39 case $c in 28 if ssh -Q cipher-auth | grep "^${c}\$" >/dev/null 2>&1 ; then
40 aes*-gcm@openssh.com) test $n -gt 0 && break;; 29 break
41 esac 30 fi
42 n=`expr $n + 1` 31 n=`expr $n + 1`
43done; done 32done; done
44 33
diff --git a/regress/forward-control.sh b/regress/forward-control.sh
index 80ddb4167..7f7d105e8 100644
--- a/regress/forward-control.sh
+++ b/regress/forward-control.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: forward-control.sh,v 1.1 2012/12/02 20:47:48 djm Exp $ 1# $OpenBSD: forward-control.sh,v 1.2 2013/11/18 05:09:32 naddy Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="sshd control of local and remote forwarding" 4tid="sshd control of local and remote forwarding"
diff --git a/regress/integrity.sh b/regress/integrity.sh
index 1d17fe10a..852d82690 100644
--- a/regress/integrity.sh
+++ b/regress/integrity.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: integrity.sh,v 1.10 2013/05/17 01:32:11 dtucker Exp $ 1# $OpenBSD: integrity.sh,v 1.12 2013/11/21 03:18:51 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="integrity" 4tid="integrity"
@@ -8,18 +8,10 @@ tid="integrity"
8# XXX and ssh tries to read... 8# XXX and ssh tries to read...
9tries=10 9tries=10
10startoffset=2900 10startoffset=2900
11macs="hmac-sha1 hmac-md5 umac-64@openssh.com umac-128@openssh.com 11macs=`${SSH} -Q mac`
12 hmac-sha1-96 hmac-md5-96
13 hmac-sha1-etm@openssh.com hmac-md5-etm@openssh.com
14 umac-64-etm@openssh.com umac-128-etm@openssh.com
15 hmac-sha1-96-etm@openssh.com hmac-md5-96-etm@openssh.com"
16config_defined HAVE_EVP_SHA256 &&
17 macs="$macs hmac-sha2-256 hmac-sha2-512
18 hmac-sha2-256-etm@openssh.com hmac-sha2-512-etm@openssh.com"
19# The following are not MACs, but ciphers with integrated integrity. They are 12# The following are not MACs, but ciphers with integrated integrity. They are
20# handled specially below. 13# handled specially below.
21config_defined OPENSSL_HAVE_EVPGCM && \ 14macs="$macs `${SSH} -Q cipher-auth`"
22 macs="$macs aes128-gcm@openssh.com aes256-gcm@openssh.com"
23 15
24# avoid DH group exchange as the extra traffic makes it harder to get the 16# avoid DH group exchange as the extra traffic makes it harder to get the
25# offset into the stream right. 17# offset into the stream right.
@@ -44,12 +36,14 @@ for m in $macs; do
44 fi 36 fi
45 # modify output from sshd at offset $off 37 # modify output from sshd at offset $off
46 pxy="proxycommand=$cmd | $OBJ/modpipe -wm xor:$off:1" 38 pxy="proxycommand=$cmd | $OBJ/modpipe -wm xor:$off:1"
47 case $m in 39 if ssh -Q cipher-auth | grep "^${m}\$" >/dev/null 2>&1 ; then
48 aes*gcm*) macopt="-c $m";; 40 macopt="-c $m"
49 *) macopt="-m $m";; 41 else
50 esac 42 macopt="-m $m -c aes128-ctr"
43 fi
51 verbose "test $tid: $m @$off" 44 verbose "test $tid: $m @$off"
52 ${SSH} $macopt -2F $OBJ/ssh_proxy -o "$pxy" \ 45 ${SSH} $macopt -2F $OBJ/ssh_proxy -o "$pxy" \
46 -oServerAliveInterval=1 -oServerAliveCountMax=30 \
53 999.999.999.999 'printf "%4096s" " "' >/dev/null 47 999.999.999.999 'printf "%4096s" " "' >/dev/null
54 if [ $? -eq 0 ]; then 48 if [ $? -eq 0 ]; then
55 fail "ssh -m $m succeeds with bit-flip at $off" 49 fail "ssh -m $m succeeds with bit-flip at $off"
diff --git a/regress/kextype.sh b/regress/kextype.sh
index 79c0817bb..8c2ac09d6 100644
--- a/regress/kextype.sh
+++ b/regress/kextype.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: kextype.sh,v 1.1 2010/09/22 12:26:05 djm Exp $ 1# $OpenBSD: kextype.sh,v 1.4 2013/11/07 04:26:56 dtucker Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="login with different key exchange algorithms" 4tid="login with different key exchange algorithms"
@@ -7,18 +7,8 @@ TIME=/usr/bin/time
7cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak 7cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
8cp $OBJ/ssh_proxy $OBJ/ssh_proxy_bak 8cp $OBJ/ssh_proxy $OBJ/ssh_proxy_bak
9 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" 10tries="1 2 3 4"
21for k in $kextypes; do 11for k in `${SSH} -Q kex`; do
22 verbose "kex $k" 12 verbose "kex $k"
23 for i in $tries; do 13 for i in $tries; do
24 ${SSH} -F $OBJ/ssh_proxy -o KexAlgorithms=$k x true 14 ${SSH} -F $OBJ/ssh_proxy -o KexAlgorithms=$k x true
diff --git a/regress/keytype.sh b/regress/keytype.sh
index 59586bf0d..9752acb0a 100644
--- a/regress/keytype.sh
+++ b/regress/keytype.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: keytype.sh,v 1.2 2013/05/17 00:37:40 dtucker Exp $ 1# $OpenBSD: keytype.sh,v 1.3 2013/12/06 13:52:46 markus Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="login with different key types" 4tid="login with different key types"
@@ -11,10 +11,16 @@ fi
11cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak 11cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
12cp $OBJ/ssh_proxy $OBJ/ssh_proxy_bak 12cp $OBJ/ssh_proxy $OBJ/ssh_proxy_bak
13 13
14ktypes="dsa-1024 rsa-2048 rsa-3072" 14# Traditional and builtin key types.
15if test "$TEST_SSH_ECC" = "yes"; then 15ktypes="dsa-1024 rsa-2048 rsa-3072 ed25519-512"
16 ktypes="$ktypes ecdsa-256 ecdsa-384 ecdsa-521" 16# Types not present in all OpenSSL versions.
17fi 17for i in `$SSH -Q key`; do
18 case "$i" in
19 ecdsa-sha2-nistp256) ktypes="$ktypes ecdsa-256" ;;
20 ecdsa-sha2-nistp384) ktypes="$ktypes ecdsa-384" ;;
21 ecdsa-sha2-nistp521) ktypes="$ktypes ecdsa-521" ;;
22 esac
23done
18 24
19for kt in $ktypes; do 25for kt in $ktypes; do
20 rm -f $OBJ/key.$kt 26 rm -f $OBJ/key.$kt
diff --git a/regress/krl.sh b/regress/krl.sh
index de9cc8764..09246371c 100644
--- a/regress/krl.sh
+++ b/regress/krl.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: krl.sh,v 1.1 2013/01/18 00:45:29 djm Exp $ 1# $OpenBSD: krl.sh,v 1.2 2013/11/21 03:15:46 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="key revocation lists" 4tid="key revocation lists"
@@ -101,6 +101,9 @@ $SSHKEYGEN $OPTS -kf $OBJ/krl-keyid -s $OBJ/revoked-ca.pub $OBJ/revoked-keyid \
101 >/dev/null || fatal "$SSHKEYGEN KRL failed" 101 >/dev/null || fatal "$SSHKEYGEN KRL failed"
102} 102}
103 103
104## XXX dump with trace and grep for set cert serials
105## XXX test ranges near (u64)-1, etc.
106
104verbose "$tid: generating KRLs" 107verbose "$tid: generating KRLs"
105genkrls 108genkrls
106 109
diff --git a/regress/modpipe.c b/regress/modpipe.c
index 85747cf7d..e854f9e07 100755
--- a/regress/modpipe.c
+++ b/regress/modpipe.c
@@ -14,7 +14,7 @@
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17/* $OpenBSD: modpipe.c,v 1.5 2013/05/10 03:46:14 djm Exp $ */ 17/* $OpenBSD: modpipe.c,v 1.6 2013/11/21 03:16:47 djm Exp $ */
18 18
19#include "includes.h" 19#include "includes.h"
20 20
@@ -68,7 +68,7 @@ usage(void)
68#define MAX_MODIFICATIONS 256 68#define MAX_MODIFICATIONS 256
69struct modification { 69struct modification {
70 enum { MOD_XOR, MOD_AND_OR } what; 70 enum { MOD_XOR, MOD_AND_OR } what;
71 u_int64_t offset; 71 unsigned long long offset;
72 u_int8_t m1, m2; 72 u_int8_t m1, m2;
73}; 73};
74 74
@@ -79,7 +79,7 @@ parse_modification(const char *s, struct modification *m)
79 int n, m1, m2; 79 int n, m1, m2;
80 80
81 bzero(m, sizeof(*m)); 81 bzero(m, sizeof(*m));
82 if ((n = sscanf(s, "%16[^:]%*[:]%lli%*[:]%i%*[:]%i", 82 if ((n = sscanf(s, "%16[^:]%*[:]%llu%*[:]%i%*[:]%i",
83 what, &m->offset, &m1, &m2)) < 3) 83 what, &m->offset, &m1, &m2)) < 3)
84 errx(1, "Invalid modification spec \"%s\"", s); 84 errx(1, "Invalid modification spec \"%s\"", s);
85 if (strcasecmp(what, "xor") == 0) { 85 if (strcasecmp(what, "xor") == 0) {
diff --git a/regress/rekey.sh b/regress/rekey.sh
index 8eb7efaf9..cf9401ea0 100644
--- a/regress/rekey.sh
+++ b/regress/rekey.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: rekey.sh,v 1.8 2013/05/17 04:29:14 dtucker Exp $ 1# $OpenBSD: rekey.sh,v 1.14 2013/11/21 03:18:51 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="rekey" 4tid="rekey"
@@ -7,34 +7,67 @@ LOG=${TEST_SSH_LOGFILE}
7 7
8rm -f ${LOG} 8rm -f ${LOG}
9 9
10for s in 16 1k 128k 256k; do 10# Test rekeying based on data volume only.
11 verbose "client rekeylimit ${s}" 11# Arguments will be passed to ssh.
12ssh_data_rekeying()
13{
12 rm -f ${COPY} ${LOG} 14 rm -f ${COPY} ${LOG}
13 cat $DATA | \ 15 ${SSH} <${DATA} -oCompression=no $@ -v -F $OBJ/ssh_proxy somehost \
14 ${SSH} -oCompression=no -oRekeyLimit=$s \ 16 "cat > ${COPY}"
15 -v -F $OBJ/ssh_proxy somehost "cat > ${COPY}"
16 if [ $? -ne 0 ]; then 17 if [ $? -ne 0 ]; then
17 fail "ssh failed" 18 fail "ssh failed ($@)"
18 fi 19 fi
19 cmp $DATA ${COPY} || fail "corrupted copy" 20 cmp ${DATA} ${COPY} || fail "corrupted copy ($@)"
20 n=`grep 'NEWKEYS sent' ${LOG} | wc -l` 21 n=`grep 'NEWKEYS sent' ${LOG} | wc -l`
21 n=`expr $n - 1` 22 n=`expr $n - 1`
22 trace "$n rekeying(s)" 23 trace "$n rekeying(s)"
23 if [ $n -lt 1 ]; then 24 if [ $n -lt 1 ]; then
24 fail "no rekeying occured" 25 fail "no rekeying occured ($@)"
25 fi 26 fi
27}
28
29increase_datafile_size 300
30
31opts=""
32for i in `${SSH} -Q kex`; do
33 opts="$opts KexAlgorithms=$i"
34done
35for i in `${SSH} -Q cipher`; do
36 opts="$opts Ciphers=$i"
37done
38for i in `${SSH} -Q mac`; do
39 opts="$opts MACs=$i"
40done
41
42for opt in $opts; do
43 verbose "client rekey $opt"
44 ssh_data_rekeying -oRekeyLimit=256k -o$opt
45done
46
47# AEAD ciphers are magical so test with all KexAlgorithms
48if ${SSH} -Q cipher-auth | grep '^.*$' >/dev/null 2>&1 ; then
49 for c in `${SSH} -Q cipher-auth`; do
50 for kex in `${SSH} -Q kex`; do
51 verbose "client rekey $c $kex"
52 ssh_data_rekeying -oRekeyLimit=256k -oCiphers=$c -oKexAlgorithms=$kex
53 done
54 done
55fi
56
57for s in 16 1k 128k 256k; do
58 verbose "client rekeylimit ${s}"
59 ssh_data_rekeying -oCompression=no -oRekeyLimit=$s
26done 60done
27 61
28for s in 5 10; do 62for s in 5 10; do
29 verbose "client rekeylimit default ${s}" 63 verbose "client rekeylimit default ${s}"
30 rm -f ${COPY} ${LOG} 64 rm -f ${COPY} ${LOG}
31 cat $DATA | \ 65 ${SSH} < ${DATA} -oCompression=no -oRekeyLimit="default $s" -F \
32 ${SSH} -oCompression=no -oRekeyLimit="default $s" -F \ 66 $OBJ/ssh_proxy somehost "cat >${COPY};sleep $s;sleep 3"
33 $OBJ/ssh_proxy somehost "cat >${COPY};sleep $s;sleep 3"
34 if [ $? -ne 0 ]; then 67 if [ $? -ne 0 ]; then
35 fail "ssh failed" 68 fail "ssh failed"
36 fi 69 fi
37 cmp $DATA ${COPY} || fail "corrupted copy" 70 cmp ${DATA} ${COPY} || fail "corrupted copy"
38 n=`grep 'NEWKEYS sent' ${LOG} | wc -l` 71 n=`grep 'NEWKEYS sent' ${LOG} | wc -l`
39 n=`expr $n - 1` 72 n=`expr $n - 1`
40 trace "$n rekeying(s)" 73 trace "$n rekeying(s)"
@@ -98,10 +131,10 @@ for size in 16 1k 1K 1m 1M 1g 1G; do
98 awk '/rekeylimit/{print $3}'` 131 awk '/rekeylimit/{print $3}'`
99 132
100 if [ "$bytes" != "$b" ]; then 133 if [ "$bytes" != "$b" ]; then
101 fatal "rekeylimit size: expected $bytes got $b" 134 fatal "rekeylimit size: expected $bytes bytes got $b"
102 fi 135 fi
103 if [ "$seconds" != "$s" ]; then 136 if [ "$seconds" != "$s" ]; then
104 fatal "rekeylimit time: expected $time got $s" 137 fatal "rekeylimit time: expected $time seconds got $s"
105 fi 138 fi
106 done 139 done
107done 140done
diff --git a/regress/scp-ssh-wrapper.sh b/regress/scp-ssh-wrapper.sh
index d1005a995..c63bc2bc1 100644
--- a/regress/scp-ssh-wrapper.sh
+++ b/regress/scp-ssh-wrapper.sh
@@ -17,7 +17,7 @@ printname () {
17} 17}
18 18
19# Discard all but last argument. We use arg later. 19# Discard all but last argument. We use arg later.
20while test "$1" != ""; do 20while test "x$1" != "x"; do
21 arg="$1" 21 arg="$1"
22 shift 22 shift
23done 23done
@@ -52,6 +52,8 @@ badserver_4)
52 echo "X" 52 echo "X"
53 ;; 53 ;;
54*) 54*)
55 exec $arg 55 set -- $arg
56 shift
57 exec $SCP "$@"
56 ;; 58 ;;
57esac 59esac
diff --git a/regress/scp.sh b/regress/scp.sh
index 29c5b35d4..c2da2a862 100644
--- a/regress/scp.sh
+++ b/regress/scp.sh
@@ -20,6 +20,7 @@ SRC=`dirname ${SCRIPT}`
20cp ${SRC}/scp-ssh-wrapper.sh ${OBJ}/scp-ssh-wrapper.scp 20cp ${SRC}/scp-ssh-wrapper.sh ${OBJ}/scp-ssh-wrapper.scp
21chmod 755 ${OBJ}/scp-ssh-wrapper.scp 21chmod 755 ${OBJ}/scp-ssh-wrapper.scp
22scpopts="-q -S ${OBJ}/scp-ssh-wrapper.scp" 22scpopts="-q -S ${OBJ}/scp-ssh-wrapper.scp"
23export SCP # used in scp-ssh-wrapper.scp
23 24
24scpclean() { 25scpclean() {
25 rm -rf ${COPY} ${COPY2} ${DIR} ${DIR2} 26 rm -rf ${COPY} ${COPY2} ${DIR} ${DIR2}
diff --git a/regress/setuid-allowed.c b/regress/setuid-allowed.c
new file mode 100644
index 000000000..37b7dc8ad
--- /dev/null
+++ b/regress/setuid-allowed.c
@@ -0,0 +1,56 @@
1/*
2 * Copyright (c) 2013 Damien Miller <djm@mindrot.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17/* $OpenBSD$ */
18
19#include "includes.h"
20
21#include <sys/types.h>
22#ifdef HAVE_SYS_STATVFS_H
23# include <sys/statvfs.h>
24#endif
25#include <stdio.h>
26#include <errno.h>
27
28void
29usage(void)
30{
31 fprintf(stderr, "check-setuid [path]\n");
32 exit(1);
33}
34
35int
36main(int argc, char **argv)
37{
38 const char *path = ".";
39 struct statvfs sb;
40
41 if (argc > 2)
42 usage();
43 else if (argc == 2)
44 path = argv[1];
45
46 if (statvfs(path, &sb) != 0) {
47 /* Don't return an error if the host doesn't support statvfs */
48 if (errno == ENOSYS)
49 return 0;
50 fprintf(stderr, "statvfs for \"%s\" failed: %s\n",
51 path, strerror(errno));
52 }
53 return (sb.f_flag & ST_NOSUID) ? 1 : 0;
54}
55
56
diff --git a/regress/sftp-perm.sh b/regress/sftp-perm.sh
new file mode 100644
index 000000000..304ca0ac5
--- /dev/null
+++ b/regress/sftp-perm.sh
@@ -0,0 +1,269 @@
1# $OpenBSD: sftp-perm.sh,v 1.2 2013/10/17 22:00:18 djm Exp $
2# Placed in the Public Domain.
3
4tid="sftp permissions"
5
6SERVER_LOG=${OBJ}/sftp-server.log
7CLIENT_LOG=${OBJ}/sftp.log
8TEST_SFTP_SERVER=${OBJ}/sftp-server.sh
9
10prepare_server() {
11 printf "#!/bin/sh\nexec $SFTPSERVER -el debug3 $* 2>$SERVER_LOG\n" \
12 > $TEST_SFTP_SERVER
13 chmod a+x $TEST_SFTP_SERVER
14}
15
16run_client() {
17 echo "$@" | ${SFTP} -D ${TEST_SFTP_SERVER} -vvvb - >$CLIENT_LOG 2>&1
18}
19
20prepare_files() {
21 _prep="$1"
22 rm -f ${COPY} ${COPY}.1
23 test -d ${COPY}.dd && { rmdir ${COPY}.dd || fatal "rmdir ${COPY}.dd"; }
24 test -z "$_prep" && return
25 sh -c "$_prep" || fail "preparation failed: \"$_prep\""
26}
27
28postcondition() {
29 _title="$1"
30 _check="$2"
31 test -z "$_check" && return
32 ${TEST_SHELL} -c "$_check" || fail "postcondition check failed: $_title"
33}
34
35ro_test() {
36 _desc=$1
37 _cmd="$2"
38 _prep="$3"
39 _expect_success_post="$4"
40 _expect_fail_post="$5"
41 verbose "$tid: read-only $_desc"
42 # Plain (no options, mostly to test that _cmd is good)
43 prepare_files "$_prep"
44 prepare_server
45 run_client "$_cmd" || fail "plain $_desc failed"
46 postcondition "$_desc no-readonly" "$_expect_success_post"
47 # Read-only enabled
48 prepare_files "$_prep"
49 prepare_server -R
50 run_client "$_cmd" && fail "read-only $_desc succeeded"
51 postcondition "$_desc readonly" "$_expect_fail_post"
52}
53
54perm_test() {
55 _op=$1
56 _whitelist_ops=$2
57 _cmd="$3"
58 _prep="$4"
59 _expect_success_post="$5"
60 _expect_fail_post="$6"
61 verbose "$tid: explicit $_op"
62 # Plain (no options, mostly to test that _cmd is good)
63 prepare_files "$_prep"
64 prepare_server
65 run_client "$_cmd" || fail "plain $_op failed"
66 postcondition "$_op no white/blacklists" "$_expect_success_post"
67 # Whitelist
68 prepare_files "$_prep"
69 prepare_server -p $_op,$_whitelist_ops
70 run_client "$_cmd" || fail "whitelisted $_op failed"
71 postcondition "$_op whitelisted" "$_expect_success_post"
72 # Blacklist
73 prepare_files "$_prep"
74 prepare_server -P $_op
75 run_client "$_cmd" && fail "blacklisted $_op succeeded"
76 postcondition "$_op blacklisted" "$_expect_fail_post"
77 # Whitelist with op missing.
78 prepare_files "$_prep"
79 prepare_server -p $_whitelist_ops
80 run_client "$_cmd" && fail "no whitelist $_op succeeded"
81 postcondition "$_op not in whitelist" "$_expect_fail_post"
82}
83
84ro_test \
85 "upload" \
86 "put $DATA $COPY" \
87 "" \
88 "cmp $DATA $COPY" \
89 "test ! -f $COPY"
90
91ro_test \
92 "setstat" \
93 "chmod 0700 $COPY" \
94 "touch $COPY; chmod 0400 $COPY" \
95 "test -x $COPY" \
96 "test ! -x $COPY"
97
98ro_test \
99 "rm" \
100 "rm $COPY" \
101 "touch $COPY" \
102 "test ! -f $COPY" \
103 "test -f $COPY"
104
105ro_test \
106 "mkdir" \
107 "mkdir ${COPY}.dd" \
108 "" \
109 "test -d ${COPY}.dd" \
110 "test ! -d ${COPY}.dd"
111
112ro_test \
113 "rmdir" \
114 "rmdir ${COPY}.dd" \
115 "mkdir ${COPY}.dd" \
116 "test ! -d ${COPY}.dd" \
117 "test -d ${COPY}.dd"
118
119ro_test \
120 "posix-rename" \
121 "rename $COPY ${COPY}.1" \
122 "touch $COPY" \
123 "test -f ${COPY}.1 -a ! -f $COPY" \
124 "test -f $COPY -a ! -f ${COPY}.1"
125
126ro_test \
127 "oldrename" \
128 "rename -l $COPY ${COPY}.1" \
129 "touch $COPY" \
130 "test -f ${COPY}.1 -a ! -f $COPY" \
131 "test -f $COPY -a ! -f ${COPY}.1"
132
133ro_test \
134 "symlink" \
135 "ln -s $COPY ${COPY}.1" \
136 "touch $COPY" \
137 "test -h ${COPY}.1" \
138 "test ! -h ${COPY}.1"
139
140ro_test \
141 "hardlink" \
142 "ln $COPY ${COPY}.1" \
143 "touch $COPY" \
144 "test -f ${COPY}.1" \
145 "test ! -f ${COPY}.1"
146
147# Test explicit permissions
148
149perm_test \
150 "open" \
151 "realpath,stat,lstat,read,close" \
152 "get $DATA $COPY" \
153 "" \
154 "cmp $DATA $COPY" \
155 "! cmp $DATA $COPY 2>/dev/null"
156
157perm_test \
158 "read" \
159 "realpath,stat,lstat,open,close" \
160 "get $DATA $COPY" \
161 "" \
162 "cmp $DATA $COPY" \
163 "! cmp $DATA $COPY 2>/dev/null"
164
165perm_test \
166 "write" \
167 "realpath,stat,lstat,open,close" \
168 "put $DATA $COPY" \
169 "" \
170 "cmp $DATA $COPY" \
171 "! cmp $DATA $COPY 2>/dev/null"
172
173perm_test \
174 "lstat" \
175 "realpath,stat,open,read,close" \
176 "get $DATA $COPY" \
177 "" \
178 "cmp $DATA $COPY" \
179 "! cmp $DATA $COPY 2>/dev/null"
180
181perm_test \
182 "opendir" \
183 "realpath,readdir,stat,lstat" \
184 "ls -ln $OBJ"
185
186perm_test \
187 "readdir" \
188 "realpath,opendir,stat,lstat" \
189 "ls -ln $OBJ"
190
191perm_test \
192 "setstat" \
193 "realpath,stat,lstat" \
194 "chmod 0700 $COPY" \
195 "touch $COPY; chmod 0400 $COPY" \
196 "test -x $COPY" \
197 "test ! -x $COPY"
198
199perm_test \
200 "remove" \
201 "realpath,stat,lstat" \
202 "rm $COPY" \
203 "touch $COPY" \
204 "test ! -f $COPY" \
205 "test -f $COPY"
206
207perm_test \
208 "mkdir" \
209 "realpath,stat,lstat" \
210 "mkdir ${COPY}.dd" \
211 "" \
212 "test -d ${COPY}.dd" \
213 "test ! -d ${COPY}.dd"
214
215perm_test \
216 "rmdir" \
217 "realpath,stat,lstat" \
218 "rmdir ${COPY}.dd" \
219 "mkdir ${COPY}.dd" \
220 "test ! -d ${COPY}.dd" \
221 "test -d ${COPY}.dd"
222
223perm_test \
224 "posix-rename" \
225 "realpath,stat,lstat" \
226 "rename $COPY ${COPY}.1" \
227 "touch $COPY" \
228 "test -f ${COPY}.1 -a ! -f $COPY" \
229 "test -f $COPY -a ! -f ${COPY}.1"
230
231perm_test \
232 "rename" \
233 "realpath,stat,lstat" \
234 "rename -l $COPY ${COPY}.1" \
235 "touch $COPY" \
236 "test -f ${COPY}.1 -a ! -f $COPY" \
237 "test -f $COPY -a ! -f ${COPY}.1"
238
239perm_test \
240 "symlink" \
241 "realpath,stat,lstat" \
242 "ln -s $COPY ${COPY}.1" \
243 "touch $COPY" \
244 "test -h ${COPY}.1" \
245 "test ! -h ${COPY}.1"
246
247perm_test \
248 "hardlink" \
249 "realpath,stat,lstat" \
250 "ln $COPY ${COPY}.1" \
251 "touch $COPY" \
252 "test -f ${COPY}.1" \
253 "test ! -f ${COPY}.1"
254
255perm_test \
256 "statvfs" \
257 "realpath,stat,lstat" \
258 "df /"
259
260# XXX need good tests for:
261# fstat
262# fsetstat
263# realpath
264# stat
265# readlink
266# fstatvfs
267
268rm -rf ${COPY} ${COPY}.1 ${COPY}.dd
269
diff --git a/regress/test-exec.sh b/regress/test-exec.sh
index eee446264..aac8aa5c2 100644
--- a/regress/test-exec.sh
+++ b/regress/test-exec.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: test-exec.sh,v 1.46 2013/06/21 02:26:26 djm Exp $ 1# $OpenBSD: test-exec.sh,v 1.47 2013/11/09 05:41:34 dtucker Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4#SUDO=sudo 4#SUDO=sudo
@@ -133,7 +133,12 @@ fi
133# Path to sshd must be absolute for rexec 133# Path to sshd must be absolute for rexec
134case "$SSHD" in 134case "$SSHD" in
135/*) ;; 135/*) ;;
136*) SSHD=`which sshd` ;; 136*) SSHD=`which $SSHD` ;;
137esac
138
139case "$SSHAGENT" in
140/*) ;;
141*) SSHAGENT=`which $SSHAGENT` ;;
137esac 142esac
138 143
139# Logfiles. 144# Logfiles.
@@ -166,14 +171,22 @@ SSH="$SSHLOGWRAP"
166 171
167# Some test data. We make a copy because some tests will overwrite it. 172# Some test data. We make a copy because some tests will overwrite it.
168# The tests may assume that $DATA exists and is writable and $COPY does 173# The tests may assume that $DATA exists and is writable and $COPY does
169# not exist. 174# not exist. Tests requiring larger data files can call increase_datafile_size
175# [kbytes] to ensure the file is at least that large.
170DATANAME=data 176DATANAME=data
171DATA=$OBJ/${DATANAME} 177DATA=$OBJ/${DATANAME}
172cat $SSHD $SSHD $SSHD $SSHD >${DATA} 178cat ${SSHAGENT} >${DATA}
173chmod u+w ${DATA} 179chmod u+w ${DATA}
174COPY=$OBJ/copy 180COPY=$OBJ/copy
175rm -f ${COPY} 181rm -f ${COPY}
176 182
183increase_datafile_size()
184{
185 while [ `du -k ${DATA} | cut -f1` -lt $1 ]; do
186 cat ${SSHAGENT} >>${DATA}
187 done
188}
189
177# these should be used in tests 190# these should be used in tests
178export SSH SSHD SSHAGENT SSHADD SSHKEYGEN SSHKEYSCAN SFTP SFTPSERVER SCP 191export SSH SSHD SSHAGENT SSHADD SSHKEYGEN SSHKEYSCAN SFTP SFTPSERVER SCP
179#echo $SSH $SSHD $SSHAGENT $SSHADD $SSHKEYGEN $SSHKEYSCAN $SFTP $SFTPSERVER $SCP 192#echo $SSH $SSHD $SSHAGENT $SSHADD $SSHKEYGEN $SSHKEYSCAN $SFTP $SFTPSERVER $SCP
diff --git a/regress/try-ciphers.sh b/regress/try-ciphers.sh
index e17c9f5e9..ac34cedbf 100644
--- a/regress/try-ciphers.sh
+++ b/regress/try-ciphers.sh
@@ -1,37 +1,22 @@
1# $OpenBSD: try-ciphers.sh,v 1.20 2013/05/17 10:16:26 dtucker Exp $ 1# $OpenBSD: try-ciphers.sh,v 1.22 2013/11/21 03:18:51 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="try ciphers" 4tid="try ciphers"
5 5
6ciphers="aes128-cbc 3des-cbc blowfish-cbc cast128-cbc 6for c in `${SSH} -Q cipher`; do
7 arcfour128 arcfour256 arcfour
8 aes192-cbc aes256-cbc rijndael-cbc@lysator.liu.se
9 aes128-ctr aes192-ctr aes256-ctr"
10config_defined OPENSSL_HAVE_EVPGCM && \
11 ciphers="$ciphers aes128-gcm@openssh.com aes256-gcm@openssh.com"
12macs="hmac-sha1 hmac-md5 umac-64@openssh.com umac-128@openssh.com
13 hmac-sha1-96 hmac-md5-96
14 hmac-sha1-etm@openssh.com hmac-md5-etm@openssh.com
15 umac-64-etm@openssh.com umac-128-etm@openssh.com
16 hmac-sha1-96-etm@openssh.com hmac-md5-96-etm@openssh.com
17 hmac-ripemd160-etm@openssh.com"
18config_defined HAVE_EVP_SHA256 &&
19 macs="$macs hmac-sha2-256 hmac-sha2-512
20 hmac-sha2-256-etm@openssh.com hmac-sha2-512-etm@openssh.com"
21
22for c in $ciphers; do
23 n=0 7 n=0
24 for m in $macs; do 8 for m in `${SSH} -Q mac`; do
25 trace "proto 2 cipher $c mac $m" 9 trace "proto 2 cipher $c mac $m"
26 verbose "test $tid: proto 2 cipher $c mac $m" 10 verbose "test $tid: proto 2 cipher $c mac $m"
27 ${SSH} -F $OBJ/ssh_proxy -2 -m $m -c $c somehost true 11 ${SSH} -F $OBJ/ssh_proxy -2 -m $m -c $c somehost true
28 if [ $? -ne 0 ]; then 12 if [ $? -ne 0 ]; then
29 fail "ssh -2 failed with mac $m cipher $c" 13 fail "ssh -2 failed with mac $m cipher $c"
30 fi 14 fi
31 # No point trying all MACs for GCM since they are ignored. 15 # No point trying all MACs for AEAD ciphers since they
32 case $c in 16 # are ignored.
33 aes*-gcm@openssh.com) test $n -gt 0 && break;; 17 if ssh -Q cipher-auth | grep "^${c}\$" >/dev/null 2>&1 ; then
34 esac 18 break
19 fi
35 n=`expr $n + 1` 20 n=`expr $n + 1`
36 done 21 done
37done 22done
diff --git a/roaming_client.c b/roaming_client.c
index 81c496827..de049cdc1 100644
--- a/roaming_client.c
+++ b/roaming_client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: roaming_client.c,v 1.5 2013/05/17 00:13:14 djm Exp $ */ 1/* $OpenBSD: roaming_client.c,v 1.7 2014/01/09 23:20:00 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2004-2009 AppGate Network Security AB 3 * Copyright (c) 2004-2009 AppGate Network Security AB
4 * 4 *
@@ -48,6 +48,7 @@
48#include "roaming.h" 48#include "roaming.h"
49#include "ssh2.h" 49#include "ssh2.h"
50#include "sshconnect.h" 50#include "sshconnect.h"
51#include "digest.h"
51 52
52/* import */ 53/* import */
53extern Options options; 54extern Options options;
@@ -90,10 +91,8 @@ request_roaming(void)
90static void 91static void
91roaming_auth_required(void) 92roaming_auth_required(void)
92{ 93{
93 u_char digest[SHA_DIGEST_LENGTH]; 94 u_char digest[SSH_DIGEST_MAX_LENGTH];
94 EVP_MD_CTX md;
95 Buffer b; 95 Buffer b;
96 const EVP_MD *evp_md = EVP_sha1();
97 u_int64_t chall, oldchall; 96 u_int64_t chall, oldchall;
98 97
99 chall = packet_get_int64(); 98 chall = packet_get_int64();
@@ -107,14 +106,13 @@ roaming_auth_required(void)
107 buffer_init(&b); 106 buffer_init(&b);
108 buffer_put_int64(&b, cookie); 107 buffer_put_int64(&b, cookie);
109 buffer_put_int64(&b, chall); 108 buffer_put_int64(&b, chall);
110 EVP_DigestInit(&md, evp_md); 109 if (ssh_digest_buffer(SSH_DIGEST_SHA1, &b, digest, sizeof(digest)) != 0)
111 EVP_DigestUpdate(&md, buffer_ptr(&b), buffer_len(&b)); 110 fatal("%s: ssh_digest_buffer failed", __func__);
112 EVP_DigestFinal(&md, digest, NULL);
113 buffer_free(&b); 111 buffer_free(&b);
114 112
115 packet_start(SSH2_MSG_KEX_ROAMING_AUTH); 113 packet_start(SSH2_MSG_KEX_ROAMING_AUTH);
116 packet_put_int64(key1 ^ get_recv_bytes()); 114 packet_put_int64(key1 ^ get_recv_bytes());
117 packet_put_raw(digest, sizeof(digest)); 115 packet_put_raw(digest, ssh_digest_bytes(SSH_DIGEST_SHA1));
118 packet_send(); 116 packet_send();
119 117
120 oldkey1 = key1; 118 oldkey1 = key1;
@@ -259,10 +257,10 @@ wait_for_roaming_reconnect(void)
259 if (c != '\n' && c != '\r') 257 if (c != '\n' && c != '\r')
260 continue; 258 continue;
261 259
262 if (ssh_connect(host, &hostaddr, options.port, 260 if (ssh_connect(host, NULL, &hostaddr, options.port,
263 options.address_family, 1, &timeout_ms, 261 options.address_family, 1, &timeout_ms,
264 options.tcp_keep_alive, options.use_privileged_port, 262 options.tcp_keep_alive, options.use_privileged_port) == 0 &&
265 options.proxy_command) == 0 && roaming_resume() == 0) { 263 roaming_resume() == 0) {
266 packet_restore_state(); 264 packet_restore_state();
267 reenter_guard = 0; 265 reenter_guard = 0;
268 fprintf(stderr, "[connection resumed]\n"); 266 fprintf(stderr, "[connection resumed]\n");
diff --git a/roaming_common.c b/roaming_common.c
index 50d6177d0..787bef04a 100644
--- a/roaming_common.c
+++ b/roaming_common.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: roaming_common.c,v 1.10 2013/07/12 00:19:59 djm Exp $ */ 1/* $OpenBSD: roaming_common.c,v 1.12 2014/01/09 23:20:00 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2004-2009 AppGate Network Security AB 3 * Copyright (c) 2004-2009 AppGate Network Security AB
4 * 4 *
@@ -36,6 +36,7 @@
36#include "cipher.h" 36#include "cipher.h"
37#include "buffer.h" 37#include "buffer.h"
38#include "roaming.h" 38#include "roaming.h"
39#include "digest.h"
39 40
40static size_t out_buf_size = 0; 41static size_t out_buf_size = 0;
41static char *out_buf = NULL; 42static char *out_buf = NULL;
@@ -49,7 +50,7 @@ int roaming_enabled = 0;
49int resume_in_progress = 0; 50int resume_in_progress = 0;
50 51
51int 52int
52get_snd_buf_size() 53get_snd_buf_size(void)
53{ 54{
54 int fd = packet_get_connection_out(); 55 int fd = packet_get_connection_out();
55 int optval; 56 int optval;
@@ -61,7 +62,7 @@ get_snd_buf_size()
61} 62}
62 63
63int 64int
64get_recv_buf_size() 65get_recv_buf_size(void)
65{ 66{
66 int fd = packet_get_connection_in(); 67 int fd = packet_get_connection_in();
67 int optval; 68 int optval;
@@ -225,9 +226,7 @@ resend_bytes(int fd, u_int64_t *offset)
225void 226void
226calculate_new_key(u_int64_t *key, u_int64_t cookie, u_int64_t challenge) 227calculate_new_key(u_int64_t *key, u_int64_t cookie, u_int64_t challenge)
227{ 228{
228 const EVP_MD *md = EVP_sha1(); 229 u_char hash[SSH_DIGEST_MAX_LENGTH];
229 EVP_MD_CTX ctx;
230 u_char hash[EVP_MAX_MD_SIZE];
231 Buffer b; 230 Buffer b;
232 231
233 buffer_init(&b); 232 buffer_init(&b);
@@ -235,12 +234,11 @@ calculate_new_key(u_int64_t *key, u_int64_t cookie, u_int64_t challenge)
235 buffer_put_int64(&b, cookie); 234 buffer_put_int64(&b, cookie);
236 buffer_put_int64(&b, challenge); 235 buffer_put_int64(&b, challenge);
237 236
238 EVP_DigestInit(&ctx, md); 237 if (ssh_digest_buffer(SSH_DIGEST_SHA1, &b, hash, sizeof(hash)) != 0)
239 EVP_DigestUpdate(&ctx, buffer_ptr(&b), buffer_len(&b)); 238 fatal("%s: digest_buffer failed", __func__);
240 EVP_DigestFinal(&ctx, hash, NULL);
241 239
242 buffer_clear(&b); 240 buffer_clear(&b);
243 buffer_append(&b, hash, EVP_MD_size(md)); 241 buffer_append(&b, hash, ssh_digest_bytes(SSH_DIGEST_SHA1));
244 *key = buffer_get_int64(&b); 242 *key = buffer_get_int64(&b);
245 buffer_free(&b); 243 buffer_free(&b);
246} 244}
diff --git a/sandbox-capsicum.c b/sandbox-capsicum.c
new file mode 100644
index 000000000..ee2a7e79e
--- /dev/null
+++ b/sandbox-capsicum.c
@@ -0,0 +1,120 @@
1/*
2 * Copyright (c) 2011 Dag-Erling Smorgrav
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include "includes.h"
18
19#ifdef SANDBOX_CAPSICUM
20
21#include <sys/types.h>
22#include <sys/param.h>
23#include <sys/time.h>
24#include <sys/resource.h>
25#include <sys/capability.h>
26
27#include <errno.h>
28#include <stdarg.h>
29#include <stdio.h>
30#include <stdlib.h>
31#include <string.h>
32#include <unistd.h>
33
34#include "log.h"
35#include "monitor.h"
36#include "ssh-sandbox.h"
37#include "xmalloc.h"
38
39/*
40 * Capsicum sandbox that sets zero nfiles, nprocs and filesize rlimits,
41 * limits rights on stdout, stdin, stderr, monitor and switches to
42 * capability mode.
43 */
44
45struct ssh_sandbox {
46 struct monitor *monitor;
47 pid_t child_pid;
48};
49
50struct ssh_sandbox *
51ssh_sandbox_init(struct monitor *monitor)
52{
53 struct ssh_sandbox *box;
54
55 /*
56 * Strictly, we don't need to maintain any state here but we need
57 * to return non-NULL to satisfy the API.
58 */
59 debug3("%s: preparing capsicum sandbox", __func__);
60 box = xcalloc(1, sizeof(*box));
61 box->monitor = monitor;
62 box->child_pid = 0;
63
64 return box;
65}
66
67void
68ssh_sandbox_child(struct ssh_sandbox *box)
69{
70 struct rlimit rl_zero;
71 cap_rights_t rights;
72
73 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
74
75 if (setrlimit(RLIMIT_FSIZE, &rl_zero) == -1)
76 fatal("%s: setrlimit(RLIMIT_FSIZE, { 0, 0 }): %s",
77 __func__, strerror(errno));
78#ifndef SANDBOX_SKIP_RLIMIT_NOFILE
79 if (setrlimit(RLIMIT_NOFILE, &rl_zero) == -1)
80 fatal("%s: setrlimit(RLIMIT_NOFILE, { 0, 0 }): %s",
81 __func__, strerror(errno));
82#endif
83 if (setrlimit(RLIMIT_NPROC, &rl_zero) == -1)
84 fatal("%s: setrlimit(RLIMIT_NPROC, { 0, 0 }): %s",
85 __func__, strerror(errno));
86
87 cap_rights_init(&rights);
88
89 if (cap_rights_limit(STDIN_FILENO, &rights) < 0 && errno != ENOSYS)
90 fatal("can't limit stdin: %m");
91 if (cap_rights_limit(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS)
92 fatal("can't limit stdout: %m");
93 if (cap_rights_limit(STDERR_FILENO, &rights) < 0 && errno != ENOSYS)
94 fatal("can't limit stderr: %m");
95
96 cap_rights_init(&rights, CAP_READ, CAP_WRITE);
97 if (cap_rights_limit(box->monitor->m_recvfd, &rights) == -1)
98 fatal("%s: failed to limit the network socket", __func__);
99 cap_rights_init(&rights, CAP_WRITE);
100 if (cap_rights_limit(box->monitor->m_log_sendfd, &rights) == -1)
101 fatal("%s: failed to limit the logging socket", __func__);
102 if (cap_enter() < 0 && errno != ENOSYS)
103 fatal("%s: failed to enter capability mode", __func__);
104
105}
106
107void
108ssh_sandbox_parent_finish(struct ssh_sandbox *box)
109{
110 free(box);
111 debug3("%s: finished", __func__);
112}
113
114void
115ssh_sandbox_parent_preauth(struct ssh_sandbox *box, pid_t child_pid)
116{
117 box->child_pid = child_pid;
118}
119
120#endif /* SANDBOX_CAPSICUM */
diff --git a/sandbox-darwin.c b/sandbox-darwin.c
index 69901ef14..35f0c4d1a 100644
--- a/sandbox-darwin.c
+++ b/sandbox-darwin.c
@@ -40,7 +40,7 @@ struct ssh_sandbox {
40}; 40};
41 41
42struct ssh_sandbox * 42struct ssh_sandbox *
43ssh_sandbox_init(void) 43ssh_sandbox_init(struct monitor *monitor)
44{ 44{
45 struct ssh_sandbox *box; 45 struct ssh_sandbox *box;
46 46
diff --git a/sandbox-null.c b/sandbox-null.c
index 29fa9669f..d4cb9188b 100644
--- a/sandbox-null.c
+++ b/sandbox-null.c
@@ -39,7 +39,7 @@ struct ssh_sandbox {
39}; 39};
40 40
41struct ssh_sandbox * 41struct ssh_sandbox *
42ssh_sandbox_init(void) 42ssh_sandbox_init(struct monitor *monitor)
43{ 43{
44 struct ssh_sandbox *box; 44 struct ssh_sandbox *box;
45 45
diff --git a/sandbox-rlimit.c b/sandbox-rlimit.c
index a00386337..bba80778b 100644
--- a/sandbox-rlimit.c
+++ b/sandbox-rlimit.c
@@ -42,7 +42,7 @@ struct ssh_sandbox {
42}; 42};
43 43
44struct ssh_sandbox * 44struct ssh_sandbox *
45ssh_sandbox_init(void) 45ssh_sandbox_init(struct monitor *monitor)
46{ 46{
47 struct ssh_sandbox *box; 47 struct ssh_sandbox *box;
48 48
@@ -69,9 +69,11 @@ ssh_sandbox_child(struct ssh_sandbox *box)
69 fatal("%s: setrlimit(RLIMIT_FSIZE, { 0, 0 }): %s", 69 fatal("%s: setrlimit(RLIMIT_FSIZE, { 0, 0 }): %s",
70 __func__, strerror(errno)); 70 __func__, strerror(errno));
71#endif 71#endif
72#ifndef SANDBOX_SKIP_RLIMIT_NOFILE
72 if (setrlimit(RLIMIT_NOFILE, &rl_zero) == -1) 73 if (setrlimit(RLIMIT_NOFILE, &rl_zero) == -1)
73 fatal("%s: setrlimit(RLIMIT_NOFILE, { 0, 0 }): %s", 74 fatal("%s: setrlimit(RLIMIT_NOFILE, { 0, 0 }): %s",
74 __func__, strerror(errno)); 75 __func__, strerror(errno));
76#endif
75#ifdef HAVE_RLIMIT_NPROC 77#ifdef HAVE_RLIMIT_NPROC
76 if (setrlimit(RLIMIT_NPROC, &rl_zero) == -1) 78 if (setrlimit(RLIMIT_NPROC, &rl_zero) == -1)
77 fatal("%s: setrlimit(RLIMIT_NPROC, { 0, 0 }): %s", 79 fatal("%s: setrlimit(RLIMIT_NPROC, { 0, 0 }): %s",
diff --git a/sandbox-seccomp-filter.c b/sandbox-seccomp-filter.c
index cc1465305..2f73067e1 100644
--- a/sandbox-seccomp-filter.c
+++ b/sandbox-seccomp-filter.c
@@ -132,7 +132,7 @@ struct ssh_sandbox {
132}; 132};
133 133
134struct ssh_sandbox * 134struct ssh_sandbox *
135ssh_sandbox_init(void) 135ssh_sandbox_init(struct monitor *monitor)
136{ 136{
137 struct ssh_sandbox *box; 137 struct ssh_sandbox *box;
138 138
diff --git a/sandbox-systrace.c b/sandbox-systrace.c
index cc0db46c4..53fbd47cb 100644
--- a/sandbox-systrace.c
+++ b/sandbox-systrace.c
@@ -78,7 +78,7 @@ struct ssh_sandbox {
78}; 78};
79 79
80struct ssh_sandbox * 80struct ssh_sandbox *
81ssh_sandbox_init(void) 81ssh_sandbox_init(struct monitor *monitor)
82{ 82{
83 struct ssh_sandbox *box; 83 struct ssh_sandbox *box;
84 84
diff --git a/sc25519.c b/sc25519.c
new file mode 100644
index 000000000..1568d9a58
--- /dev/null
+++ b/sc25519.c
@@ -0,0 +1,308 @@
1/* $OpenBSD: sc25519.c,v 1.3 2013/12/09 11:03:45 markus Exp $ */
2
3/*
4 * Public Domain, Authors: Daniel J. Bernstein, Niels Duif, Tanja Lange,
5 * Peter Schwabe, Bo-Yin Yang.
6 * Copied from supercop-20130419/crypto_sign/ed25519/ref/sc25519.c
7 */
8
9#include "includes.h"
10
11#include "sc25519.h"
12
13/*Arithmetic modulo the group order m = 2^252 + 27742317777372353535851937790883648493 = 7237005577332262213973186563042994240857116359379907606001950938285454250989 */
14
15static const crypto_uint32 m[32] = {0xED, 0xD3, 0xF5, 0x5C, 0x1A, 0x63, 0x12, 0x58, 0xD6, 0x9C, 0xF7, 0xA2, 0xDE, 0xF9, 0xDE, 0x14,
16 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10};
17
18static const crypto_uint32 mu[33] = {0x1B, 0x13, 0x2C, 0x0A, 0xA3, 0xE5, 0x9C, 0xED, 0xA7, 0x29, 0x63, 0x08, 0x5D, 0x21, 0x06, 0x21,
19 0xEB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F};
20
21static crypto_uint32 lt(crypto_uint32 a,crypto_uint32 b) /* 16-bit inputs */
22{
23 unsigned int x = a;
24 x -= (unsigned int) b; /* 0..65535: no; 4294901761..4294967295: yes */
25 x >>= 31; /* 0: no; 1: yes */
26 return x;
27}
28
29/* Reduce coefficients of r before calling reduce_add_sub */
30static void reduce_add_sub(sc25519 *r)
31{
32 crypto_uint32 pb = 0;
33 crypto_uint32 b;
34 crypto_uint32 mask;
35 int i;
36 unsigned char t[32];
37
38 for(i=0;i<32;i++)
39 {
40 pb += m[i];
41 b = lt(r->v[i],pb);
42 t[i] = r->v[i]-pb+(b<<8);
43 pb = b;
44 }
45 mask = b - 1;
46 for(i=0;i<32;i++)
47 r->v[i] ^= mask & (r->v[i] ^ t[i]);
48}
49
50/* Reduce coefficients of x before calling barrett_reduce */
51static void barrett_reduce(sc25519 *r, const crypto_uint32 x[64])
52{
53 /* See HAC, Alg. 14.42 */
54 int i,j;
55 crypto_uint32 q2[66];
56 crypto_uint32 *q3 = q2 + 33;
57 crypto_uint32 r1[33];
58 crypto_uint32 r2[33];
59 crypto_uint32 carry;
60 crypto_uint32 pb = 0;
61 crypto_uint32 b;
62
63 for (i = 0;i < 66;++i) q2[i] = 0;
64 for (i = 0;i < 33;++i) r2[i] = 0;
65
66 for(i=0;i<33;i++)
67 for(j=0;j<33;j++)
68 if(i+j >= 31) q2[i+j] += mu[i]*x[j+31];
69 carry = q2[31] >> 8;
70 q2[32] += carry;
71 carry = q2[32] >> 8;
72 q2[33] += carry;
73
74 for(i=0;i<33;i++)r1[i] = x[i];
75 for(i=0;i<32;i++)
76 for(j=0;j<33;j++)
77 if(i+j < 33) r2[i+j] += m[i]*q3[j];
78
79 for(i=0;i<32;i++)
80 {
81 carry = r2[i] >> 8;
82 r2[i+1] += carry;
83 r2[i] &= 0xff;
84 }
85
86 for(i=0;i<32;i++)
87 {
88 pb += r2[i];
89 b = lt(r1[i],pb);
90 r->v[i] = r1[i]-pb+(b<<8);
91 pb = b;
92 }
93
94 /* XXX: Can it really happen that r<0?, See HAC, Alg 14.42, Step 3
95 * If so: Handle it here!
96 */
97
98 reduce_add_sub(r);
99 reduce_add_sub(r);
100}
101
102void sc25519_from32bytes(sc25519 *r, const unsigned char x[32])
103{
104 int i;
105 crypto_uint32 t[64];
106 for(i=0;i<32;i++) t[i] = x[i];
107 for(i=32;i<64;++i) t[i] = 0;
108 barrett_reduce(r, t);
109}
110
111void shortsc25519_from16bytes(shortsc25519 *r, const unsigned char x[16])
112{
113 int i;
114 for(i=0;i<16;i++) r->v[i] = x[i];
115}
116
117void sc25519_from64bytes(sc25519 *r, const unsigned char x[64])
118{
119 int i;
120 crypto_uint32 t[64];
121 for(i=0;i<64;i++) t[i] = x[i];
122 barrett_reduce(r, t);
123}
124
125void sc25519_from_shortsc(sc25519 *r, const shortsc25519 *x)
126{
127 int i;
128 for(i=0;i<16;i++)
129 r->v[i] = x->v[i];
130 for(i=0;i<16;i++)
131 r->v[16+i] = 0;
132}
133
134void sc25519_to32bytes(unsigned char r[32], const sc25519 *x)
135{
136 int i;
137 for(i=0;i<32;i++) r[i] = x->v[i];
138}
139
140int sc25519_iszero_vartime(const sc25519 *x)
141{
142 int i;
143 for(i=0;i<32;i++)
144 if(x->v[i] != 0) return 0;
145 return 1;
146}
147
148int sc25519_isshort_vartime(const sc25519 *x)
149{
150 int i;
151 for(i=31;i>15;i--)
152 if(x->v[i] != 0) return 0;
153 return 1;
154}
155
156int sc25519_lt_vartime(const sc25519 *x, const sc25519 *y)
157{
158 int i;
159 for(i=31;i>=0;i--)
160 {
161 if(x->v[i] < y->v[i]) return 1;
162 if(x->v[i] > y->v[i]) return 0;
163 }
164 return 0;
165}
166
167void sc25519_add(sc25519 *r, const sc25519 *x, const sc25519 *y)
168{
169 int i, carry;
170 for(i=0;i<32;i++) r->v[i] = x->v[i] + y->v[i];
171 for(i=0;i<31;i++)
172 {
173 carry = r->v[i] >> 8;
174 r->v[i+1] += carry;
175 r->v[i] &= 0xff;
176 }
177 reduce_add_sub(r);
178}
179
180void sc25519_sub_nored(sc25519 *r, const sc25519 *x, const sc25519 *y)
181{
182 crypto_uint32 b = 0;
183 crypto_uint32 t;
184 int i;
185 for(i=0;i<32;i++)
186 {
187 t = x->v[i] - y->v[i] - b;
188 r->v[i] = t & 255;
189 b = (t >> 8) & 1;
190 }
191}
192
193void sc25519_mul(sc25519 *r, const sc25519 *x, const sc25519 *y)
194{
195 int i,j,carry;
196 crypto_uint32 t[64];
197 for(i=0;i<64;i++)t[i] = 0;
198
199 for(i=0;i<32;i++)
200 for(j=0;j<32;j++)
201 t[i+j] += x->v[i] * y->v[j];
202
203 /* Reduce coefficients */
204 for(i=0;i<63;i++)
205 {
206 carry = t[i] >> 8;
207 t[i+1] += carry;
208 t[i] &= 0xff;
209 }
210
211 barrett_reduce(r, t);
212}
213
214void sc25519_mul_shortsc(sc25519 *r, const sc25519 *x, const shortsc25519 *y)
215{
216 sc25519 t;
217 sc25519_from_shortsc(&t, y);
218 sc25519_mul(r, x, &t);
219}
220
221void sc25519_window3(signed char r[85], const sc25519 *s)
222{
223 char carry;
224 int i;
225 for(i=0;i<10;i++)
226 {
227 r[8*i+0] = s->v[3*i+0] & 7;
228 r[8*i+1] = (s->v[3*i+0] >> 3) & 7;
229 r[8*i+2] = (s->v[3*i+0] >> 6) & 7;
230 r[8*i+2] ^= (s->v[3*i+1] << 2) & 7;
231 r[8*i+3] = (s->v[3*i+1] >> 1) & 7;
232 r[8*i+4] = (s->v[3*i+1] >> 4) & 7;
233 r[8*i+5] = (s->v[3*i+1] >> 7) & 7;
234 r[8*i+5] ^= (s->v[3*i+2] << 1) & 7;
235 r[8*i+6] = (s->v[3*i+2] >> 2) & 7;
236 r[8*i+7] = (s->v[3*i+2] >> 5) & 7;
237 }
238 r[8*i+0] = s->v[3*i+0] & 7;
239 r[8*i+1] = (s->v[3*i+0] >> 3) & 7;
240 r[8*i+2] = (s->v[3*i+0] >> 6) & 7;
241 r[8*i+2] ^= (s->v[3*i+1] << 2) & 7;
242 r[8*i+3] = (s->v[3*i+1] >> 1) & 7;
243 r[8*i+4] = (s->v[3*i+1] >> 4) & 7;
244
245 /* Making it signed */
246 carry = 0;
247 for(i=0;i<84;i++)
248 {
249 r[i] += carry;
250 r[i+1] += r[i] >> 3;
251 r[i] &= 7;
252 carry = r[i] >> 2;
253 r[i] -= carry<<3;
254 }
255 r[84] += carry;
256}
257
258void sc25519_window5(signed char r[51], const sc25519 *s)
259{
260 char carry;
261 int i;
262 for(i=0;i<6;i++)
263 {
264 r[8*i+0] = s->v[5*i+0] & 31;
265 r[8*i+1] = (s->v[5*i+0] >> 5) & 31;
266 r[8*i+1] ^= (s->v[5*i+1] << 3) & 31;
267 r[8*i+2] = (s->v[5*i+1] >> 2) & 31;
268 r[8*i+3] = (s->v[5*i+1] >> 7) & 31;
269 r[8*i+3] ^= (s->v[5*i+2] << 1) & 31;
270 r[8*i+4] = (s->v[5*i+2] >> 4) & 31;
271 r[8*i+4] ^= (s->v[5*i+3] << 4) & 31;
272 r[8*i+5] = (s->v[5*i+3] >> 1) & 31;
273 r[8*i+6] = (s->v[5*i+3] >> 6) & 31;
274 r[8*i+6] ^= (s->v[5*i+4] << 2) & 31;
275 r[8*i+7] = (s->v[5*i+4] >> 3) & 31;
276 }
277 r[8*i+0] = s->v[5*i+0] & 31;
278 r[8*i+1] = (s->v[5*i+0] >> 5) & 31;
279 r[8*i+1] ^= (s->v[5*i+1] << 3) & 31;
280 r[8*i+2] = (s->v[5*i+1] >> 2) & 31;
281
282 /* Making it signed */
283 carry = 0;
284 for(i=0;i<50;i++)
285 {
286 r[i] += carry;
287 r[i+1] += r[i] >> 5;
288 r[i] &= 31;
289 carry = r[i] >> 4;
290 r[i] -= carry<<5;
291 }
292 r[50] += carry;
293}
294
295void sc25519_2interleave2(unsigned char r[127], const sc25519 *s1, const sc25519 *s2)
296{
297 int i;
298 for(i=0;i<31;i++)
299 {
300 r[4*i] = ( s1->v[i] & 3) ^ (( s2->v[i] & 3) << 2);
301 r[4*i+1] = ((s1->v[i] >> 2) & 3) ^ (((s2->v[i] >> 2) & 3) << 2);
302 r[4*i+2] = ((s1->v[i] >> 4) & 3) ^ (((s2->v[i] >> 4) & 3) << 2);
303 r[4*i+3] = ((s1->v[i] >> 6) & 3) ^ (((s2->v[i] >> 6) & 3) << 2);
304 }
305 r[124] = ( s1->v[31] & 3) ^ (( s2->v[31] & 3) << 2);
306 r[125] = ((s1->v[31] >> 2) & 3) ^ (((s2->v[31] >> 2) & 3) << 2);
307 r[126] = ((s1->v[31] >> 4) & 3) ^ (((s2->v[31] >> 4) & 3) << 2);
308}
diff --git a/sc25519.h b/sc25519.h
new file mode 100644
index 000000000..a2c15d5ff
--- /dev/null
+++ b/sc25519.h
@@ -0,0 +1,80 @@
1/* $OpenBSD: sc25519.h,v 1.3 2013/12/09 11:03:45 markus Exp $ */
2
3/*
4 * Public Domain, Authors: Daniel J. Bernstein, Niels Duif, Tanja Lange,
5 * Peter Schwabe, Bo-Yin Yang.
6 * Copied from supercop-20130419/crypto_sign/ed25519/ref/sc25519.h
7 */
8
9#ifndef SC25519_H
10#define SC25519_H
11
12#include "crypto_api.h"
13
14#define sc25519 crypto_sign_ed25519_ref_sc25519
15#define shortsc25519 crypto_sign_ed25519_ref_shortsc25519
16#define sc25519_from32bytes crypto_sign_ed25519_ref_sc25519_from32bytes
17#define shortsc25519_from16bytes crypto_sign_ed25519_ref_shortsc25519_from16bytes
18#define sc25519_from64bytes crypto_sign_ed25519_ref_sc25519_from64bytes
19#define sc25519_from_shortsc crypto_sign_ed25519_ref_sc25519_from_shortsc
20#define sc25519_to32bytes crypto_sign_ed25519_ref_sc25519_to32bytes
21#define sc25519_iszero_vartime crypto_sign_ed25519_ref_sc25519_iszero_vartime
22#define sc25519_isshort_vartime crypto_sign_ed25519_ref_sc25519_isshort_vartime
23#define sc25519_lt_vartime crypto_sign_ed25519_ref_sc25519_lt_vartime
24#define sc25519_add crypto_sign_ed25519_ref_sc25519_add
25#define sc25519_sub_nored crypto_sign_ed25519_ref_sc25519_sub_nored
26#define sc25519_mul crypto_sign_ed25519_ref_sc25519_mul
27#define sc25519_mul_shortsc crypto_sign_ed25519_ref_sc25519_mul_shortsc
28#define sc25519_window3 crypto_sign_ed25519_ref_sc25519_window3
29#define sc25519_window5 crypto_sign_ed25519_ref_sc25519_window5
30#define sc25519_2interleave2 crypto_sign_ed25519_ref_sc25519_2interleave2
31
32typedef struct
33{
34 crypto_uint32 v[32];
35}
36sc25519;
37
38typedef struct
39{
40 crypto_uint32 v[16];
41}
42shortsc25519;
43
44void sc25519_from32bytes(sc25519 *r, const unsigned char x[32]);
45
46void shortsc25519_from16bytes(shortsc25519 *r, const unsigned char x[16]);
47
48void sc25519_from64bytes(sc25519 *r, const unsigned char x[64]);
49
50void sc25519_from_shortsc(sc25519 *r, const shortsc25519 *x);
51
52void sc25519_to32bytes(unsigned char r[32], const sc25519 *x);
53
54int sc25519_iszero_vartime(const sc25519 *x);
55
56int sc25519_isshort_vartime(const sc25519 *x);
57
58int sc25519_lt_vartime(const sc25519 *x, const sc25519 *y);
59
60void sc25519_add(sc25519 *r, const sc25519 *x, const sc25519 *y);
61
62void sc25519_sub_nored(sc25519 *r, const sc25519 *x, const sc25519 *y);
63
64void sc25519_mul(sc25519 *r, const sc25519 *x, const sc25519 *y);
65
66void sc25519_mul_shortsc(sc25519 *r, const sc25519 *x, const shortsc25519 *y);
67
68/* Convert s into a representation of the form \sum_{i=0}^{84}r[i]2^3
69 * with r[i] in {-4,...,3}
70 */
71void sc25519_window3(signed char r[85], const sc25519 *s);
72
73/* Convert s into a representation of the form \sum_{i=0}^{50}r[i]2^5
74 * with r[i] in {-16,...,15}
75 */
76void sc25519_window5(signed char r[51], const sc25519 *s);
77
78void sc25519_2interleave2(unsigned char r[127], const sc25519 *s1, const sc25519 *s2);
79
80#endif
diff --git a/schnorr.c b/schnorr.c
index 93822fed4..aa3a57770 100644
--- a/schnorr.c
+++ b/schnorr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: schnorr.c,v 1.8 2013/11/08 00:39:15 djm Exp $ */ 1/* $OpenBSD: schnorr.c,v 1.9 2014/01/09 23:20:00 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2008 Damien Miller. All rights reserved. 3 * Copyright (c) 2008 Damien Miller. All rights reserved.
4 * 4 *
@@ -41,6 +41,7 @@
41#include "log.h" 41#include "log.h"
42 42
43#include "schnorr.h" 43#include "schnorr.h"
44#include "digest.h"
44 45
45#include "openbsd-compat/openssl-compat.h" 46#include "openbsd-compat/openssl-compat.h"
46 47
@@ -57,12 +58,12 @@
57 58
58/* 59/*
59 * Calculate hash component of Schnorr signature H(g || g^v || g^x || id) 60 * Calculate hash component of Schnorr signature H(g || g^v || g^x || id)
60 * using the hash function defined by "evp_md". Returns signature as 61 * using the hash function defined by "hash_alg". Returns signature as
61 * bignum or NULL on error. 62 * bignum or NULL on error.
62 */ 63 */
63static BIGNUM * 64static BIGNUM *
64schnorr_hash(const BIGNUM *p, const BIGNUM *q, const BIGNUM *g, 65schnorr_hash(const BIGNUM *p, const BIGNUM *q, const BIGNUM *g,
65 const EVP_MD *evp_md, const BIGNUM *g_v, const BIGNUM *g_x, 66 int hash_alg, const BIGNUM *g_v, const BIGNUM *g_x,
66 const u_char *id, u_int idlen) 67 const u_char *id, u_int idlen)
67{ 68{
68 u_char *digest; 69 u_char *digest;
@@ -88,7 +89,7 @@ schnorr_hash(const BIGNUM *p, const BIGNUM *q, const BIGNUM *g,
88 89
89 SCHNORR_DEBUG_BUF((buffer_ptr(&b), buffer_len(&b), 90 SCHNORR_DEBUG_BUF((buffer_ptr(&b), buffer_len(&b),
90 "%s: hashblob", __func__)); 91 "%s: hashblob", __func__));
91 if (hash_buffer(buffer_ptr(&b), buffer_len(&b), evp_md, 92 if (hash_buffer(buffer_ptr(&b), buffer_len(&b), hash_alg,
92 &digest, &digest_len) != 0) { 93 &digest, &digest_len) != 0) {
93 error("%s: hash_buffer", __func__); 94 error("%s: hash_buffer", __func__);
94 goto out; 95 goto out;
@@ -113,7 +114,7 @@ schnorr_hash(const BIGNUM *p, const BIGNUM *q, const BIGNUM *g,
113/* 114/*
114 * Generate Schnorr signature to prove knowledge of private value 'x' used 115 * Generate Schnorr signature to prove knowledge of private value 'x' used
115 * in public exponent g^x, under group defined by 'grp_p', 'grp_q' and 'grp_g' 116 * in public exponent g^x, under group defined by 'grp_p', 'grp_q' and 'grp_g'
116 * using the hash function "evp_md". 117 * using the hash function "hash_alg".
117 * 'idlen' bytes from 'id' will be included in the signature hash as an anti- 118 * 'idlen' bytes from 'id' will be included in the signature hash as an anti-
118 * replay salt. 119 * replay salt.
119 * 120 *
@@ -123,7 +124,7 @@ schnorr_hash(const BIGNUM *p, const BIGNUM *q, const BIGNUM *g,
123 */ 124 */
124int 125int
125schnorr_sign(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g, 126schnorr_sign(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
126 const EVP_MD *evp_md, const BIGNUM *x, const BIGNUM *g_x, 127 int hash_alg, const BIGNUM *x, const BIGNUM *g_x,
127 const u_char *id, u_int idlen, BIGNUM **r_p, BIGNUM **e_p) 128 const u_char *id, u_int idlen, BIGNUM **r_p, BIGNUM **e_p)
128{ 129{
129 int success = -1; 130 int success = -1;
@@ -173,7 +174,7 @@ schnorr_sign(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
173 SCHNORR_DEBUG_BN((g_v, "%s: g_v = ", __func__)); 174 SCHNORR_DEBUG_BN((g_v, "%s: g_v = ", __func__));
174 175
175 /* h = H(g || g^v || g^x || id) */ 176 /* h = H(g || g^v || g^x || id) */
176 if ((h = schnorr_hash(grp_p, grp_q, grp_g, evp_md, g_v, g_x, 177 if ((h = schnorr_hash(grp_p, grp_q, grp_g, hash_alg, g_v, g_x,
177 id, idlen)) == NULL) { 178 id, idlen)) == NULL) {
178 error("%s: schnorr_hash failed", __func__); 179 error("%s: schnorr_hash failed", __func__);
179 goto out; 180 goto out;
@@ -223,7 +224,7 @@ schnorr_sign_buf(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
223 Buffer b; 224 Buffer b;
224 BIGNUM *r, *e; 225 BIGNUM *r, *e;
225 226
226 if (schnorr_sign(grp_p, grp_q, grp_g, EVP_sha256(), 227 if (schnorr_sign(grp_p, grp_q, grp_g, SSH_DIGEST_SHA256,
227 x, g_x, id, idlen, &r, &e) != 0) 228 x, g_x, id, idlen, &r, &e) != 0)
228 return -1; 229 return -1;
229 230
@@ -248,13 +249,13 @@ schnorr_sign_buf(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
248/* 249/*
249 * Verify Schnorr signature { r (v - xh mod q), e (g^v mod p) } against 250 * Verify Schnorr signature { r (v - xh mod q), e (g^v mod p) } against
250 * public exponent g_x (g^x) under group defined by 'grp_p', 'grp_q' and 251 * public exponent g_x (g^x) under group defined by 'grp_p', 'grp_q' and
251 * 'grp_g' using hash "evp_md". 252 * 'grp_g' using hash "hash_alg".
252 * Signature hash will be salted with 'idlen' bytes from 'id'. 253 * Signature hash will be salted with 'idlen' bytes from 'id'.
253 * Returns -1 on failure, 0 on incorrect signature or 1 on matching signature. 254 * Returns -1 on failure, 0 on incorrect signature or 1 on matching signature.
254 */ 255 */
255int 256int
256schnorr_verify(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g, 257schnorr_verify(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
257 const EVP_MD *evp_md, const BIGNUM *g_x, const u_char *id, u_int idlen, 258 int hash_alg, const BIGNUM *g_x, const u_char *id, u_int idlen,
258 const BIGNUM *r, const BIGNUM *e) 259 const BIGNUM *r, const BIGNUM *e)
259{ 260{
260 int success = -1; 261 int success = -1;
@@ -302,7 +303,7 @@ schnorr_verify(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
302 303
303 SCHNORR_DEBUG_BN((g_xh, "%s: g_xh = ", __func__)); 304 SCHNORR_DEBUG_BN((g_xh, "%s: g_xh = ", __func__));
304 /* h = H(g || g^v || g^x || id) */ 305 /* h = H(g || g^v || g^x || id) */
305 if ((h = schnorr_hash(grp_p, grp_q, grp_g, evp_md, e, g_x, 306 if ((h = schnorr_hash(grp_p, grp_q, grp_g, hash_alg, e, g_x,
306 id, idlen)) == NULL) { 307 id, idlen)) == NULL) {
307 error("%s: schnorr_hash failed", __func__); 308 error("%s: schnorr_hash failed", __func__);
308 goto out; 309 goto out;
@@ -385,7 +386,7 @@ schnorr_verify_buf(const BIGNUM *grp_p, const BIGNUM *grp_q,
385 goto out; 386 goto out;
386 } 387 }
387 388
388 ret = schnorr_verify(grp_p, grp_q, grp_g, EVP_sha256(), 389 ret = schnorr_verify(grp_p, grp_q, grp_g, SSH_DIGEST_SHA256,
389 g_x, id, idlen, r, e); 390 g_x, id, idlen, r, e);
390 out: 391 out:
391 BN_clear_free(e); 392 BN_clear_free(e);
@@ -443,43 +444,33 @@ bn_rand_range_gt_one(const BIGNUM *high)
443 return NULL; 444 return NULL;
444} 445}
445 446
447/* XXX convert all callers of this to use ssh_digest_memory() directly */
446/* 448/*
447 * Hash contents of buffer 'b' with hash 'md'. Returns 0 on success, 449 * Hash contents of buffer 'b' with hash 'md'. Returns 0 on success,
448 * with digest via 'digestp' (caller to free) and length via 'lenp'. 450 * with digest via 'digestp' (caller to free) and length via 'lenp'.
449 * Returns -1 on failure. 451 * Returns -1 on failure.
450 */ 452 */
451int 453int
452hash_buffer(const u_char *buf, u_int len, const EVP_MD *md, 454hash_buffer(const u_char *buf, u_int len, int hash_alg,
453 u_char **digestp, u_int *lenp) 455 u_char **digestp, u_int *lenp)
454{ 456{
455 u_char digest[EVP_MAX_MD_SIZE]; 457 u_char digest[SSH_DIGEST_MAX_LENGTH];
456 u_int digest_len; 458 u_int digest_len = ssh_digest_bytes(hash_alg);
457 EVP_MD_CTX evp_md_ctx;
458 int success = -1;
459 459
460 EVP_MD_CTX_init(&evp_md_ctx); 460 if (digest_len == 0) {
461 461 error("%s: invalid hash", __func__);
462 if (EVP_DigestInit_ex(&evp_md_ctx, md, NULL) != 1) { 462 return -1;
463 error("%s: EVP_DigestInit_ex", __func__);
464 goto out;
465 }
466 if (EVP_DigestUpdate(&evp_md_ctx, buf, len) != 1) {
467 error("%s: EVP_DigestUpdate", __func__);
468 goto out;
469 } 463 }
470 if (EVP_DigestFinal_ex(&evp_md_ctx, digest, &digest_len) != 1) { 464 if (ssh_digest_memory(hash_alg, buf, len, digest, digest_len) != 0) {
471 error("%s: EVP_DigestFinal_ex", __func__); 465 error("%s: digest_memory failed", __func__);
472 goto out; 466 return -1;
473 } 467 }
474 *digestp = xmalloc(digest_len); 468 *digestp = xmalloc(digest_len);
475 *lenp = digest_len; 469 *lenp = digest_len;
476 memcpy(*digestp, digest, *lenp); 470 memcpy(*digestp, digest, *lenp);
477 success = 0;
478 out:
479 EVP_MD_CTX_cleanup(&evp_md_ctx);
480 bzero(digest, sizeof(digest)); 471 bzero(digest, sizeof(digest));
481 digest_len = 0; 472 digest_len = 0;
482 return success; 473 return 0;
483} 474}
484 475
485/* print formatted string followed by bignum */ 476/* print formatted string followed by bignum */
diff --git a/schnorr.h b/schnorr.h
index 9730b47ce..e2405c102 100644
--- a/schnorr.h
+++ b/schnorr.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: schnorr.h,v 1.1 2009/03/05 07:18:19 djm Exp $ */ 1/* $OpenBSD: schnorr.h,v 1.2 2014/01/09 23:20:00 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2009 Damien Miller. All rights reserved. 3 * Copyright (c) 2009 Damien Miller. All rights reserved.
4 * 4 *
@@ -27,7 +27,7 @@ struct modp_group {
27}; 27};
28 28
29BIGNUM *bn_rand_range_gt_one(const BIGNUM *high); 29BIGNUM *bn_rand_range_gt_one(const BIGNUM *high);
30int hash_buffer(const u_char *, u_int, const EVP_MD *, u_char **, u_int *); 30int hash_buffer(const u_char *, u_int, int, u_char **, u_int *);
31void debug3_bn(const BIGNUM *, const char *, ...) 31void debug3_bn(const BIGNUM *, const char *, ...)
32 __attribute__((__nonnull__ (2))) 32 __attribute__((__nonnull__ (2)))
33 __attribute__((format(printf, 2, 3))); 33 __attribute__((format(printf, 2, 3)));
@@ -40,7 +40,7 @@ void modp_group_free(struct modp_group *);
40/* Signature and verification functions */ 40/* Signature and verification functions */
41int 41int
42schnorr_sign(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g, 42schnorr_sign(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
43 const EVP_MD *evp_md, const BIGNUM *x, const BIGNUM *g_x, 43 int hash_alg, const BIGNUM *x, const BIGNUM *g_x,
44 const u_char *id, u_int idlen, BIGNUM **r_p, BIGNUM **e_p); 44 const u_char *id, u_int idlen, BIGNUM **r_p, BIGNUM **e_p);
45int 45int
46schnorr_sign_buf(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g, 46schnorr_sign_buf(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
@@ -48,7 +48,7 @@ schnorr_sign_buf(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
48 u_char **sig, u_int *siglen); 48 u_char **sig, u_int *siglen);
49int 49int
50schnorr_verify(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g, 50schnorr_verify(const BIGNUM *grp_p, const BIGNUM *grp_q, const BIGNUM *grp_g,
51 const EVP_MD *evp_md, const BIGNUM *g_x, const u_char *id, u_int idlen, 51 int hash_alg, const BIGNUM *g_x, const u_char *id, u_int idlen,
52 const BIGNUM *r, const BIGNUM *e); 52 const BIGNUM *r, const BIGNUM *e);
53int 53int
54schnorr_verify_buf(const BIGNUM *grp_p, const BIGNUM *grp_q, 54schnorr_verify_buf(const BIGNUM *grp_p, const BIGNUM *grp_q,
diff --git a/scp.0 b/scp.0
index fe7087bc4..ced71546b 100644
--- a/scp.0
+++ b/scp.0
@@ -67,6 +67,11 @@ DESCRIPTION
67 AddressFamily 67 AddressFamily
68 BatchMode 68 BatchMode
69 BindAddress 69 BindAddress
70 CanonicalDomains
71 CanonicalizeFallbackLocal
72 CanonicalizeHostname
73 CanonicalizeMaxDots
74 CanonicalizePermittedCNAMEs
70 ChallengeResponseAuthentication 75 ChallengeResponseAuthentication
71 CheckHostIP 76 CheckHostIP
72 Cipher 77 Cipher
@@ -155,4 +160,4 @@ AUTHORS
155 Timo Rinne <tri@iki.fi> 160 Timo Rinne <tri@iki.fi>
156 Tatu Ylonen <ylo@cs.hut.fi> 161 Tatu Ylonen <ylo@cs.hut.fi>
157 162
158OpenBSD 5.4 July 16, 2013 OpenBSD 5.4 163OpenBSD 5.4 October 20, 2013 OpenBSD 5.4
diff --git a/scp.1 b/scp.1
index c83012c92..3b67cff0e 100644
--- a/scp.1
+++ b/scp.1
@@ -8,9 +8,9 @@
8.\" 8.\"
9.\" Created: Sun May 7 00:14:37 1995 ylo 9.\" Created: Sun May 7 00:14:37 1995 ylo
10.\" 10.\"
11.\" $OpenBSD: scp.1,v 1.59 2013/07/16 00:07:52 schwarze Exp $ 11.\" $OpenBSD: scp.1,v 1.61 2013/10/20 09:51:26 djm Exp $
12.\" 12.\"
13.Dd $Mdocdate: July 16 2013 $ 13.Dd $Mdocdate: October 20 2013 $
14.Dt SCP 1 14.Dt SCP 1
15.Os 15.Os
16.Sh NAME 16.Sh NAME
@@ -130,6 +130,11 @@ For full details of the options listed below, and their possible values, see
130.It AddressFamily 130.It AddressFamily
131.It BatchMode 131.It BatchMode
132.It BindAddress 132.It BindAddress
133.It CanonicalDomains
134.It CanonicalizeFallbackLocal
135.It CanonicalizeHostname
136.It CanonicalizeMaxDots
137.It CanonicalizePermittedCNAMEs
133.It ChallengeResponseAuthentication 138.It ChallengeResponseAuthentication
134.It CheckHostIP 139.It CheckHostIP
135.It Cipher 140.It Cipher
@@ -232,8 +237,9 @@ debugging connection, authentication, and configuration problems.
232.Nm 237.Nm
233is based on the 238is based on the
234.Xr rcp 1 239.Xr rcp 1
235program in BSD source code from the Regents of the University of 240program in
236California. 241.Bx
242source code from the Regents of the University of California.
237.Sh AUTHORS 243.Sh AUTHORS
238.An Timo Rinne Aq Mt tri@iki.fi 244.An Timo Rinne Aq Mt tri@iki.fi
239.An Tatu Ylonen Aq Mt ylo@cs.hut.fi 245.An Tatu Ylonen Aq Mt ylo@cs.hut.fi
diff --git a/scp.c b/scp.c
index 28ded5e9a..18d3b1dc9 100644
--- a/scp.c
+++ b/scp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: scp.c,v 1.178 2013/06/22 06:31:57 djm Exp $ */ 1/* $OpenBSD: scp.c,v 1.179 2013/11/20 20:53:10 deraadt 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).
@@ -1023,7 +1023,7 @@ sink(int argc, char **argv)
1023 if (*cp++ != ' ') 1023 if (*cp++ != ' ')
1024 SCREWUP("mode not delimited"); 1024 SCREWUP("mode not delimited");
1025 1025
1026 for (size = 0; isdigit(*cp);) 1026 for (size = 0; isdigit((unsigned char)*cp);)
1027 size = size * 10 + (*cp++ - '0'); 1027 size = size * 10 + (*cp++ - '0');
1028 if (*cp++ != ' ') 1028 if (*cp++ != ' ')
1029 SCREWUP("size not delimited"); 1029 SCREWUP("size not delimited");
@@ -1287,7 +1287,7 @@ okname(char *cp0)
1287 c = (int)*cp; 1287 c = (int)*cp;
1288 if (c & 0200) 1288 if (c & 0200)
1289 goto bad; 1289 goto bad;
1290 if (!isalpha(c) && !isdigit(c)) { 1290 if (!isalpha(c) && !isdigit((unsigned char)c)) {
1291 switch (c) { 1291 switch (c) {
1292 case '\'': 1292 case '\'':
1293 case '"': 1293 case '"':
diff --git a/servconf.c b/servconf.c
index 747edde6c..9bcd05bf2 100644
--- a/servconf.c
+++ b/servconf.c
@@ -1,5 +1,5 @@
1 1
2/* $OpenBSD: servconf.c,v 1.240 2013/07/19 07:37:48 markus Exp $ */ 2/* $OpenBSD: servconf.c,v 1.248 2013/12/06 13:39:49 markus Exp $ */
3/* 3/*
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5 * All rights reserved 5 * All rights reserved
@@ -92,6 +92,7 @@ initialize_server_options(ServerOptions *options)
92 options->x11_forwarding = -1; 92 options->x11_forwarding = -1;
93 options->x11_display_offset = -1; 93 options->x11_display_offset = -1;
94 options->x11_use_localhost = -1; 94 options->x11_use_localhost = -1;
95 options->permit_tty = -1;
95 options->xauth_location = NULL; 96 options->xauth_location = NULL;
96 options->strict_modes = -1; 97 options->strict_modes = -1;
97 options->tcp_keep_alive = -1; 98 options->tcp_keep_alive = -1;
@@ -179,6 +180,8 @@ fill_default_server_options(ServerOptions *options)
179 options->host_key_files[options->num_host_key_files++] = 180 options->host_key_files[options->num_host_key_files++] =
180 _PATH_HOST_ECDSA_KEY_FILE; 181 _PATH_HOST_ECDSA_KEY_FILE;
181#endif 182#endif
183 options->host_key_files[options->num_host_key_files++] =
184 _PATH_HOST_ED25519_KEY_FILE;
182 } 185 }
183 } 186 }
184 /* No certificates by default */ 187 /* No certificates by default */
@@ -212,6 +215,8 @@ fill_default_server_options(ServerOptions *options)
212 options->x11_use_localhost = 1; 215 options->x11_use_localhost = 1;
213 if (options->xauth_location == NULL) 216 if (options->xauth_location == NULL)
214 options->xauth_location = _PATH_XAUTH; 217 options->xauth_location = _PATH_XAUTH;
218 if (options->permit_tty == -1)
219 options->permit_tty = 1;
215 if (options->strict_modes == -1) 220 if (options->strict_modes == -1)
216 options->strict_modes = 1; 221 options->strict_modes = 1;
217 if (options->tcp_keep_alive == -1) 222 if (options->tcp_keep_alive == -1)
@@ -329,7 +334,7 @@ typedef enum {
329 sListenAddress, sAddressFamily, 334 sListenAddress, sAddressFamily,
330 sPrintMotd, sPrintLastLog, sIgnoreRhosts, 335 sPrintMotd, sPrintLastLog, sIgnoreRhosts,
331 sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost, 336 sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost,
332 sStrictModes, sEmptyPasswd, sTCPKeepAlive, 337 sPermitTTY, sStrictModes, sEmptyPasswd, sTCPKeepAlive,
333 sPermitUserEnvironment, sUseLogin, sAllowTcpForwarding, sCompression, 338 sPermitUserEnvironment, sUseLogin, sAllowTcpForwarding, sCompression,
334 sRekeyLimit, sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups, 339 sRekeyLimit, sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
335 sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile, 340 sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile,
@@ -462,6 +467,7 @@ static struct {
462 { "useprivilegeseparation", sUsePrivilegeSeparation, SSHCFG_GLOBAL}, 467 { "useprivilegeseparation", sUsePrivilegeSeparation, SSHCFG_GLOBAL},
463 { "acceptenv", sAcceptEnv, SSHCFG_ALL }, 468 { "acceptenv", sAcceptEnv, SSHCFG_ALL },
464 { "permittunnel", sPermitTunnel, SSHCFG_ALL }, 469 { "permittunnel", sPermitTunnel, SSHCFG_ALL },
470 { "permittty", sPermitTTY, SSHCFG_ALL },
465 { "match", sMatch, SSHCFG_ALL }, 471 { "match", sMatch, SSHCFG_ALL },
466 { "permitopen", sPermitOpen, SSHCFG_ALL }, 472 { "permitopen", sPermitOpen, SSHCFG_ALL },
467 { "forcecommand", sForceCommand, SSHCFG_ALL }, 473 { "forcecommand", sForceCommand, SSHCFG_ALL },
@@ -641,13 +647,13 @@ out:
641 647
642/* 648/*
643 * All of the attributes on a single Match line are ANDed together, so we need 649 * All of the attributes on a single Match line are ANDed together, so we need
644 * to check every * attribute and set the result to zero if any attribute does 650 * to check every attribute and set the result to zero if any attribute does
645 * not match. 651 * not match.
646 */ 652 */
647static int 653static int
648match_cfg_line(char **condition, int line, struct connection_info *ci) 654match_cfg_line(char **condition, int line, struct connection_info *ci)
649{ 655{
650 int result = 1, port; 656 int result = 1, attributes = 0, port;
651 char *arg, *attrib, *cp = *condition; 657 char *arg, *attrib, *cp = *condition;
652 size_t len; 658 size_t len;
653 659
@@ -661,6 +667,17 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
661 ci->laddress ? ci->laddress : "(null)", ci->lport); 667 ci->laddress ? ci->laddress : "(null)", ci->lport);
662 668
663 while ((attrib = strdelim(&cp)) && *attrib != '\0') { 669 while ((attrib = strdelim(&cp)) && *attrib != '\0') {
670 attributes++;
671 if (strcasecmp(attrib, "all") == 0) {
672 if (attributes != 1 ||
673 ((arg = strdelim(&cp)) != NULL && *arg != '\0')) {
674 error("'all' cannot be combined with other "
675 "Match attributes");
676 return -1;
677 }
678 *condition = cp;
679 return 1;
680 }
664 if ((arg = strdelim(&cp)) == NULL || *arg == '\0') { 681 if ((arg = strdelim(&cp)) == NULL || *arg == '\0') {
665 error("Missing Match criteria for %s", attrib); 682 error("Missing Match criteria for %s", attrib);
666 return -1; 683 return -1;
@@ -754,6 +771,10 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
754 return -1; 771 return -1;
755 } 772 }
756 } 773 }
774 if (attributes == 0) {
775 error("One or more attributes required for Match");
776 return -1;
777 }
757 if (ci != NULL) 778 if (ci != NULL)
758 debug3("match %sfound", result ? "" : "not "); 779 debug3("match %sfound", result ? "" : "not ");
759 *condition = cp; 780 *condition = cp;
@@ -1117,6 +1138,10 @@ process_server_config_line(ServerOptions *options, char *line,
1117 charptr = &options->xauth_location; 1138 charptr = &options->xauth_location;
1118 goto parse_filename; 1139 goto parse_filename;
1119 1140
1141 case sPermitTTY:
1142 intptr = &options->permit_tty;
1143 goto parse_flag;
1144
1120 case sStrictModes: 1145 case sStrictModes:
1121 intptr = &options->strict_modes; 1146 intptr = &options->strict_modes;
1122 goto parse_flag; 1147 goto parse_flag;
@@ -1719,24 +1744,6 @@ int server_match_spec_complete(struct connection_info *ci)
1719 return 0; /* partial */ 1744 return 0; /* partial */
1720} 1745}
1721 1746
1722/* Helper macros */
1723#define M_CP_INTOPT(n) do {\
1724 if (src->n != -1) \
1725 dst->n = src->n; \
1726} while (0)
1727#define M_CP_STROPT(n) do {\
1728 if (src->n != NULL) { \
1729 free(dst->n); \
1730 dst->n = src->n; \
1731 } \
1732} while(0)
1733#define M_CP_STRARRAYOPT(n, num_n) do {\
1734 if (src->num_n != 0) { \
1735 for (dst->num_n = 0; dst->num_n < src->num_n; dst->num_n++) \
1736 dst->n[dst->num_n] = xstrdup(src->n[dst->num_n]); \
1737 } \
1738} while(0)
1739
1740/* 1747/*
1741 * Copy any supported values that are set. 1748 * Copy any supported values that are set.
1742 * 1749 *
@@ -1747,6 +1754,11 @@ int server_match_spec_complete(struct connection_info *ci)
1747void 1754void
1748copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth) 1755copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth)
1749{ 1756{
1757#define M_CP_INTOPT(n) do {\
1758 if (src->n != -1) \
1759 dst->n = src->n; \
1760} while (0)
1761
1750 M_CP_INTOPT(password_authentication); 1762 M_CP_INTOPT(password_authentication);
1751 M_CP_INTOPT(gss_authentication); 1763 M_CP_INTOPT(gss_authentication);
1752 M_CP_INTOPT(rsa_authentication); 1764 M_CP_INTOPT(rsa_authentication);
@@ -1756,8 +1768,6 @@ copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth)
1756 M_CP_INTOPT(hostbased_uses_name_from_packet_only); 1768 M_CP_INTOPT(hostbased_uses_name_from_packet_only);
1757 M_CP_INTOPT(kbd_interactive_authentication); 1769 M_CP_INTOPT(kbd_interactive_authentication);
1758 M_CP_INTOPT(zero_knowledge_password_authentication); 1770 M_CP_INTOPT(zero_knowledge_password_authentication);
1759 M_CP_STROPT(authorized_keys_command);
1760 M_CP_STROPT(authorized_keys_command_user);
1761 M_CP_INTOPT(permit_root_login); 1771 M_CP_INTOPT(permit_root_login);
1762 M_CP_INTOPT(permit_empty_passwd); 1772 M_CP_INTOPT(permit_empty_passwd);
1763 1773
@@ -1768,6 +1778,7 @@ copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth)
1768 M_CP_INTOPT(x11_display_offset); 1778 M_CP_INTOPT(x11_display_offset);
1769 M_CP_INTOPT(x11_forwarding); 1779 M_CP_INTOPT(x11_forwarding);
1770 M_CP_INTOPT(x11_use_localhost); 1780 M_CP_INTOPT(x11_use_localhost);
1781 M_CP_INTOPT(permit_tty);
1771 M_CP_INTOPT(max_sessions); 1782 M_CP_INTOPT(max_sessions);
1772 M_CP_INTOPT(max_authtries); 1783 M_CP_INTOPT(max_authtries);
1773 M_CP_INTOPT(ip_qos_interactive); 1784 M_CP_INTOPT(ip_qos_interactive);
@@ -1775,6 +1786,20 @@ copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth)
1775 M_CP_INTOPT(rekey_limit); 1786 M_CP_INTOPT(rekey_limit);
1776 M_CP_INTOPT(rekey_interval); 1787 M_CP_INTOPT(rekey_interval);
1777 1788
1789 /* M_CP_STROPT and M_CP_STRARRAYOPT should not appear before here */
1790#define M_CP_STROPT(n) do {\
1791 if (src->n != NULL && dst->n != src->n) { \
1792 free(dst->n); \
1793 dst->n = src->n; \
1794 } \
1795} while(0)
1796#define M_CP_STRARRAYOPT(n, num_n) do {\
1797 if (src->num_n != 0) { \
1798 for (dst->num_n = 0; dst->num_n < src->num_n; dst->num_n++) \
1799 dst->n[dst->num_n] = xstrdup(src->n[dst->num_n]); \
1800 } \
1801} while(0)
1802
1778 /* See comment in servconf.h */ 1803 /* See comment in servconf.h */
1779 COPY_MATCH_STRING_OPTS(); 1804 COPY_MATCH_STRING_OPTS();
1780 1805
@@ -1998,6 +2023,7 @@ dump_config(ServerOptions *o)
1998 dump_cfg_fmtint(sPrintLastLog, o->print_lastlog); 2023 dump_cfg_fmtint(sPrintLastLog, o->print_lastlog);
1999 dump_cfg_fmtint(sX11Forwarding, o->x11_forwarding); 2024 dump_cfg_fmtint(sX11Forwarding, o->x11_forwarding);
2000 dump_cfg_fmtint(sX11UseLocalhost, o->x11_use_localhost); 2025 dump_cfg_fmtint(sX11UseLocalhost, o->x11_use_localhost);
2026 dump_cfg_fmtint(sPermitTTY, o->permit_tty);
2001 dump_cfg_fmtint(sStrictModes, o->strict_modes); 2027 dump_cfg_fmtint(sStrictModes, o->strict_modes);
2002 dump_cfg_fmtint(sTCPKeepAlive, o->tcp_keep_alive); 2028 dump_cfg_fmtint(sTCPKeepAlive, o->tcp_keep_alive);
2003 dump_cfg_fmtint(sEmptyPasswd, o->permit_empty_passwd); 2029 dump_cfg_fmtint(sEmptyPasswd, o->permit_empty_passwd);
@@ -2012,8 +2038,9 @@ dump_config(ServerOptions *o)
2012 /* string arguments */ 2038 /* string arguments */
2013 dump_cfg_string(sPidFile, o->pid_file); 2039 dump_cfg_string(sPidFile, o->pid_file);
2014 dump_cfg_string(sXAuthLocation, o->xauth_location); 2040 dump_cfg_string(sXAuthLocation, o->xauth_location);
2015 dump_cfg_string(sCiphers, o->ciphers); 2041 dump_cfg_string(sCiphers, o->ciphers ? o->ciphers :
2016 dump_cfg_string(sMacs, o->macs); 2042 cipher_alg_list(',', 0));
2043 dump_cfg_string(sMacs, o->macs ? o->macs : mac_alg_list(','));
2017 dump_cfg_string(sBanner, o->banner); 2044 dump_cfg_string(sBanner, o->banner);
2018 dump_cfg_string(sForceCommand, o->adm_forced_command); 2045 dump_cfg_string(sForceCommand, o->adm_forced_command);
2019 dump_cfg_string(sChrootDirectory, o->chroot_directory); 2046 dump_cfg_string(sChrootDirectory, o->chroot_directory);
@@ -2025,6 +2052,8 @@ dump_config(ServerOptions *o)
2025 dump_cfg_string(sAuthorizedKeysCommand, o->authorized_keys_command); 2052 dump_cfg_string(sAuthorizedKeysCommand, o->authorized_keys_command);
2026 dump_cfg_string(sAuthorizedKeysCommandUser, o->authorized_keys_command_user); 2053 dump_cfg_string(sAuthorizedKeysCommandUser, o->authorized_keys_command_user);
2027 dump_cfg_string(sHostKeyAgent, o->host_key_agent); 2054 dump_cfg_string(sHostKeyAgent, o->host_key_agent);
2055 dump_cfg_string(sKexAlgorithms, o->kex_algorithms ? o->kex_algorithms :
2056 kex_alg_list(','));
2028 2057
2029 /* string arguments requiring a lookup */ 2058 /* string arguments requiring a lookup */
2030 dump_cfg_string(sLogLevel, log_level_name(o->log_level)); 2059 dump_cfg_string(sLogLevel, log_level_name(o->log_level));
@@ -2063,7 +2092,8 @@ dump_config(ServerOptions *o)
2063 printf("ipqos %s ", iptos2str(o->ip_qos_interactive)); 2092 printf("ipqos %s ", iptos2str(o->ip_qos_interactive));
2064 printf("%s\n", iptos2str(o->ip_qos_bulk)); 2093 printf("%s\n", iptos2str(o->ip_qos_bulk));
2065 2094
2066 printf("rekeylimit %lld %d\n", o->rekey_limit, o->rekey_interval); 2095 printf("rekeylimit %lld %d\n", (long long)o->rekey_limit,
2096 o->rekey_interval);
2067 2097
2068 channel_print_adm_permitted_opens(); 2098 channel_print_adm_permitted_opens();
2069} 2099}
diff --git a/servconf.h b/servconf.h
index 98aad8ba2..8812c5aab 100644
--- a/servconf.h
+++ b/servconf.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: servconf.h,v 1.109 2013/07/19 07:37:48 markus Exp $ */ 1/* $OpenBSD: servconf.h,v 1.111 2013/12/05 01:16:41 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -82,6 +82,7 @@ typedef struct {
82 * searching at */ 82 * searching at */
83 int x11_use_localhost; /* If true, use localhost for fake X11 server. */ 83 int x11_use_localhost; /* If true, use localhost for fake X11 server. */
84 char *xauth_location; /* Location of xauth program */ 84 char *xauth_location; /* Location of xauth program */
85 int permit_tty; /* If false, deny pty allocation */
85 int strict_modes; /* If true, require string home dir modes. */ 86 int strict_modes; /* If true, require string home dir modes. */
86 int tcp_keep_alive; /* If true, set SO_KEEPALIVE. */ 87 int tcp_keep_alive; /* If true, set SO_KEEPALIVE. */
87 int ip_qos_interactive; /* IP ToS/DSCP/class for interactive */ 88 int ip_qos_interactive; /* IP ToS/DSCP/class for interactive */
@@ -201,6 +202,9 @@ struct connection_info {
201 * Match sub-config and the main config, and must be sent from the 202 * Match sub-config and the main config, and must be sent from the
202 * privsep slave to the privsep master. We use a macro to ensure all 203 * privsep slave to the privsep master. We use a macro to ensure all
203 * the options are copied and the copies are done in the correct order. 204 * the options are copied and the copies are done in the correct order.
205 *
206 * NB. an option must appear in servconf.c:copy_set_server_options() or
207 * COPY_MATCH_STRING_OPTS here but never both.
204 */ 208 */
205#define COPY_MATCH_STRING_OPTS() do { \ 209#define COPY_MATCH_STRING_OPTS() do { \
206 M_CP_STROPT(banner); \ 210 M_CP_STROPT(banner); \
diff --git a/serverloop.c b/serverloop.c
index ccbad617d..5b2f8028d 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: serverloop.c,v 1.168 2013/07/12 00:19:59 djm Exp $ */ 1/* $OpenBSD: serverloop.c,v 1.169 2013/12/19 00:19:12 dtucker 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
@@ -304,7 +304,8 @@ wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp,
304 if (compat20 && 304 if (compat20 &&
305 max_time_milliseconds == 0 && options.client_alive_interval) { 305 max_time_milliseconds == 0 && options.client_alive_interval) {
306 client_alive_scheduled = 1; 306 client_alive_scheduled = 1;
307 max_time_milliseconds = options.client_alive_interval * 1000; 307 max_time_milliseconds =
308 (u_int64_t)options.client_alive_interval * 1000;
308 } 309 }
309 310
310 if (compat20) { 311 if (compat20) {
diff --git a/session.c b/session.c
index d4b57bdfb..12dd9ab10 100644
--- a/session.c
+++ b/session.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: session.c,v 1.266 2013/07/19 07:37:48 markus Exp $ */ 1/* $OpenBSD: session.c,v 1.269 2014/01/18 09:36:26 dtucker 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
@@ -441,7 +441,7 @@ do_authenticated1(Authctxt *authctxt)
441 } 441 }
442} 442}
443 443
444#define USE_PIPES 444#define USE_PIPES 1
445/* 445/*
446 * This is called to fork and execute a command when we have no tty. This 446 * This is called to fork and execute a command when we have no tty. This
447 * will call do_child from the child, and server_loop from the parent after 447 * will call do_child from the child, and server_loop from the parent after
@@ -794,27 +794,50 @@ int
794do_exec(Session *s, const char *command) 794do_exec(Session *s, const char *command)
795{ 795{
796 int ret; 796 int ret;
797 const char *forced = NULL;
798 char session_type[1024], *tty = NULL;
797 799
798 if (options.adm_forced_command) { 800 if (options.adm_forced_command) {
799 original_command = command; 801 original_command = command;
800 command = options.adm_forced_command; 802 command = options.adm_forced_command;
801 if (IS_INTERNAL_SFTP(command)) { 803 forced = "(config)";
802 s->is_subsystem = s->is_subsystem ?
803 SUBSYSTEM_INT_SFTP : SUBSYSTEM_INT_SFTP_ERROR;
804 } else if (s->is_subsystem)
805 s->is_subsystem = SUBSYSTEM_EXT;
806 debug("Forced command (config) '%.900s'", command);
807 } else if (forced_command) { 804 } else if (forced_command) {
808 original_command = command; 805 original_command = command;
809 command = forced_command; 806 command = forced_command;
807 forced = "(key-option)";
808 }
809 if (forced != NULL) {
810 if (IS_INTERNAL_SFTP(command)) { 810 if (IS_INTERNAL_SFTP(command)) {
811 s->is_subsystem = s->is_subsystem ? 811 s->is_subsystem = s->is_subsystem ?
812 SUBSYSTEM_INT_SFTP : SUBSYSTEM_INT_SFTP_ERROR; 812 SUBSYSTEM_INT_SFTP : SUBSYSTEM_INT_SFTP_ERROR;
813 } else if (s->is_subsystem) 813 } else if (s->is_subsystem)
814 s->is_subsystem = SUBSYSTEM_EXT; 814 s->is_subsystem = SUBSYSTEM_EXT;
815 debug("Forced command (key option) '%.900s'", command); 815 snprintf(session_type, sizeof(session_type),
816 "forced-command %s '%.900s'", forced, command);
817 } else if (s->is_subsystem) {
818 snprintf(session_type, sizeof(session_type),
819 "subsystem '%.900s'", s->subsys);
820 } else if (command == NULL) {
821 snprintf(session_type, sizeof(session_type), "shell");
822 } else {
823 /* NB. we don't log unforced commands to preserve privacy */
824 snprintf(session_type, sizeof(session_type), "command");
825 }
826
827 if (s->ttyfd != -1) {
828 tty = s->tty;
829 if (strncmp(tty, "/dev/", 5) == 0)
830 tty += 5;
816 } 831 }
817 832
833 verbose("Starting session: %s%s%s for %s from %.200s port %d",
834 session_type,
835 tty == NULL ? "" : " on ",
836 tty == NULL ? "" : tty,
837 s->pw->pw_name,
838 get_remote_ipaddr(),
839 get_remote_port());
840
818#ifdef SSH_AUDIT_EVENTS 841#ifdef SSH_AUDIT_EVENTS
819 if (command != NULL) 842 if (command != NULL)
820 PRIVSEP(audit_run_command(command)); 843 PRIVSEP(audit_run_command(command));
@@ -1529,6 +1552,11 @@ do_setusercontext(struct passwd *pw)
1529 */ 1552 */
1530 (void) setusercontext(lc, pw, pw->pw_uid, LOGIN_SETUMASK); 1553 (void) setusercontext(lc, pw, pw->pw_uid, LOGIN_SETUMASK);
1531#else 1554#else
1555# ifdef USE_LIBIAF
1556 if (set_id(pw->pw_name) != 0) {
1557 fatal("set_id(%s) Failed", pw->pw_name);
1558 }
1559# endif /* USE_LIBIAF */
1532 /* Permanently switch to the desired uid. */ 1560 /* Permanently switch to the desired uid. */
1533 permanently_set_uid(pw); 1561 permanently_set_uid(pw);
1534#endif 1562#endif
@@ -2039,7 +2067,7 @@ session_pty_req(Session *s)
2039 u_int len; 2067 u_int len;
2040 int n_bytes; 2068 int n_bytes;
2041 2069
2042 if (no_pty_flag) { 2070 if (no_pty_flag || !options.permit_tty) {
2043 debug("Allocating a pty not permitted for this authentication."); 2071 debug("Allocating a pty not permitted for this authentication.");
2044 return 0; 2072 return 0;
2045 } 2073 }
@@ -2100,15 +2128,16 @@ session_subsystem_req(Session *s)
2100 struct stat st; 2128 struct stat st;
2101 u_int len; 2129 u_int len;
2102 int success = 0; 2130 int success = 0;
2103 char *prog, *cmd, *subsys = packet_get_string(&len); 2131 char *prog, *cmd;
2104 u_int i; 2132 u_int i;
2105 2133
2134 s->subsys = packet_get_string(&len);
2106 packet_check_eom(); 2135 packet_check_eom();
2107 logit("subsystem request for %.100s by user %s", subsys, 2136 debug2("subsystem request for %.100s by user %s", s->subsys,
2108 s->pw->pw_name); 2137 s->pw->pw_name);
2109 2138
2110 for (i = 0; i < options.num_subsystems; i++) { 2139 for (i = 0; i < options.num_subsystems; i++) {
2111 if (strcmp(subsys, options.subsystem_name[i]) == 0) { 2140 if (strcmp(s->subsys, options.subsystem_name[i]) == 0) {
2112 prog = options.subsystem_command[i]; 2141 prog = options.subsystem_command[i];
2113 cmd = options.subsystem_args[i]; 2142 cmd = options.subsystem_args[i];
2114 if (strcmp(INTERNAL_SFTP_NAME, prog) == 0) { 2143 if (strcmp(INTERNAL_SFTP_NAME, prog) == 0) {
@@ -2127,10 +2156,9 @@ session_subsystem_req(Session *s)
2127 } 2156 }
2128 2157
2129 if (!success) 2158 if (!success)
2130 logit("subsystem request for %.100s failed, subsystem not found", 2159 logit("subsystem request for %.100s by user %s failed, "
2131 subsys); 2160 "subsystem not found", s->subsys, s->pw->pw_name);
2132 2161
2133 free(subsys);
2134 return success; 2162 return success;
2135} 2163}
2136 2164
@@ -2481,6 +2509,7 @@ session_close(Session *s)
2481 free(s->auth_display); 2509 free(s->auth_display);
2482 free(s->auth_data); 2510 free(s->auth_data);
2483 free(s->auth_proto); 2511 free(s->auth_proto);
2512 free(s->subsys);
2484 if (s->env != NULL) { 2513 if (s->env != NULL) {
2485 for (i = 0; i < s->num_env; i++) { 2514 for (i = 0; i < s->num_env; i++) {
2486 free(s->env[i].name); 2515 free(s->env[i].name);
diff --git a/session.h b/session.h
index cbb8e3a32..6a2f35e41 100644
--- a/session.h
+++ b/session.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: session.h,v 1.30 2008/05/08 12:21:16 djm Exp $ */ 1/* $OpenBSD: session.h,v 1.31 2013/10/14 21:20:52 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.
@@ -55,6 +55,7 @@ struct Session {
55 int chanid; 55 int chanid;
56 int *x11_chanids; 56 int *x11_chanids;
57 int is_subsystem; 57 int is_subsystem;
58 char *subsys;
58 u_int num_env; 59 u_int num_env;
59 struct { 60 struct {
60 char *name; 61 char *name;
diff --git a/sftp-client.c b/sftp-client.c
index 2f9793778..fc035f2ef 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-client.c,v 1.108 2013/11/08 00:39:15 djm Exp $ */ 1/* $OpenBSD: sftp-client.c,v 1.113 2014/01/17 00:21:06 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 *
@@ -42,6 +42,7 @@
42#include <signal.h> 42#include <signal.h>
43#include <stdarg.h> 43#include <stdarg.h>
44#include <stdio.h> 44#include <stdio.h>
45#include <stdlib.h>
45#include <string.h> 46#include <string.h>
46#include <unistd.h> 47#include <unistd.h>
47 48
@@ -76,6 +77,7 @@ struct sftp_conn {
76#define SFTP_EXT_STATVFS 0x00000002 77#define SFTP_EXT_STATVFS 0x00000002
77#define SFTP_EXT_FSTATVFS 0x00000004 78#define SFTP_EXT_FSTATVFS 0x00000004
78#define SFTP_EXT_HARDLINK 0x00000008 79#define SFTP_EXT_HARDLINK 0x00000008
80#define SFTP_EXT_FSYNC 0x00000010
79 u_int exts; 81 u_int exts;
80 u_int64_t limit_kbps; 82 u_int64_t limit_kbps;
81 struct bwlimit bwlimit_in, bwlimit_out; 83 struct bwlimit bwlimit_in, bwlimit_out;
@@ -337,7 +339,8 @@ do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests,
337 Buffer msg; 339 Buffer msg;
338 struct sftp_conn *ret; 340 struct sftp_conn *ret;
339 341
340 ret = xmalloc(sizeof(*ret)); 342 ret = xcalloc(1, sizeof(*ret));
343 ret->msg_id = 1;
341 ret->fd_in = fd_in; 344 ret->fd_in = fd_in;
342 ret->fd_out = fd_out; 345 ret->fd_out = fd_out;
343 ret->transfer_buflen = transfer_buflen; 346 ret->transfer_buflen = transfer_buflen;
@@ -387,6 +390,10 @@ do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests,
387 strcmp(value, "1") == 0) { 390 strcmp(value, "1") == 0) {
388 ret->exts |= SFTP_EXT_HARDLINK; 391 ret->exts |= SFTP_EXT_HARDLINK;
389 known = 1; 392 known = 1;
393 } else if (strcmp(name, "fsync@openssh.com") == 0 &&
394 strcmp(value, "1") == 0) {
395 ret->exts |= SFTP_EXT_FSYNC;
396 known = 1;
390 } 397 }
391 if (known) { 398 if (known) {
392 debug2("Server supports extension \"%s\" revision %s", 399 debug2("Server supports extension \"%s\" revision %s",
@@ -447,12 +454,16 @@ do_close(struct sftp_conn *conn, char *handle, u_int handle_len)
447 454
448 455
449static int 456static int
450do_lsreaddir(struct sftp_conn *conn, char *path, int printflag, 457do_lsreaddir(struct sftp_conn *conn, char *path, int print_flag,
451 SFTP_DIRENT ***dir) 458 SFTP_DIRENT ***dir)
452{ 459{
453 Buffer msg; 460 Buffer msg;
454 u_int count, type, id, handle_len, i, expected_id, ents = 0; 461 u_int count, type, id, handle_len, i, expected_id, ents = 0;
455 char *handle; 462 char *handle;
463 int status = SSH2_FX_FAILURE;
464
465 if (dir)
466 *dir = NULL;
456 467
457 id = conn->msg_id++; 468 id = conn->msg_id++;
458 469
@@ -499,20 +510,12 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int printflag,
499 fatal("ID mismatch (%u != %u)", id, expected_id); 510 fatal("ID mismatch (%u != %u)", id, expected_id);
500 511
501 if (type == SSH2_FXP_STATUS) { 512 if (type == SSH2_FXP_STATUS) {
502 int status = buffer_get_int(&msg); 513 status = buffer_get_int(&msg);
503
504 debug3("Received SSH2_FXP_STATUS %d", status); 514 debug3("Received SSH2_FXP_STATUS %d", status);
505 515 if (status == SSH2_FX_EOF)
506 if (status == SSH2_FX_EOF) {
507 break; 516 break;
508 } else { 517 error("Couldn't read directory: %s", fx2txt(status));
509 error("Couldn't read directory: %s", 518 goto out;
510 fx2txt(status));
511 do_close(conn, handle, handle_len);
512 free(handle);
513 buffer_free(&msg);
514 return(status);
515 }
516 } else if (type != SSH2_FXP_NAME) 519 } else if (type != SSH2_FXP_NAME)
517 fatal("Expected SSH2_FXP_NAME(%u) packet, got %u", 520 fatal("Expected SSH2_FXP_NAME(%u) packet, got %u",
518 SSH2_FXP_NAME, type); 521 SSH2_FXP_NAME, type);
@@ -529,7 +532,7 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int printflag,
529 longname = buffer_get_string(&msg, NULL); 532 longname = buffer_get_string(&msg, NULL);
530 a = decode_attrib(&msg); 533 a = decode_attrib(&msg);
531 534
532 if (printflag) 535 if (print_flag)
533 printf("%s\n", longname); 536 printf("%s\n", longname);
534 537
535 /* 538 /*
@@ -540,10 +543,7 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int printflag,
540 if (strchr(filename, '/') != NULL) { 543 if (strchr(filename, '/') != NULL) {
541 error("Server sent suspect path \"%s\" " 544 error("Server sent suspect path \"%s\" "
542 "during readdir of \"%s\"", filename, path); 545 "during readdir of \"%s\"", filename, path);
543 goto next; 546 } else if (dir) {
544 }
545
546 if (dir) {
547 *dir = xrealloc(*dir, ents + 2, sizeof(**dir)); 547 *dir = xrealloc(*dir, ents + 2, sizeof(**dir));
548 (*dir)[ents] = xcalloc(1, sizeof(***dir)); 548 (*dir)[ents] = xcalloc(1, sizeof(***dir));
549 (*dir)[ents]->filename = xstrdup(filename); 549 (*dir)[ents]->filename = xstrdup(filename);
@@ -551,24 +551,29 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int printflag,
551 memcpy(&(*dir)[ents]->a, a, sizeof(*a)); 551 memcpy(&(*dir)[ents]->a, a, sizeof(*a));
552 (*dir)[++ents] = NULL; 552 (*dir)[++ents] = NULL;
553 } 553 }
554 next:
555 free(filename); 554 free(filename);
556 free(longname); 555 free(longname);
557 } 556 }
558 } 557 }
558 status = 0;
559 559
560 out:
560 buffer_free(&msg); 561 buffer_free(&msg);
561 do_close(conn, handle, handle_len); 562 do_close(conn, handle, handle_len);
562 free(handle); 563 free(handle);
563 564
564 /* Don't return partial matches on interrupt */ 565 if (status != 0 && dir != NULL) {
565 if (interrupted && dir != NULL && *dir != NULL) { 566 /* Don't return results on error */
567 free_sftp_dirents(*dir);
568 *dir = NULL;
569 } else if (interrupted && dir != NULL && *dir != NULL) {
570 /* Don't return partial matches on interrupt */
566 free_sftp_dirents(*dir); 571 free_sftp_dirents(*dir);
567 *dir = xcalloc(1, sizeof(**dir)); 572 *dir = xcalloc(1, sizeof(**dir));
568 **dir = NULL; 573 **dir = NULL;
569 } 574 }
570 575
571 return 0; 576 return status;
572} 577}
573 578
574int 579int
@@ -581,6 +586,8 @@ void free_sftp_dirents(SFTP_DIRENT **s)
581{ 586{
582 int i; 587 int i;
583 588
589 if (s == NULL)
590 return;
584 for (i = 0; s[i]; i++) { 591 for (i = 0; s[i]; i++) {
585 free(s[i]->filename); 592 free(s[i]->filename);
586 free(s[i]->longname); 593 free(s[i]->longname);
@@ -605,7 +612,7 @@ do_rm(struct sftp_conn *conn, char *path)
605} 612}
606 613
607int 614int
608do_mkdir(struct sftp_conn *conn, char *path, Attrib *a, int printflag) 615do_mkdir(struct sftp_conn *conn, char *path, Attrib *a, int print_flag)
609{ 616{
610 u_int status, id; 617 u_int status, id;
611 618
@@ -614,7 +621,7 @@ do_mkdir(struct sftp_conn *conn, char *path, Attrib *a, int printflag)
614 strlen(path), a); 621 strlen(path), a);
615 622
616 status = get_status(conn, id); 623 status = get_status(conn, id);
617 if (status != SSH2_FX_OK && printflag) 624 if (status != SSH2_FX_OK && print_flag)
618 error("Couldn't create directory: %s", fx2txt(status)); 625 error("Couldn't create directory: %s", fx2txt(status));
619 626
620 return(status); 627 return(status);
@@ -742,7 +749,7 @@ do_realpath(struct sftp_conn *conn, char *path)
742 if (type == SSH2_FXP_STATUS) { 749 if (type == SSH2_FXP_STATUS) {
743 u_int status = buffer_get_int(&msg); 750 u_int status = buffer_get_int(&msg);
744 751
745 error("Couldn't canonicalise: %s", fx2txt(status)); 752 error("Couldn't canonicalize: %s", fx2txt(status));
746 buffer_free(&msg); 753 buffer_free(&msg);
747 return NULL; 754 return NULL;
748 } else if (type != SSH2_FXP_NAME) 755 } else if (type != SSH2_FXP_NAME)
@@ -768,16 +775,18 @@ do_realpath(struct sftp_conn *conn, char *path)
768} 775}
769 776
770int 777int
771do_rename(struct sftp_conn *conn, char *oldpath, char *newpath) 778do_rename(struct sftp_conn *conn, char *oldpath, char *newpath,
779 int force_legacy)
772{ 780{
773 Buffer msg; 781 Buffer msg;
774 u_int status, id; 782 u_int status, id;
783 int use_ext = (conn->exts & SFTP_EXT_POSIX_RENAME) && !force_legacy;
775 784
776 buffer_init(&msg); 785 buffer_init(&msg);
777 786
778 /* Send rename request */ 787 /* Send rename request */
779 id = conn->msg_id++; 788 id = conn->msg_id++;
780 if ((conn->exts & SFTP_EXT_POSIX_RENAME)) { 789 if (use_ext) {
781 buffer_put_char(&msg, SSH2_FXP_EXTENDED); 790 buffer_put_char(&msg, SSH2_FXP_EXTENDED);
782 buffer_put_int(&msg, id); 791 buffer_put_int(&msg, id);
783 buffer_put_cstring(&msg, "posix-rename@openssh.com"); 792 buffer_put_cstring(&msg, "posix-rename@openssh.com");
@@ -789,8 +798,8 @@ do_rename(struct sftp_conn *conn, char *oldpath, char *newpath)
789 buffer_put_cstring(&msg, newpath); 798 buffer_put_cstring(&msg, newpath);
790 send_msg(conn, &msg); 799 send_msg(conn, &msg);
791 debug3("Sent message %s \"%s\" -> \"%s\"", 800 debug3("Sent message %s \"%s\" -> \"%s\"",
792 (conn->exts & SFTP_EXT_POSIX_RENAME) ? "posix-rename@openssh.com" : 801 use_ext ? "posix-rename@openssh.com" : "SSH2_FXP_RENAME",
793 "SSH2_FXP_RENAME", oldpath, newpath); 802 oldpath, newpath);
794 buffer_free(&msg); 803 buffer_free(&msg);
795 804
796 status = get_status(conn, id); 805 status = get_status(conn, id);
@@ -866,6 +875,36 @@ do_symlink(struct sftp_conn *conn, char *oldpath, char *newpath)
866 return(status); 875 return(status);
867} 876}
868 877
878int
879do_fsync(struct sftp_conn *conn, char *handle, u_int handle_len)
880{
881 Buffer msg;
882 u_int status, id;
883
884 /* Silently return if the extension is not supported */
885 if ((conn->exts & SFTP_EXT_FSYNC) == 0)
886 return -1;
887
888 buffer_init(&msg);
889
890 /* Send fsync request */
891 id = conn->msg_id++;
892
893 buffer_put_char(&msg, SSH2_FXP_EXTENDED);
894 buffer_put_int(&msg, id);
895 buffer_put_cstring(&msg, "fsync@openssh.com");
896 buffer_put_string(&msg, handle, handle_len);
897 send_msg(conn, &msg);
898 debug3("Sent message fsync@openssh.com I:%u", id);
899 buffer_free(&msg);
900
901 status = get_status(conn, id);
902 if (status != SSH2_FX_OK)
903 error("Couldn't sync file: %s", fx2txt(status));
904
905 return status;
906}
907
869#ifdef notyet 908#ifdef notyet
870char * 909char *
871do_readlink(struct sftp_conn *conn, char *path) 910do_readlink(struct sftp_conn *conn, char *path)
@@ -988,7 +1027,7 @@ send_read_request(struct sftp_conn *conn, u_int id, u_int64_t offset,
988 1027
989int 1028int
990do_download(struct sftp_conn *conn, char *remote_path, char *local_path, 1029do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
991 Attrib *a, int pflag, int resume) 1030 Attrib *a, int preserve_flag, int resume_flag, int fsync_flag)
992{ 1031{
993 Attrib junk; 1032 Attrib junk;
994 Buffer msg; 1033 Buffer msg;
@@ -1051,27 +1090,33 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
1051 return(-1); 1090 return(-1);
1052 } 1091 }
1053 1092
1054 local_fd = open(local_path, O_WRONLY | O_CREAT | (resume ? 0 : O_TRUNC), 1093 local_fd = open(local_path,
1055 mode | S_IWUSR); 1094 O_WRONLY | O_CREAT | (resume_flag ? 0 : O_TRUNC), mode | S_IWUSR);
1056 if (local_fd == -1) { 1095 if (local_fd == -1) {
1057 error("Couldn't open local file \"%s\" for writing: %s", 1096 error("Couldn't open local file \"%s\" for writing: %s",
1058 local_path, strerror(errno)); 1097 local_path, strerror(errno));
1059 goto fail; 1098 goto fail;
1060 } 1099 }
1061 offset = highwater = 0; 1100 offset = highwater = 0;
1062 if (resume) { 1101 if (resume_flag) {
1063 if (fstat(local_fd, &st) == -1) { 1102 if (fstat(local_fd, &st) == -1) {
1064 error("Unable to stat local file \"%s\": %s", 1103 error("Unable to stat local file \"%s\": %s",
1065 local_path, strerror(errno)); 1104 local_path, strerror(errno));
1066 goto fail; 1105 goto fail;
1067 } 1106 }
1068 if ((size_t)st.st_size > size) { 1107 if (st.st_size < 0) {
1108 error("\"%s\" has negative size", local_path);
1109 goto fail;
1110 }
1111 if ((u_int64_t)st.st_size > size) {
1069 error("Unable to resume download of \"%s\": " 1112 error("Unable to resume download of \"%s\": "
1070 "local file is larger than remote", local_path); 1113 "local file is larger than remote", local_path);
1071 fail: 1114 fail:
1072 do_close(conn, handle, handle_len); 1115 do_close(conn, handle, handle_len);
1073 buffer_free(&msg); 1116 buffer_free(&msg);
1074 free(handle); 1117 free(handle);
1118 if (local_fd != -1)
1119 close(local_fd);
1075 return -1; 1120 return -1;
1076 } 1121 }
1077 offset = highwater = st.st_size; 1122 offset = highwater = st.st_size;
@@ -1209,7 +1254,7 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
1209 fatal("Transfer complete, but requests still in queue"); 1254 fatal("Transfer complete, but requests still in queue");
1210 /* Truncate at highest contiguous point to avoid holes on interrupt */ 1255 /* Truncate at highest contiguous point to avoid holes on interrupt */
1211 if (read_error || write_error || interrupted) { 1256 if (read_error || write_error || interrupted) {
1212 if (reordered && resume) { 1257 if (reordered && resume_flag) {
1213 error("Unable to resume download of \"%s\": " 1258 error("Unable to resume download of \"%s\": "
1214 "server reordered requests", local_path); 1259 "server reordered requests", local_path);
1215 } 1260 }
@@ -1219,6 +1264,7 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
1219 if (read_error) { 1264 if (read_error) {
1220 error("Couldn't read from remote file \"%s\" : %s", 1265 error("Couldn't read from remote file \"%s\" : %s",
1221 remote_path, fx2txt(status)); 1266 remote_path, fx2txt(status));
1267 status = -1;
1222 do_close(conn, handle, handle_len); 1268 do_close(conn, handle, handle_len);
1223 } else if (write_error) { 1269 } else if (write_error) {
1224 error("Couldn't write to \"%s\": %s", local_path, 1270 error("Couldn't write to \"%s\": %s", local_path,
@@ -1227,17 +1273,18 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
1227 do_close(conn, handle, handle_len); 1273 do_close(conn, handle, handle_len);
1228 } else { 1274 } else {
1229 status = do_close(conn, handle, handle_len); 1275 status = do_close(conn, handle, handle_len);
1230 if (interrupted) 1276 if (interrupted || status != SSH2_FX_OK)
1231 status = -1; 1277 status = -1;
1232 /* Override umask and utimes if asked */ 1278 /* Override umask and utimes if asked */
1233#ifdef HAVE_FCHMOD 1279#ifdef HAVE_FCHMOD
1234 if (pflag && fchmod(local_fd, mode) == -1) 1280 if (preserve_flag && fchmod(local_fd, mode) == -1)
1235#else 1281#else
1236 if (pflag && chmod(local_path, mode) == -1) 1282 if (preserve_flag && chmod(local_path, mode) == -1)
1237#endif /* HAVE_FCHMOD */ 1283#endif /* HAVE_FCHMOD */
1238 error("Couldn't set mode on \"%s\": %s", local_path, 1284 error("Couldn't set mode on \"%s\": %s", local_path,
1239 strerror(errno)); 1285 strerror(errno));
1240 if (pflag && (a->flags & SSH2_FILEXFER_ATTR_ACMODTIME)) { 1286 if (preserve_flag &&
1287 (a->flags & SSH2_FILEXFER_ATTR_ACMODTIME)) {
1241 struct timeval tv[2]; 1288 struct timeval tv[2];
1242 tv[0].tv_sec = a->atime; 1289 tv[0].tv_sec = a->atime;
1243 tv[1].tv_sec = a->mtime; 1290 tv[1].tv_sec = a->mtime;
@@ -1246,6 +1293,12 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
1246 error("Can't set times on \"%s\": %s", 1293 error("Can't set times on \"%s\": %s",
1247 local_path, strerror(errno)); 1294 local_path, strerror(errno));
1248 } 1295 }
1296 if (fsync_flag) {
1297 debug("syncing \"%s\"", local_path);
1298 if (fsync(local_fd) == -1)
1299 error("Couldn't sync file \"%s\": %s",
1300 local_path, strerror(errno));
1301 }
1249 } 1302 }
1250 close(local_fd); 1303 close(local_fd);
1251 buffer_free(&msg); 1304 buffer_free(&msg);
@@ -1255,8 +1308,9 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
1255} 1308}
1256 1309
1257static int 1310static int
1258download_dir_internal(struct sftp_conn *conn, char *src, char *dst, 1311download_dir_internal(struct sftp_conn *conn, char *src, char *dst, int depth,
1259 Attrib *dirattrib, int pflag, int printflag, int depth, int resume) 1312 Attrib *dirattrib, int preserve_flag, int print_flag, int resume_flag,
1313 int fsync_flag)
1260{ 1314{
1261 int i, ret = 0; 1315 int i, ret = 0;
1262 SFTP_DIRENT **dir_entries; 1316 SFTP_DIRENT **dir_entries;
@@ -1277,7 +1331,7 @@ download_dir_internal(struct sftp_conn *conn, char *src, char *dst,
1277 error("\"%s\" is not a directory", src); 1331 error("\"%s\" is not a directory", src);
1278 return -1; 1332 return -1;
1279 } 1333 }
1280 if (printflag) 1334 if (print_flag)
1281 printf("Retrieving %s\n", src); 1335 printf("Retrieving %s\n", src);
1282 1336
1283 if (dirattrib->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) 1337 if (dirattrib->flags & SSH2_FILEXFER_ATTR_PERMISSIONS)
@@ -1308,12 +1362,13 @@ download_dir_internal(struct sftp_conn *conn, char *src, char *dst,
1308 strcmp(filename, "..") == 0) 1362 strcmp(filename, "..") == 0)
1309 continue; 1363 continue;
1310 if (download_dir_internal(conn, new_src, new_dst, 1364 if (download_dir_internal(conn, new_src, new_dst,
1311 &(dir_entries[i]->a), pflag, printflag, 1365 depth + 1, &(dir_entries[i]->a), preserve_flag,
1312 depth + 1, resume) == -1) 1366 print_flag, resume_flag, fsync_flag) == -1)
1313 ret = -1; 1367 ret = -1;
1314 } else if (S_ISREG(dir_entries[i]->a.perm) ) { 1368 } else if (S_ISREG(dir_entries[i]->a.perm) ) {
1315 if (do_download(conn, new_src, new_dst, 1369 if (do_download(conn, new_src, new_dst,
1316 &(dir_entries[i]->a), pflag, resume) == -1) { 1370 &(dir_entries[i]->a), preserve_flag,
1371 resume_flag, fsync_flag) == -1) {
1317 error("Download of file %s to %s failed", 1372 error("Download of file %s to %s failed",
1318 new_src, new_dst); 1373 new_src, new_dst);
1319 ret = -1; 1374 ret = -1;
@@ -1325,7 +1380,7 @@ download_dir_internal(struct sftp_conn *conn, char *src, char *dst,
1325 free(new_src); 1380 free(new_src);
1326 } 1381 }
1327 1382
1328 if (pflag) { 1383 if (preserve_flag) {
1329 if (dirattrib->flags & SSH2_FILEXFER_ATTR_ACMODTIME) { 1384 if (dirattrib->flags & SSH2_FILEXFER_ATTR_ACMODTIME) {
1330 struct timeval tv[2]; 1385 struct timeval tv[2];
1331 tv[0].tv_sec = dirattrib->atime; 1386 tv[0].tv_sec = dirattrib->atime;
@@ -1346,25 +1401,26 @@ download_dir_internal(struct sftp_conn *conn, char *src, char *dst,
1346 1401
1347int 1402int
1348download_dir(struct sftp_conn *conn, char *src, char *dst, 1403download_dir(struct sftp_conn *conn, char *src, char *dst,
1349 Attrib *dirattrib, int pflag, int printflag, int resume) 1404 Attrib *dirattrib, int preserve_flag, int print_flag,
1405 int resume_flag, int fsync_flag)
1350{ 1406{
1351 char *src_canon; 1407 char *src_canon;
1352 int ret; 1408 int ret;
1353 1409
1354 if ((src_canon = do_realpath(conn, src)) == NULL) { 1410 if ((src_canon = do_realpath(conn, src)) == NULL) {
1355 error("Unable to canonicalise path \"%s\"", src); 1411 error("Unable to canonicalize path \"%s\"", src);
1356 return -1; 1412 return -1;
1357 } 1413 }
1358 1414
1359 ret = download_dir_internal(conn, src_canon, dst, 1415 ret = download_dir_internal(conn, src_canon, dst, 0,
1360 dirattrib, pflag, printflag, 0, resume); 1416 dirattrib, preserve_flag, print_flag, resume_flag, fsync_flag);
1361 free(src_canon); 1417 free(src_canon);
1362 return ret; 1418 return ret;
1363} 1419}
1364 1420
1365int 1421int
1366do_upload(struct sftp_conn *conn, char *local_path, char *remote_path, 1422do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
1367 int pflag) 1423 int preserve_flag, int fsync_flag)
1368{ 1424{
1369 int local_fd; 1425 int local_fd;
1370 int status = SSH2_FX_OK; 1426 int status = SSH2_FX_OK;
@@ -1408,7 +1464,7 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
1408 a.flags &= ~SSH2_FILEXFER_ATTR_SIZE; 1464 a.flags &= ~SSH2_FILEXFER_ATTR_SIZE;
1409 a.flags &= ~SSH2_FILEXFER_ATTR_UIDGID; 1465 a.flags &= ~SSH2_FILEXFER_ATTR_UIDGID;
1410 a.perm &= 0777; 1466 a.perm &= 0777;
1411 if (!pflag) 1467 if (!preserve_flag)
1412 a.flags &= ~SSH2_FILEXFER_ATTR_ACMODTIME; 1468 a.flags &= ~SSH2_FILEXFER_ATTR_ACMODTIME;
1413 1469
1414 buffer_init(&msg); 1470 buffer_init(&msg);
@@ -1537,9 +1593,12 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
1537 } 1593 }
1538 1594
1539 /* Override umask and utimes if asked */ 1595 /* Override umask and utimes if asked */
1540 if (pflag) 1596 if (preserve_flag)
1541 do_fsetstat(conn, handle, handle_len, &a); 1597 do_fsetstat(conn, handle, handle_len, &a);
1542 1598
1599 if (fsync_flag)
1600 (void)do_fsync(conn, handle, handle_len);
1601
1543 if (do_close(conn, handle, handle_len) != SSH2_FX_OK) 1602 if (do_close(conn, handle, handle_len) != SSH2_FX_OK)
1544 status = -1; 1603 status = -1;
1545 free(handle); 1604 free(handle);
@@ -1548,8 +1607,8 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
1548} 1607}
1549 1608
1550static int 1609static int
1551upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, 1610upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, int depth,
1552 int pflag, int printflag, int depth) 1611 int preserve_flag, int print_flag, int fsync_flag)
1553{ 1612{
1554 int ret = 0, status; 1613 int ret = 0, status;
1555 DIR *dirp; 1614 DIR *dirp;
@@ -1572,7 +1631,7 @@ upload_dir_internal(struct sftp_conn *conn, char *src, char *dst,
1572 error("\"%s\" is not a directory", src); 1631 error("\"%s\" is not a directory", src);
1573 return -1; 1632 return -1;
1574 } 1633 }
1575 if (printflag) 1634 if (print_flag)
1576 printf("Entering %s\n", src); 1635 printf("Entering %s\n", src);
1577 1636
1578 attrib_clear(&a); 1637 attrib_clear(&a);
@@ -1580,7 +1639,7 @@ upload_dir_internal(struct sftp_conn *conn, char *src, char *dst,
1580 a.flags &= ~SSH2_FILEXFER_ATTR_SIZE; 1639 a.flags &= ~SSH2_FILEXFER_ATTR_SIZE;
1581 a.flags &= ~SSH2_FILEXFER_ATTR_UIDGID; 1640 a.flags &= ~SSH2_FILEXFER_ATTR_UIDGID;
1582 a.perm &= 01777; 1641 a.perm &= 01777;
1583 if (!pflag) 1642 if (!preserve_flag)
1584 a.flags &= ~SSH2_FILEXFER_ATTR_ACMODTIME; 1643 a.flags &= ~SSH2_FILEXFER_ATTR_ACMODTIME;
1585 1644
1586 status = do_mkdir(conn, dst, &a, 0); 1645 status = do_mkdir(conn, dst, &a, 0);
@@ -1618,10 +1677,12 @@ upload_dir_internal(struct sftp_conn *conn, char *src, char *dst,
1618 continue; 1677 continue;
1619 1678
1620 if (upload_dir_internal(conn, new_src, new_dst, 1679 if (upload_dir_internal(conn, new_src, new_dst,
1621 pflag, printflag, depth + 1) == -1) 1680 depth + 1, preserve_flag, print_flag,
1681 fsync_flag) == -1)
1622 ret = -1; 1682 ret = -1;
1623 } else if (S_ISREG(sb.st_mode)) { 1683 } else if (S_ISREG(sb.st_mode)) {
1624 if (do_upload(conn, new_src, new_dst, pflag) == -1) { 1684 if (do_upload(conn, new_src, new_dst,
1685 preserve_flag, fsync_flag) == -1) {
1625 error("Uploading of file %s to %s failed!", 1686 error("Uploading of file %s to %s failed!",
1626 new_src, new_dst); 1687 new_src, new_dst);
1627 ret = -1; 1688 ret = -1;
@@ -1639,18 +1700,20 @@ upload_dir_internal(struct sftp_conn *conn, char *src, char *dst,
1639} 1700}
1640 1701
1641int 1702int
1642upload_dir(struct sftp_conn *conn, char *src, char *dst, int printflag, 1703upload_dir(struct sftp_conn *conn, char *src, char *dst, int preserve_flag,
1643 int pflag) 1704 int print_flag, int fsync_flag)
1644{ 1705{
1645 char *dst_canon; 1706 char *dst_canon;
1646 int ret; 1707 int ret;
1647 1708
1648 if ((dst_canon = do_realpath(conn, dst)) == NULL) { 1709 if ((dst_canon = do_realpath(conn, dst)) == NULL) {
1649 error("Unable to canonicalise path \"%s\"", dst); 1710 error("Unable to canonicalize path \"%s\"", dst);
1650 return -1; 1711 return -1;
1651 } 1712 }
1652 1713
1653 ret = upload_dir_internal(conn, src, dst_canon, pflag, printflag, 0); 1714 ret = upload_dir_internal(conn, src, dst_canon, 0, preserve_flag,
1715 print_flag, fsync_flag);
1716
1654 free(dst_canon); 1717 free(dst_canon);
1655 return ret; 1718 return ret;
1656} 1719}
diff --git a/sftp-client.h b/sftp-client.h
index 111a998c8..ba92ad01a 100644
--- a/sftp-client.h
+++ b/sftp-client.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-client.h,v 1.21 2013/07/25 00:56:51 djm Exp $ */ 1/* $OpenBSD: sftp-client.h,v 1.24 2013/10/17 00:30:13 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>
@@ -92,7 +92,7 @@ char *do_realpath(struct sftp_conn *, char *);
92int do_statvfs(struct sftp_conn *, const char *, struct sftp_statvfs *, int); 92int do_statvfs(struct sftp_conn *, const char *, struct sftp_statvfs *, int);
93 93
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 *m, int force_legacy);
96 96
97/* Link 'oldpath' to 'newpath' */ 97/* Link 'oldpath' to 'newpath' */
98int do_hardlink(struct sftp_conn *, char *, char *); 98int do_hardlink(struct sftp_conn *, char *, char *);
@@ -100,31 +100,33 @@ int do_hardlink(struct sftp_conn *, char *, char *);
100/* Rename 'oldpath' to 'newpath' */ 100/* Rename 'oldpath' to 'newpath' */
101int do_symlink(struct sftp_conn *, char *, char *); 101int do_symlink(struct sftp_conn *, char *, char *);
102 102
103/* XXX: add callbacks to do_download/do_upload so we can do progress meter */ 103/* Call fsync() on open file 'handle' */
104int do_fsync(struct sftp_conn *conn, char *, u_int);
104 105
105/* 106/*
106 * Download 'remote_path' to 'local_path'. Preserve permissions and times 107 * Download 'remote_path' to 'local_path'. Preserve permissions and times
107 * if 'pflag' is set 108 * if 'pflag' is set
108 */ 109 */
109int do_download(struct sftp_conn *, char *, char *, Attrib *, int, int); 110int do_download(struct sftp_conn *, char *, char *, Attrib *, int, int, int);
110 111
111/* 112/*
112 * Recursively download 'remote_directory' to 'local_directory'. Preserve 113 * Recursively download 'remote_directory' to 'local_directory'. Preserve
113 * times if 'pflag' is set 114 * times if 'pflag' is set
114 */ 115 */
115int download_dir(struct sftp_conn *, char *, char *, Attrib *, int, int, int); 116int download_dir(struct sftp_conn *, char *, char *, Attrib *, int,
117 int, int, int);
116 118
117/* 119/*
118 * Upload 'local_path' to 'remote_path'. Preserve permissions and times 120 * Upload 'local_path' to 'remote_path'. Preserve permissions and times
119 * if 'pflag' is set 121 * if 'pflag' is set
120 */ 122 */
121int do_upload(struct sftp_conn *, char *, char *, int); 123int do_upload(struct sftp_conn *, char *, char *, int, int);
122 124
123/* 125/*
124 * Recursively upload 'local_directory' to 'remote_directory'. Preserve 126 * Recursively upload 'local_directory' to 'remote_directory'. Preserve
125 * times if 'pflag' is set 127 * times if 'pflag' is set
126 */ 128 */
127int upload_dir(struct sftp_conn *, char *, char *, int, int); 129int upload_dir(struct sftp_conn *, char *, char *, int, int, int);
128 130
129/* Concatenate paths, taking care of slashes. Caller must free result. */ 131/* Concatenate paths, taking care of slashes. Caller must free result. */
130char *path_append(char *, char *); 132char *path_append(char *, char *);
diff --git a/sftp-common.c b/sftp-common.c
index 413efc209..70a929ccc 100644
--- a/sftp-common.c
+++ b/sftp-common.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-common.c,v 1.24 2013/05/17 00:13:14 djm Exp $ */ 1/* $OpenBSD: sftp-common.c,v 1.26 2014/01/09 03:26:00 guenther Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2001 Damien Miller. All rights reserved. 4 * Copyright (c) 2001 Damien Miller. All rights reserved.
@@ -33,6 +33,7 @@
33#include <grp.h> 33#include <grp.h>
34#include <pwd.h> 34#include <pwd.h>
35#include <stdio.h> 35#include <stdio.h>
36#include <stdlib.h>
36#include <string.h> 37#include <string.h>
37#include <time.h> 38#include <time.h>
38#include <stdarg.h> 39#include <stdarg.h>
@@ -194,6 +195,7 @@ ls_file(const char *name, const struct stat *st, int remote, int si_units)
194 char *user, *group; 195 char *user, *group;
195 char buf[1024], mode[11+1], tbuf[12+1], ubuf[11+1], gbuf[11+1]; 196 char buf[1024], mode[11+1], tbuf[12+1], ubuf[11+1], gbuf[11+1];
196 char sbuf[FMT_SCALED_STRSIZE]; 197 char sbuf[FMT_SCALED_STRSIZE];
198 time_t now;
197 199
198 strmode(st->st_mode, mode); 200 strmode(st->st_mode, mode);
199 if (!remote) { 201 if (!remote) {
@@ -209,7 +211,9 @@ ls_file(const char *name, const struct stat *st, int remote, int si_units)
209 group = gbuf; 211 group = gbuf;
210 } 212 }
211 if (ltime != NULL) { 213 if (ltime != NULL) {
212 if (time(NULL) - st->st_mtime < (365*24*60*60)/2) 214 now = time(NULL);
215 if (now - (365*24*60*60)/2 < st->st_mtime &&
216 now >= st->st_mtime)
213 sz = strftime(tbuf, sizeof tbuf, "%b %e %H:%M", ltime); 217 sz = strftime(tbuf, sizeof tbuf, "%b %e %H:%M", ltime);
214 else 218 else
215 sz = strftime(tbuf, sizeof tbuf, "%b %e %Y", ltime); 219 sz = strftime(tbuf, sizeof tbuf, "%b %e %Y", ltime);
diff --git a/sftp-glob.c b/sftp-glob.c
index e1f5a6109..d85aecc9a 100644
--- a/sftp-glob.c
+++ b/sftp-glob.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-glob.c,v 1.25 2013/11/08 00:39:15 djm Exp $ */ 1/* $OpenBSD: sftp-glob.c,v 1.26 2013/11/08 11:15:19 dtucker 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 *
@@ -23,6 +23,7 @@
23#endif 23#endif
24 24
25#include <dirent.h> 25#include <dirent.h>
26#include <stdlib.h>
26#include <string.h> 27#include <string.h>
27 28
28#include "xmalloc.h" 29#include "xmalloc.h"
diff --git a/sftp-server.0 b/sftp-server.0
index 391f42736..5bf8da600 100644
--- a/sftp-server.0
+++ b/sftp-server.0
@@ -5,7 +5,9 @@ NAME
5 5
6SYNOPSIS 6SYNOPSIS
7 sftp-server [-ehR] [-d start_directory] [-f log_facility] [-l log_level] 7 sftp-server [-ehR] [-d start_directory] [-f log_facility] [-l log_level]
8 [-P blacklisted_requests] [-p whitelisted_requests]
8 [-u umask] 9 [-u umask]
10 sftp-server -Q protocol_feature
9 11
10DESCRIPTION 12DESCRIPTION
11 sftp-server is a program that speaks the server side of SFTP protocol to 13 sftp-server is a program that speaks the server side of SFTP protocol to
@@ -46,6 +48,26 @@ DESCRIPTION
46 DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify higher 48 DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify higher
47 levels of debugging output. The default is ERROR. 49 levels of debugging output. The default is ERROR.
48 50
51 -P blacklisted_requests
52 Specify a comma-separated list of SFTP protocol requests that are
53 banned by the server. sftp-server will reply to any blacklisted
54 request with a failure. The -Q flag can be used to determine the
55 supported request types. If both a blacklist and a whitelist are
56 specified, then the blacklist is applied before the whitelist.
57
58 -p whitelisted_requests
59 Specify a comma-separated list of SFTP protocol requests that are
60 permitted by the server. All request types that are not on the
61 whitelist will be logged and replied to with a failure message.
62
63 Care must be taken when using this feature to ensure that
64 requests made implicitly by SFTP clients are permitted.
65
66 -Q protocol_feature
67 Query protocol features supported by sftp-server. At present the
68 only feature that may be queried is ``requests'', which may be
69 used for black or whitelisting (flags -P and -p respectively).
70
49 -R Places this instance of sftp-server into a read-only mode. 71 -R Places this instance of sftp-server into a read-only mode.
50 Attempts to open files for writing, as well as other operations 72 Attempts to open files for writing, as well as other operations
51 that change the state of the filesystem, will be denied. 73 that change the state of the filesystem, will be denied.
@@ -70,4 +92,4 @@ HISTORY
70AUTHORS 92AUTHORS
71 Markus Friedl <markus@openbsd.org> 93 Markus Friedl <markus@openbsd.org>
72 94
73OpenBSD 5.4 July 16, 2013 OpenBSD 5.4 95OpenBSD 5.4 October 14, 2013 OpenBSD 5.4
diff --git a/sftp-server.8 b/sftp-server.8
index cc925b96e..1e0b277b4 100644
--- a/sftp-server.8
+++ b/sftp-server.8
@@ -1,4 +1,4 @@
1.\" $OpenBSD: sftp-server.8,v 1.23 2013/07/16 00:07:52 schwarze Exp $ 1.\" $OpenBSD: sftp-server.8,v 1.25 2013/10/14 14:18:56 jmc Exp $
2.\" 2.\"
3.\" Copyright (c) 2000 Markus Friedl. All rights reserved. 3.\" Copyright (c) 2000 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: July 16 2013 $ 25.Dd $Mdocdate: October 14 2013 $
26.Dt SFTP-SERVER 8 26.Dt SFTP-SERVER 8
27.Os 27.Os
28.Sh NAME 28.Sh NAME
@@ -30,11 +30,17 @@
30.Nd SFTP server subsystem 30.Nd SFTP server subsystem
31.Sh SYNOPSIS 31.Sh SYNOPSIS
32.Nm sftp-server 32.Nm sftp-server
33.Bk -words
33.Op Fl ehR 34.Op Fl ehR
34.Op Fl d Ar start_directory 35.Op Fl d Ar start_directory
35.Op Fl f Ar log_facility 36.Op Fl f Ar log_facility
36.Op Fl l Ar log_level 37.Op Fl l Ar log_level
38.Op Fl P Ar blacklisted_requests
39.Op Fl p Ar whitelisted_requests
37.Op Fl u Ar umask 40.Op Fl u Ar umask
41.Ek
42.Nm
43.Fl Q Ar protocol_feature
38.Sh DESCRIPTION 44.Sh DESCRIPTION
39.Nm 45.Nm
40is a program that speaks the server side of SFTP protocol 46is a program that speaks the server side of SFTP protocol
@@ -93,6 +99,34 @@ performs on behalf of the client.
93DEBUG and DEBUG1 are equivalent. 99DEBUG and DEBUG1 are equivalent.
94DEBUG2 and DEBUG3 each specify higher levels of debugging output. 100DEBUG2 and DEBUG3 each specify higher levels of debugging output.
95The default is ERROR. 101The default is ERROR.
102.It Fl P Ar blacklisted_requests
103Specify a comma-separated list of SFTP protocol requests that are banned by
104the server.
105.Nm
106will reply to any blacklisted request with a failure.
107The
108.Fl Q
109flag can be used to determine the supported request types.
110If both a blacklist and a whitelist are specified, then the blacklist is
111applied before the whitelist.
112.It Fl p Ar whitelisted_requests
113Specify a comma-separated list of SFTP protocol requests that are permitted
114by the server.
115All request types that are not on the whitelist will be logged and replied
116to with a failure message.
117.Pp
118Care must be taken when using this feature to ensure that requests made
119implicitly by SFTP clients are permitted.
120.It Fl Q Ar protocol_feature
121Query protocol features supported by
122.Nm .
123At present the only feature that may be queried is
124.Dq requests ,
125which may be used for black or whitelisting (flags
126.Fl P
127and
128.Fl p
129respectively).
96.It Fl R 130.It Fl R
97Places this instance of 131Places this instance of
98.Nm 132.Nm
diff --git a/sftp-server.c b/sftp-server.c
index 285f21aaf..b8eb59c36 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-server.c,v 1.97 2013/05/17 00:13:14 djm Exp $ */ 1/* $OpenBSD: sftp-server.c,v 1.103 2014/01/17 06:23:24 dtucker 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 *
@@ -46,6 +46,7 @@
46#include "buffer.h" 46#include "buffer.h"
47#include "log.h" 47#include "log.h"
48#include "misc.h" 48#include "misc.h"
49#include "match.h"
49#include "uidswap.h" 50#include "uidswap.h"
50 51
51#include "sftp.h" 52#include "sftp.h"
@@ -57,24 +58,29 @@
57#define get_string(lenp) buffer_get_string(&iqueue, lenp); 58#define get_string(lenp) buffer_get_string(&iqueue, lenp);
58 59
59/* Our verbosity */ 60/* Our verbosity */
60LogLevel log_level = SYSLOG_LEVEL_ERROR; 61static LogLevel log_level = SYSLOG_LEVEL_ERROR;
61 62
62/* Our client */ 63/* Our client */
63struct passwd *pw = NULL; 64static struct passwd *pw = NULL;
64char *client_addr = NULL; 65static char *client_addr = NULL;
65 66
66/* input and output queue */ 67/* input and output queue */
67Buffer iqueue; 68static Buffer iqueue;
68Buffer oqueue; 69static Buffer oqueue;
69 70
70/* Version of client */ 71/* Version of client */
71u_int version; 72static u_int version;
73
74/* SSH2_FXP_INIT received */
75static int init_done;
72 76
73/* Disable writes */ 77/* Disable writes */
74int readonly; 78static int readonly;
75 79
76/* portable attributes, etc. */ 80/* Requests that are allowed/denied */
81static char *request_whitelist, *request_blacklist;
77 82
83/* portable attributes, etc. */
78typedef struct Stat Stat; 84typedef struct Stat Stat;
79 85
80struct Stat { 86struct Stat {
@@ -83,6 +89,102 @@ struct Stat {
83 Attrib attrib; 89 Attrib attrib;
84}; 90};
85 91
92/* Packet handlers */
93static void process_open(u_int32_t id);
94static void process_close(u_int32_t id);
95static void process_read(u_int32_t id);
96static void process_write(u_int32_t id);
97static void process_stat(u_int32_t id);
98static void process_lstat(u_int32_t id);
99static void process_fstat(u_int32_t id);
100static void process_setstat(u_int32_t id);
101static void process_fsetstat(u_int32_t id);
102static void process_opendir(u_int32_t id);
103static void process_readdir(u_int32_t id);
104static void process_remove(u_int32_t id);
105static void process_mkdir(u_int32_t id);
106static void process_rmdir(u_int32_t id);
107static void process_realpath(u_int32_t id);
108static void process_rename(u_int32_t id);
109static void process_readlink(u_int32_t id);
110static void process_symlink(u_int32_t id);
111static void process_extended_posix_rename(u_int32_t id);
112static void process_extended_statvfs(u_int32_t id);
113static void process_extended_fstatvfs(u_int32_t id);
114static void process_extended_hardlink(u_int32_t id);
115static void process_extended_fsync(u_int32_t id);
116static void process_extended(u_int32_t id);
117
118struct sftp_handler {
119 const char *name; /* user-visible name for fine-grained perms */
120 const char *ext_name; /* extended request name */
121 u_int type; /* packet type, for non extended packets */
122 void (*handler)(u_int32_t);
123 int does_write; /* if nonzero, banned for readonly mode */
124};
125
126struct sftp_handler handlers[] = {
127 /* NB. SSH2_FXP_OPEN does the readonly check in the handler itself */
128 { "open", NULL, SSH2_FXP_OPEN, process_open, 0 },
129 { "close", NULL, SSH2_FXP_CLOSE, process_close, 0 },
130 { "read", NULL, SSH2_FXP_READ, process_read, 0 },
131 { "write", NULL, SSH2_FXP_WRITE, process_write, 1 },
132 { "lstat", NULL, SSH2_FXP_LSTAT, process_lstat, 0 },
133 { "fstat", NULL, SSH2_FXP_FSTAT, process_fstat, 0 },
134 { "setstat", NULL, SSH2_FXP_SETSTAT, process_setstat, 1 },
135 { "fsetstat", NULL, SSH2_FXP_FSETSTAT, process_fsetstat, 1 },
136 { "opendir", NULL, SSH2_FXP_OPENDIR, process_opendir, 0 },
137 { "readdir", NULL, SSH2_FXP_READDIR, process_readdir, 0 },
138 { "remove", NULL, SSH2_FXP_REMOVE, process_remove, 1 },
139 { "mkdir", NULL, SSH2_FXP_MKDIR, process_mkdir, 1 },
140 { "rmdir", NULL, SSH2_FXP_RMDIR, process_rmdir, 1 },
141 { "realpath", NULL, SSH2_FXP_REALPATH, process_realpath, 0 },
142 { "stat", NULL, SSH2_FXP_STAT, process_stat, 0 },
143 { "rename", NULL, SSH2_FXP_RENAME, process_rename, 1 },
144 { "readlink", NULL, SSH2_FXP_READLINK, process_readlink, 0 },
145 { "symlink", NULL, SSH2_FXP_SYMLINK, process_symlink, 1 },
146 { NULL, NULL, 0, NULL, 0 }
147};
148
149/* SSH2_FXP_EXTENDED submessages */
150struct sftp_handler extended_handlers[] = {
151 { "posix-rename", "posix-rename@openssh.com", 0,
152 process_extended_posix_rename, 1 },
153 { "statvfs", "statvfs@openssh.com", 0, process_extended_statvfs, 0 },
154 { "fstatvfs", "fstatvfs@openssh.com", 0, process_extended_fstatvfs, 0 },
155 { "hardlink", "hardlink@openssh.com", 0, process_extended_hardlink, 1 },
156 { "fsync", "fsync@openssh.com", 0, process_extended_fsync, 1 },
157 { NULL, NULL, 0, NULL, 0 }
158};
159
160static int
161request_permitted(struct sftp_handler *h)
162{
163 char *result;
164
165 if (readonly && h->does_write) {
166 verbose("Refusing %s request in read-only mode", h->name);
167 return 0;
168 }
169 if (request_blacklist != NULL &&
170 ((result = match_list(h->name, request_blacklist, NULL))) != NULL) {
171 free(result);
172 verbose("Refusing blacklisted %s request", h->name);
173 return 0;
174 }
175 if (request_whitelist != NULL &&
176 ((result = match_list(h->name, request_whitelist, NULL))) != NULL) {
177 free(result);
178 debug2("Permitting whitelisted %s request", h->name);
179 return 1;
180 }
181 if (request_whitelist != NULL) {
182 verbose("Refusing non-whitelisted %s request", h->name);
183 return 0;
184 }
185 return 1;
186}
187
86static int 188static int
87errno_to_portable(int unixerrno) 189errno_to_portable(int unixerrno)
88{ 190{
@@ -130,6 +232,8 @@ flags_from_portable(int pflags)
130 } else if (pflags & SSH2_FXF_WRITE) { 232 } else if (pflags & SSH2_FXF_WRITE) {
131 flags = O_WRONLY; 233 flags = O_WRONLY;
132 } 234 }
235 if (pflags & SSH2_FXF_APPEND)
236 flags |= O_APPEND;
133 if (pflags & SSH2_FXF_CREAT) 237 if (pflags & SSH2_FXF_CREAT)
134 flags |= O_CREAT; 238 flags |= O_CREAT;
135 if (pflags & SSH2_FXF_TRUNC) 239 if (pflags & SSH2_FXF_TRUNC)
@@ -156,6 +260,8 @@ string_from_portable(int pflags)
156 PAPPEND("READ") 260 PAPPEND("READ")
157 if (pflags & SSH2_FXF_WRITE) 261 if (pflags & SSH2_FXF_WRITE)
158 PAPPEND("WRITE") 262 PAPPEND("WRITE")
263 if (pflags & SSH2_FXF_APPEND)
264 PAPPEND("APPEND")
159 if (pflags & SSH2_FXF_CREAT) 265 if (pflags & SSH2_FXF_CREAT)
160 PAPPEND("CREATE") 266 PAPPEND("CREATE")
161 if (pflags & SSH2_FXF_TRUNC) 267 if (pflags & SSH2_FXF_TRUNC)
@@ -179,6 +285,7 @@ struct Handle {
179 int use; 285 int use;
180 DIR *dirp; 286 DIR *dirp;
181 int fd; 287 int fd;
288 int flags;
182 char *name; 289 char *name;
183 u_int64_t bytes_read, bytes_write; 290 u_int64_t bytes_read, bytes_write;
184 int next_unused; 291 int next_unused;
@@ -202,7 +309,7 @@ static void handle_unused(int i)
202} 309}
203 310
204static int 311static int
205handle_new(int use, const char *name, int fd, DIR *dirp) 312handle_new(int use, const char *name, int fd, int flags, DIR *dirp)
206{ 313{
207 int i; 314 int i;
208 315
@@ -220,6 +327,7 @@ handle_new(int use, const char *name, int fd, DIR *dirp)
220 handles[i].use = use; 327 handles[i].use = use;
221 handles[i].dirp = dirp; 328 handles[i].dirp = dirp;
222 handles[i].fd = fd; 329 handles[i].fd = fd;
330 handles[i].flags = flags;
223 handles[i].name = xstrdup(name); 331 handles[i].name = xstrdup(name);
224 handles[i].bytes_read = handles[i].bytes_write = 0; 332 handles[i].bytes_read = handles[i].bytes_write = 0;
225 333
@@ -282,6 +390,14 @@ handle_to_fd(int handle)
282 return -1; 390 return -1;
283} 391}
284 392
393static int
394handle_to_flags(int handle)
395{
396 if (handle_is_ok(handle, HANDLE_FILE))
397 return handles[handle].flags;
398 return 0;
399}
400
285static void 401static void
286handle_update_read(int handle, ssize_t bytes) 402handle_update_read(int handle, ssize_t bytes)
287{ 403{
@@ -538,19 +654,21 @@ process_init(void)
538 /* hardlink extension */ 654 /* hardlink extension */
539 buffer_put_cstring(&msg, "hardlink@openssh.com"); 655 buffer_put_cstring(&msg, "hardlink@openssh.com");
540 buffer_put_cstring(&msg, "1"); /* version */ 656 buffer_put_cstring(&msg, "1"); /* version */
657 /* fsync extension */
658 buffer_put_cstring(&msg, "fsync@openssh.com");
659 buffer_put_cstring(&msg, "1"); /* version */
541 send_msg(&msg); 660 send_msg(&msg);
542 buffer_free(&msg); 661 buffer_free(&msg);
543} 662}
544 663
545static void 664static void
546process_open(void) 665process_open(u_int32_t id)
547{ 666{
548 u_int32_t id, pflags; 667 u_int32_t pflags;
549 Attrib *a; 668 Attrib *a;
550 char *name; 669 char *name;
551 int handle, fd, flags, mode, status = SSH2_FX_FAILURE; 670 int handle, fd, flags, mode, status = SSH2_FX_FAILURE;
552 671
553 id = get_int();
554 name = get_string(NULL); 672 name = get_string(NULL);
555 pflags = get_int(); /* portable flags */ 673 pflags = get_int(); /* portable flags */
556 debug3("request %u: open flags %d", id, pflags); 674 debug3("request %u: open flags %d", id, pflags);
@@ -560,14 +678,16 @@ process_open(void)
560 logit("open \"%s\" flags %s mode 0%o", 678 logit("open \"%s\" flags %s mode 0%o",
561 name, string_from_portable(pflags), mode); 679 name, string_from_portable(pflags), mode);
562 if (readonly && 680 if (readonly &&
563 ((flags & O_ACCMODE) == O_WRONLY || (flags & O_ACCMODE) == O_RDWR)) 681 ((flags & O_ACCMODE) == O_WRONLY ||
564 status = SSH2_FX_PERMISSION_DENIED; 682 (flags & O_ACCMODE) == O_RDWR)) {
565 else { 683 verbose("Refusing open request in read-only mode");
684 status = SSH2_FX_PERMISSION_DENIED;
685 } else {
566 fd = open(name, flags, mode); 686 fd = open(name, flags, mode);
567 if (fd < 0) { 687 if (fd < 0) {
568 status = errno_to_portable(errno); 688 status = errno_to_portable(errno);
569 } else { 689 } else {
570 handle = handle_new(HANDLE_FILE, name, fd, NULL); 690 handle = handle_new(HANDLE_FILE, name, fd, flags, NULL);
571 if (handle < 0) { 691 if (handle < 0) {
572 close(fd); 692 close(fd);
573 } else { 693 } else {
@@ -582,12 +702,10 @@ process_open(void)
582} 702}
583 703
584static void 704static void
585process_close(void) 705process_close(u_int32_t id)
586{ 706{
587 u_int32_t id;
588 int handle, ret, status = SSH2_FX_FAILURE; 707 int handle, ret, status = SSH2_FX_FAILURE;
589 708
590 id = get_int();
591 handle = get_handle(); 709 handle = get_handle();
592 debug3("request %u: close handle %u", id, handle); 710 debug3("request %u: close handle %u", id, handle);
593 handle_log_close(handle, NULL); 711 handle_log_close(handle, NULL);
@@ -597,14 +715,13 @@ process_close(void)
597} 715}
598 716
599static void 717static void
600process_read(void) 718process_read(u_int32_t id)
601{ 719{
602 char buf[64*1024]; 720 char buf[64*1024];
603 u_int32_t id, len; 721 u_int32_t len;
604 int handle, fd, ret, status = SSH2_FX_FAILURE; 722 int handle, fd, ret, status = SSH2_FX_FAILURE;
605 u_int64_t off; 723 u_int64_t off;
606 724
607 id = get_int();
608 handle = get_handle(); 725 handle = get_handle();
609 off = get_int64(); 726 off = get_int64();
610 len = get_int(); 727 len = get_int();
@@ -638,15 +755,13 @@ process_read(void)
638} 755}
639 756
640static void 757static void
641process_write(void) 758process_write(u_int32_t id)
642{ 759{
643 u_int32_t id;
644 u_int64_t off; 760 u_int64_t off;
645 u_int len; 761 u_int len;
646 int handle, fd, ret, status; 762 int handle, fd, ret, status;
647 char *data; 763 char *data;
648 764
649 id = get_int();
650 handle = get_handle(); 765 handle = get_handle();
651 off = get_int64(); 766 off = get_int64();
652 data = get_string(&len); 767 data = get_string(&len);
@@ -657,10 +772,9 @@ process_write(void)
657 772
658 if (fd < 0) 773 if (fd < 0)
659 status = SSH2_FX_FAILURE; 774 status = SSH2_FX_FAILURE;
660 else if (readonly)
661 status = SSH2_FX_PERMISSION_DENIED;
662 else { 775 else {
663 if (lseek(fd, off, SEEK_SET) < 0) { 776 if (!(handle_to_flags(handle) & O_APPEND) &&
777 lseek(fd, off, SEEK_SET) < 0) {
664 status = errno_to_portable(errno); 778 status = errno_to_portable(errno);
665 error("process_write: seek failed"); 779 error("process_write: seek failed");
666 } else { 780 } else {
@@ -683,15 +797,13 @@ process_write(void)
683} 797}
684 798
685static void 799static void
686process_do_stat(int do_lstat) 800process_do_stat(u_int32_t id, int do_lstat)
687{ 801{
688 Attrib a; 802 Attrib a;
689 struct stat st; 803 struct stat st;
690 u_int32_t id;
691 char *name; 804 char *name;
692 int ret, status = SSH2_FX_FAILURE; 805 int ret, status = SSH2_FX_FAILURE;
693 806
694 id = get_int();
695 name = get_string(NULL); 807 name = get_string(NULL);
696 debug3("request %u: %sstat", id, do_lstat ? "l" : ""); 808 debug3("request %u: %sstat", id, do_lstat ? "l" : "");
697 verbose("%sstat name \"%s\"", do_lstat ? "l" : "", name); 809 verbose("%sstat name \"%s\"", do_lstat ? "l" : "", name);
@@ -709,26 +821,24 @@ process_do_stat(int do_lstat)
709} 821}
710 822
711static void 823static void
712process_stat(void) 824process_stat(u_int32_t id)
713{ 825{
714 process_do_stat(0); 826 process_do_stat(id, 0);
715} 827}
716 828
717static void 829static void
718process_lstat(void) 830process_lstat(u_int32_t id)
719{ 831{
720 process_do_stat(1); 832 process_do_stat(id, 1);
721} 833}
722 834
723static void 835static void
724process_fstat(void) 836process_fstat(u_int32_t id)
725{ 837{
726 Attrib a; 838 Attrib a;
727 struct stat st; 839 struct stat st;
728 u_int32_t id;
729 int fd, ret, handle, status = SSH2_FX_FAILURE; 840 int fd, ret, handle, status = SSH2_FX_FAILURE;
730 841
731 id = get_int();
732 handle = get_handle(); 842 handle = get_handle();
733 debug("request %u: fstat \"%s\" (handle %u)", 843 debug("request %u: fstat \"%s\" (handle %u)",
734 id, handle_to_name(handle), handle); 844 id, handle_to_name(handle), handle);
@@ -760,21 +870,15 @@ attrib_to_tv(const Attrib *a)
760} 870}
761 871
762static void 872static void
763process_setstat(void) 873process_setstat(u_int32_t id)
764{ 874{
765 Attrib *a; 875 Attrib *a;
766 u_int32_t id;
767 char *name; 876 char *name;
768 int status = SSH2_FX_OK, ret; 877 int status = SSH2_FX_OK, ret;
769 878
770 id = get_int();
771 name = get_string(NULL); 879 name = get_string(NULL);
772 a = get_attrib(); 880 a = get_attrib();
773 debug("request %u: setstat name \"%s\"", id, name); 881 debug("request %u: setstat name \"%s\"", id, name);
774 if (readonly) {
775 status = SSH2_FX_PERMISSION_DENIED;
776 a->flags = 0;
777 }
778 if (a->flags & SSH2_FILEXFER_ATTR_SIZE) { 882 if (a->flags & SSH2_FILEXFER_ATTR_SIZE) {
779 logit("set \"%s\" size %llu", 883 logit("set \"%s\" size %llu",
780 name, (unsigned long long)a->size); 884 name, (unsigned long long)a->size);
@@ -811,22 +915,18 @@ process_setstat(void)
811} 915}
812 916
813static void 917static void
814process_fsetstat(void) 918process_fsetstat(u_int32_t id)
815{ 919{
816 Attrib *a; 920 Attrib *a;
817 u_int32_t id;
818 int handle, fd, ret; 921 int handle, fd, ret;
819 int status = SSH2_FX_OK; 922 int status = SSH2_FX_OK;
820 923
821 id = get_int();
822 handle = get_handle(); 924 handle = get_handle();
823 a = get_attrib(); 925 a = get_attrib();
824 debug("request %u: fsetstat handle %d", id, handle); 926 debug("request %u: fsetstat handle %d", id, handle);
825 fd = handle_to_fd(handle); 927 fd = handle_to_fd(handle);
826 if (fd < 0) 928 if (fd < 0)
827 status = SSH2_FX_FAILURE; 929 status = SSH2_FX_FAILURE;
828 else if (readonly)
829 status = SSH2_FX_PERMISSION_DENIED;
830 else { 930 else {
831 char *name = handle_to_name(handle); 931 char *name = handle_to_name(handle);
832 932
@@ -878,14 +978,12 @@ process_fsetstat(void)
878} 978}
879 979
880static void 980static void
881process_opendir(void) 981process_opendir(u_int32_t id)
882{ 982{
883 DIR *dirp = NULL; 983 DIR *dirp = NULL;
884 char *path; 984 char *path;
885 int handle, status = SSH2_FX_FAILURE; 985 int handle, status = SSH2_FX_FAILURE;
886 u_int32_t id;
887 986
888 id = get_int();
889 path = get_string(NULL); 987 path = get_string(NULL);
890 debug3("request %u: opendir", id); 988 debug3("request %u: opendir", id);
891 logit("opendir \"%s\"", path); 989 logit("opendir \"%s\"", path);
@@ -893,7 +991,7 @@ process_opendir(void)
893 if (dirp == NULL) { 991 if (dirp == NULL) {
894 status = errno_to_portable(errno); 992 status = errno_to_portable(errno);
895 } else { 993 } else {
896 handle = handle_new(HANDLE_DIR, path, 0, dirp); 994 handle = handle_new(HANDLE_DIR, path, 0, 0, dirp);
897 if (handle < 0) { 995 if (handle < 0) {
898 closedir(dirp); 996 closedir(dirp);
899 } else { 997 } else {
@@ -908,15 +1006,13 @@ process_opendir(void)
908} 1006}
909 1007
910static void 1008static void
911process_readdir(void) 1009process_readdir(u_int32_t id)
912{ 1010{
913 DIR *dirp; 1011 DIR *dirp;
914 struct dirent *dp; 1012 struct dirent *dp;
915 char *path; 1013 char *path;
916 int handle; 1014 int handle;
917 u_int32_t id;
918 1015
919 id = get_int();
920 handle = get_handle(); 1016 handle = get_handle();
921 debug("request %u: readdir \"%s\" (handle %d)", id, 1017 debug("request %u: readdir \"%s\" (handle %d)", id,
922 handle_to_name(handle), handle); 1018 handle_to_name(handle), handle);
@@ -964,81 +1060,61 @@ process_readdir(void)
964} 1060}
965 1061
966static void 1062static void
967process_remove(void) 1063process_remove(u_int32_t id)
968{ 1064{
969 char *name; 1065 char *name;
970 u_int32_t id;
971 int status = SSH2_FX_FAILURE; 1066 int status = SSH2_FX_FAILURE;
972 int ret; 1067 int ret;
973 1068
974 id = get_int();
975 name = get_string(NULL); 1069 name = get_string(NULL);
976 debug3("request %u: remove", id); 1070 debug3("request %u: remove", id);
977 logit("remove name \"%s\"", name); 1071 logit("remove name \"%s\"", name);
978 if (readonly) 1072 ret = unlink(name);
979 status = SSH2_FX_PERMISSION_DENIED; 1073 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
980 else {
981 ret = unlink(name);
982 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
983 }
984 send_status(id, status); 1074 send_status(id, status);
985 free(name); 1075 free(name);
986} 1076}
987 1077
988static void 1078static void
989process_mkdir(void) 1079process_mkdir(u_int32_t id)
990{ 1080{
991 Attrib *a; 1081 Attrib *a;
992 u_int32_t id;
993 char *name; 1082 char *name;
994 int ret, mode, status = SSH2_FX_FAILURE; 1083 int ret, mode, status = SSH2_FX_FAILURE;
995 1084
996 id = get_int();
997 name = get_string(NULL); 1085 name = get_string(NULL);
998 a = get_attrib(); 1086 a = get_attrib();
999 mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? 1087 mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ?
1000 a->perm & 07777 : 0777; 1088 a->perm & 07777 : 0777;
1001 debug3("request %u: mkdir", id); 1089 debug3("request %u: mkdir", id);
1002 logit("mkdir name \"%s\" mode 0%o", name, mode); 1090 logit("mkdir name \"%s\" mode 0%o", name, mode);
1003 if (readonly) 1091 ret = mkdir(name, mode);
1004 status = SSH2_FX_PERMISSION_DENIED; 1092 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
1005 else {
1006 ret = mkdir(name, mode);
1007 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
1008 }
1009 send_status(id, status); 1093 send_status(id, status);
1010 free(name); 1094 free(name);
1011} 1095}
1012 1096
1013static void 1097static void
1014process_rmdir(void) 1098process_rmdir(u_int32_t id)
1015{ 1099{
1016 u_int32_t id;
1017 char *name; 1100 char *name;
1018 int ret, status; 1101 int ret, status;
1019 1102
1020 id = get_int();
1021 name = get_string(NULL); 1103 name = get_string(NULL);
1022 debug3("request %u: rmdir", id); 1104 debug3("request %u: rmdir", id);
1023 logit("rmdir name \"%s\"", name); 1105 logit("rmdir name \"%s\"", name);
1024 if (readonly) 1106 ret = rmdir(name);
1025 status = SSH2_FX_PERMISSION_DENIED; 1107 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
1026 else {
1027 ret = rmdir(name);
1028 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
1029 }
1030 send_status(id, status); 1108 send_status(id, status);
1031 free(name); 1109 free(name);
1032} 1110}
1033 1111
1034static void 1112static void
1035process_realpath(void) 1113process_realpath(u_int32_t id)
1036{ 1114{
1037 char resolvedname[MAXPATHLEN]; 1115 char resolvedname[MAXPATHLEN];
1038 u_int32_t id;
1039 char *path; 1116 char *path;
1040 1117
1041 id = get_int();
1042 path = get_string(NULL); 1118 path = get_string(NULL);
1043 if (path[0] == '\0') { 1119 if (path[0] == '\0') {
1044 free(path); 1120 free(path);
@@ -1058,22 +1134,18 @@ process_realpath(void)
1058} 1134}
1059 1135
1060static void 1136static void
1061process_rename(void) 1137process_rename(u_int32_t id)
1062{ 1138{
1063 u_int32_t id;
1064 char *oldpath, *newpath; 1139 char *oldpath, *newpath;
1065 int status; 1140 int status;
1066 struct stat sb; 1141 struct stat sb;
1067 1142
1068 id = get_int();
1069 oldpath = get_string(NULL); 1143 oldpath = get_string(NULL);
1070 newpath = get_string(NULL); 1144 newpath = get_string(NULL);
1071 debug3("request %u: rename", id); 1145 debug3("request %u: rename", id);
1072 logit("rename old \"%s\" new \"%s\"", oldpath, newpath); 1146 logit("rename old \"%s\" new \"%s\"", oldpath, newpath);
1073 status = SSH2_FX_FAILURE; 1147 status = SSH2_FX_FAILURE;
1074 if (readonly) 1148 if (lstat(oldpath, &sb) == -1)
1075 status = SSH2_FX_PERMISSION_DENIED;
1076 else if (lstat(oldpath, &sb) == -1)
1077 status = errno_to_portable(errno); 1149 status = errno_to_portable(errno);
1078 else if (S_ISREG(sb.st_mode)) { 1150 else if (S_ISREG(sb.st_mode)) {
1079 /* Race-free rename of regular files */ 1151 /* Race-free rename of regular files */
@@ -1120,14 +1192,12 @@ process_rename(void)
1120} 1192}
1121 1193
1122static void 1194static void
1123process_readlink(void) 1195process_readlink(u_int32_t id)
1124{ 1196{
1125 u_int32_t id;
1126 int len; 1197 int len;
1127 char buf[MAXPATHLEN]; 1198 char buf[MAXPATHLEN];
1128 char *path; 1199 char *path;
1129 1200
1130 id = get_int();
1131 path = get_string(NULL); 1201 path = get_string(NULL);
1132 debug3("request %u: readlink", id); 1202 debug3("request %u: readlink", id);
1133 verbose("readlink \"%s\"", path); 1203 verbose("readlink \"%s\"", path);
@@ -1145,24 +1215,18 @@ process_readlink(void)
1145} 1215}
1146 1216
1147static void 1217static void
1148process_symlink(void) 1218process_symlink(u_int32_t id)
1149{ 1219{
1150 u_int32_t id;
1151 char *oldpath, *newpath; 1220 char *oldpath, *newpath;
1152 int ret, status; 1221 int ret, status;
1153 1222
1154 id = get_int();
1155 oldpath = get_string(NULL); 1223 oldpath = get_string(NULL);
1156 newpath = get_string(NULL); 1224 newpath = get_string(NULL);
1157 debug3("request %u: symlink", id); 1225 debug3("request %u: symlink", id);
1158 logit("symlink old \"%s\" new \"%s\"", oldpath, newpath); 1226 logit("symlink old \"%s\" new \"%s\"", oldpath, newpath);
1159 /* this will fail if 'newpath' exists */ 1227 /* this will fail if 'newpath' exists */
1160 if (readonly) 1228 ret = symlink(oldpath, newpath);
1161 status = SSH2_FX_PERMISSION_DENIED; 1229 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
1162 else {
1163 ret = symlink(oldpath, newpath);
1164 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
1165 }
1166 send_status(id, status); 1230 send_status(id, status);
1167 free(oldpath); 1231 free(oldpath);
1168 free(newpath); 1232 free(newpath);
@@ -1178,12 +1242,8 @@ process_extended_posix_rename(u_int32_t id)
1178 newpath = get_string(NULL); 1242 newpath = get_string(NULL);
1179 debug3("request %u: posix-rename", id); 1243 debug3("request %u: posix-rename", id);
1180 logit("posix-rename old \"%s\" new \"%s\"", oldpath, newpath); 1244 logit("posix-rename old \"%s\" new \"%s\"", oldpath, newpath);
1181 if (readonly) 1245 ret = rename(oldpath, newpath);
1182 status = SSH2_FX_PERMISSION_DENIED; 1246 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
1183 else {
1184 ret = rename(oldpath, newpath);
1185 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
1186 }
1187 send_status(id, status); 1247 send_status(id, status);
1188 free(oldpath); 1248 free(oldpath);
1189 free(newpath); 1249 free(newpath);
@@ -1196,8 +1256,8 @@ process_extended_statvfs(u_int32_t id)
1196 struct statvfs st; 1256 struct statvfs st;
1197 1257
1198 path = get_string(NULL); 1258 path = get_string(NULL);
1199 debug3("request %u: statfs", id); 1259 debug3("request %u: statvfs", id);
1200 logit("statfs \"%s\"", path); 1260 logit("statvfs \"%s\"", path);
1201 1261
1202 if (statvfs(path, &st) != 0) 1262 if (statvfs(path, &st) != 0)
1203 send_status(id, errno_to_portable(errno)); 1263 send_status(id, errno_to_portable(errno));
@@ -1235,35 +1295,50 @@ process_extended_hardlink(u_int32_t id)
1235 newpath = get_string(NULL); 1295 newpath = get_string(NULL);
1236 debug3("request %u: hardlink", id); 1296 debug3("request %u: hardlink", id);
1237 logit("hardlink old \"%s\" new \"%s\"", oldpath, newpath); 1297 logit("hardlink old \"%s\" new \"%s\"", oldpath, newpath);
1238 if (readonly) 1298 ret = link(oldpath, newpath);
1239 status = SSH2_FX_PERMISSION_DENIED; 1299 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
1240 else {
1241 ret = link(oldpath, newpath);
1242 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
1243 }
1244 send_status(id, status); 1300 send_status(id, status);
1245 free(oldpath); 1301 free(oldpath);
1246 free(newpath); 1302 free(newpath);
1247} 1303}
1248 1304
1249static void 1305static void
1250process_extended(void) 1306process_extended_fsync(u_int32_t id)
1307{
1308 int handle, fd, ret, status = SSH2_FX_OP_UNSUPPORTED;
1309
1310 handle = get_handle();
1311 debug3("request %u: fsync (handle %u)", id, handle);
1312 verbose("fsync \"%s\"", handle_to_name(handle));
1313 if ((fd = handle_to_fd(handle)) < 0)
1314 status = SSH2_FX_NO_SUCH_FILE;
1315 else if (handle_is_ok(handle, HANDLE_FILE)) {
1316 ret = fsync(fd);
1317 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
1318 }
1319 send_status(id, status);
1320}
1321
1322static void
1323process_extended(u_int32_t id)
1251{ 1324{
1252 u_int32_t id;
1253 char *request; 1325 char *request;
1326 u_int i;
1254 1327
1255 id = get_int();
1256 request = get_string(NULL); 1328 request = get_string(NULL);
1257 if (strcmp(request, "posix-rename@openssh.com") == 0) 1329 for (i = 0; extended_handlers[i].handler != NULL; i++) {
1258 process_extended_posix_rename(id); 1330 if (strcmp(request, extended_handlers[i].ext_name) == 0) {
1259 else if (strcmp(request, "statvfs@openssh.com") == 0) 1331 if (!request_permitted(&extended_handlers[i]))
1260 process_extended_statvfs(id); 1332 send_status(id, SSH2_FX_PERMISSION_DENIED);
1261 else if (strcmp(request, "fstatvfs@openssh.com") == 0) 1333 else
1262 process_extended_fstatvfs(id); 1334 extended_handlers[i].handler(id);
1263 else if (strcmp(request, "hardlink@openssh.com") == 0) 1335 break;
1264 process_extended_hardlink(id); 1336 }
1265 else 1337 }
1338 if (extended_handlers[i].handler == NULL) {
1339 error("Unknown extended request \"%.100s\"", request);
1266 send_status(id, SSH2_FX_OP_UNSUPPORTED); /* MUST */ 1340 send_status(id, SSH2_FX_OP_UNSUPPORTED); /* MUST */
1341 }
1267 free(request); 1342 free(request);
1268} 1343}
1269 1344
@@ -1272,11 +1347,9 @@ process_extended(void)
1272static void 1347static void
1273process(void) 1348process(void)
1274{ 1349{
1275 u_int msg_len; 1350 u_int msg_len, buf_len, consumed, type, i;
1276 u_int buf_len;
1277 u_int consumed;
1278 u_int type;
1279 u_char *cp; 1351 u_char *cp;
1352 u_int32_t id;
1280 1353
1281 buf_len = buffer_len(&iqueue); 1354 buf_len = buffer_len(&iqueue);
1282 if (buf_len < 5) 1355 if (buf_len < 5)
@@ -1293,70 +1366,35 @@ process(void)
1293 buffer_consume(&iqueue, 4); 1366 buffer_consume(&iqueue, 4);
1294 buf_len -= 4; 1367 buf_len -= 4;
1295 type = buffer_get_char(&iqueue); 1368 type = buffer_get_char(&iqueue);
1369
1296 switch (type) { 1370 switch (type) {
1297 case SSH2_FXP_INIT: 1371 case SSH2_FXP_INIT:
1298 process_init(); 1372 process_init();
1299 break; 1373 init_done = 1;
1300 case SSH2_FXP_OPEN:
1301 process_open();
1302 break;
1303 case SSH2_FXP_CLOSE:
1304 process_close();
1305 break;
1306 case SSH2_FXP_READ:
1307 process_read();
1308 break;
1309 case SSH2_FXP_WRITE:
1310 process_write();
1311 break;
1312 case SSH2_FXP_LSTAT:
1313 process_lstat();
1314 break;
1315 case SSH2_FXP_FSTAT:
1316 process_fstat();
1317 break;
1318 case SSH2_FXP_SETSTAT:
1319 process_setstat();
1320 break;
1321 case SSH2_FXP_FSETSTAT:
1322 process_fsetstat();
1323 break;
1324 case SSH2_FXP_OPENDIR:
1325 process_opendir();
1326 break;
1327 case SSH2_FXP_READDIR:
1328 process_readdir();
1329 break;
1330 case SSH2_FXP_REMOVE:
1331 process_remove();
1332 break;
1333 case SSH2_FXP_MKDIR:
1334 process_mkdir();
1335 break;
1336 case SSH2_FXP_RMDIR:
1337 process_rmdir();
1338 break;
1339 case SSH2_FXP_REALPATH:
1340 process_realpath();
1341 break;
1342 case SSH2_FXP_STAT:
1343 process_stat();
1344 break;
1345 case SSH2_FXP_RENAME:
1346 process_rename();
1347 break;
1348 case SSH2_FXP_READLINK:
1349 process_readlink();
1350 break;
1351 case SSH2_FXP_SYMLINK:
1352 process_symlink();
1353 break; 1374 break;
1354 case SSH2_FXP_EXTENDED: 1375 case SSH2_FXP_EXTENDED:
1355 process_extended(); 1376 if (!init_done)
1377 fatal("Received extended request before init");
1378 id = get_int();
1379 process_extended(id);
1356 break; 1380 break;
1357 default: 1381 default:
1358 error("Unknown message %d", type); 1382 if (!init_done)
1359 break; 1383 fatal("Received %u request before init", type);
1384 id = get_int();
1385 for (i = 0; handlers[i].handler != NULL; i++) {
1386 if (type == handlers[i].type) {
1387 if (!request_permitted(&handlers[i])) {
1388 send_status(id,
1389 SSH2_FX_PERMISSION_DENIED);
1390 } else {
1391 handlers[i].handler(id);
1392 }
1393 break;
1394 }
1395 }
1396 if (handlers[i].handler == NULL)
1397 error("Unknown message %u", type);
1360 } 1398 }
1361 /* discard the remaining bytes from the current packet */ 1399 /* discard the remaining bytes from the current packet */
1362 if (buf_len < buffer_len(&iqueue)) { 1400 if (buf_len < buffer_len(&iqueue)) {
@@ -1365,7 +1403,7 @@ process(void)
1365 } 1403 }
1366 consumed = buf_len - buffer_len(&iqueue); 1404 consumed = buf_len - buffer_len(&iqueue);
1367 if (msg_len < consumed) { 1405 if (msg_len < consumed) {
1368 error("msg_len %d < consumed %d", msg_len, consumed); 1406 error("msg_len %u < consumed %u", msg_len, consumed);
1369 sftp_server_cleanup_exit(255); 1407 sftp_server_cleanup_exit(255);
1370 } 1408 }
1371 if (msg_len > consumed) 1409 if (msg_len > consumed)
@@ -1391,8 +1429,10 @@ sftp_server_usage(void)
1391 1429
1392 fprintf(stderr, 1430 fprintf(stderr,
1393 "usage: %s [-ehR] [-d start_directory] [-f log_facility] " 1431 "usage: %s [-ehR] [-d start_directory] [-f log_facility] "
1394 "[-l log_level]\n\t[-u umask]\n", 1432 "[-l log_level]\n\t[-P blacklisted_requests] "
1395 __progname); 1433 "[-p whitelisted_requests] [-u umask]\n"
1434 " %s -Q protocol_feature\n",
1435 __progname, __progname);
1396 exit(1); 1436 exit(1);
1397} 1437}
1398 1438
@@ -1400,7 +1440,7 @@ int
1400sftp_server_main(int argc, char **argv, struct passwd *user_pw) 1440sftp_server_main(int argc, char **argv, struct passwd *user_pw)
1401{ 1441{
1402 fd_set *rset, *wset; 1442 fd_set *rset, *wset;
1403 int in, out, max, ch, skipargs = 0, log_stderr = 0; 1443 int i, in, out, max, ch, skipargs = 0, log_stderr = 0;
1404 ssize_t len, olen, set_size; 1444 ssize_t len, olen, set_size;
1405 SyslogFacility log_facility = SYSLOG_FACILITY_AUTH; 1445 SyslogFacility log_facility = SYSLOG_FACILITY_AUTH;
1406 char *cp, *homedir = NULL, buf[4*4096]; 1446 char *cp, *homedir = NULL, buf[4*4096];
@@ -1414,8 +1454,20 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
1414 1454
1415 pw = pwcopy(user_pw); 1455 pw = pwcopy(user_pw);
1416 1456
1417 while (!skipargs && (ch = getopt(argc, argv, "d:f:l:u:cehR")) != -1) { 1457 while (!skipargs && (ch = getopt(argc, argv,
1458 "d:f:l:P:p:Q:u:cehR")) != -1) {
1418 switch (ch) { 1459 switch (ch) {
1460 case 'Q':
1461 if (strcasecmp(optarg, "requests") != 0) {
1462 fprintf(stderr, "Invalid query type\n");
1463 exit(1);
1464 }
1465 for (i = 0; handlers[i].handler != NULL; i++)
1466 printf("%s\n", handlers[i].name);
1467 for (i = 0; extended_handlers[i].handler != NULL; i++)
1468 printf("%s\n", extended_handlers[i].name);
1469 exit(0);
1470 break;
1419 case 'R': 1471 case 'R':
1420 readonly = 1; 1472 readonly = 1;
1421 break; 1473 break;
@@ -1445,6 +1497,16 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
1445 "u", user_pw->pw_name, (char *)NULL); 1497 "u", user_pw->pw_name, (char *)NULL);
1446 free(cp); 1498 free(cp);
1447 break; 1499 break;
1500 case 'p':
1501 if (request_whitelist != NULL)
1502 fatal("Permitted requests already set");
1503 request_whitelist = xstrdup(optarg);
1504 break;
1505 case 'P':
1506 if (request_blacklist != NULL)
1507 fatal("Refused requests already set");
1508 request_blacklist = xstrdup(optarg);
1509 break;
1448 case 'u': 1510 case 'u':
1449 errno = 0; 1511 errno = 0;
1450 mask = strtol(optarg, &cp, 8); 1512 mask = strtol(optarg, &cp, 8);
diff --git a/sftp.0 b/sftp.0
index 8bfc8086b..248737046 100644
--- a/sftp.0
+++ b/sftp.0
@@ -4,7 +4,7 @@ NAME
4 sftp - secure file transfer program 4 sftp - secure file transfer program
5 5
6SYNOPSIS 6SYNOPSIS
7 sftp [-1246Cpqrv] [-B buffer_size] [-b batchfile] [-c cipher] 7 sftp [-1246aCfpqrv] [-B buffer_size] [-b batchfile] [-c cipher]
8 [-D sftp_server_path] [-F ssh_config] [-i identity_file] [-l limit] 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
@@ -44,6 +44,11 @@ DESCRIPTION
44 44
45 -6 Forces sftp to use IPv6 addresses only. 45 -6 Forces sftp to use IPv6 addresses only.
46 46
47 -a Attempt to continue interrupted downloads rather than overwriting
48 existing partial or complete copies of files. If the remote file
49 contents differ from the partial local copy then the resultant
50 file is likely to be corrupt.
51
47 -B buffer_size 52 -B buffer_size
48 Specify the size of the buffer that sftp uses when transferring 53 Specify the size of the buffer that sftp uses when transferring
49 files. Larger buffers require fewer round trips at the cost of 54 files. Larger buffers require fewer round trips at the cost of
@@ -74,6 +79,10 @@ DESCRIPTION
74 Specifies an alternative per-user configuration file for ssh(1). 79 Specifies an alternative per-user configuration file for ssh(1).
75 This option is directly passed to ssh(1). 80 This option is directly passed to ssh(1).
76 81
82 -f Requests that files be flushed to disk immediately after
83 transfer. When uploading files, this feature is only enabled if
84 the server implements the "fsync@openssh.com" extension.
85
77 -i identity_file 86 -i identity_file
78 Selects the file from which the identity (private key) for public 87 Selects the file from which the identity (private key) for public
79 key authentication is read. This option is directly passed to 88 key authentication is read. This option is directly passed to
@@ -93,6 +102,11 @@ DESCRIPTION
93 AddressFamily 102 AddressFamily
94 BatchMode 103 BatchMode
95 BindAddress 104 BindAddress
105 CanonicalDomains
106 CanonicalizeFallbackLocal
107 CanonicalizeHostname
108 CanonicalizeMaxDots
109 CanonicalizePermittedCNAMEs
96 ChallengeResponseAuthentication 110 ChallengeResponseAuthentication
97 CheckHostIP 111 CheckHostIP
98 Cipher 112 Cipher
@@ -209,7 +223,7 @@ INTERACTIVE COMMANDS
209 223
210 exit Quit sftp. 224 exit Quit sftp.
211 225
212 get [-aPpr] remote-path [local-path] 226 get [-afPpr] remote-path [local-path]
213 Retrieve the remote-path and store it on the local machine. If 227 Retrieve the remote-path and store it on the local machine. If
214 the local path name is not specified, it is given the same name 228 the local path name is not specified, it is given the same name
215 it has on the remote machine. remote-path may contain glob(3) 229 it has on the remote machine. remote-path may contain glob(3)
@@ -220,8 +234,11 @@ INTERACTIVE COMMANDS
220 If the -a flag is specified, then attempt to resume partial 234 If the -a flag is specified, then attempt to resume partial
221 transfers of existing files. Note that resumption assumes that 235 transfers of existing files. Note that resumption assumes that
222 any partial copy of the local file matches the remote copy. If 236 any partial copy of the local file matches the remote copy. If
223 the remote file differs from the partial local copy then the 237 the remote file contents differ from the partial local copy then
224 resultant file is likely to be corrupt. 238 the resultant file is likely to be corrupt.
239
240 If the -f flag is specified, then fsync(2) will be called after
241 the file transfer has completed to flush the file to disk.
225 242
226 If either the -P or -p flag is specified, then full file 243 If either the -P or -p flag is specified, then full file
227 permissions and access times are copied too. 244 permissions and access times are copied too.
@@ -293,7 +310,7 @@ INTERACTIVE COMMANDS
293 progress 310 progress
294 Toggle display of progress meter. 311 Toggle display of progress meter.
295 312
296 put [-Ppr] local-path [remote-path] 313 put [-fPpr] local-path [remote-path]
297 Upload local-path and store it on the remote machine. If the 314 Upload local-path and store it on the remote machine. If the
298 remote path name is not specified, it is given the same name it 315 remote path name is not specified, it is given the same name it
299 has on the local machine. local-path may contain glob(3) 316 has on the local machine. local-path may contain glob(3)
@@ -301,6 +318,11 @@ INTERACTIVE COMMANDS
301 remote-path is specified, then remote-path must specify a 318 remote-path is specified, then remote-path must specify a
302 directory. 319 directory.
303 320
321 If the -f flag is specified, then a request will be sent to the
322 server to call fsync(2) after the file has been transferred.
323 Note that this is only supported by servers that implement the
324 "fsync@openssh.com" extension.
325
304 If either the -P or -p flag is specified, then full file 326 If either the -P or -p flag is specified, then full file
305 permissions and access times are copied too. 327 permissions and access times are copied too.
306 328
@@ -345,4 +367,4 @@ SEE ALSO
345 T. Ylonen and S. Lehtinen, SSH File Transfer Protocol, draft-ietf-secsh- 367 T. Ylonen and S. Lehtinen, SSH File Transfer Protocol, draft-ietf-secsh-
346 filexfer-00.txt, January 2001, work in progress material. 368 filexfer-00.txt, January 2001, work in progress material.
347 369
348OpenBSD 5.4 July 25, 2013 OpenBSD 5.4 370OpenBSD 5.4 October 20, 2013 OpenBSD 5.4
diff --git a/sftp.1 b/sftp.1
index 2577fe875..a700c2adb 100644
--- a/sftp.1
+++ b/sftp.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: sftp.1,v 1.92 2013/07/25 00:56:51 djm Exp $ 1.\" $OpenBSD: sftp.1,v 1.97 2013/10/20 09:51:26 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: July 25 2013 $ 25.Dd $Mdocdate: October 20 2013 $
26.Dt SFTP 1 26.Dt SFTP 1
27.Os 27.Os
28.Sh NAME 28.Sh NAME
@@ -31,7 +31,7 @@
31.Sh SYNOPSIS 31.Sh SYNOPSIS
32.Nm sftp 32.Nm sftp
33.Bk -words 33.Bk -words
34.Op Fl 1246Cpqrv 34.Op Fl 1246aCfpqrv
35.Op Fl B Ar buffer_size 35.Op Fl B Ar buffer_size
36.Op Fl b Ar batchfile 36.Op Fl b Ar batchfile
37.Op Fl c Ar cipher 37.Op Fl c Ar cipher
@@ -107,6 +107,11 @@ to use IPv4 addresses only.
107Forces 107Forces
108.Nm 108.Nm
109to use IPv6 addresses only. 109to use IPv6 addresses only.
110.It Fl a
111Attempt to continue interrupted downloads rather than overwriting existing
112partial or complete copies of files.
113If the remote file contents differ from the partial local copy then the
114resultant file is likely to be corrupt.
110.It Fl B Ar buffer_size 115.It Fl B Ar buffer_size
111Specify the size of the buffer that 116Specify the size of the buffer that
112.Nm 117.Nm
@@ -159,6 +164,10 @@ per-user configuration file for
159.Xr ssh 1 . 164.Xr ssh 1 .
160This option is directly passed to 165This option is directly passed to
161.Xr ssh 1 . 166.Xr ssh 1 .
167.It Fl f
168Requests that files be flushed to disk immediately after transfer.
169When uploading files, this feature is only enabled if the server
170implements the "fsync@openssh.com" extension.
162.It Fl i Ar identity_file 171.It Fl i Ar identity_file
163Selects the file from which the identity (private key) for public key 172Selects the file from which the identity (private key) for public key
164authentication is read. 173authentication is read.
@@ -184,6 +193,11 @@ For full details of the options listed below, and their possible values, see
184.It AddressFamily 193.It AddressFamily
185.It BatchMode 194.It BatchMode
186.It BindAddress 195.It BindAddress
196.It CanonicalDomains
197.It CanonicalizeFallbackLocal
198.It CanonicalizeHostname
199.It CanonicalizeMaxDots
200.It CanonicalizePermittedCNAMEs
187.It ChallengeResponseAuthentication 201.It ChallengeResponseAuthentication
188.It CheckHostIP 202.It CheckHostIP
189.It Cipher 203.It Cipher
@@ -343,7 +357,7 @@ extension.
343Quit 357Quit
344.Nm sftp . 358.Nm sftp .
345.It Xo Ic get 359.It Xo Ic get
346.Op Fl aPpr 360.Op Fl afPpr
347.Ar remote-path 361.Ar remote-path
348.Op Ar local-path 362.Op Ar local-path
349.Xc 363.Xc
@@ -368,8 +382,15 @@ If the
368flag is specified, then attempt to resume partial transfers of existing files. 382flag is specified, then attempt to resume partial transfers of existing files.
369Note that resumption assumes that any partial copy of the local file matches 383Note that resumption assumes that any partial copy of the local file matches
370the remote copy. 384the remote copy.
371If the remote file differs from the partial local copy then the resultant file 385If the remote file contents differ from the partial local copy then the
372is likely to be corrupt. 386resultant file is likely to be corrupt.
387.Pp
388If the
389.Fl f
390flag is specified, then
391.Xr fsync 2
392will be called after the file transfer has completed to flush the file
393to disk.
373.Pp 394.Pp
374If either the 395If either the
375.Fl P 396.Fl P
@@ -474,7 +495,7 @@ Create remote directory specified by
474.It Ic progress 495.It Ic progress
475Toggle display of progress meter. 496Toggle display of progress meter.
476.It Xo Ic put 497.It Xo Ic put
477.Op Fl Ppr 498.Op Fl fPpr
478.Ar local-path 499.Ar local-path
479.Op Ar remote-path 500.Op Ar remote-path
480.Xc 501.Xc
@@ -493,6 +514,14 @@ is specified, then
493.Ar remote-path 514.Ar remote-path
494must specify a directory. 515must specify a directory.
495.Pp 516.Pp
517If the
518.Fl f
519flag is specified, then a request will be sent to the server to call
520.Xr fsync 2
521after the file has been transferred.
522Note that this is only supported by servers that implement
523the "fsync@openssh.com" extension.
524.Pp
496If either the 525If either the
497.Fl P 526.Fl P
498or 527or
diff --git a/sftp.c b/sftp.c
index 969328de4..ad1f8c84d 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp.c,v 1.148 2013/07/25 00:56:52 djm Exp $ */ 1/* $OpenBSD: sftp.c,v 1.158 2013/11/20 20:54:10 deraadt 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 *
@@ -94,6 +94,9 @@ int global_aflag = 0;
94/* When this option is set, the file transfers will always preserve times */ 94/* When this option is set, the file transfers will always preserve times */
95int global_pflag = 0; 95int global_pflag = 0;
96 96
97/* When this option is set, transfers will have fsync() called on each file */
98int global_fflag = 0;
99
97/* SIGINT received during command processing */ 100/* SIGINT received during command processing */
98volatile sig_atomic_t interrupted = 0; 101volatile sig_atomic_t interrupted = 0;
99 102
@@ -129,32 +132,34 @@ extern char *__progname;
129#define SORT_FLAGS (LS_NAME_SORT|LS_TIME_SORT|LS_SIZE_SORT) 132#define SORT_FLAGS (LS_NAME_SORT|LS_TIME_SORT|LS_SIZE_SORT)
130 133
131/* Commands for interactive mode */ 134/* Commands for interactive mode */
132#define I_CHDIR 1 135enum sftp_command {
133#define I_CHGRP 2 136 I_CHDIR = 1,
134#define I_CHMOD 3 137 I_CHGRP,
135#define I_CHOWN 4 138 I_CHMOD,
136#define I_DF 24 139 I_CHOWN,
137#define I_GET 5 140 I_DF,
138#define I_HELP 6 141 I_GET,
139#define I_LCHDIR 7 142 I_HELP,
140#define I_LINK 25 143 I_LCHDIR,
141#define I_LLS 8 144 I_LINK,
142#define I_LMKDIR 9 145 I_LLS,
143#define I_LPWD 10 146 I_LMKDIR,
144#define I_LS 11 147 I_LPWD,
145#define I_LUMASK 12 148 I_LS,
146#define I_MKDIR 13 149 I_LUMASK,
147#define I_PUT 14 150 I_MKDIR,
148#define I_PWD 15 151 I_PUT,
149#define I_QUIT 16 152 I_PWD,
150#define I_RENAME 17 153 I_QUIT,
151#define I_RM 18 154 I_RENAME,
152#define I_RMDIR 19 155 I_RM,
153#define I_SHELL 20 156 I_RMDIR,
154#define I_SYMLINK 21 157 I_SHELL,
155#define I_VERSION 22 158 I_SYMLINK,
156#define I_PROGRESS 23 159 I_VERSION,
157#define I_REGET 26 160 I_PROGRESS,
161 I_REGET,
162};
158 163
159struct CMD { 164struct CMD {
160 const char *c; 165 const char *c;
@@ -357,7 +362,7 @@ make_absolute(char *p, char *pwd)
357 362
358static int 363static int
359parse_getput_flags(const char *cmd, char **argv, int argc, 364parse_getput_flags(const char *cmd, char **argv, int argc,
360 int *aflag, int *pflag, int *rflag) 365 int *aflag, int *fflag, int *pflag, int *rflag)
361{ 366{
362 extern int opterr, optind, optopt, optreset; 367 extern int opterr, optind, optopt, optreset;
363 int ch; 368 int ch;
@@ -365,12 +370,15 @@ parse_getput_flags(const char *cmd, char **argv, int argc,
365 optind = optreset = 1; 370 optind = optreset = 1;
366 opterr = 0; 371 opterr = 0;
367 372
368 *aflag = *rflag = *pflag = 0; 373 *aflag = *fflag = *rflag = *pflag = 0;
369 while ((ch = getopt(argc, argv, "aPpRr")) != -1) { 374 while ((ch = getopt(argc, argv, "afPpRr")) != -1) {
370 switch (ch) { 375 switch (ch) {
371 case 'a': 376 case 'a':
372 *aflag = 1; 377 *aflag = 1;
373 break; 378 break;
379 case 'f':
380 *fflag = 1;
381 break;
374 case 'p': 382 case 'p':
375 case 'P': 383 case 'P':
376 *pflag = 1; 384 *pflag = 1;
@@ -413,6 +421,30 @@ parse_link_flags(const char *cmd, char **argv, int argc, int *sflag)
413} 421}
414 422
415static int 423static int
424parse_rename_flags(const char *cmd, char **argv, int argc, int *lflag)
425{
426 extern int opterr, optind, optopt, optreset;
427 int ch;
428
429 optind = optreset = 1;
430 opterr = 0;
431
432 *lflag = 0;
433 while ((ch = getopt(argc, argv, "l")) != -1) {
434 switch (ch) {
435 case 'l':
436 *lflag = 1;
437 break;
438 default:
439 error("%s: Invalid flag -%c", cmd, optopt);
440 return -1;
441 }
442 }
443
444 return optind;
445}
446
447static int
416parse_ls_flags(char **argv, int argc, int *lflag) 448parse_ls_flags(char **argv, int argc, int *lflag)
417{ 449{
418 extern int opterr, optind, optopt, optreset; 450 extern int opterr, optind, optopt, optreset;
@@ -493,6 +525,26 @@ parse_df_flags(const char *cmd, char **argv, int argc, int *hflag, int *iflag)
493} 525}
494 526
495static int 527static int
528parse_no_flags(const char *cmd, char **argv, int argc)
529{
530 extern int opterr, optind, optopt, optreset;
531 int ch;
532
533 optind = optreset = 1;
534 opterr = 0;
535
536 while ((ch = getopt(argc, argv, "")) != -1) {
537 switch (ch) {
538 default:
539 error("%s: Invalid flag -%c", cmd, optopt);
540 return -1;
541 }
542 }
543
544 return optind;
545}
546
547static int
496is_dir(char *path) 548is_dir(char *path)
497{ 549{
498 struct stat sb; 550 struct stat sb;
@@ -528,7 +580,7 @@ pathname_is_dir(char *pathname)
528 580
529static int 581static int
530process_get(struct sftp_conn *conn, char *src, char *dst, char *pwd, 582process_get(struct sftp_conn *conn, char *src, char *dst, char *pwd,
531 int pflag, int rflag, int resume) 583 int pflag, int rflag, int resume, int fflag)
532{ 584{
533 char *abs_src = NULL; 585 char *abs_src = NULL;
534 char *abs_dst = NULL; 586 char *abs_dst = NULL;
@@ -587,11 +639,13 @@ process_get(struct sftp_conn *conn, char *src, char *dst, char *pwd,
587 printf("Fetching %s to %s\n", g.gl_pathv[i], abs_dst); 639 printf("Fetching %s to %s\n", g.gl_pathv[i], abs_dst);
588 if (pathname_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) { 640 if (pathname_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) {
589 if (download_dir(conn, g.gl_pathv[i], abs_dst, NULL, 641 if (download_dir(conn, g.gl_pathv[i], abs_dst, NULL,
590 pflag || global_pflag, 1, resume) == -1) 642 pflag || global_pflag, 1, resume,
643 fflag || global_fflag) == -1)
591 err = -1; 644 err = -1;
592 } else { 645 } else {
593 if (do_download(conn, g.gl_pathv[i], abs_dst, NULL, 646 if (do_download(conn, g.gl_pathv[i], abs_dst, NULL,
594 pflag || global_pflag, resume) == -1) 647 pflag || global_pflag, resume,
648 fflag || global_fflag) == -1)
595 err = -1; 649 err = -1;
596 } 650 }
597 free(abs_dst); 651 free(abs_dst);
@@ -606,7 +660,7 @@ out:
606 660
607static int 661static int
608process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd, 662process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd,
609 int pflag, int rflag) 663 int pflag, int rflag, int fflag)
610{ 664{
611 char *tmp_dst = NULL; 665 char *tmp_dst = NULL;
612 char *abs_dst = NULL; 666 char *abs_dst = NULL;
@@ -647,7 +701,7 @@ process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd,
647 error("stat %s: %s", g.gl_pathv[i], strerror(errno)); 701 error("stat %s: %s", g.gl_pathv[i], strerror(errno));
648 continue; 702 continue;
649 } 703 }
650 704
651 tmp = xstrdup(g.gl_pathv[i]); 705 tmp = xstrdup(g.gl_pathv[i]);
652 if ((filename = basename(tmp)) == NULL) { 706 if ((filename = basename(tmp)) == NULL) {
653 error("basename %s: %s", tmp, strerror(errno)); 707 error("basename %s: %s", tmp, strerror(errno));
@@ -673,11 +727,13 @@ process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd,
673 printf("Uploading %s to %s\n", g.gl_pathv[i], abs_dst); 727 printf("Uploading %s to %s\n", g.gl_pathv[i], abs_dst);
674 if (pathname_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) { 728 if (pathname_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) {
675 if (upload_dir(conn, g.gl_pathv[i], abs_dst, 729 if (upload_dir(conn, g.gl_pathv[i], abs_dst,
676 pflag || global_pflag, 1) == -1) 730 pflag || global_pflag, 1,
731 fflag || global_fflag) == -1)
677 err = -1; 732 err = -1;
678 } else { 733 } else {
679 if (do_upload(conn, g.gl_pathv[i], abs_dst, 734 if (do_upload(conn, g.gl_pathv[i], abs_dst,
680 pflag || global_pflag) == -1) 735 pflag || global_pflag,
736 fflag || global_fflag) == -1)
681 err = -1; 737 err = -1;
682 } 738 }
683 } 739 }
@@ -975,7 +1031,7 @@ undo_glob_escape(char *s)
975 * 1031 *
976 * If "lastquote" is not NULL, the quoting character used for the last 1032 * If "lastquote" is not NULL, the quoting character used for the last
977 * argument is placed in *lastquote ("\0", "'" or "\""). 1033 * argument is placed in *lastquote ("\0", "'" or "\"").
978 * 1034 *
979 * If "terminated" is not NULL, *terminated will be set to 1 when the 1035 * If "terminated" is not NULL, *terminated will be set to 1 when the
980 * last argument's quote has been properly terminated or 0 otherwise. 1036 * last argument's quote has been properly terminated or 0 otherwise.
981 * This parameter is only of use if "sloppy" is set. 1037 * This parameter is only of use if "sloppy" is set.
@@ -1009,7 +1065,7 @@ makeargv(const char *arg, int *argcp, int sloppy, char *lastquote,
1009 error("Too many arguments."); 1065 error("Too many arguments.");
1010 return NULL; 1066 return NULL;
1011 } 1067 }
1012 if (isspace(arg[i])) { 1068 if (isspace((unsigned char)arg[i])) {
1013 if (state == MA_UNQUOTED) { 1069 if (state == MA_UNQUOTED) {
1014 /* Terminate current argument */ 1070 /* Terminate current argument */
1015 argvs[j++] = '\0'; 1071 argvs[j++] = '\0';
@@ -1024,7 +1080,7 @@ makeargv(const char *arg, int *argcp, int sloppy, char *lastquote,
1024 state = q; 1080 state = q;
1025 if (lastquote != NULL) 1081 if (lastquote != NULL)
1026 *lastquote = arg[i]; 1082 *lastquote = arg[i];
1027 } else if (state == MA_UNQUOTED) 1083 } else if (state == MA_UNQUOTED)
1028 state = q; 1084 state = q;
1029 else if (state == q) 1085 else if (state == q)
1030 state = MA_UNQUOTED; 1086 state = MA_UNQUOTED;
@@ -1130,9 +1186,9 @@ makeargv(const char *arg, int *argcp, int sloppy, char *lastquote,
1130} 1186}
1131 1187
1132static int 1188static int
1133parse_args(const char **cpp, int *aflag, int *hflag, int *iflag, int *lflag, 1189parse_args(const char **cpp, int *ignore_errors, int *aflag, int *fflag,
1134 int *pflag, int *rflag, int *sflag, unsigned long *n_arg, 1190 int *hflag, int *iflag, int *lflag, int *pflag, int *rflag, int *sflag,
1135 char **path1, char **path2) 1191 unsigned long *n_arg, char **path1, char **path2)
1136{ 1192{
1137 const char *cmd, *cp = *cpp; 1193 const char *cmd, *cp = *cpp;
1138 char *cp2, **argv; 1194 char *cp2, **argv;
@@ -1144,9 +1200,9 @@ parse_args(const char **cpp, int *aflag, int *hflag, int *iflag, int *lflag,
1144 cp = cp + strspn(cp, WHITESPACE); 1200 cp = cp + strspn(cp, WHITESPACE);
1145 1201
1146 /* Check for leading '-' (disable error processing) */ 1202 /* Check for leading '-' (disable error processing) */
1147 *iflag = 0; 1203 *ignore_errors = 0;
1148 if (*cp == '-') { 1204 if (*cp == '-') {
1149 *iflag = 1; 1205 *ignore_errors = 1;
1150 cp++; 1206 cp++;
1151 cp = cp + strspn(cp, WHITESPACE); 1207 cp = cp + strspn(cp, WHITESPACE);
1152 } 1208 }
@@ -1176,7 +1232,8 @@ parse_args(const char **cpp, int *aflag, int *hflag, int *iflag, int *lflag,
1176 } 1232 }
1177 1233
1178 /* Get arguments and parse flags */ 1234 /* Get arguments and parse flags */
1179 *aflag = *lflag = *pflag = *rflag = *hflag = *n_arg = 0; 1235 *aflag = *fflag = *hflag = *iflag = *lflag = *pflag = 0;
1236 *rflag = *sflag = 0;
1180 *path1 = *path2 = NULL; 1237 *path1 = *path2 = NULL;
1181 optidx = 1; 1238 optidx = 1;
1182 switch (cmdnum) { 1239 switch (cmdnum) {
@@ -1184,7 +1241,7 @@ parse_args(const char **cpp, int *aflag, int *hflag, int *iflag, int *lflag,
1184 case I_REGET: 1241 case I_REGET:
1185 case I_PUT: 1242 case I_PUT:
1186 if ((optidx = parse_getput_flags(cmd, argv, argc, 1243 if ((optidx = parse_getput_flags(cmd, argv, argc,
1187 aflag, pflag, rflag)) == -1) 1244 aflag, fflag, pflag, rflag)) == -1)
1188 return -1; 1245 return -1;
1189 /* Get first pathname (mandatory) */ 1246 /* Get first pathname (mandatory) */
1190 if (argc - optidx < 1) { 1247 if (argc - optidx < 1) {
@@ -1208,8 +1265,15 @@ parse_args(const char **cpp, int *aflag, int *hflag, int *iflag, int *lflag,
1208 case I_LINK: 1265 case I_LINK:
1209 if ((optidx = parse_link_flags(cmd, argv, argc, sflag)) == -1) 1266 if ((optidx = parse_link_flags(cmd, argv, argc, sflag)) == -1)
1210 return -1; 1267 return -1;
1211 case I_SYMLINK: 1268 goto parse_two_paths;
1212 case I_RENAME: 1269 case I_RENAME:
1270 if ((optidx = parse_rename_flags(cmd, argv, argc, lflag)) == -1)
1271 return -1;
1272 goto parse_two_paths;
1273 case I_SYMLINK:
1274 if ((optidx = parse_no_flags(cmd, argv, argc)) == -1)
1275 return -1;
1276 parse_two_paths:
1213 if (argc - optidx < 2) { 1277 if (argc - optidx < 2) {
1214 error("You must specify two paths after a %s " 1278 error("You must specify two paths after a %s "
1215 "command.", cmd); 1279 "command.", cmd);
@@ -1227,6 +1291,8 @@ parse_args(const char **cpp, int *aflag, int *hflag, int *iflag, int *lflag,
1227 case I_CHDIR: 1291 case I_CHDIR:
1228 case I_LCHDIR: 1292 case I_LCHDIR:
1229 case I_LMKDIR: 1293 case I_LMKDIR:
1294 if ((optidx = parse_no_flags(cmd, argv, argc)) == -1)
1295 return -1;
1230 /* Get pathname (mandatory) */ 1296 /* Get pathname (mandatory) */
1231 if (argc - optidx < 1) { 1297 if (argc - optidx < 1) {
1232 error("You must specify a path after a %s command.", 1298 error("You must specify a path after a %s command.",
@@ -1268,6 +1334,8 @@ parse_args(const char **cpp, int *aflag, int *hflag, int *iflag, int *lflag,
1268 base = 8; 1334 base = 8;
1269 case I_CHOWN: 1335 case I_CHOWN:
1270 case I_CHGRP: 1336 case I_CHGRP:
1337 if ((optidx = parse_no_flags(cmd, argv, argc)) == -1)
1338 return -1;
1271 /* Get numeric arg (mandatory) */ 1339 /* Get numeric arg (mandatory) */
1272 if (argc - optidx < 1) 1340 if (argc - optidx < 1)
1273 goto need_num_arg; 1341 goto need_num_arg;
@@ -1298,6 +1366,8 @@ parse_args(const char **cpp, int *aflag, int *hflag, int *iflag, int *lflag,
1298 case I_HELP: 1366 case I_HELP:
1299 case I_VERSION: 1367 case I_VERSION:
1300 case I_PROGRESS: 1368 case I_PROGRESS:
1369 if ((optidx = parse_no_flags(cmd, argv, argc)) == -1)
1370 return -1;
1301 break; 1371 break;
1302 default: 1372 default:
1303 fatal("Command not implemented"); 1373 fatal("Command not implemented");
@@ -1312,8 +1382,8 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
1312 int err_abort) 1382 int err_abort)
1313{ 1383{
1314 char *path1, *path2, *tmp; 1384 char *path1, *path2, *tmp;
1315 int aflag = 0, hflag = 0, iflag = 0, lflag = 0, pflag = 0; 1385 int ignore_errors = 0, aflag = 0, fflag = 0, hflag = 0, iflag = 0;
1316 int rflag = 0, sflag = 0; 1386 int lflag = 0, pflag = 0, rflag = 0, sflag = 0;
1317 int cmdnum, i; 1387 int cmdnum, i;
1318 unsigned long n_arg = 0; 1388 unsigned long n_arg = 0;
1319 Attrib a, *aa; 1389 Attrib a, *aa;
@@ -1322,9 +1392,9 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
1322 glob_t g; 1392 glob_t g;
1323 1393
1324 path1 = path2 = NULL; 1394 path1 = path2 = NULL;
1325 cmdnum = parse_args(&cmd, &aflag, &hflag, &iflag, &lflag, &pflag, 1395 cmdnum = parse_args(&cmd, &ignore_errors, &aflag, &fflag, &hflag,
1326 &rflag, &sflag, &n_arg, &path1, &path2); 1396 &iflag, &lflag, &pflag, &rflag, &sflag, &n_arg, &path1, &path2);
1327 if (iflag != 0) 1397 if (ignore_errors != 0)
1328 err_abort = 0; 1398 err_abort = 0;
1329 1399
1330 memset(&g, 0, sizeof(g)); 1400 memset(&g, 0, sizeof(g));
@@ -1343,20 +1413,22 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
1343 /* FALLTHROUGH */ 1413 /* FALLTHROUGH */
1344 case I_GET: 1414 case I_GET:
1345 err = process_get(conn, path1, path2, *pwd, pflag, 1415 err = process_get(conn, path1, path2, *pwd, pflag,
1346 rflag, aflag); 1416 rflag, aflag, fflag);
1347 break; 1417 break;
1348 case I_PUT: 1418 case I_PUT:
1349 err = process_put(conn, path1, path2, *pwd, pflag, rflag); 1419 err = process_put(conn, path1, path2, *pwd, pflag,
1420 rflag, fflag);
1350 break; 1421 break;
1351 case I_RENAME: 1422 case I_RENAME:
1352 path1 = make_absolute(path1, *pwd); 1423 path1 = make_absolute(path1, *pwd);
1353 path2 = make_absolute(path2, *pwd); 1424 path2 = make_absolute(path2, *pwd);
1354 err = do_rename(conn, path1, path2); 1425 err = do_rename(conn, path1, path2, lflag);
1355 break; 1426 break;
1356 case I_SYMLINK: 1427 case I_SYMLINK:
1357 sflag = 1; 1428 sflag = 1;
1358 case I_LINK: 1429 case I_LINK:
1359 path1 = make_absolute(path1, *pwd); 1430 if (!sflag)
1431 path1 = make_absolute(path1, *pwd);
1360 path2 = make_absolute(path2, *pwd); 1432 path2 = make_absolute(path2, *pwd);
1361 err = (sflag ? do_symlink : do_hardlink)(conn, path1, path2); 1433 err = (sflag ? do_symlink : do_hardlink)(conn, path1, path2);
1362 break; 1434 break;
@@ -1567,7 +1639,7 @@ complete_display(char **list, u_int len)
1567 char *tmp; 1639 char *tmp;
1568 1640
1569 /* Count entries for sort and find longest */ 1641 /* Count entries for sort and find longest */
1570 for (y = 0; list[y]; y++) 1642 for (y = 0; list[y]; y++)
1571 m = MAX(m, strlen(list[y])); 1643 m = MAX(m, strlen(list[y]));
1572 1644
1573 if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1) 1645 if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1)
@@ -1612,8 +1684,8 @@ complete_ambiguous(const char *word, char **list, size_t count)
1612 for (y = 1; list[y]; y++) { 1684 for (y = 1; list[y]; y++) {
1613 u_int x; 1685 u_int x;
1614 1686
1615 for (x = 0; x < matchlen; x++) 1687 for (x = 0; x < matchlen; x++)
1616 if (list[0][x] != list[y][x]) 1688 if (list[0][x] != list[y][x])
1617 break; 1689 break;
1618 1690
1619 matchlen = x; 1691 matchlen = x;
@@ -1625,7 +1697,7 @@ complete_ambiguous(const char *word, char **list, size_t count)
1625 tmp[matchlen] = '\0'; 1697 tmp[matchlen] = '\0';
1626 return tmp; 1698 return tmp;
1627 } 1699 }
1628 } 1700 }
1629 1701
1630 return xstrdup(word); 1702 return xstrdup(word);
1631} 1703}
@@ -1645,12 +1717,12 @@ complete_cmd_parse(EditLine *el, char *cmd, int lastarg, char quote,
1645 if (cmd == NULL) { 1717 if (cmd == NULL) {
1646 for (y = 0; cmds[y].c; y++) 1718 for (y = 0; cmds[y].c; y++)
1647 list[count++] = xstrdup(cmds[y].c); 1719 list[count++] = xstrdup(cmds[y].c);
1648 1720
1649 list[count] = NULL; 1721 list[count] = NULL;
1650 complete_display(list, 0); 1722 complete_display(list, 0);
1651 1723
1652 for (y = 0; list[y] != NULL; y++) 1724 for (y = 0; list[y] != NULL; y++)
1653 free(list[y]); 1725 free(list[y]);
1654 free(list); 1726 free(list);
1655 return count; 1727 return count;
1656 } 1728 }
@@ -1658,7 +1730,7 @@ complete_cmd_parse(EditLine *el, char *cmd, int lastarg, char quote,
1658 /* Prepare subset of commands that start with "cmd" */ 1730 /* Prepare subset of commands that start with "cmd" */
1659 cmdlen = strlen(cmd); 1731 cmdlen = strlen(cmd);
1660 for (y = 0; cmds[y].c; y++) { 1732 for (y = 0; cmds[y].c; y++) {
1661 if (!strncasecmp(cmd, cmds[y].c, cmdlen)) 1733 if (!strncasecmp(cmd, cmds[y].c, cmdlen))
1662 list[count++] = xstrdup(cmds[y].c); 1734 list[count++] = xstrdup(cmds[y].c);
1663 } 1735 }
1664 list[count] = NULL; 1736 list[count] = NULL;
@@ -1673,8 +1745,8 @@ complete_cmd_parse(EditLine *el, char *cmd, int lastarg, char quote,
1673 if (count > 1) 1745 if (count > 1)
1674 complete_display(list, 0); 1746 complete_display(list, 0);
1675 1747
1676 for (y = 0; list[y]; y++) 1748 for (y = 0; list[y]; y++)
1677 free(list[y]); 1749 free(list[y]);
1678 free(list); 1750 free(list);
1679 1751
1680 if (tmp != NULL) { 1752 if (tmp != NULL) {
@@ -1714,7 +1786,7 @@ complete_is_remote(char *cmd) {
1714 return -1; 1786 return -1;
1715 1787
1716 for (i = 0; cmds[i].c; i++) { 1788 for (i = 0; cmds[i].c; i++) {
1717 if (!strncasecmp(cmd, cmds[i].c, strlen(cmds[i].c))) 1789 if (!strncasecmp(cmd, cmds[i].c, strlen(cmds[i].c)))
1718 return cmds[i].t; 1790 return cmds[i].t;
1719 } 1791 }
1720 1792
@@ -1731,7 +1803,7 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path,
1731 u_int i, hadglob, pwdlen, len, tmplen, filelen, cesc, isesc, isabs; 1803 u_int i, hadglob, pwdlen, len, tmplen, filelen, cesc, isesc, isabs;
1732 int clen; 1804 int clen;
1733 const LineInfo *lf; 1805 const LineInfo *lf;
1734 1806
1735 /* Glob from "file" location */ 1807 /* Glob from "file" location */
1736 if (file == NULL) 1808 if (file == NULL)
1737 tmp = xstrdup("*"); 1809 tmp = xstrdup("*");
@@ -1745,9 +1817,9 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path,
1745 if (remote != LOCAL) { 1817 if (remote != LOCAL) {
1746 tmp = make_absolute(tmp, remote_path); 1818 tmp = make_absolute(tmp, remote_path);
1747 remote_glob(conn, tmp, GLOB_DOOFFS|GLOB_MARK, NULL, &g); 1819 remote_glob(conn, tmp, GLOB_DOOFFS|GLOB_MARK, NULL, &g);
1748 } else 1820 } else
1749 glob(tmp, GLOB_DOOFFS|GLOB_MARK, NULL, &g); 1821 glob(tmp, GLOB_DOOFFS|GLOB_MARK, NULL, &g);
1750 1822
1751 /* Determine length of pwd so we can trim completion display */ 1823 /* Determine length of pwd so we can trim completion display */
1752 for (hadglob = tmplen = pwdlen = 0; tmp[tmplen] != 0; tmplen++) { 1824 for (hadglob = tmplen = pwdlen = 0; tmp[tmplen] != 0; tmplen++) {
1753 /* Terminate counting on first unescaped glob metacharacter */ 1825 /* Terminate counting on first unescaped glob metacharacter */
@@ -1763,7 +1835,7 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path,
1763 } 1835 }
1764 free(tmp); 1836 free(tmp);
1765 1837
1766 if (g.gl_matchc == 0) 1838 if (g.gl_matchc == 0)
1767 goto out; 1839 goto out;
1768 1840
1769 if (g.gl_matchc > 1) 1841 if (g.gl_matchc > 1)
@@ -1796,7 +1868,7 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path,
1796 1868
1797 if (tmplen > (filelen - cesc)) { 1869 if (tmplen > (filelen - cesc)) {
1798 tmp2 = tmp + filelen - cesc; 1870 tmp2 = tmp + filelen - cesc;
1799 len = strlen(tmp2); 1871 len = strlen(tmp2);
1800 /* quote argument on way out */ 1872 /* quote argument on way out */
1801 for (i = 0; i < len; i += clen) { 1873 for (i = 0; i < len; i += clen) {
1802 if ((clen = mblen(tmp2 + i, len - i)) < 0 || 1874 if ((clen = mblen(tmp2 + i, len - i)) < 0 ||
@@ -1852,7 +1924,7 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path,
1852static unsigned char 1924static unsigned char
1853complete(EditLine *el, int ch) 1925complete(EditLine *el, int ch)
1854{ 1926{
1855 char **argv, *line, quote; 1927 char **argv, *line, quote;
1856 int argc, carg; 1928 int argc, carg;
1857 u_int cursor, len, terminated, ret = CC_ERROR; 1929 u_int cursor, len, terminated, ret = CC_ERROR;
1858 const LineInfo *lf; 1930 const LineInfo *lf;
@@ -1891,7 +1963,7 @@ complete(EditLine *el, int ch)
1891 } else if (carg == 1 && cursor > 0 && line[cursor - 1] != ' ') { 1963 } else if (carg == 1 && cursor > 0 && line[cursor - 1] != ' ') {
1892 /* Handle the command parsing */ 1964 /* Handle the command parsing */
1893 if (complete_cmd_parse(el, argv[0], argc == carg, 1965 if (complete_cmd_parse(el, argv[0], argc == carg,
1894 quote, terminated) != 0) 1966 quote, terminated) != 0)
1895 ret = CC_REDISPLAY; 1967 ret = CC_REDISPLAY;
1896 } else if (carg >= 1) { 1968 } else if (carg >= 1) {
1897 /* Handle file parsing */ 1969 /* Handle file parsing */
@@ -1904,11 +1976,11 @@ complete(EditLine *el, int ch)
1904 if (remote != 0 && 1976 if (remote != 0 &&
1905 complete_match(el, complete_ctx->conn, 1977 complete_match(el, complete_ctx->conn,
1906 *complete_ctx->remote_pathp, filematch, 1978 *complete_ctx->remote_pathp, filematch,
1907 remote, carg == argc, quote, terminated) != 0) 1979 remote, carg == argc, quote, terminated) != 0)
1908 ret = CC_REDISPLAY; 1980 ret = CC_REDISPLAY;
1909 } 1981 }
1910 1982
1911 free(line); 1983 free(line);
1912 return ret; 1984 return ret;
1913} 1985}
1914#endif /* USE_LIBEDIT */ 1986#endif /* USE_LIBEDIT */
@@ -1942,12 +2014,19 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
1942 el_source(el, NULL); 2014 el_source(el, NULL);
1943 2015
1944 /* Tab Completion */ 2016 /* Tab Completion */
1945 el_set(el, EL_ADDFN, "ftp-complete", 2017 el_set(el, EL_ADDFN, "ftp-complete",
1946 "Context sensitive argument completion", complete); 2018 "Context sensitive argument completion", complete);
1947 complete_ctx.conn = conn; 2019 complete_ctx.conn = conn;
1948 complete_ctx.remote_pathp = &remote_path; 2020 complete_ctx.remote_pathp = &remote_path;
1949 el_set(el, EL_CLIENTDATA, (void*)&complete_ctx); 2021 el_set(el, EL_CLIENTDATA, (void*)&complete_ctx);
1950 el_set(el, EL_BIND, "^I", "ftp-complete", NULL); 2022 el_set(el, EL_BIND, "^I", "ftp-complete", NULL);
2023 /* enable ctrl-left-arrow and ctrl-right-arrow */
2024 el_set(el, EL_BIND, "\\e[1;5C", "em-next-word", NULL);
2025 el_set(el, EL_BIND, "\\e[5C", "em-next-word", NULL);
2026 el_set(el, EL_BIND, "\\e[1;5D", "ed-prev-word", NULL);
2027 el_set(el, EL_BIND, "\\e\\e[D", "ed-prev-word", NULL);
2028 /* make ^w match ksh behaviour */
2029 el_set(el, EL_BIND, "^w", "ed-delete-prev-word", NULL);
1951 } 2030 }
1952#endif /* USE_LIBEDIT */ 2031#endif /* USE_LIBEDIT */
1953 2032
@@ -2116,7 +2195,7 @@ usage(void)
2116 extern char *__progname; 2195 extern char *__progname;
2117 2196
2118 fprintf(stderr, 2197 fprintf(stderr,
2119 "usage: %s [-1246Cpqrv] [-B buffer_size] [-b batchfile] [-c cipher]\n" 2198 "usage: %s [-1246aCfpqrv] [-B buffer_size] [-b batchfile] [-c cipher]\n"
2120 " [-D sftp_server_path] [-F ssh_config] " 2199 " [-D sftp_server_path] [-F ssh_config] "
2121 "[-i identity_file] [-l limit]\n" 2200 "[-i identity_file] [-l limit]\n"
2122 " [-o ssh_option] [-P port] [-R num_requests] " 2201 " [-o ssh_option] [-P port] [-R num_requests] "
@@ -2164,7 +2243,7 @@ main(int argc, char **argv)
2164 infile = stdin; 2243 infile = stdin;
2165 2244
2166 while ((ch = getopt(argc, argv, 2245 while ((ch = getopt(argc, argv,
2167 "1246ahpqrvCc:D:i:l:o:s:S:b:B:F:P:R:")) != -1) { 2246 "1246afhpqrvCc:D:i:l:o:s:S:b:B:F:P:R:")) != -1) {
2168 switch (ch) { 2247 switch (ch) {
2169 /* Passed through to ssh(1) */ 2248 /* Passed through to ssh(1) */
2170 case '4': 2249 case '4':
@@ -2224,6 +2303,9 @@ main(int argc, char **argv)
2224 quiet = batchmode = 1; 2303 quiet = batchmode = 1;
2225 addargs(&args, "-obatchmode yes"); 2304 addargs(&args, "-obatchmode yes");
2226 break; 2305 break;
2306 case 'f':
2307 global_fflag = 1;
2308 break;
2227 case 'p': 2309 case 'p':
2228 global_pflag = 1; 2310 global_pflag = 1;
2229 break; 2311 break;
diff --git a/smult_curve25519_ref.c b/smult_curve25519_ref.c
new file mode 100644
index 000000000..2e69934d4
--- /dev/null
+++ b/smult_curve25519_ref.c
@@ -0,0 +1,265 @@
1/* $OpenBSD: smult_curve25519_ref.c,v 1.2 2013/11/02 22:02:14 markus Exp $ */
2/*
3version 20081011
4Matthew Dempsky
5Public domain.
6Derived from public domain code by D. J. Bernstein.
7*/
8
9int crypto_scalarmult_curve25519(unsigned char *, const unsigned char *, const unsigned char *);
10
11static void add(unsigned int out[32],const unsigned int a[32],const unsigned int b[32])
12{
13 unsigned int j;
14 unsigned int u;
15 u = 0;
16 for (j = 0;j < 31;++j) { u += a[j] + b[j]; out[j] = u & 255; u >>= 8; }
17 u += a[31] + b[31]; out[31] = u;
18}
19
20static void sub(unsigned int out[32],const unsigned int a[32],const unsigned int b[32])
21{
22 unsigned int j;
23 unsigned int u;
24 u = 218;
25 for (j = 0;j < 31;++j) {
26 u += a[j] + 65280 - b[j];
27 out[j] = u & 255;
28 u >>= 8;
29 }
30 u += a[31] - b[31];
31 out[31] = u;
32}
33
34static void squeeze(unsigned int a[32])
35{
36 unsigned int j;
37 unsigned int u;
38 u = 0;
39 for (j = 0;j < 31;++j) { u += a[j]; a[j] = u & 255; u >>= 8; }
40 u += a[31]; a[31] = u & 127;
41 u = 19 * (u >> 7);
42 for (j = 0;j < 31;++j) { u += a[j]; a[j] = u & 255; u >>= 8; }
43 u += a[31]; a[31] = u;
44}
45
46static const unsigned int minusp[32] = {
47 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128
48} ;
49
50static void freeze(unsigned int a[32])
51{
52 unsigned int aorig[32];
53 unsigned int j;
54 unsigned int negative;
55
56 for (j = 0;j < 32;++j) aorig[j] = a[j];
57 add(a,a,minusp);
58 negative = -((a[31] >> 7) & 1);
59 for (j = 0;j < 32;++j) a[j] ^= negative & (aorig[j] ^ a[j]);
60}
61
62static void mult(unsigned int out[32],const unsigned int a[32],const unsigned int b[32])
63{
64 unsigned int i;
65 unsigned int j;
66 unsigned int u;
67
68 for (i = 0;i < 32;++i) {
69 u = 0;
70 for (j = 0;j <= i;++j) u += a[j] * b[i - j];
71 for (j = i + 1;j < 32;++j) u += 38 * a[j] * b[i + 32 - j];
72 out[i] = u;
73 }
74 squeeze(out);
75}
76
77static void mult121665(unsigned int out[32],const unsigned int a[32])
78{
79 unsigned int j;
80 unsigned int u;
81
82 u = 0;
83 for (j = 0;j < 31;++j) { u += 121665 * a[j]; out[j] = u & 255; u >>= 8; }
84 u += 121665 * a[31]; out[31] = u & 127;
85 u = 19 * (u >> 7);
86 for (j = 0;j < 31;++j) { u += out[j]; out[j] = u & 255; u >>= 8; }
87 u += out[j]; out[j] = u;
88}
89
90static void square(unsigned int out[32],const unsigned int a[32])
91{
92 unsigned int i;
93 unsigned int j;
94 unsigned int u;
95
96 for (i = 0;i < 32;++i) {
97 u = 0;
98 for (j = 0;j < i - j;++j) u += a[j] * a[i - j];
99 for (j = i + 1;j < i + 32 - j;++j) u += 38 * a[j] * a[i + 32 - j];
100 u *= 2;
101 if ((i & 1) == 0) {
102 u += a[i / 2] * a[i / 2];
103 u += 38 * a[i / 2 + 16] * a[i / 2 + 16];
104 }
105 out[i] = u;
106 }
107 squeeze(out);
108}
109
110static void select(unsigned int p[64],unsigned int q[64],const unsigned int r[64],const unsigned int s[64],unsigned int b)
111{
112 unsigned int j;
113 unsigned int t;
114 unsigned int bminus1;
115
116 bminus1 = b - 1;
117 for (j = 0;j < 64;++j) {
118 t = bminus1 & (r[j] ^ s[j]);
119 p[j] = s[j] ^ t;
120 q[j] = r[j] ^ t;
121 }
122}
123
124static void mainloop(unsigned int work[64],const unsigned char e[32])
125{
126 unsigned int xzm1[64];
127 unsigned int xzm[64];
128 unsigned int xzmb[64];
129 unsigned int xzm1b[64];
130 unsigned int xznb[64];
131 unsigned int xzn1b[64];
132 unsigned int a0[64];
133 unsigned int a1[64];
134 unsigned int b0[64];
135 unsigned int b1[64];
136 unsigned int c1[64];
137 unsigned int r[32];
138 unsigned int s[32];
139 unsigned int t[32];
140 unsigned int u[32];
141 unsigned int j;
142 unsigned int b;
143 int pos;
144
145 for (j = 0;j < 32;++j) xzm1[j] = work[j];
146 xzm1[32] = 1;
147 for (j = 33;j < 64;++j) xzm1[j] = 0;
148
149 xzm[0] = 1;
150 for (j = 1;j < 64;++j) xzm[j] = 0;
151
152 for (pos = 254;pos >= 0;--pos) {
153 b = e[pos / 8] >> (pos & 7);
154 b &= 1;
155 select(xzmb,xzm1b,xzm,xzm1,b);
156 add(a0,xzmb,xzmb + 32);
157 sub(a0 + 32,xzmb,xzmb + 32);
158 add(a1,xzm1b,xzm1b + 32);
159 sub(a1 + 32,xzm1b,xzm1b + 32);
160 square(b0,a0);
161 square(b0 + 32,a0 + 32);
162 mult(b1,a1,a0 + 32);
163 mult(b1 + 32,a1 + 32,a0);
164 add(c1,b1,b1 + 32);
165 sub(c1 + 32,b1,b1 + 32);
166 square(r,c1 + 32);
167 sub(s,b0,b0 + 32);
168 mult121665(t,s);
169 add(u,t,b0);
170 mult(xznb,b0,b0 + 32);
171 mult(xznb + 32,s,u);
172 square(xzn1b,c1);
173 mult(xzn1b + 32,r,work);
174 select(xzm,xzm1,xznb,xzn1b,b);
175 }
176
177 for (j = 0;j < 64;++j) work[j] = xzm[j];
178}
179
180static void recip(unsigned int out[32],const unsigned int z[32])
181{
182 unsigned int z2[32];
183 unsigned int z9[32];
184 unsigned int z11[32];
185 unsigned int z2_5_0[32];
186 unsigned int z2_10_0[32];
187 unsigned int z2_20_0[32];
188 unsigned int z2_50_0[32];
189 unsigned int z2_100_0[32];
190 unsigned int t0[32];
191 unsigned int t1[32];
192 int i;
193
194 /* 2 */ square(z2,z);
195 /* 4 */ square(t1,z2);
196 /* 8 */ square(t0,t1);
197 /* 9 */ mult(z9,t0,z);
198 /* 11 */ mult(z11,z9,z2);
199 /* 22 */ square(t0,z11);
200 /* 2^5 - 2^0 = 31 */ mult(z2_5_0,t0,z9);
201
202 /* 2^6 - 2^1 */ square(t0,z2_5_0);
203 /* 2^7 - 2^2 */ square(t1,t0);
204 /* 2^8 - 2^3 */ square(t0,t1);
205 /* 2^9 - 2^4 */ square(t1,t0);
206 /* 2^10 - 2^5 */ square(t0,t1);
207 /* 2^10 - 2^0 */ mult(z2_10_0,t0,z2_5_0);
208
209 /* 2^11 - 2^1 */ square(t0,z2_10_0);
210 /* 2^12 - 2^2 */ square(t1,t0);
211 /* 2^20 - 2^10 */ for (i = 2;i < 10;i += 2) { square(t0,t1); square(t1,t0); }
212 /* 2^20 - 2^0 */ mult(z2_20_0,t1,z2_10_0);
213
214 /* 2^21 - 2^1 */ square(t0,z2_20_0);
215 /* 2^22 - 2^2 */ square(t1,t0);
216 /* 2^40 - 2^20 */ for (i = 2;i < 20;i += 2) { square(t0,t1); square(t1,t0); }
217 /* 2^40 - 2^0 */ mult(t0,t1,z2_20_0);
218
219 /* 2^41 - 2^1 */ square(t1,t0);
220 /* 2^42 - 2^2 */ square(t0,t1);
221 /* 2^50 - 2^10 */ for (i = 2;i < 10;i += 2) { square(t1,t0); square(t0,t1); }
222 /* 2^50 - 2^0 */ mult(z2_50_0,t0,z2_10_0);
223
224 /* 2^51 - 2^1 */ square(t0,z2_50_0);
225 /* 2^52 - 2^2 */ square(t1,t0);
226 /* 2^100 - 2^50 */ for (i = 2;i < 50;i += 2) { square(t0,t1); square(t1,t0); }
227 /* 2^100 - 2^0 */ mult(z2_100_0,t1,z2_50_0);
228
229 /* 2^101 - 2^1 */ square(t1,z2_100_0);
230 /* 2^102 - 2^2 */ square(t0,t1);
231 /* 2^200 - 2^100 */ for (i = 2;i < 100;i += 2) { square(t1,t0); square(t0,t1); }
232 /* 2^200 - 2^0 */ mult(t1,t0,z2_100_0);
233
234 /* 2^201 - 2^1 */ square(t0,t1);
235 /* 2^202 - 2^2 */ square(t1,t0);
236 /* 2^250 - 2^50 */ for (i = 2;i < 50;i += 2) { square(t0,t1); square(t1,t0); }
237 /* 2^250 - 2^0 */ mult(t0,t1,z2_50_0);
238
239 /* 2^251 - 2^1 */ square(t1,t0);
240 /* 2^252 - 2^2 */ square(t0,t1);
241 /* 2^253 - 2^3 */ square(t1,t0);
242 /* 2^254 - 2^4 */ square(t0,t1);
243 /* 2^255 - 2^5 */ square(t1,t0);
244 /* 2^255 - 21 */ mult(out,t1,z11);
245}
246
247int crypto_scalarmult_curve25519(unsigned char *q,
248 const unsigned char *n,
249 const unsigned char *p)
250{
251 unsigned int work[96];
252 unsigned char e[32];
253 unsigned int i;
254 for (i = 0;i < 32;++i) e[i] = n[i];
255 e[0] &= 248;
256 e[31] &= 127;
257 e[31] |= 64;
258 for (i = 0;i < 32;++i) work[i] = p[i];
259 mainloop(work,e);
260 recip(work + 32,work + 32);
261 mult(work + 64,work,work + 32);
262 freeze(work + 64);
263 for (i = 0;i < 32;++i) q[i] = work[64 + i];
264 return 0;
265}
diff --git a/ssh-add.0 b/ssh-add.0
index bcd1e7322..8d10f7ff4 100644
--- a/ssh-add.0
+++ b/ssh-add.0
@@ -11,11 +11,11 @@ SYNOPSIS
11DESCRIPTION 11DESCRIPTION
12 ssh-add adds private key 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, ~/.ssh/id_ecdsa and ~/.ssh/identity. After 14 ~/.ssh/id_rsa, ~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519 and
15 loading a private key, ssh-add will try to load corresponding certificate 15 ~/.ssh/identity. After loading a private key, ssh-add will try to load
16 information from the filename obtained by appending -cert.pub to the name 16 corresponding certificate information from the filename obtained by
17 of the private key file. Alternative file names can be given on the 17 appending -cert.pub to the name of the private key file. Alternative
18 command line. 18 file names can be given on the command line.
19 19
20 If any file requires a passphrase, ssh-add asks for the passphrase from 20 If any file requires a passphrase, ssh-add asks for the passphrase from
21 the user. The passphrase is read from the user's tty. ssh-add retries 21 the user. The passphrase is read from the user's tty. ssh-add retries
@@ -95,6 +95,10 @@ FILES
95 Contains the protocol version 2 ECDSA authentication identity of 95 Contains the protocol version 2 ECDSA authentication identity of
96 the user. 96 the user.
97 97
98 ~/.ssh/id_ed25519
99 Contains the protocol version 2 ED25519 authentication identity
100 of the user.
101
98 ~/.ssh/id_rsa 102 ~/.ssh/id_rsa
99 Contains the protocol version 2 RSA authentication identity of 103 Contains the protocol version 2 RSA authentication identity of
100 the user. 104 the user.
@@ -116,4 +120,4 @@ AUTHORS
116 created OpenSSH. Markus Friedl contributed the support for SSH protocol 120 created OpenSSH. Markus Friedl contributed the support for SSH protocol
117 versions 1.5 and 2.0. 121 versions 1.5 and 2.0.
118 122
119OpenBSD 5.4 December 3, 2012 OpenBSD 5.4 123OpenBSD 5.4 December 7, 2013 OpenBSD 5.4
diff --git a/ssh-add.1 b/ssh-add.1
index 44846b67e..4812448fa 100644
--- a/ssh-add.1
+++ b/ssh-add.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ssh-add.1,v 1.58 2012/12/03 08:33:02 jmc Exp $ 1.\" $OpenBSD: ssh-add.1,v 1.59 2013/12/07 11:58:46 naddy 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
@@ -35,7 +35,7 @@
35.\" (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
36.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37.\" 37.\"
38.Dd $Mdocdate: December 3 2012 $ 38.Dd $Mdocdate: December 7 2013 $
39.Dt SSH-ADD 1 39.Dt SSH-ADD 1
40.Os 40.Os
41.Sh NAME 41.Sh NAME
@@ -57,7 +57,8 @@ adds private key identities to the authentication agent,
57When run without arguments, it adds the files 57When run without arguments, it adds the files
58.Pa ~/.ssh/id_rsa , 58.Pa ~/.ssh/id_rsa ,
59.Pa ~/.ssh/id_dsa , 59.Pa ~/.ssh/id_dsa ,
60.Pa ~/.ssh/id_ecdsa 60.Pa ~/.ssh/id_ecdsa ,
61.Pa ~/.ssh/id_ed25519
61and 62and
62.Pa ~/.ssh/identity . 63.Pa ~/.ssh/identity .
63After loading a private key, 64After loading a private key,
@@ -169,6 +170,8 @@ Contains the protocol version 1 RSA authentication identity of the user.
169Contains the protocol version 2 DSA authentication identity of the user. 170Contains the protocol version 2 DSA authentication identity of the user.
170.It Pa ~/.ssh/id_ecdsa 171.It Pa ~/.ssh/id_ecdsa
171Contains the protocol version 2 ECDSA authentication identity of the user. 172Contains the protocol version 2 ECDSA authentication identity of the user.
173.It Pa ~/.ssh/id_ed25519
174Contains the protocol version 2 ED25519 authentication identity of the user.
172.It Pa ~/.ssh/id_rsa 175.It Pa ~/.ssh/id_rsa
173Contains the protocol version 2 RSA authentication identity of the user. 176Contains the protocol version 2 RSA authentication identity of the user.
174.El 177.El
diff --git a/ssh-add.c b/ssh-add.c
index 5e8166f66..63ce72083 100644
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-add.c,v 1.106 2013/05/17 00:13:14 djm Exp $ */ 1/* $OpenBSD: ssh-add.c,v 1.108 2013/12/19 00:10:30 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
@@ -73,6 +73,7 @@ static char *default_files[] = {
73#ifdef OPENSSL_HAS_ECC 73#ifdef OPENSSL_HAS_ECC
74 _PATH_SSH_CLIENT_ID_ECDSA, 74 _PATH_SSH_CLIENT_ID_ECDSA,
75#endif 75#endif
76 _PATH_SSH_CLIENT_ID_ED25519,
76 _PATH_SSH_CLIENT_IDENTITY, 77 _PATH_SSH_CLIENT_IDENTITY,
77 NULL 78 NULL
78}; 79};
@@ -292,14 +293,17 @@ add_file(AuthenticationConnection *ac, const char *filename, int key_only)
292static int 293static int
293update_card(AuthenticationConnection *ac, int add, const char *id) 294update_card(AuthenticationConnection *ac, int add, const char *id)
294{ 295{
295 char *pin; 296 char *pin = NULL;
296 int ret = -1; 297 int ret = -1;
297 298
298 pin = read_passphrase("Enter passphrase for PKCS#11: ", RP_ALLOW_STDIN); 299 if (add) {
299 if (pin == NULL) 300 if ((pin = read_passphrase("Enter passphrase for PKCS#11: ",
300 return -1; 301 RP_ALLOW_STDIN)) == NULL)
302 return -1;
303 }
301 304
302 if (ssh_update_card(ac, add, id, pin, lifetime, confirm)) { 305 if (ssh_update_card(ac, add, id, pin == NULL ? "" : pin,
306 lifetime, confirm)) {
303 fprintf(stderr, "Card %s: %s\n", 307 fprintf(stderr, "Card %s: %s\n",
304 add ? "added" : "removed", id); 308 add ? "added" : "removed", id);
305 ret = 0; 309 ret = 0;
diff --git a/ssh-agent.0 b/ssh-agent.0
index e5f0f7342..c4c53ef94 100644
--- a/ssh-agent.0
+++ b/ssh-agent.0
@@ -9,12 +9,12 @@ 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, ECDSA). The idea is that ssh-agent is started 12 authentication (RSA, DSA, ECDSA, ED25519). The idea is that ssh-agent is
13 in the beginning of an X-session or a login session, and all other 13 started in the beginning of an X-session or a login session, and all
14 windows or programs are started as clients to the ssh-agent program. 14 other windows or programs are started as clients to the ssh-agent
15 Through use of environment variables the agent can be located and 15 program. Through use of environment variables the agent can be located
16 automatically used for authentication when logging in to other machines 16 and automatically used for authentication when logging in to other
17 using ssh(1). 17 machines using ssh(1).
18 18
19 The options are as follows: 19 The options are as follows:
20 20
@@ -46,13 +46,14 @@ DESCRIPTION
46 46
47 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
48 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
49 ~/.ssh/id_rsa, ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and ~/.ssh/identity. If 49 ~/.ssh/id_rsa, ~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519 and
50 the identity has a passphrase, ssh-add(1) asks for the passphrase on the 50 ~/.ssh/identity. If the identity has a passphrase, ssh-add(1) asks for
51 terminal if it has one or from a small X11 program if running under X11. 51 the passphrase on the terminal if it has one or from a small X11 program
52 If neither of these is the case then the authentication will fail. It 52 if running under X11. If neither of these is the case then the
53 then sends the identity to the agent. Several identities can be stored 53 authentication will fail. It then sends the identity to the agent.
54 in the agent; the agent can automatically use any of these identities. 54 Several identities can be stored in the agent; the agent can
55 ssh-add -l displays the identities currently held by the agent. 55 automatically use any of these identities. ssh-add -l displays the
56 identities currently held by the agent.
56 57
57 The idea is that the agent is run in the user's local PC, laptop, or 58 The idea is that the agent is run in the user's local PC, laptop, or
58 terminal. Authentication data need not be stored on any other machine, 59 terminal. Authentication data need not be stored on any other machine,
@@ -100,6 +101,10 @@ FILES
100 Contains the protocol version 2 ECDSA authentication identity of 101 Contains the protocol version 2 ECDSA authentication identity of
101 the user. 102 the user.
102 103
104 ~/.ssh/id_ed25519
105 Contains the protocol version 2 ED25519 authentication identity
106 of the user.
107
103 ~/.ssh/id_rsa 108 ~/.ssh/id_rsa
104 Contains the protocol version 2 RSA authentication identity of 109 Contains the protocol version 2 RSA authentication identity of
105 the user. 110 the user.
@@ -120,4 +125,4 @@ AUTHORS
120 created OpenSSH. Markus Friedl contributed the support for SSH protocol 125 created OpenSSH. Markus Friedl contributed the support for SSH protocol
121 versions 1.5 and 2.0. 126 versions 1.5 and 2.0.
122 127
123OpenBSD 5.4 November 21, 2010 OpenBSD 5.4 128OpenBSD 5.4 December 7, 2013 OpenBSD 5.4
diff --git a/ssh-agent.1 b/ssh-agent.1
index bb801c902..281ecbdcf 100644
--- a/ssh-agent.1
+++ b/ssh-agent.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ssh-agent.1,v 1.53 2010/11/21 01:01:13 djm Exp $ 1.\" $OpenBSD: ssh-agent.1,v 1.54 2013/12/07 11:58:46 naddy 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: November 21 2010 $ 37.Dd $Mdocdate: December 7 2013 $
38.Dt SSH-AGENT 1 38.Dt SSH-AGENT 1
39.Os 39.Os
40.Sh NAME 40.Sh NAME
@@ -53,7 +53,7 @@
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, ECDSA). 56(RSA, DSA, ECDSA, ED25519).
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
@@ -115,7 +115,8 @@ When executed without arguments,
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 118.Pa ~/.ssh/id_ecdsa ,
119.Pa ~/.ssh/id_ed25519
119and 120and
120.Pa ~/.ssh/identity . 121.Pa ~/.ssh/identity .
121If the identity has a passphrase, 122If the identity has a passphrase,
@@ -190,6 +191,8 @@ Contains the protocol version 1 RSA authentication identity of the user.
190Contains the protocol version 2 DSA authentication identity of the user. 191Contains the protocol version 2 DSA authentication identity of the user.
191.It Pa ~/.ssh/id_ecdsa 192.It Pa ~/.ssh/id_ecdsa
192Contains the protocol version 2 ECDSA authentication identity of the user. 193Contains the protocol version 2 ECDSA authentication identity of the user.
194.It Pa ~/.ssh/id_ed25519
195Contains the protocol version 2 ED25519 authentication identity of the user.
193.It Pa ~/.ssh/id_rsa 196.It Pa ~/.ssh/id_rsa
194Contains the protocol version 2 RSA authentication identity of the user. 197Contains the protocol version 2 RSA authentication identity of the user.
195.It Pa $TMPDIR/ssh-XXXXXXXXXX/agent.\*(Ltppid\*(Gt 198.It Pa $TMPDIR/ssh-XXXXXXXXXX/agent.\*(Ltppid\*(Gt
diff --git a/ssh-agent.c b/ssh-agent.c
index c3b11729c..95117e076 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-agent.c,v 1.177 2013/07/20 01:50:20 djm Exp $ */ 1/* $OpenBSD: ssh-agent.c,v 1.181 2013/12/19 01:19:41 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
@@ -464,16 +464,9 @@ process_add_identity(SocketEntry *e, int version)
464 Idtab *tab = idtab_lookup(version); 464 Idtab *tab = idtab_lookup(version);
465 Identity *id; 465 Identity *id;
466 int type, success = 0, confirm = 0; 466 int type, success = 0, confirm = 0;
467 char *type_name, *comment; 467 char *comment;
468 time_t death = 0; 468 time_t death = 0;
469 Key *k = NULL; 469 Key *k = NULL;
470#ifdef OPENSSL_HAS_ECC
471 BIGNUM *exponent;
472 EC_POINT *q;
473 char *curve;
474#endif
475 u_char *cert;
476 u_int len;
477 470
478 switch (version) { 471 switch (version) {
479 case 1: 472 case 1:
@@ -490,125 +483,21 @@ process_add_identity(SocketEntry *e, int version)
490 483
491 /* Generate additional parameters */ 484 /* Generate additional parameters */
492 rsa_generate_additional_parameters(k->rsa); 485 rsa_generate_additional_parameters(k->rsa);
493 break; 486
494 case 2: 487 /* enable blinding */
495 type_name = buffer_get_string(&e->request, NULL);
496 type = key_type_from_name(type_name);
497 switch (type) {
498 case KEY_DSA:
499 k = key_new_private(type);
500 buffer_get_bignum2(&e->request, k->dsa->p);
501 buffer_get_bignum2(&e->request, k->dsa->q);
502 buffer_get_bignum2(&e->request, k->dsa->g);
503 buffer_get_bignum2(&e->request, k->dsa->pub_key);
504 buffer_get_bignum2(&e->request, k->dsa->priv_key);
505 break;
506 case KEY_DSA_CERT_V00:
507 case KEY_DSA_CERT:
508 cert = buffer_get_string(&e->request, &len);
509 if ((k = key_from_blob(cert, len)) == NULL)
510 fatal("Certificate parse failed");
511 free(cert);
512 key_add_private(k);
513 buffer_get_bignum2(&e->request, k->dsa->priv_key);
514 break;
515#ifdef OPENSSL_HAS_ECC
516 case KEY_ECDSA:
517 k = key_new_private(type);
518 k->ecdsa_nid = key_ecdsa_nid_from_name(type_name);
519 curve = buffer_get_string(&e->request, NULL);
520 if (k->ecdsa_nid != key_curve_name_to_nid(curve))
521 fatal("%s: curve names mismatch", __func__);
522 free(curve);
523 k->ecdsa = EC_KEY_new_by_curve_name(k->ecdsa_nid);
524 if (k->ecdsa == NULL)
525 fatal("%s: EC_KEY_new_by_curve_name failed",
526 __func__);
527 q = EC_POINT_new(EC_KEY_get0_group(k->ecdsa));
528 if (q == NULL)
529 fatal("%s: BN_new failed", __func__);
530 if ((exponent = BN_new()) == NULL)
531 fatal("%s: BN_new failed", __func__);
532 buffer_get_ecpoint(&e->request,
533 EC_KEY_get0_group(k->ecdsa), q);
534 buffer_get_bignum2(&e->request, exponent);
535 if (EC_KEY_set_public_key(k->ecdsa, q) != 1)
536 fatal("%s: EC_KEY_set_public_key failed",
537 __func__);
538 if (EC_KEY_set_private_key(k->ecdsa, exponent) != 1)
539 fatal("%s: EC_KEY_set_private_key failed",
540 __func__);
541 if (key_ec_validate_public(EC_KEY_get0_group(k->ecdsa),
542 EC_KEY_get0_public_key(k->ecdsa)) != 0)
543 fatal("%s: bad ECDSA public key", __func__);
544 if (key_ec_validate_private(k->ecdsa) != 0)
545 fatal("%s: bad ECDSA private key", __func__);
546 BN_clear_free(exponent);
547 EC_POINT_free(q);
548 break;
549 case KEY_ECDSA_CERT:
550 cert = buffer_get_string(&e->request, &len);
551 if ((k = key_from_blob(cert, len)) == NULL)
552 fatal("Certificate parse failed");
553 free(cert);
554 key_add_private(k);
555 if ((exponent = BN_new()) == NULL)
556 fatal("%s: BN_new failed", __func__);
557 buffer_get_bignum2(&e->request, exponent);
558 if (EC_KEY_set_private_key(k->ecdsa, exponent) != 1)
559 fatal("%s: EC_KEY_set_private_key failed",
560 __func__);
561 if (key_ec_validate_public(EC_KEY_get0_group(k->ecdsa),
562 EC_KEY_get0_public_key(k->ecdsa)) != 0 ||
563 key_ec_validate_private(k->ecdsa) != 0)
564 fatal("%s: bad ECDSA key", __func__);
565 BN_clear_free(exponent);
566 break;
567#endif /* OPENSSL_HAS_ECC */
568 case KEY_RSA:
569 k = key_new_private(type);
570 buffer_get_bignum2(&e->request, k->rsa->n);
571 buffer_get_bignum2(&e->request, k->rsa->e);
572 buffer_get_bignum2(&e->request, k->rsa->d);
573 buffer_get_bignum2(&e->request, k->rsa->iqmp);
574 buffer_get_bignum2(&e->request, k->rsa->p);
575 buffer_get_bignum2(&e->request, k->rsa->q);
576
577 /* Generate additional parameters */
578 rsa_generate_additional_parameters(k->rsa);
579 break;
580 case KEY_RSA_CERT_V00:
581 case KEY_RSA_CERT:
582 cert = buffer_get_string(&e->request, &len);
583 if ((k = key_from_blob(cert, len)) == NULL)
584 fatal("Certificate parse failed");
585 free(cert);
586 key_add_private(k);
587 buffer_get_bignum2(&e->request, k->rsa->d);
588 buffer_get_bignum2(&e->request, k->rsa->iqmp);
589 buffer_get_bignum2(&e->request, k->rsa->p);
590 buffer_get_bignum2(&e->request, k->rsa->q);
591 break;
592 default:
593 free(type_name);
594 buffer_clear(&e->request);
595 goto send;
596 }
597 free(type_name);
598 break;
599 }
600 /* enable blinding */
601 switch (k->type) {
602 case KEY_RSA:
603 case KEY_RSA_CERT_V00:
604 case KEY_RSA_CERT:
605 case KEY_RSA1:
606 if (RSA_blinding_on(k->rsa, NULL) != 1) { 488 if (RSA_blinding_on(k->rsa, NULL) != 1) {
607 error("process_add_identity: RSA_blinding_on failed"); 489 error("process_add_identity: RSA_blinding_on failed");
608 key_free(k); 490 key_free(k);
609 goto send; 491 goto send;
610 } 492 }
611 break; 493 break;
494 case 2:
495 k = key_private_deserialize(&e->request);
496 if (k == NULL) {
497 buffer_clear(&e->request);
498 goto send;
499 }
500 break;
612 } 501 }
613 comment = buffer_get_string(&e->request, NULL); 502 comment = buffer_get_string(&e->request, NULL);
614 if (k == NULL) { 503 if (k == NULL) {
@@ -771,6 +660,9 @@ process_remove_smartcard_key(SocketEntry *e)
771 tab = idtab_lookup(version); 660 tab = idtab_lookup(version);
772 for (id = TAILQ_FIRST(&tab->idlist); id; id = nxt) { 661 for (id = TAILQ_FIRST(&tab->idlist); id; id = nxt) {
773 nxt = TAILQ_NEXT(id, next); 662 nxt = TAILQ_NEXT(id, next);
663 /* Skip file--based keys */
664 if (id->provider == NULL)
665 continue;
774 if (!strcmp(provider, id->provider)) { 666 if (!strcmp(provider, id->provider)) {
775 TAILQ_REMOVE(&tab->idlist, id, next); 667 TAILQ_REMOVE(&tab->idlist, id, next);
776 free_identity(id); 668 free_identity(id);
diff --git a/ssh-dss.c b/ssh-dss.c
index 322ec9fd8..7b897475c 100644
--- a/ssh-dss.c
+++ b/ssh-dss.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-dss.c,v 1.28 2013/05/17 00:13:14 djm Exp $ */ 1/* $OpenBSD: ssh-dss.c,v 1.30 2014/01/09 23:20:00 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -38,6 +38,7 @@
38#include "compat.h" 38#include "compat.h"
39#include "log.h" 39#include "log.h"
40#include "key.h" 40#include "key.h"
41#include "digest.h"
41 42
42#define INTBLOB_LEN 20 43#define INTBLOB_LEN 20
43#define SIGBLOB_LEN (2*INTBLOB_LEN) 44#define SIGBLOB_LEN (2*INTBLOB_LEN)
@@ -47,20 +48,21 @@ ssh_dss_sign(const Key *key, u_char **sigp, u_int *lenp,
47 const u_char *data, u_int datalen) 48 const u_char *data, u_int datalen)
48{ 49{
49 DSA_SIG *sig; 50 DSA_SIG *sig;
50 const EVP_MD *evp_md = EVP_sha1(); 51 u_char digest[SSH_DIGEST_MAX_LENGTH], sigblob[SIGBLOB_LEN];
51 EVP_MD_CTX md; 52 u_int rlen, slen, len, dlen = ssh_digest_bytes(SSH_DIGEST_SHA1);
52 u_char digest[EVP_MAX_MD_SIZE], sigblob[SIGBLOB_LEN];
53 u_int rlen, slen, len, dlen;
54 Buffer b; 53 Buffer b;
55 54
56 if (key == NULL || key->dsa == NULL || (key->type != KEY_DSA && 55 if (key == NULL || key_type_plain(key->type) != KEY_DSA ||
57 key->type != KEY_DSA_CERT && key->type != KEY_DSA_CERT_V00)) { 56 key->dsa == NULL) {
58 error("ssh_dss_sign: no DSA key"); 57 error("%s: no DSA key", __func__);
58 return -1;
59 }
60
61 if (ssh_digest_memory(SSH_DIGEST_SHA1, data, datalen,
62 digest, sizeof(digest)) != 0) {
63 error("%s: ssh_digest_memory failed", __func__);
59 return -1; 64 return -1;
60 } 65 }
61 EVP_DigestInit(&md, evp_md);
62 EVP_DigestUpdate(&md, data, datalen);
63 EVP_DigestFinal(&md, digest, &dlen);
64 66
65 sig = DSA_do_sign(digest, dlen, key->dsa); 67 sig = DSA_do_sign(digest, dlen, key->dsa);
66 memset(digest, 'd', sizeof(digest)); 68 memset(digest, 'd', sizeof(digest));
@@ -110,16 +112,14 @@ ssh_dss_verify(const Key *key, const u_char *signature, u_int signaturelen,
110 const u_char *data, u_int datalen) 112 const u_char *data, u_int datalen)
111{ 113{
112 DSA_SIG *sig; 114 DSA_SIG *sig;
113 const EVP_MD *evp_md = EVP_sha1(); 115 u_char digest[SSH_DIGEST_MAX_LENGTH], *sigblob;
114 EVP_MD_CTX md; 116 u_int len, dlen = ssh_digest_bytes(SSH_DIGEST_SHA1);
115 u_char digest[EVP_MAX_MD_SIZE], *sigblob;
116 u_int len, dlen;
117 int rlen, ret; 117 int rlen, ret;
118 Buffer b; 118 Buffer b;
119 119
120 if (key == NULL || key->dsa == NULL || (key->type != KEY_DSA && 120 if (key == NULL || key_type_plain(key->type) != KEY_DSA ||
121 key->type != KEY_DSA_CERT && key->type != KEY_DSA_CERT_V00)) { 121 key->dsa == NULL) {
122 error("ssh_dss_verify: no DSA key"); 122 error("%s: no DSA key", __func__);
123 return -1; 123 return -1;
124 } 124 }
125 125
@@ -135,7 +135,7 @@ ssh_dss_verify(const Key *key, const u_char *signature, u_int signaturelen,
135 buffer_append(&b, signature, signaturelen); 135 buffer_append(&b, signature, signaturelen);
136 ktype = buffer_get_cstring(&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("%s: cannot handle type %s", __func__, ktype);
139 buffer_free(&b); 139 buffer_free(&b);
140 free(ktype); 140 free(ktype);
141 return -1; 141 return -1;
@@ -145,8 +145,8 @@ ssh_dss_verify(const Key *key, const u_char *signature, u_int signaturelen,
145 rlen = buffer_len(&b); 145 rlen = buffer_len(&b);
146 buffer_free(&b); 146 buffer_free(&b);
147 if (rlen != 0) { 147 if (rlen != 0) {
148 error("ssh_dss_verify: " 148 error("%s: remaining bytes in signature %d",
149 "remaining bytes in signature %d", rlen); 149 __func__, rlen);
150 free(sigblob); 150 free(sigblob);
151 return -1; 151 return -1;
152 } 152 }
@@ -158,30 +158,32 @@ ssh_dss_verify(const Key *key, const u_char *signature, u_int signaturelen,
158 158
159 /* parse signature */ 159 /* parse signature */
160 if ((sig = DSA_SIG_new()) == NULL) 160 if ((sig = DSA_SIG_new()) == NULL)
161 fatal("ssh_dss_verify: DSA_SIG_new failed"); 161 fatal("%s: DSA_SIG_new failed", __func__);
162 if ((sig->r = BN_new()) == NULL) 162 if ((sig->r = BN_new()) == NULL)
163 fatal("ssh_dss_verify: BN_new failed"); 163 fatal("%s: BN_new failed", __func__);
164 if ((sig->s = BN_new()) == NULL) 164 if ((sig->s = BN_new()) == NULL)
165 fatal("ssh_dss_verify: BN_new failed"); 165 fatal("ssh_dss_verify: BN_new failed");
166 if ((BN_bin2bn(sigblob, INTBLOB_LEN, sig->r) == NULL) || 166 if ((BN_bin2bn(sigblob, INTBLOB_LEN, sig->r) == NULL) ||
167 (BN_bin2bn(sigblob+ INTBLOB_LEN, INTBLOB_LEN, sig->s) == NULL)) 167 (BN_bin2bn(sigblob+ INTBLOB_LEN, INTBLOB_LEN, sig->s) == NULL))
168 fatal("ssh_dss_verify: BN_bin2bn failed"); 168 fatal("%s: BN_bin2bn failed", __func__);
169 169
170 /* clean up */ 170 /* clean up */
171 memset(sigblob, 0, len); 171 memset(sigblob, 0, len);
172 free(sigblob); 172 free(sigblob);
173 173
174 /* sha1 the data */ 174 /* sha1 the data */
175 EVP_DigestInit(&md, evp_md); 175 if (ssh_digest_memory(SSH_DIGEST_SHA1, data, datalen,
176 EVP_DigestUpdate(&md, data, datalen); 176 digest, sizeof(digest)) != 0) {
177 EVP_DigestFinal(&md, digest, &dlen); 177 error("%s: digest_memory failed", __func__);
178 return -1;
179 }
178 180
179 ret = DSA_do_verify(digest, dlen, sig, key->dsa); 181 ret = DSA_do_verify(digest, dlen, sig, key->dsa);
180 memset(digest, 'd', sizeof(digest)); 182 memset(digest, 'd', sizeof(digest));
181 183
182 DSA_SIG_free(sig); 184 DSA_SIG_free(sig);
183 185
184 debug("ssh_dss_verify: signature %s", 186 debug("%s: signature %s", __func__,
185 ret == 1 ? "correct" : ret == 0 ? "incorrect" : "error"); 187 ret == 1 ? "correct" : ret == 0 ? "incorrect" : "error");
186 return ret; 188 return ret;
187} 189}
diff --git a/ssh-ecdsa.c b/ssh-ecdsa.c
index 766338941..10ad9da60 100644
--- a/ssh-ecdsa.c
+++ b/ssh-ecdsa.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-ecdsa.c,v 1.6 2013/05/17 00:13:14 djm Exp $ */ 1/* $OpenBSD: ssh-ecdsa.c,v 1.8 2014/01/09 23:20:00 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) 2010 Damien Miller. All rights reserved. 4 * Copyright (c) 2010 Damien Miller. All rights reserved.
@@ -42,27 +42,34 @@
42#include "compat.h" 42#include "compat.h"
43#include "log.h" 43#include "log.h"
44#include "key.h" 44#include "key.h"
45#include "digest.h"
45 46
46int 47int
47ssh_ecdsa_sign(const Key *key, u_char **sigp, u_int *lenp, 48ssh_ecdsa_sign(const Key *key, u_char **sigp, u_int *lenp,
48 const u_char *data, u_int datalen) 49 const u_char *data, u_int datalen)
49{ 50{
50 ECDSA_SIG *sig; 51 ECDSA_SIG *sig;
51 const EVP_MD *evp_md; 52 int hash_alg;
52 EVP_MD_CTX md; 53 u_char digest[SSH_DIGEST_MAX_LENGTH];
53 u_char digest[EVP_MAX_MD_SIZE];
54 u_int len, dlen; 54 u_int len, dlen;
55 Buffer b, bb; 55 Buffer b, bb;
56 56
57 if (key == NULL || key->ecdsa == NULL || 57 if (key == NULL || key_type_plain(key->type) != KEY_ECDSA ||
58 (key->type != KEY_ECDSA && key->type != KEY_ECDSA_CERT)) { 58 key->ecdsa == NULL) {
59 error("%s: no ECDSA key", __func__); 59 error("%s: no ECDSA key", __func__);
60 return -1; 60 return -1;
61 } 61 }
62 evp_md = key_ec_nid_to_evpmd(key->ecdsa_nid); 62
63 EVP_DigestInit(&md, evp_md); 63 hash_alg = key_ec_nid_to_hash_alg(key->ecdsa_nid);
64 EVP_DigestUpdate(&md, data, datalen); 64 if ((dlen = ssh_digest_bytes(hash_alg)) == 0) {
65 EVP_DigestFinal(&md, digest, &dlen); 65 error("%s: bad hash algorithm %d", __func__, hash_alg);
66 return -1;
67 }
68 if (ssh_digest_memory(hash_alg, data, datalen,
69 digest, sizeof(digest)) != 0) {
70 error("%s: digest_memory failed", __func__);
71 return -1;
72 }
66 73
67 sig = ECDSA_do_sign(digest, dlen, key->ecdsa); 74 sig = ECDSA_do_sign(digest, dlen, key->ecdsa);
68 memset(digest, 'd', sizeof(digest)); 75 memset(digest, 'd', sizeof(digest));
@@ -97,20 +104,18 @@ ssh_ecdsa_verify(const Key *key, const u_char *signature, u_int signaturelen,
97 const u_char *data, u_int datalen) 104 const u_char *data, u_int datalen)
98{ 105{
99 ECDSA_SIG *sig; 106 ECDSA_SIG *sig;
100 const EVP_MD *evp_md; 107 int hash_alg;
101 EVP_MD_CTX md; 108 u_char digest[SSH_DIGEST_MAX_LENGTH], *sigblob;
102 u_char digest[EVP_MAX_MD_SIZE], *sigblob;
103 u_int len, dlen; 109 u_int len, dlen;
104 int rlen, ret; 110 int rlen, ret;
105 Buffer b, bb; 111 Buffer b, bb;
106 char *ktype; 112 char *ktype;
107 113
108 if (key == NULL || key->ecdsa == NULL || 114 if (key == NULL || key_type_plain(key->type) != KEY_ECDSA ||
109 (key->type != KEY_ECDSA && key->type != KEY_ECDSA_CERT)) { 115 key->ecdsa == NULL) {
110 error("%s: no ECDSA key", __func__); 116 error("%s: no ECDSA key", __func__);
111 return -1; 117 return -1;
112 } 118 }
113 evp_md = key_ec_nid_to_evpmd(key->ecdsa_nid);
114 119
115 /* fetch signature */ 120 /* fetch signature */
116 buffer_init(&b); 121 buffer_init(&b);
@@ -152,9 +157,16 @@ ssh_ecdsa_verify(const Key *key, const u_char *signature, u_int signaturelen,
152 free(sigblob); 157 free(sigblob);
153 158
154 /* hash the data */ 159 /* hash the data */
155 EVP_DigestInit(&md, evp_md); 160 hash_alg = key_ec_nid_to_hash_alg(key->ecdsa_nid);
156 EVP_DigestUpdate(&md, data, datalen); 161 if ((dlen = ssh_digest_bytes(hash_alg)) == 0) {
157 EVP_DigestFinal(&md, digest, &dlen); 162 error("%s: bad hash algorithm %d", __func__, hash_alg);
163 return -1;
164 }
165 if (ssh_digest_memory(hash_alg, data, datalen,
166 digest, sizeof(digest)) != 0) {
167 error("%s: digest_memory failed", __func__);
168 return -1;
169 }
158 170
159 ret = ECDSA_do_verify(digest, dlen, sig, key->ecdsa); 171 ret = ECDSA_do_verify(digest, dlen, sig, key->ecdsa);
160 memset(digest, 'd', sizeof(digest)); 172 memset(digest, 'd', sizeof(digest));
diff --git a/ssh-ed25519.c b/ssh-ed25519.c
new file mode 100644
index 000000000..1aedcf83a
--- /dev/null
+++ b/ssh-ed25519.c
@@ -0,0 +1,143 @@
1/* $OpenBSD: ssh-ed25519.c,v 1.1 2013/12/06 13:39:49 markus Exp $ */
2/*
3 * Copyright (c) 2013 Markus Friedl <markus@openbsd.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#include <sys/types.h>
21
22#include "crypto_api.h"
23
24#include <string.h>
25#include <stdarg.h>
26
27#include "xmalloc.h"
28#include "log.h"
29#include "buffer.h"
30#include "key.h"
31#include "ssh.h"
32
33int
34ssh_ed25519_sign(const Key *key, u_char **sigp, u_int *lenp,
35 const u_char *data, u_int datalen)
36{
37 u_char *sig;
38 u_int slen, len;
39 unsigned long long smlen;
40 int ret;
41 Buffer b;
42
43 if (key == NULL || key_type_plain(key->type) != KEY_ED25519 ||
44 key->ed25519_sk == NULL) {
45 error("%s: no ED25519 key", __func__);
46 return -1;
47 }
48 smlen = slen = datalen + crypto_sign_ed25519_BYTES;
49 sig = xmalloc(slen);
50
51 if ((ret = crypto_sign_ed25519(sig, &smlen, data, datalen,
52 key->ed25519_sk)) != 0 || smlen <= datalen) {
53 error("%s: crypto_sign_ed25519 failed: %d", __func__, ret);
54 free(sig);
55 return -1;
56 }
57 /* encode signature */
58 buffer_init(&b);
59 buffer_put_cstring(&b, "ssh-ed25519");
60 buffer_put_string(&b, sig, smlen - datalen);
61 len = buffer_len(&b);
62 if (lenp != NULL)
63 *lenp = len;
64 if (sigp != NULL) {
65 *sigp = xmalloc(len);
66 memcpy(*sigp, buffer_ptr(&b), len);
67 }
68 buffer_free(&b);
69 memset(sig, 's', slen);
70 free(sig);
71
72 return 0;
73}
74
75int
76ssh_ed25519_verify(const Key *key, const u_char *signature, u_int signaturelen,
77 const u_char *data, u_int datalen)
78{
79 Buffer b;
80 char *ktype;
81 u_char *sigblob, *sm, *m;
82 u_int len;
83 unsigned long long smlen, mlen;
84 int rlen, ret;
85
86 if (key == NULL || key_type_plain(key->type) != KEY_ED25519 ||
87 key->ed25519_pk == NULL) {
88 error("%s: no ED25519 key", __func__);
89 return -1;
90 }
91 buffer_init(&b);
92 buffer_append(&b, signature, signaturelen);
93 ktype = buffer_get_cstring(&b, NULL);
94 if (strcmp("ssh-ed25519", ktype) != 0) {
95 error("%s: cannot handle type %s", __func__, ktype);
96 buffer_free(&b);
97 free(ktype);
98 return -1;
99 }
100 free(ktype);
101 sigblob = buffer_get_string(&b, &len);
102 rlen = buffer_len(&b);
103 buffer_free(&b);
104 if (rlen != 0) {
105 error("%s: remaining bytes in signature %d", __func__, rlen);
106 free(sigblob);
107 return -1;
108 }
109 if (len > crypto_sign_ed25519_BYTES) {
110 error("%s: len %u > crypto_sign_ed25519_BYTES %u", __func__,
111 len, crypto_sign_ed25519_BYTES);
112 free(sigblob);
113 return -1;
114 }
115 smlen = len + datalen;
116 sm = xmalloc(smlen);
117 memcpy(sm, sigblob, len);
118 memcpy(sm+len, data, datalen);
119 mlen = smlen;
120 m = xmalloc(mlen);
121 if ((ret = crypto_sign_ed25519_open(m, &mlen, sm, smlen,
122 key->ed25519_pk)) != 0) {
123 debug2("%s: crypto_sign_ed25519_open failed: %d",
124 __func__, ret);
125 }
126 if (ret == 0 && mlen != datalen) {
127 debug2("%s: crypto_sign_ed25519_open "
128 "mlen != datalen (%llu != %u)", __func__, mlen, datalen);
129 ret = -1;
130 }
131 /* XXX compare 'm' and 'data' ? */
132
133 memset(sigblob, 's', len);
134 memset(sm, 'S', smlen);
135 memset(m, 'm', smlen); /* NB. mlen may be invalid if ret != 0 */
136 free(sigblob);
137 free(sm);
138 free(m);
139 debug("%s: signature %scorrect", __func__, (ret != 0) ? "in" : "");
140
141 /* translate return code carefully */
142 return (ret == 0) ? 1 : -1;
143}
diff --git a/ssh-keygen.0 b/ssh-keygen.0
index 2b0e9a692..a69b37d67 100644
--- a/ssh-keygen.0
+++ b/ssh-keygen.0
@@ -19,8 +19,8 @@ SYNOPSIS
19 ssh-keygen -R hostname [-f known_hosts_file] 19 ssh-keygen -R hostname [-f known_hosts_file]
20 ssh-keygen -r hostname [-f input_keyfile] [-g] 20 ssh-keygen -r hostname [-f input_keyfile] [-g]
21 ssh-keygen -G output_file [-v] [-b bits] [-M memory] [-S start_point] 21 ssh-keygen -G output_file [-v] [-b bits] [-M memory] [-S start_point]
22 ssh-keygen -T output_file -f input_file [-v] [-a num_trials] 22 ssh-keygen -T output_file -f input_file [-v] [-a rounds] [-J num_lines]
23 [-J num_lines] [-j start_line] [-K checkpt] [-W generator] 23 [-j start_line] [-K checkpt] [-W generator]
24 ssh-keygen -s ca_key -I certificate_identity [-h] [-n principals] 24 ssh-keygen -s ca_key -I certificate_identity [-h] [-n principals]
25 [-O option] [-V validity_interval] [-z serial_number] file ... 25 [-O option] [-V validity_interval] [-z serial_number] file ...
26 ssh-keygen -L [-f input_keyfile] 26 ssh-keygen -L [-f input_keyfile]
@@ -32,10 +32,10 @@ SYNOPSIS
32DESCRIPTION 32DESCRIPTION
33 ssh-keygen generates, manages and converts authentication keys for 33 ssh-keygen generates, manages and converts authentication keys for
34 ssh(1). ssh-keygen can create RSA keys for use by SSH protocol version 1 34 ssh(1). ssh-keygen can create RSA keys for use by SSH protocol version 1
35 and DSA, ECDSA or RSA keys for use by SSH protocol version 2. The type 35 and DSA, ECDSA, ED25519 or RSA keys for use by SSH protocol version 2.
36 of key to be generated is specified with the -t option. If invoked 36 The type of key to be generated is specified with the -t option. If
37 without any arguments, ssh-keygen will generate an RSA key for use in SSH 37 invoked without any arguments, ssh-keygen will generate an RSA key for
38 protocol 2 connections. 38 use in SSH protocol 2 connections.
39 39
40 ssh-keygen is also used to generate groups for use in Diffie-Hellman 40 ssh-keygen is also used to generate groups for use in Diffie-Hellman
41 group exchange (DH-GEX). See the MODULI GENERATION section for details. 41 group exchange (DH-GEX). See the MODULI GENERATION section for details.
@@ -46,9 +46,9 @@ DESCRIPTION
46 46
47 Normally each user wishing to use SSH with public key authentication runs 47 Normally each user wishing to use SSH with public key authentication runs
48 this once to create the authentication key in ~/.ssh/identity, 48 this once to create the authentication key in ~/.ssh/identity,
49 ~/.ssh/id_ecdsa, ~/.ssh/id_dsa or ~/.ssh/id_rsa. Additionally, the 49 ~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519 or ~/.ssh/id_rsa.
50 system administrator may use this to generate host keys, as seen in 50 Additionally, the system administrator may use this to generate host
51 /etc/rc. 51 keys, as seen in /etc/rc.
52 52
53 Normally this program generates the key and asks for a file in which to 53 Normally this program generates the key and asks for a file in which to
54 store the private key. The public key is stored in a file with the same 54 store the private key. The public key is stored in a file with the same
@@ -79,15 +79,22 @@ DESCRIPTION
79 79
80 The options are as follows: 80 The options are as follows:
81 81
82 -A For each of the key types (rsa1, rsa, dsa and ecdsa) for which 82 -A For each of the key types (rsa1, rsa, dsa, ecdsa and ed25519) for
83 host keys do not exist, generate the host keys with the default 83 which host keys do not exist, generate the host keys with the
84 key file path, an empty passphrase, default bits for the key 84 default key file path, an empty passphrase, default bits for the
85 type, and default comment. This is used by /etc/rc to generate 85 key type, and default comment. This is used by /etc/rc to
86 new host keys. 86 generate new host keys.
87 87
88 -a trials 88 -a rounds
89 Specifies the number of primality tests to perform when screening 89 When saving a new-format private key (i.e. an ed25519 key or any
90 DH-GEX candidates using the -T command. 90 SSH protocol 2 key when the -o flag is set), this option
91 specifies the number of KDF (key derivation function) rounds
92 used. Higher numbers result in slower passphrase verification
93 and increased resistance to brute-force password cracking (should
94 the keys be stolen).
95
96 When screening DH-GEX candidates ( using the -T command). This
97 option specifies the number of primality tests to perform.
91 98
92 -B Show the bubblebabble digest of specified private or public key 99 -B Show the bubblebabble digest of specified private or public key
93 file. 100 file.
@@ -100,7 +107,8 @@ DESCRIPTION
100 the -b flag determines the key length by selecting from one of 107 the -b flag determines the key length by selecting from one of
101 three elliptic curve sizes: 256, 384 or 521 bits. Attempting to 108 three elliptic curve sizes: 256, 384 or 521 bits. Attempting to
102 use bit lengths other than these three values for ECDSA keys will 109 use bit lengths other than these three values for ECDSA keys will
103 fail. 110 fail. ED25519 keys have a fixed length and the -b flag will be
111 ignored.
104 112
105 -C comment 113 -C comment
106 Provides a new comment. 114 Provides a new comment.
@@ -262,6 +270,12 @@ DESCRIPTION
262 270
263 At present, no options are valid for host keys. 271 At present, no options are valid for host keys.
264 272
273 -o Causes ssh-keygen to save SSH protocol 2 private keys using the
274 new OpenSSH format rather than the more compatible PEM format.
275 The new format has increased resistance to brute-force password
276 cracking but is not supported by versions of OpenSSH prior to
277 6.5. Ed25519 keys always use the new private key format.
278
265 -P passphrase 279 -P passphrase
266 Provides the (old) passphrase. 280 Provides the (old) passphrase.
267 281
@@ -301,8 +315,8 @@ DESCRIPTION
301 315
302 -t type 316 -t type
303 Specifies the type of key to create. The possible values are 317 Specifies the type of key to create. The possible values are
304 ``rsa1'' for protocol version 1 and ``dsa'', ``ecdsa'' or ``rsa'' 318 ``rsa1'' for protocol version 1 and ``dsa'', ``ecdsa'',
305 for protocol version 2. 319 ``ed25519'', or ``rsa'' for protocol version 2.
306 320
307 -u Update a KRL. When specified with -k, keys listed via the 321 -u Update a KRL. When specified with -k, keys listed via the
308 command line are added to the existing KRL rather than a new KRL 322 command line are added to the existing KRL rather than a new KRL
@@ -441,7 +455,7 @@ CERTIFICATES
441KEY REVOCATION LISTS 455KEY REVOCATION LISTS
442 ssh-keygen is able to manage OpenSSH format Key Revocation Lists (KRLs). 456 ssh-keygen is able to manage OpenSSH format Key Revocation Lists (KRLs).
443 These binary files specify keys or certificates to be revoked using a 457 These binary files specify keys or certificates to be revoked using a
444 compact format, taking as little a one bit per certificate if they are 458 compact format, taking as little as one bit per certificate if they are
445 being revoked by serial number. 459 being revoked by serial number.
446 460
447 KRLs may be generated using the -k flag. This option reads one or more 461 KRLs may be generated using the -k flag. This option reads one or more
@@ -508,24 +522,26 @@ FILES
508 522
509 ~/.ssh/id_dsa 523 ~/.ssh/id_dsa
510 ~/.ssh/id_ecdsa 524 ~/.ssh/id_ecdsa
525 ~/.ssh/id_ed25519
511 ~/.ssh/id_rsa 526 ~/.ssh/id_rsa
512 Contains the protocol version 2 DSA, ECDSA or RSA authentication 527 Contains the protocol version 2 DSA, ECDSA, ED25519 or RSA
513 identity of the user. This file should not be readable by anyone 528 authentication identity of the user. This file should not be
514 but the user. It is possible to specify a passphrase when 529 readable by anyone but the user. It is possible to specify a
515 generating the key; that passphrase will be used to encrypt the 530 passphrase when generating the key; that passphrase will be used
516 private part of this file using 128-bit AES. This file is not 531 to encrypt the private part of this file using 128-bit AES. This
517 automatically accessed by ssh-keygen but it is offered as the 532 file is not automatically accessed by ssh-keygen but it is
518 default file for the private key. ssh(1) will read this file 533 offered as the default file for the private key. ssh(1) will
519 when a login attempt is made. 534 read this file when a login attempt is made.
520 535
521 ~/.ssh/id_dsa.pub 536 ~/.ssh/id_dsa.pub
522 ~/.ssh/id_ecdsa.pub 537 ~/.ssh/id_ecdsa.pub
538 ~/.ssh/id_ed25519.pub
523 ~/.ssh/id_rsa.pub 539 ~/.ssh/id_rsa.pub
524 Contains the protocol version 2 DSA, ECDSA or RSA public key for 540 Contains the protocol version 2 DSA, ECDSA, ED25519 or RSA public
525 authentication. The contents of this file should be added to 541 key for authentication. The contents of this file should be
526 ~/.ssh/authorized_keys on all machines where the user wishes to 542 added to ~/.ssh/authorized_keys on all machines where the user
527 log in using public key authentication. There is no need to keep 543 wishes to log in using public key authentication. There is no
528 the contents of this file secret. 544 need to keep the contents of this file secret.
529 545
530 /etc/moduli 546 /etc/moduli
531 Contains Diffie-Hellman groups used for DH-GEX. The file format 547 Contains Diffie-Hellman groups used for DH-GEX. The file format
@@ -543,4 +559,4 @@ AUTHORS
543 created OpenSSH. Markus Friedl contributed the support for SSH protocol 559 created OpenSSH. Markus Friedl contributed the support for SSH protocol
544 versions 1.5 and 2.0. 560 versions 1.5 and 2.0.
545 561
546OpenBSD 5.4 June 27, 2013 OpenBSD 5.4 562OpenBSD 5.4 December 21, 2013 OpenBSD 5.4
diff --git a/ssh-keygen.1 b/ssh-keygen.1
index 0d55854e9..0e0ed989f 100644
--- a/ssh-keygen.1
+++ b/ssh-keygen.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ssh-keygen.1,v 1.116 2013/06/27 14:05:37 jmc Exp $ 1.\" $OpenBSD: ssh-keygen.1,v 1.119 2013/12/21 07:10:47 tedu 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
@@ -35,7 +35,7 @@
35.\" (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
36.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37.\" 37.\"
38.Dd $Mdocdate: June 27 2013 $ 38.Dd $Mdocdate: December 21 2013 $
39.Dt SSH-KEYGEN 1 39.Dt SSH-KEYGEN 1
40.Os 40.Os
41.Sh NAME 41.Sh NAME
@@ -103,7 +103,7 @@
103.Fl T Ar output_file 103.Fl T Ar output_file
104.Fl f Ar input_file 104.Fl f Ar input_file
105.Op Fl v 105.Op Fl v
106.Op Fl a Ar num_trials 106.Op Fl a Ar rounds
107.Op Fl J Ar num_lines 107.Op Fl J Ar num_lines
108.Op Fl j Ar start_line 108.Op Fl j Ar start_line
109.Op Fl K Ar checkpt 109.Op Fl K Ar checkpt
@@ -139,8 +139,8 @@
139generates, manages and converts authentication keys for 139generates, manages and converts authentication keys for
140.Xr ssh 1 . 140.Xr ssh 1 .
141.Nm 141.Nm
142can create RSA keys for use by SSH protocol version 1 and DSA, ECDSA or RSA 142can create RSA keys for use by SSH protocol version 1 and
143keys for use by SSH protocol version 2. 143DSA, ECDSA, ED25519 or RSA keys for use by SSH protocol version 2.
144The type of key to be generated is specified with the 144The type of key to be generated is specified with the
145.Fl t 145.Fl t
146option. 146option.
@@ -167,8 +167,9 @@ Normally each user wishing to use SSH
167with public key authentication runs this once to create the authentication 167with public key authentication runs this once to create the authentication
168key in 168key in
169.Pa ~/.ssh/identity , 169.Pa ~/.ssh/identity ,
170.Pa ~/.ssh/id_dsa ,
170.Pa ~/.ssh/id_ecdsa , 171.Pa ~/.ssh/id_ecdsa ,
171.Pa ~/.ssh/id_dsa 172.Pa ~/.ssh/id_ed25519
172or 173or
173.Pa ~/.ssh/id_rsa . 174.Pa ~/.ssh/id_rsa .
174Additionally, the system administrator may use this to generate host keys, 175Additionally, the system administrator may use this to generate host keys,
@@ -216,17 +217,27 @@ should be placed to be activated.
216The options are as follows: 217The options are as follows:
217.Bl -tag -width Ds 218.Bl -tag -width Ds
218.It Fl A 219.It Fl A
219For each of the key types (rsa1, rsa, dsa and ecdsa) for which host keys 220For each of the key types (rsa1, rsa, dsa, ecdsa and ed25519)
221for which host keys
220do not exist, generate the host keys with the default key file path, 222do not exist, generate the host keys with the default key file path,
221an empty passphrase, default bits for the key type, and default comment. 223an empty passphrase, default bits for the key type, and default comment.
222This is used by 224This is used by
223.Pa /etc/rc 225.Pa /etc/rc
224to generate new host keys. 226to generate new host keys.
225.It Fl a Ar trials 227.It Fl a Ar rounds
226Specifies the number of primality tests to perform when screening DH-GEX 228When saving a new-format private key (i.e. an ed25519 key or any SSH protocol
227candidates using the 2292 key when the
230.Fl o
231flag is set), this option specifies the number of KDF (key derivation function)
232rounds used.
233Higher numbers result in slower passphrase verification and increased
234resistance to brute-force password cracking (should the keys be stolen).
235.Pp
236When screening DH-GEX candidates (
237using the
228.Fl T 238.Fl T
229command. 239command).
240This option specifies the number of primality tests to perform.
230.It Fl B 241.It Fl B
231Show the bubblebabble digest of specified private or public key file. 242Show the bubblebabble digest of specified private or public key file.
232.It Fl b Ar bits 243.It Fl b Ar bits
@@ -240,6 +251,9 @@ flag determines the key length by selecting from one of three elliptic
240curve sizes: 256, 384 or 521 bits. 251curve sizes: 256, 384 or 521 bits.
241Attempting to use bit lengths other than these three values for ECDSA keys 252Attempting to use bit lengths other than these three values for ECDSA keys
242will fail. 253will fail.
254ED25519 keys have a fixed length and the
255.Fl b
256flag will be ignored.
243.It Fl C Ar comment 257.It Fl C Ar comment
244Provides a new comment. 258Provides a new comment.
245.It Fl c 259.It Fl c
@@ -447,6 +461,14 @@ format.
447.El 461.El
448.Pp 462.Pp
449At present, no options are valid for host keys. 463At present, no options are valid for host keys.
464.It Fl o
465Causes
466.Nm
467to save SSH protocol 2 private keys using the new OpenSSH format rather than
468the more compatible PEM format.
469The new format has increased resistance to brute-force password cracking
470but is not supported by versions of OpenSSH prior to 6.5.
471Ed25519 keys always use the new private key format.
450.It Fl P Ar passphrase 472.It Fl P Ar passphrase
451Provides the (old) passphrase. 473Provides the (old) passphrase.
452.It Fl p 474.It Fl p
@@ -498,7 +520,8 @@ The possible values are
498.Dq rsa1 520.Dq rsa1
499for protocol version 1 and 521for protocol version 1 and
500.Dq dsa , 522.Dq dsa ,
501.Dq ecdsa 523.Dq ecdsa ,
524.Dq ed25519 ,
502or 525or
503.Dq rsa 526.Dq rsa
504for protocol version 2. 527for protocol version 2.
@@ -691,7 +714,7 @@ Please refer to those manual pages for details.
691.Nm 714.Nm
692is able to manage OpenSSH format Key Revocation Lists (KRLs). 715is able to manage OpenSSH format Key Revocation Lists (KRLs).
693These binary files specify keys or certificates to be revoked using a 716These binary files specify keys or certificates to be revoked using a
694compact format, taking as little a one bit per certificate if they are being 717compact format, taking as little as one bit per certificate if they are being
695revoked by serial number. 718revoked by serial number.
696.Pp 719.Pp
697KRLs may be generated using the 720KRLs may be generated using the
@@ -778,8 +801,10 @@ There is no need to keep the contents of this file secret.
778.Pp 801.Pp
779.It Pa ~/.ssh/id_dsa 802.It Pa ~/.ssh/id_dsa
780.It Pa ~/.ssh/id_ecdsa 803.It Pa ~/.ssh/id_ecdsa
804.It Pa ~/.ssh/id_ed25519
781.It Pa ~/.ssh/id_rsa 805.It Pa ~/.ssh/id_rsa
782Contains the protocol version 2 DSA, ECDSA or RSA authentication identity of the user. 806Contains the protocol version 2 DSA, ECDSA, ED25519 or RSA
807authentication identity of the user.
783This file should not be readable by anyone but the user. 808This file should not be readable by anyone but the user.
784It is possible to 809It is possible to
785specify a passphrase when generating the key; that passphrase will be 810specify a passphrase when generating the key; that passphrase will be
@@ -792,8 +817,10 @@ will read this file when a login attempt is made.
792.Pp 817.Pp
793.It Pa ~/.ssh/id_dsa.pub 818.It Pa ~/.ssh/id_dsa.pub
794.It Pa ~/.ssh/id_ecdsa.pub 819.It Pa ~/.ssh/id_ecdsa.pub
820.It Pa ~/.ssh/id_ed25519.pub
795.It Pa ~/.ssh/id_rsa.pub 821.It Pa ~/.ssh/id_rsa.pub
796Contains the protocol version 2 DSA, ECDSA or RSA public key for authentication. 822Contains the protocol version 2 DSA, ECDSA, ED25519 or RSA
823public key for authentication.
797The contents of this file should be added to 824The contents of this file should be added to
798.Pa ~/.ssh/authorized_keys 825.Pa ~/.ssh/authorized_keys
799on all machines 826on all machines
diff --git a/ssh-keygen.c b/ssh-keygen.c
index 03c444d42..eae83a461 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keygen.c,v 1.230 2013/07/20 01:44:37 djm Exp $ */ 1/* $OpenBSD: ssh-keygen.c,v 1.238 2013/12/06 13:39:49 markus 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
@@ -150,6 +150,18 @@ char *key_type_name = NULL;
150/* Load key from this PKCS#11 provider */ 150/* Load key from this PKCS#11 provider */
151char *pkcs11provider = NULL; 151char *pkcs11provider = NULL;
152 152
153/* Use new OpenSSH private key format when writing SSH2 keys instead of PEM */
154int use_new_format = 0;
155
156/* Cipher for new-format private keys */
157char *new_format_cipher = NULL;
158
159/*
160 * Number of KDF rounds to derive new format keys /
161 * number of primality trials when screening moduli.
162 */
163int rounds = 0;
164
153/* argv0 */ 165/* argv0 */
154extern char *__progname; 166extern char *__progname;
155 167
@@ -185,7 +197,7 @@ type_bits_valid(int type, u_int32_t *bitsp)
185 } 197 }
186 if (type == KEY_DSA && *bitsp != 1024) 198 if (type == KEY_DSA && *bitsp != 1024)
187 fatal("DSA keys must be 1024 bits"); 199 fatal("DSA keys must be 1024 bits");
188 else if (type != KEY_ECDSA && *bitsp < 768) 200 else if (type != KEY_ECDSA && type != KEY_ED25519 && *bitsp < 768)
189 fatal("Key must at least be 768 bits"); 201 fatal("Key must at least be 768 bits");
190 else if (type == KEY_ECDSA && key_ecdsa_bits_to_nid(*bitsp) == -1) 202 else if (type == KEY_ECDSA && key_ecdsa_bits_to_nid(*bitsp) == -1)
191 fatal("Invalid ECDSA key length - valid lengths are " 203 fatal("Invalid ECDSA key length - valid lengths are "
@@ -221,6 +233,10 @@ ask_filename(struct passwd *pw, const char *prompt)
221 case KEY_RSA: 233 case KEY_RSA:
222 name = _PATH_SSH_CLIENT_ID_RSA; 234 name = _PATH_SSH_CLIENT_ID_RSA;
223 break; 235 break;
236 case KEY_ED25519:
237 case KEY_ED25519_CERT:
238 name = _PATH_SSH_CLIENT_ID_ED25519;
239 break;
224 default: 240 default:
225 fprintf(stderr, "bad key type\n"); 241 fprintf(stderr, "bad key type\n");
226 exit(1); 242 exit(1);
@@ -884,6 +900,7 @@ do_gen_all_hostkeys(struct passwd *pw)
884#ifdef OPENSSL_HAS_ECC 900#ifdef OPENSSL_HAS_ECC
885 { "ecdsa", "ECDSA",_PATH_HOST_ECDSA_KEY_FILE }, 901 { "ecdsa", "ECDSA",_PATH_HOST_ECDSA_KEY_FILE },
886#endif 902#endif
903 { "ed25519", "ED25519",_PATH_HOST_ED25519_KEY_FILE },
887 { NULL, NULL, NULL } 904 { NULL, NULL, NULL }
888 }; 905 };
889 906
@@ -910,7 +927,6 @@ do_gen_all_hostkeys(struct passwd *pw)
910 } 927 }
911 printf("%s ", key_types[i].key_type_display); 928 printf("%s ", key_types[i].key_type_display);
912 fflush(stdout); 929 fflush(stdout);
913 arc4random_stir();
914 type = key_type_from_name(key_types[i].key_type); 930 type = key_type_from_name(key_types[i].key_type);
915 strlcpy(identity_file, key_types[i].path, sizeof(identity_file)); 931 strlcpy(identity_file, key_types[i].path, sizeof(identity_file));
916 bits = 0; 932 bits = 0;
@@ -924,7 +940,8 @@ do_gen_all_hostkeys(struct passwd *pw)
924 public = key_from_private(private); 940 public = key_from_private(private);
925 snprintf(comment, sizeof comment, "%s@%s", pw->pw_name, 941 snprintf(comment, sizeof comment, "%s@%s", pw->pw_name,
926 hostname); 942 hostname);
927 if (!key_save_private(private, identity_file, "", comment)) { 943 if (!key_save_private(private, identity_file, "", comment,
944 use_new_format, new_format_cipher, rounds)) {
928 printf("Saving the key failed: %s.\n", identity_file); 945 printf("Saving the key failed: %s.\n", identity_file);
929 key_free(private); 946 key_free(private);
930 key_free(public); 947 key_free(public);
@@ -932,7 +949,6 @@ do_gen_all_hostkeys(struct passwd *pw)
932 continue; 949 continue;
933 } 950 }
934 key_free(private); 951 key_free(private);
935 arc4random_stir();
936 strlcat(identity_file, ".pub", sizeof(identity_file)); 952 strlcat(identity_file, ".pub", sizeof(identity_file));
937 fd = open(identity_file, O_WRONLY | O_CREAT | O_TRUNC, 0644); 953 fd = open(identity_file, O_WRONLY | O_CREAT | O_TRUNC, 0644);
938 if (fd == -1) { 954 if (fd == -1) {
@@ -1001,6 +1017,7 @@ do_known_hosts(struct passwd *pw, const char *name)
1001 char line[16*1024], tmp[MAXPATHLEN], old[MAXPATHLEN]; 1017 char line[16*1024], tmp[MAXPATHLEN], old[MAXPATHLEN];
1002 int c, skip = 0, inplace = 0, num = 0, invalid = 0, has_unhashed = 0; 1018 int c, skip = 0, inplace = 0, num = 0, invalid = 0, has_unhashed = 0;
1003 int ca; 1019 int ca;
1020 int found_key = 0;
1004 1021
1005 if (!have_identity) { 1022 if (!have_identity) {
1006 cp = tilde_expand_filename(_PATH_SSH_USER_HOSTFILE, pw->pw_uid); 1023 cp = tilde_expand_filename(_PATH_SSH_USER_HOSTFILE, pw->pw_uid);
@@ -1103,11 +1120,13 @@ do_known_hosts(struct passwd *pw, const char *name)
1103 } 1120 }
1104 c = (strcmp(cp2, cp) == 0); 1121 c = (strcmp(cp2, cp) == 0);
1105 if (find_host && c) { 1122 if (find_host && c) {
1106 printf("# Host %s found: " 1123 if (!quiet)
1107 "line %d type %s%s\n", name, 1124 printf("# Host %s found: "
1108 num, key_type(pub), 1125 "line %d type %s%s\n", name,
1109 ca ? " (CA key)" : ""); 1126 num, key_type(pub),
1127 ca ? " (CA key)" : "");
1110 printhost(out, cp, pub, ca, 0); 1128 printhost(out, cp, pub, ca, 0);
1129 found_key = 1;
1111 } 1130 }
1112 if (delete_host) { 1131 if (delete_host) {
1113 if (!c && !ca) 1132 if (!c && !ca)
@@ -1124,12 +1143,14 @@ do_known_hosts(struct passwd *pw, const char *name)
1124 c = (match_hostname(name, cp, 1143 c = (match_hostname(name, cp,
1125 strlen(cp)) == 1); 1144 strlen(cp)) == 1);
1126 if (find_host && c) { 1145 if (find_host && c) {
1127 printf("# Host %s found: " 1146 if (!quiet)
1128 "line %d type %s%s\n", name, 1147 printf("# Host %s found: "
1129 num, key_type(pub), 1148 "line %d type %s%s\n", name,
1130 ca ? " (CA key)" : ""); 1149 num, key_type(pub),
1150 ca ? " (CA key)" : "");
1131 printhost(out, name, pub, 1151 printhost(out, name, pub,
1132 ca, hash_hosts && !ca); 1152 ca, hash_hosts && !ca);
1153 found_key = 1;
1133 } 1154 }
1134 if (delete_host) { 1155 if (delete_host) {
1135 if (!c && !ca) 1156 if (!c && !ca)
@@ -1205,7 +1226,7 @@ do_known_hosts(struct passwd *pw, const char *name)
1205 } 1226 }
1206 } 1227 }
1207 1228
1208 exit(0); 1229 exit (find_host && !found_key);
1209} 1230}
1210 1231
1211/* 1232/*
@@ -1272,7 +1293,8 @@ do_change_passphrase(struct passwd *pw)
1272 } 1293 }
1273 1294
1274 /* Save the file using the new passphrase. */ 1295 /* Save the file using the new passphrase. */
1275 if (!key_save_private(private, identity_file, passphrase1, comment)) { 1296 if (!key_save_private(private, identity_file, passphrase1, comment,
1297 use_new_format, new_format_cipher, rounds)) {
1276 printf("Saving the key failed: %s.\n", identity_file); 1298 printf("Saving the key failed: %s.\n", identity_file);
1277 memset(passphrase1, 0, strlen(passphrase1)); 1299 memset(passphrase1, 0, strlen(passphrase1));
1278 free(passphrase1); 1300 free(passphrase1);
@@ -1382,7 +1404,8 @@ do_change_comment(struct passwd *pw)
1382 } 1404 }
1383 1405
1384 /* Save the file using the new passphrase. */ 1406 /* Save the file using the new passphrase. */
1385 if (!key_save_private(private, identity_file, passphrase, new_comment)) { 1407 if (!key_save_private(private, identity_file, passphrase, new_comment,
1408 use_new_format, new_format_cipher, rounds)) {
1386 printf("Saving the key failed: %s.\n", identity_file); 1409 printf("Saving the key failed: %s.\n", identity_file);
1387 memset(passphrase, 0, strlen(passphrase)); 1410 memset(passphrase, 0, strlen(passphrase));
1388 free(passphrase); 1411 free(passphrase);
@@ -1593,7 +1616,7 @@ do_ca_sign(struct passwd *pw, int argc, char **argv)
1593 if ((public = key_load_public(tmp, &comment)) == NULL) 1616 if ((public = key_load_public(tmp, &comment)) == NULL)
1594 fatal("%s: unable to open \"%s\"", __func__, tmp); 1617 fatal("%s: unable to open \"%s\"", __func__, tmp);
1595 if (public->type != KEY_RSA && public->type != KEY_DSA && 1618 if (public->type != KEY_RSA && public->type != KEY_DSA &&
1596 public->type != KEY_ECDSA) 1619 public->type != KEY_ECDSA && public->type != KEY_ED25519)
1597 fatal("%s: key \"%s\" type %s cannot be certified", 1620 fatal("%s: key \"%s\" type %s cannot be certified",
1598 __func__, tmp, key_type(public)); 1621 __func__, tmp, key_type(public));
1599 1622
@@ -1738,7 +1761,7 @@ parse_cert_times(char *timespec)
1738 cert_valid_from = parse_absolute_time(from); 1761 cert_valid_from = parse_absolute_time(from);
1739 1762
1740 if (*to == '-' || *to == '+') 1763 if (*to == '-' || *to == '+')
1741 cert_valid_to = parse_relative_time(to, cert_valid_from); 1764 cert_valid_to = parse_relative_time(to, now);
1742 else 1765 else
1743 cert_valid_to = parse_absolute_time(to); 1766 cert_valid_to = parse_absolute_time(to);
1744 1767
@@ -1963,7 +1986,7 @@ update_krl_from_file(struct passwd *pw, const char *file, const Key *ca,
1963 continue; 1986 continue;
1964 if (strncasecmp(cp, "serial:", 7) == 0) { 1987 if (strncasecmp(cp, "serial:", 7) == 0) {
1965 if (ca == NULL) { 1988 if (ca == NULL) {
1966 fatal("revoking certificated by serial number " 1989 fatal("revoking certificates by serial number "
1967 "requires specification of a CA key"); 1990 "requires specification of a CA key");
1968 } 1991 }
1969 cp += 7; 1992 cp += 7;
@@ -2000,7 +2023,7 @@ update_krl_from_file(struct passwd *pw, const char *file, const Key *ca,
2000 } 2023 }
2001 } else if (strncasecmp(cp, "id:", 3) == 0) { 2024 } else if (strncasecmp(cp, "id:", 3) == 0) {
2002 if (ca == NULL) { 2025 if (ca == NULL) {
2003 fatal("revoking certificated by key ID " 2026 fatal("revoking certificates by key ID "
2004 "requires specification of a CA key"); 2027 "requires specification of a CA key");
2005 } 2028 }
2006 cp += 3; 2029 cp += 3;
@@ -2129,7 +2152,7 @@ usage(void)
2129 fprintf(stderr, "usage: %s [options]\n", __progname); 2152 fprintf(stderr, "usage: %s [options]\n", __progname);
2130 fprintf(stderr, "Options:\n"); 2153 fprintf(stderr, "Options:\n");
2131 fprintf(stderr, " -A Generate non-existent host keys for all key types.\n"); 2154 fprintf(stderr, " -A Generate non-existent host keys for all key types.\n");
2132 fprintf(stderr, " -a trials Number of trials for screening DH-GEX moduli.\n"); 2155 fprintf(stderr, " -a number Number of KDF rounds for new key format or moduli primality tests.\n");
2133 fprintf(stderr, " -B Show bubblebabble digest of key file.\n"); 2156 fprintf(stderr, " -B Show bubblebabble digest of key file.\n");
2134 fprintf(stderr, " -b bits Number of bits in the key to create.\n"); 2157 fprintf(stderr, " -b bits Number of bits in the key to create.\n");
2135 fprintf(stderr, " -C comment Provide new comment.\n"); 2158 fprintf(stderr, " -C comment Provide new comment.\n");
@@ -2157,6 +2180,7 @@ usage(void)
2157 fprintf(stderr, " -N phrase Provide new passphrase.\n"); 2180 fprintf(stderr, " -N phrase Provide new passphrase.\n");
2158 fprintf(stderr, " -n name,... User/host principal names to include in certificate\n"); 2181 fprintf(stderr, " -n name,... User/host principal names to include in certificate\n");
2159 fprintf(stderr, " -O option Specify a certificate option.\n"); 2182 fprintf(stderr, " -O option Specify a certificate option.\n");
2183 fprintf(stderr, " -o Enforce new private key format.\n");
2160 fprintf(stderr, " -P phrase Provide old passphrase.\n"); 2184 fprintf(stderr, " -P phrase Provide old passphrase.\n");
2161 fprintf(stderr, " -p Change passphrase of private key file.\n"); 2185 fprintf(stderr, " -p Change passphrase of private key file.\n");
2162 fprintf(stderr, " -Q Test whether key(s) are revoked in KRL.\n"); 2186 fprintf(stderr, " -Q Test whether key(s) are revoked in KRL.\n");
@@ -2173,6 +2197,7 @@ usage(void)
2173 fprintf(stderr, " -W gen Generator to use for generating DH-GEX moduli.\n"); 2197 fprintf(stderr, " -W gen Generator to use for generating DH-GEX moduli.\n");
2174 fprintf(stderr, " -y Read private key file and print public key.\n"); 2198 fprintf(stderr, " -y Read private key file and print public key.\n");
2175 fprintf(stderr, " -z serial Specify a serial number.\n"); 2199 fprintf(stderr, " -z serial Specify a serial number.\n");
2200 fprintf(stderr, " -Z cipher Specify a cipher for new private key format.\n");
2176 2201
2177 exit(1); 2202 exit(1);
2178} 2203}
@@ -2190,7 +2215,7 @@ main(int argc, char **argv)
2190 struct passwd *pw; 2215 struct passwd *pw;
2191 struct stat st; 2216 struct stat st;
2192 int opt, type, fd; 2217 int opt, type, fd;
2193 u_int32_t memory = 0, generator_wanted = 0, trials = 100; 2218 u_int32_t memory = 0, generator_wanted = 0;
2194 int do_gen_candidates = 0, do_screen_candidates = 0; 2219 int do_gen_candidates = 0, do_screen_candidates = 0;
2195 int gen_all_hostkeys = 0, gen_krl = 0, update_krl = 0, check_krl = 0; 2220 int gen_all_hostkeys = 0, gen_krl = 0, update_krl = 0, check_krl = 0;
2196 unsigned long start_lineno = 0, lines_to_process = 0; 2221 unsigned long start_lineno = 0, lines_to_process = 0;
@@ -2222,8 +2247,9 @@ main(int argc, char **argv)
2222 exit(1); 2247 exit(1);
2223 } 2248 }
2224 2249
2225 while ((opt = getopt(argc, argv, "ABHLQXceghiklpquvxy" 2250 /* Remaining characters: EUYdw */
2226 "C:D:F:G:I:J:K:M:N:O:P:R:S:T:V:W:a:b:f:g:j:m:n:r:s:t:z:")) != -1) { 2251 while ((opt = getopt(argc, argv, "ABHLQXceghiklopquvxy"
2252 "C:D:F:G:I:J:K:M:N:O:P:R:S:T:V:W:Z:a:b:f:g:j:m:n:r:s:t:z:")) != -1) {
2227 switch (opt) { 2253 switch (opt) {
2228 case 'A': 2254 case 'A':
2229 gen_all_hostkeys = 1; 2255 gen_all_hostkeys = 1;
@@ -2281,6 +2307,9 @@ main(int argc, char **argv)
2281 case 'n': 2307 case 'n':
2282 cert_principals = optarg; 2308 cert_principals = optarg;
2283 break; 2309 break;
2310 case 'o':
2311 use_new_format = 1;
2312 break;
2284 case 'p': 2313 case 'p':
2285 change_passphrase = 1; 2314 change_passphrase = 1;
2286 break; 2315 break;
@@ -2308,6 +2337,9 @@ main(int argc, char **argv)
2308 case 'O': 2337 case 'O':
2309 add_cert_option(optarg); 2338 add_cert_option(optarg);
2310 break; 2339 break;
2340 case 'Z':
2341 new_format_cipher = optarg;
2342 break;
2311 case 'C': 2343 case 'C':
2312 identity_comment = optarg; 2344 identity_comment = optarg;
2313 break; 2345 break;
@@ -2366,9 +2398,9 @@ main(int argc, char **argv)
2366 optarg, errstr); 2398 optarg, errstr);
2367 break; 2399 break;
2368 case 'a': 2400 case 'a':
2369 trials = (u_int32_t)strtonum(optarg, 1, UINT_MAX, &errstr); 2401 rounds = (int)strtonum(optarg, 1, INT_MAX, &errstr);
2370 if (errstr) 2402 if (errstr)
2371 fatal("Invalid number of trials: %s (%s)", 2403 fatal("Invalid number: %s (%s)",
2372 optarg, errstr); 2404 optarg, errstr);
2373 break; 2405 break;
2374 case 'M': 2406 case 'M':
@@ -2527,7 +2559,8 @@ main(int argc, char **argv)
2527 fatal("Couldn't open moduli file \"%s\": %s", 2559 fatal("Couldn't open moduli file \"%s\": %s",
2528 out_file, strerror(errno)); 2560 out_file, strerror(errno));
2529 } 2561 }
2530 if (prime_test(in, out, trials, generator_wanted, checkpoint, 2562 if (prime_test(in, out, rounds == 0 ? 100 : rounds,
2563 generator_wanted, checkpoint,
2531 start_lineno, lines_to_process) != 0) 2564 start_lineno, lines_to_process) != 0)
2532 fatal("modulus screening failed"); 2565 fatal("modulus screening failed");
2533 return (0); 2566 return (0);
@@ -2538,8 +2571,6 @@ main(int argc, char **argv)
2538 return (0); 2571 return (0);
2539 } 2572 }
2540 2573
2541 arc4random_stir();
2542
2543 if (key_type_name == NULL) 2574 if (key_type_name == NULL)
2544 key_type_name = "rsa"; 2575 key_type_name = "rsa";
2545 2576
@@ -2621,7 +2652,8 @@ passphrase_again:
2621 } 2652 }
2622 2653
2623 /* Save the key with the given passphrase and comment. */ 2654 /* Save the key with the given passphrase and comment. */
2624 if (!key_save_private(private, identity_file, passphrase1, comment)) { 2655 if (!key_save_private(private, identity_file, passphrase1, comment,
2656 use_new_format, new_format_cipher, rounds)) {
2625 printf("Saving the key failed: %s.\n", identity_file); 2657 printf("Saving the key failed: %s.\n", identity_file);
2626 memset(passphrase1, 0, strlen(passphrase1)); 2658 memset(passphrase1, 0, strlen(passphrase1));
2627 free(passphrase1); 2659 free(passphrase1);
@@ -2633,7 +2665,6 @@ passphrase_again:
2633 2665
2634 /* Clear the private key and the random number generator. */ 2666 /* Clear the private key and the random number generator. */
2635 key_free(private); 2667 key_free(private);
2636 arc4random_stir();
2637 2668
2638 if (!quiet) 2669 if (!quiet)
2639 printf("Your identification has been saved in %s.\n", identity_file); 2670 printf("Your identification has been saved in %s.\n", identity_file);
diff --git a/ssh-keyscan.0 b/ssh-keyscan.0
index 3ea99c320..09cfa0afa 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 ``dsa'', ``ecdsa'' or ``rsa'' for protocol version 2. Multiple 51 ``dsa'', ``ecdsa'', ``ed25519'', or ``rsa'' for protocol version
52 values may be specified by separating them with commas. The 52 2. Multiple values may be specified by separating them with
53 default is to fetch ``rsa'' and ``ecdsa'' keys. 53 commas. The default is to fetch ``rsa'' and ``ecdsa'' keys.
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.
@@ -77,7 +77,7 @@ FILES
77 host-or-namelist keytype base64-encoded-key 77 host-or-namelist keytype base64-encoded-key
78 78
79 Where keytype is either ``ecdsa-sha2-nistp256'', ``ecdsa-sha2-nistp384'', 79 Where keytype is either ``ecdsa-sha2-nistp256'', ``ecdsa-sha2-nistp384'',
80 ``ecdsa-sha2-nistp521'', ``ssh-dss'' or ``ssh-rsa''. 80 ``ecdsa-sha2-nistp521'', ``ssh-ed25519'', ``ssh-dss'' or ``ssh-rsa''.
81 81
82 /etc/ssh/ssh_known_hosts 82 /etc/ssh/ssh_known_hosts
83 83
@@ -106,4 +106,4 @@ BUGS
106 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
107 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.
108 108
109OpenBSD 5.4 July 16, 2013 OpenBSD 5.4 109OpenBSD 5.4 December 7, 2013 OpenBSD 5.4
diff --git a/ssh-keyscan.1 b/ssh-keyscan.1
index c35ea05e0..65ef43efd 100644
--- a/ssh-keyscan.1
+++ b/ssh-keyscan.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ssh-keyscan.1,v 1.31 2013/07/16 00:07:52 schwarze Exp $ 1.\" $OpenBSD: ssh-keyscan.1,v 1.33 2013/12/07 11:58:46 naddy 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: July 16 2013 $ 9.Dd $Mdocdate: December 7 2013 $
10.Dt SSH-KEYSCAN 1 10.Dt SSH-KEYSCAN 1
11.Os 11.Os
12.Sh NAME 12.Sh NAME
@@ -89,7 +89,8 @@ The possible values are
89.Dq rsa1 89.Dq rsa1
90for protocol version 1 and 90for protocol version 1 and
91.Dq dsa , 91.Dq dsa ,
92.Dq ecdsa 92.Dq ecdsa ,
93.Dq ed25519 ,
93or 94or
94.Dq rsa 95.Dq rsa
95for protocol version 2. 96for protocol version 2.
@@ -137,6 +138,7 @@ is either
137.Dq ecdsa-sha2-nistp256 , 138.Dq ecdsa-sha2-nistp256 ,
138.Dq ecdsa-sha2-nistp384 , 139.Dq ecdsa-sha2-nistp384 ,
139.Dq ecdsa-sha2-nistp521 , 140.Dq ecdsa-sha2-nistp521 ,
141.Dq ssh-ed25519 ,
140.Dq ssh-dss 142.Dq ssh-dss
141or 143or
142.Dq ssh-rsa . 144.Dq ssh-rsa .
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index 8b807c10a..8d0a6b8d8 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keyscan.c,v 1.87 2013/05/17 00:13:14 djm Exp $ */ 1/* $OpenBSD: ssh-keyscan.c,v 1.89 2013/12/06 13:39:49 markus 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 *
@@ -56,6 +56,7 @@ int ssh_port = SSH_DEFAULT_PORT;
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#define KT_ECDSA 8
59#define KT_ED25519 16
59 60
60int get_keytypes = KT_RSA|KT_ECDSA;/* Get RSA and ECDSA keys by default */ 61int get_keytypes = KT_RSA|KT_ECDSA;/* Get RSA and ECDSA keys by default */
61 62
@@ -245,15 +246,18 @@ keygrab_ssh2(con *c)
245 246
246 packet_set_connection(c->c_fd, c->c_fd); 247 packet_set_connection(c->c_fd, c->c_fd);
247 enable_compat20(); 248 enable_compat20();
248 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = c->c_keytype == KT_DSA? 249 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] =
249 "ssh-dss" : (c->c_keytype == KT_RSA ? "ssh-rsa" : 250 c->c_keytype == KT_DSA ? "ssh-dss" :
250 "ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521"); 251 (c->c_keytype == KT_RSA ? "ssh-rsa" :
252 (c->c_keytype == KT_ED25519 ? "ssh-ed25519" :
253 "ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521"));
251 c->c_kex = kex_setup(myproposal); 254 c->c_kex = kex_setup(myproposal);
252 c->c_kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client; 255 c->c_kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client;
253 c->c_kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client; 256 c->c_kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client;
254 c->c_kex->kex[KEX_DH_GEX_SHA1] = kexgex_client; 257 c->c_kex->kex[KEX_DH_GEX_SHA1] = kexgex_client;
255 c->c_kex->kex[KEX_DH_GEX_SHA256] = kexgex_client; 258 c->c_kex->kex[KEX_DH_GEX_SHA256] = kexgex_client;
256 c->c_kex->kex[KEX_ECDH_SHA2] = kexecdh_client; 259 c->c_kex->kex[KEX_ECDH_SHA2] = kexecdh_client;
260 c->c_kex->kex[KEX_C25519_SHA256] = kexc25519_client;
257 c->c_kex->verify_host_key = hostjump; 261 c->c_kex->verify_host_key = hostjump;
258 262
259 if (!(j = setjmp(kexjmp))) { 263 if (!(j = setjmp(kexjmp))) {
@@ -574,7 +578,7 @@ do_host(char *host)
574 578
575 if (name == NULL) 579 if (name == NULL)
576 return; 580 return;
577 for (j = KT_RSA1; j <= KT_ECDSA; j *= 2) { 581 for (j = KT_RSA1; j <= KT_ED25519; j *= 2) {
578 if (get_keytypes & j) { 582 if (get_keytypes & j) {
579 while (ncon >= MAXCON) 583 while (ncon >= MAXCON)
580 conloop(); 584 conloop();
@@ -681,6 +685,9 @@ main(int argc, char **argv)
681 case KEY_RSA: 685 case KEY_RSA:
682 get_keytypes |= KT_RSA; 686 get_keytypes |= KT_RSA;
683 break; 687 break;
688 case KEY_ED25519:
689 get_keytypes |= KT_ED25519;
690 break;
684 case KEY_UNSPEC: 691 case KEY_UNSPEC:
685 fatal("unknown key type %s", tname); 692 fatal("unknown key type %s", tname);
686 } 693 }
diff --git a/ssh-keysign.0 b/ssh-keysign.0
index 808828a07..78a20e894 100644
--- a/ssh-keysign.0
+++ b/ssh-keysign.0
@@ -25,6 +25,7 @@ FILES
25 25
26 /etc/ssh/ssh_host_dsa_key 26 /etc/ssh/ssh_host_dsa_key
27 /etc/ssh/ssh_host_ecdsa_key 27 /etc/ssh/ssh_host_ecdsa_key
28 /etc/ssh/ssh_host_ed25519_key
28 /etc/ssh/ssh_host_rsa_key 29 /etc/ssh/ssh_host_rsa_key
29 These files contain the private parts of the host keys used to 30 These files contain the private parts of the host keys used to
30 generate the digital signature. They should be owned by root, 31 generate the digital signature. They should be owned by root,
@@ -34,6 +35,7 @@ FILES
34 35
35 /etc/ssh/ssh_host_dsa_key-cert.pub 36 /etc/ssh/ssh_host_dsa_key-cert.pub
36 /etc/ssh/ssh_host_ecdsa_key-cert.pub 37 /etc/ssh/ssh_host_ecdsa_key-cert.pub
38 /etc/ssh/ssh_host_ed25519_key-cert.pub
37 /etc/ssh/ssh_host_rsa_key-cert.pub 39 /etc/ssh/ssh_host_rsa_key-cert.pub
38 If these files exist they are assumed to contain public 40 If these files exist they are assumed to contain public
39 certificate information corresponding with the private keys 41 certificate information corresponding with the private keys
@@ -48,4 +50,4 @@ HISTORY
48AUTHORS 50AUTHORS
49 Markus Friedl <markus@openbsd.org> 51 Markus Friedl <markus@openbsd.org>
50 52
51OpenBSD 5.4 July 16, 2013 OpenBSD 5.4 53OpenBSD 5.4 December 7, 2013 OpenBSD 5.4
diff --git a/ssh-keysign.8 b/ssh-keysign.8
index 5e0b2d232..69d082954 100644
--- a/ssh-keysign.8
+++ b/ssh-keysign.8
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ssh-keysign.8,v 1.13 2013/07/16 00:07:52 schwarze Exp $ 1.\" $OpenBSD: ssh-keysign.8,v 1.14 2013/12/07 11:58:46 naddy 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: July 16 2013 $ 25.Dd $Mdocdate: December 7 2013 $
26.Dt SSH-KEYSIGN 8 26.Dt SSH-KEYSIGN 8
27.Os 27.Os
28.Sh NAME 28.Sh NAME
@@ -63,6 +63,7 @@ is enabled.
63.Pp 63.Pp
64.It Pa /etc/ssh/ssh_host_dsa_key 64.It Pa /etc/ssh/ssh_host_dsa_key
65.It Pa /etc/ssh/ssh_host_ecdsa_key 65.It Pa /etc/ssh/ssh_host_ecdsa_key
66.It Pa /etc/ssh/ssh_host_ed25519_key
66.It Pa /etc/ssh/ssh_host_rsa_key 67.It Pa /etc/ssh/ssh_host_rsa_key
67These files contain the private parts of the host keys used to 68These files contain the private parts of the host keys used to
68generate the digital signature. 69generate the digital signature.
@@ -74,6 +75,7 @@ must be set-uid root if host-based authentication is used.
74.Pp 75.Pp
75.It Pa /etc/ssh/ssh_host_dsa_key-cert.pub 76.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_ecdsa_key-cert.pub
78.It Pa /etc/ssh/ssh_host_ed25519_key-cert.pub
77.It Pa /etc/ssh/ssh_host_rsa_key-cert.pub 79.It Pa /etc/ssh/ssh_host_rsa_key-cert.pub
78If these files exist they are assumed to contain public certificate 80If these files exist they are assumed to contain public certificate
79information corresponding with the private keys above. 81information corresponding with the private keys above.
diff --git a/ssh-keysign.c b/ssh-keysign.c
index 9a6653c7c..6bde8ad17 100644
--- a/ssh-keysign.c
+++ b/ssh-keysign.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keysign.c,v 1.37 2013/05/17 00:13:14 djm Exp $ */ 1/* $OpenBSD: ssh-keysign.c,v 1.39 2013/12/06 13:39:49 markus Exp $ */
2/* 2/*
3 * Copyright (c) 2002 Markus Friedl. All rights reserved. 3 * Copyright (c) 2002 Markus Friedl. All rights reserved.
4 * 4 *
@@ -150,7 +150,7 @@ main(int argc, char **argv)
150{ 150{
151 Buffer b; 151 Buffer b;
152 Options options; 152 Options options;
153#define NUM_KEYTYPES 3 153#define NUM_KEYTYPES 4
154 Key *keys[NUM_KEYTYPES], *key = NULL; 154 Key *keys[NUM_KEYTYPES], *key = NULL;
155 struct passwd *pw; 155 struct passwd *pw;
156 int key_fd[NUM_KEYTYPES], i, found, version = 2, fd; 156 int key_fd[NUM_KEYTYPES], i, found, version = 2, fd;
@@ -169,6 +169,7 @@ main(int argc, char **argv)
169 i = 0; 169 i = 0;
170 key_fd[i++] = open(_PATH_HOST_DSA_KEY_FILE, O_RDONLY); 170 key_fd[i++] = open(_PATH_HOST_DSA_KEY_FILE, O_RDONLY);
171 key_fd[i++] = open(_PATH_HOST_ECDSA_KEY_FILE, O_RDONLY); 171 key_fd[i++] = open(_PATH_HOST_ECDSA_KEY_FILE, O_RDONLY);
172 key_fd[i++] = open(_PATH_HOST_ED25519_KEY_FILE, O_RDONLY);
172 key_fd[i++] = open(_PATH_HOST_RSA_KEY_FILE, O_RDONLY); 173 key_fd[i++] = open(_PATH_HOST_RSA_KEY_FILE, O_RDONLY);
173 174
174 original_real_uid = getuid(); /* XXX readconf.c needs this */ 175 original_real_uid = getuid(); /* XXX readconf.c needs this */
@@ -179,7 +180,6 @@ main(int argc, char **argv)
179 permanently_set_uid(pw); 180 permanently_set_uid(pw);
180 181
181 seed_rng(); 182 seed_rng();
182 arc4random_stir();
183 183
184#ifdef DEBUG_SSH_KEYSIGN 184#ifdef DEBUG_SSH_KEYSIGN
185 log_init("ssh-keysign", SYSLOG_LEVEL_DEBUG3, SYSLOG_FACILITY_AUTH, 0); 185 log_init("ssh-keysign", SYSLOG_LEVEL_DEBUG3, SYSLOG_FACILITY_AUTH, 0);
@@ -187,7 +187,7 @@ main(int argc, char **argv)
187 187
188 /* verify that ssh-keysign is enabled by the admin */ 188 /* verify that ssh-keysign is enabled by the admin */
189 initialize_options(&options); 189 initialize_options(&options);
190 (void)read_config_file(_PATH_HOST_CONFIG_FILE, "", &options, 0); 190 (void)read_config_file(_PATH_HOST_CONFIG_FILE, pw, "", &options, 0);
191 fill_default_options(&options); 191 fill_default_options(&options);
192 if (options.enable_ssh_keysign != 1) 192 if (options.enable_ssh_keysign != 1)
193 fatal("ssh-keysign not enabled in %s", 193 fatal("ssh-keysign not enabled in %s",
diff --git a/ssh-pkcs11-helper.c b/ssh-pkcs11-helper.c
index 39b2e7c56..b7c52beb8 100644
--- a/ssh-pkcs11-helper.c
+++ b/ssh-pkcs11-helper.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-pkcs11-helper.c,v 1.6 2013/05/17 00:13:14 djm Exp $ */ 1/* $OpenBSD: ssh-pkcs11-helper.c,v 1.7 2013/12/02 02:56:17 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2010 Markus Friedl. All rights reserved. 3 * Copyright (c) 2010 Markus Friedl. All rights reserved.
4 * 4 *
@@ -127,7 +127,8 @@ process_add(void)
127 buffer_put_char(&msg, SSH2_AGENT_IDENTITIES_ANSWER); 127 buffer_put_char(&msg, SSH2_AGENT_IDENTITIES_ANSWER);
128 buffer_put_int(&msg, nkeys); 128 buffer_put_int(&msg, nkeys);
129 for (i = 0; i < nkeys; i++) { 129 for (i = 0; i < nkeys; i++) {
130 key_to_blob(keys[i], &blob, &blen); 130 if (key_to_blob(keys[i], &blob, &blen) == 0)
131 continue;
131 buffer_put_string(&msg, blob, blen); 132 buffer_put_string(&msg, blob, blen);
132 buffer_put_cstring(&msg, name); 133 buffer_put_cstring(&msg, name);
133 free(blob); 134 free(blob);
diff --git a/ssh-pkcs11.c b/ssh-pkcs11.c
index 618c07526..c49cbf42b 100644
--- a/ssh-pkcs11.c
+++ b/ssh-pkcs11.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-pkcs11.c,v 1.8 2013/07/12 00:20:00 djm Exp $ */ 1/* $OpenBSD: ssh-pkcs11.c,v 1.11 2013/11/13 13:48:20 markus Exp $ */
2/* 2/*
3 * Copyright (c) 2010 Markus Friedl. All rights reserved. 3 * Copyright (c) 2010 Markus Friedl. All rights reserved.
4 * 4 *
@@ -31,6 +31,8 @@
31 31
32#include "openbsd-compat/sys-queue.h" 32#include "openbsd-compat/sys-queue.h"
33 33
34#include <openssl/x509.h>
35
34#define CRYPTOKI_COMPAT 36#define CRYPTOKI_COMPAT
35#include "pkcs11.h" 37#include "pkcs11.h"
36 38
@@ -225,7 +227,7 @@ pkcs11_rsa_private_encrypt(int flen, const u_char *from, u_char *to, RSA *rsa,
225 CK_OBJECT_HANDLE obj; 227 CK_OBJECT_HANDLE obj;
226 CK_ULONG tlen = 0; 228 CK_ULONG tlen = 0;
227 CK_RV rv; 229 CK_RV rv;
228 CK_OBJECT_CLASS private_key_class = CKO_PRIVATE_KEY; 230 CK_OBJECT_CLASS private_key_class = CKO_PRIVATE_KEY;
229 CK_BBOOL true_val = CK_TRUE; 231 CK_BBOOL true_val = CK_TRUE;
230 CK_MECHANISM mech = { 232 CK_MECHANISM mech = {
231 CKM_RSA_PKCS, NULL_PTR, 0 233 CKM_RSA_PKCS, NULL_PTR, 0
@@ -238,8 +240,6 @@ pkcs11_rsa_private_encrypt(int flen, const u_char *from, u_char *to, RSA *rsa,
238 char *pin, prompt[1024]; 240 char *pin, prompt[1024];
239 int rval = -1; 241 int rval = -1;
240 242
241 /* some compilers complain about non-constant initializer so we
242 use NULL in CK_ATTRIBUTE above and set the values here */
243 key_filter[0].pValue = &private_key_class; 243 key_filter[0].pValue = &private_key_class;
244 key_filter[2].pValue = &true_val; 244 key_filter[2].pValue = &true_val;
245 245
@@ -384,36 +384,75 @@ pkcs11_open_session(struct pkcs11_provider *p, CK_ULONG slotidx, char *pin)
384 * add 'wrapped' public keys to the 'keysp' array and increment nkeys. 384 * add 'wrapped' public keys to the 'keysp' array and increment nkeys.
385 * keysp points to an (possibly empty) array with *nkeys keys. 385 * keysp points to an (possibly empty) array with *nkeys keys.
386 */ 386 */
387static int pkcs11_fetch_keys_filter(struct pkcs11_provider *, CK_ULONG,
388 CK_ATTRIBUTE [], CK_ATTRIBUTE [3], Key ***, int *)
389 __attribute__((__bounded__(__minbytes__,4, 3 * sizeof(CK_ATTRIBUTE))));
390
387static int 391static int
388pkcs11_fetch_keys(struct pkcs11_provider *p, CK_ULONG slotidx, Key ***keysp, 392pkcs11_fetch_keys(struct pkcs11_provider *p, CK_ULONG slotidx,
389 int *nkeys) 393 Key ***keysp, int *nkeys)
390{ 394{
391 Key *key; 395 CK_OBJECT_CLASS pubkey_class = CKO_PUBLIC_KEY;
392 RSA *rsa; 396 CK_OBJECT_CLASS cert_class = CKO_CERTIFICATE;
393 int i;
394 CK_RV rv;
395 CK_OBJECT_HANDLE obj;
396 CK_ULONG nfound;
397 CK_SESSION_HANDLE session;
398 CK_FUNCTION_LIST *f;
399 CK_OBJECT_CLASS pubkey_class = CKO_PUBLIC_KEY;
400 CK_ATTRIBUTE pubkey_filter[] = { 397 CK_ATTRIBUTE pubkey_filter[] = {
401 { CKA_CLASS, NULL, sizeof(pubkey_class) } 398 { CKA_CLASS, NULL, sizeof(pubkey_class) }
402 }; 399 };
403 CK_ATTRIBUTE attribs[] = { 400 CK_ATTRIBUTE cert_filter[] = {
401 { CKA_CLASS, NULL, sizeof(cert_class) }
402 };
403 CK_ATTRIBUTE pubkey_attribs[] = {
404 { CKA_ID, NULL, 0 }, 404 { CKA_ID, NULL, 0 },
405 { CKA_MODULUS, NULL, 0 }, 405 { CKA_MODULUS, NULL, 0 },
406 { CKA_PUBLIC_EXPONENT, NULL, 0 } 406 { CKA_PUBLIC_EXPONENT, NULL, 0 }
407 }; 407 };
408 408 CK_ATTRIBUTE cert_attribs[] = {
409 /* some compilers complain about non-constant initializer so we 409 { CKA_ID, NULL, 0 },
410 use NULL in CK_ATTRIBUTE above and set the value here */ 410 { CKA_SUBJECT, NULL, 0 },
411 { CKA_VALUE, NULL, 0 }
412 };
411 pubkey_filter[0].pValue = &pubkey_class; 413 pubkey_filter[0].pValue = &pubkey_class;
414 cert_filter[0].pValue = &cert_class;
415
416 if (pkcs11_fetch_keys_filter(p, slotidx, pubkey_filter, pubkey_attribs,
417 keysp, nkeys) < 0 ||
418 pkcs11_fetch_keys_filter(p, slotidx, cert_filter, cert_attribs,
419 keysp, nkeys) < 0)
420 return (-1);
421 return (0);
422}
423
424static int
425pkcs11_key_included(Key ***keysp, int *nkeys, Key *key)
426{
427 int i;
428
429 for (i = 0; i < *nkeys; i++)
430 if (key_equal(key, (*keysp)[i]))
431 return (1);
432 return (0);
433}
434
435static int
436pkcs11_fetch_keys_filter(struct pkcs11_provider *p, CK_ULONG slotidx,
437 CK_ATTRIBUTE filter[], CK_ATTRIBUTE attribs[3],
438 Key ***keysp, int *nkeys)
439{
440 Key *key;
441 RSA *rsa;
442 X509 *x509;
443 EVP_PKEY *evp;
444 int i;
445 const u_char *cp;
446 CK_RV rv;
447 CK_OBJECT_HANDLE obj;
448 CK_ULONG nfound;
449 CK_SESSION_HANDLE session;
450 CK_FUNCTION_LIST *f;
412 451
413 f = p->function_list; 452 f = p->function_list;
414 session = p->slotinfo[slotidx].session; 453 session = p->slotinfo[slotidx].session;
415 /* setup a filter the looks for public keys */ 454 /* setup a filter the looks for public keys */
416 if ((rv = f->C_FindObjectsInit(session, pubkey_filter, 1)) != CKR_OK) { 455 if ((rv = f->C_FindObjectsInit(session, filter, 1)) != CKR_OK) {
417 error("C_FindObjectsInit failed: %lu", rv); 456 error("C_FindObjectsInit failed: %lu", rv);
418 return (-1); 457 return (-1);
419 } 458 }
@@ -441,32 +480,59 @@ pkcs11_fetch_keys(struct pkcs11_provider *p, CK_ULONG slotidx, Key ***keysp,
441 /* allocate buffers for attributes */ 480 /* allocate buffers for attributes */
442 for (i = 0; i < 3; i++) 481 for (i = 0; i < 3; i++)
443 attribs[i].pValue = xmalloc(attribs[i].ulValueLen); 482 attribs[i].pValue = xmalloc(attribs[i].ulValueLen);
444 /* retrieve ID, modulus and public exponent of RSA key */ 483 /*
484 * retrieve ID, modulus and public exponent of RSA key,
485 * or ID, subject and value for certificates.
486 */
487 rsa = NULL;
445 if ((rv = f->C_GetAttributeValue(session, obj, attribs, 3)) 488 if ((rv = f->C_GetAttributeValue(session, obj, attribs, 3))
446 != CKR_OK) { 489 != CKR_OK) {
447 error("C_GetAttributeValue failed: %lu", rv); 490 error("C_GetAttributeValue failed: %lu", rv);
448 } else if ((rsa = RSA_new()) == NULL) { 491 } else if (attribs[1].type == CKA_MODULUS ) {
449 error("RSA_new failed"); 492 if ((rsa = RSA_new()) == NULL) {
493 error("RSA_new failed");
494 } else {
495 rsa->n = BN_bin2bn(attribs[1].pValue,
496 attribs[1].ulValueLen, NULL);
497 rsa->e = BN_bin2bn(attribs[2].pValue,
498 attribs[2].ulValueLen, NULL);
499 }
450 } else { 500 } else {
451 rsa->n = BN_bin2bn(attribs[1].pValue, 501 cp = attribs[2].pValue;
452 attribs[1].ulValueLen, NULL); 502 if ((x509 = X509_new()) == NULL) {
453 rsa->e = BN_bin2bn(attribs[2].pValue, 503 error("X509_new failed");
454 attribs[2].ulValueLen, NULL); 504 } else if (d2i_X509(&x509, &cp, attribs[2].ulValueLen)
455 if (rsa->n && rsa->e && 505 == NULL) {
456 pkcs11_rsa_wrap(p, slotidx, &attribs[0], rsa) == 0) { 506 error("d2i_X509 failed");
457 key = key_new(KEY_UNSPEC); 507 } else if ((evp = X509_get_pubkey(x509)) == NULL ||
458 key->rsa = rsa; 508 evp->type != EVP_PKEY_RSA ||
459 key->type = KEY_RSA; 509 evp->pkey.rsa == NULL) {
460 key->flags |= KEY_FLAG_EXT; 510 debug("X509_get_pubkey failed or no rsa");
511 } else if ((rsa = RSAPublicKey_dup(evp->pkey.rsa))
512 == NULL) {
513 error("RSAPublicKey_dup");
514 }
515 if (x509)
516 X509_free(x509);
517 }
518 if (rsa && rsa->n && rsa->e &&
519 pkcs11_rsa_wrap(p, slotidx, &attribs[0], rsa) == 0) {
520 key = key_new(KEY_UNSPEC);
521 key->rsa = rsa;
522 key->type = KEY_RSA;
523 key->flags |= KEY_FLAG_EXT;
524 if (pkcs11_key_included(keysp, nkeys, key)) {
525 key_free(key);
526 } else {
461 /* expand key array and add key */ 527 /* expand key array and add key */
462 *keysp = xrealloc(*keysp, *nkeys + 1, 528 *keysp = xrealloc(*keysp, *nkeys + 1,
463 sizeof(Key *)); 529 sizeof(Key *));
464 (*keysp)[*nkeys] = key; 530 (*keysp)[*nkeys] = key;
465 *nkeys = *nkeys + 1; 531 *nkeys = *nkeys + 1;
466 debug("have %d keys", *nkeys); 532 debug("have %d keys", *nkeys);
467 } else {
468 RSA_free(rsa);
469 } 533 }
534 } else if (rsa) {
535 RSA_free(rsa);
470 } 536 }
471 for (i = 0; i < 3; i++) 537 for (i = 0; i < 3; i++)
472 free(attribs[i].pValue); 538 free(attribs[i].pValue);
diff --git a/ssh-rsa.c b/ssh-rsa.c
index 30f96abc2..a2112d033 100644
--- a/ssh-rsa.c
+++ b/ssh-rsa.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-rsa.c,v 1.46 2013/05/17 00:13:14 djm Exp $ */ 1/* $OpenBSD: ssh-rsa.c,v 1.50 2014/01/09 23:20:00 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 *
@@ -32,6 +32,7 @@
32#include "compat.h" 32#include "compat.h"
33#include "misc.h" 33#include "misc.h"
34#include "ssh.h" 34#include "ssh.h"
35#include "digest.h"
35 36
36static int openssh_RSA_verify(int, u_char *, u_int, u_char *, u_int, RSA *); 37static int openssh_RSA_verify(int, u_char *, u_int, u_char *, u_int, RSA *);
37 38
@@ -40,26 +41,30 @@ int
40ssh_rsa_sign(const Key *key, u_char **sigp, u_int *lenp, 41ssh_rsa_sign(const Key *key, u_char **sigp, u_int *lenp,
41 const u_char *data, u_int datalen) 42 const u_char *data, u_int datalen)
42{ 43{
43 const EVP_MD *evp_md; 44 int hash_alg;
44 EVP_MD_CTX md; 45 u_char digest[SSH_DIGEST_MAX_LENGTH], *sig;
45 u_char digest[EVP_MAX_MD_SIZE], *sig;
46 u_int slen, dlen, len; 46 u_int slen, dlen, len;
47 int ok, nid; 47 int ok, nid;
48 Buffer b; 48 Buffer b;
49 49
50 if (key == NULL || key->rsa == NULL || (key->type != KEY_RSA && 50 if (key == NULL || key_type_plain(key->type) != KEY_RSA ||
51 key->type != KEY_RSA_CERT && key->type != KEY_RSA_CERT_V00)) { 51 key->rsa == NULL) {
52 error("ssh_rsa_sign: no RSA key"); 52 error("%s: no RSA key", __func__);
53 return -1; 53 return -1;
54 } 54 }
55 nid = (datafellows & SSH_BUG_RSASIGMD5) ? NID_md5 : NID_sha1; 55
56 if ((evp_md = EVP_get_digestbynid(nid)) == NULL) { 56 /* hash the data */
57 error("ssh_rsa_sign: EVP_get_digestbynid %d failed", nid); 57 hash_alg = SSH_DIGEST_SHA1;
58 nid = NID_sha1;
59 if ((dlen = ssh_digest_bytes(hash_alg)) == 0) {
60 error("%s: bad hash algorithm %d", __func__, hash_alg);
61 return -1;
62 }
63 if (ssh_digest_memory(hash_alg, data, datalen,
64 digest, sizeof(digest)) != 0) {
65 error("%s: ssh_digest_memory failed", __func__);
58 return -1; 66 return -1;
59 } 67 }
60 EVP_DigestInit(&md, evp_md);
61 EVP_DigestUpdate(&md, data, datalen);
62 EVP_DigestFinal(&md, digest, &dlen);
63 68
64 slen = RSA_size(key->rsa); 69 slen = RSA_size(key->rsa);
65 sig = xmalloc(slen); 70 sig = xmalloc(slen);
@@ -70,7 +75,7 @@ ssh_rsa_sign(const Key *key, u_char **sigp, u_int *lenp,
70 if (ok != 1) { 75 if (ok != 1) {
71 int ecode = ERR_get_error(); 76 int ecode = ERR_get_error();
72 77
73 error("ssh_rsa_sign: RSA_sign failed: %s", 78 error("%s: RSA_sign failed: %s", __func__,
74 ERR_error_string(ecode, NULL)); 79 ERR_error_string(ecode, NULL));
75 free(sig); 80 free(sig);
76 return -1; 81 return -1;
@@ -81,7 +86,7 @@ ssh_rsa_sign(const Key *key, u_char **sigp, u_int *lenp,
81 memmove(sig + diff, sig, len); 86 memmove(sig + diff, sig, len);
82 memset(sig, 0, diff); 87 memset(sig, 0, diff);
83 } else if (len > slen) { 88 } else if (len > slen) {
84 error("ssh_rsa_sign: slen %u slen2 %u", slen, len); 89 error("%s: slen %u slen2 %u", __func__, slen, len);
85 free(sig); 90 free(sig);
86 return -1; 91 return -1;
87 } 92 }
@@ -108,28 +113,29 @@ ssh_rsa_verify(const Key *key, const u_char *signature, u_int signaturelen,
108 const u_char *data, u_int datalen) 113 const u_char *data, u_int datalen)
109{ 114{
110 Buffer b; 115 Buffer b;
111 const EVP_MD *evp_md; 116 int hash_alg;
112 EVP_MD_CTX md;
113 char *ktype; 117 char *ktype;
114 u_char digest[EVP_MAX_MD_SIZE], *sigblob; 118 u_char digest[SSH_DIGEST_MAX_LENGTH], *sigblob;
115 u_int len, dlen, modlen; 119 u_int len, dlen, modlen;
116 int rlen, ret, nid; 120 int rlen, ret;
117 121
118 if (key == NULL || key->rsa == NULL || (key->type != KEY_RSA && 122 if (key == NULL || key_type_plain(key->type) != KEY_RSA ||
119 key->type != KEY_RSA_CERT && key->type != KEY_RSA_CERT_V00)) { 123 key->rsa == NULL) {
120 error("ssh_rsa_verify: no RSA key"); 124 error("%s: no RSA key", __func__);
121 return -1; 125 return -1;
122 } 126 }
127
123 if (BN_num_bits(key->rsa->n) < SSH_RSA_MINIMUM_MODULUS_SIZE) { 128 if (BN_num_bits(key->rsa->n) < SSH_RSA_MINIMUM_MODULUS_SIZE) {
124 error("ssh_rsa_verify: RSA modulus too small: %d < minimum %d bits", 129 error("%s: RSA modulus too small: %d < minimum %d bits",
125 BN_num_bits(key->rsa->n), SSH_RSA_MINIMUM_MODULUS_SIZE); 130 __func__, BN_num_bits(key->rsa->n),
131 SSH_RSA_MINIMUM_MODULUS_SIZE);
126 return -1; 132 return -1;
127 } 133 }
128 buffer_init(&b); 134 buffer_init(&b);
129 buffer_append(&b, signature, signaturelen); 135 buffer_append(&b, signature, signaturelen);
130 ktype = buffer_get_cstring(&b, NULL); 136 ktype = buffer_get_cstring(&b, NULL);
131 if (strcmp("ssh-rsa", ktype) != 0) { 137 if (strcmp("ssh-rsa", ktype) != 0) {
132 error("ssh_rsa_verify: cannot handle type %s", ktype); 138 error("%s: cannot handle type %s", __func__, ktype);
133 buffer_free(&b); 139 buffer_free(&b);
134 free(ktype); 140 free(ktype);
135 return -1; 141 return -1;
@@ -139,40 +145,43 @@ ssh_rsa_verify(const Key *key, const u_char *signature, u_int signaturelen,
139 rlen = buffer_len(&b); 145 rlen = buffer_len(&b);
140 buffer_free(&b); 146 buffer_free(&b);
141 if (rlen != 0) { 147 if (rlen != 0) {
142 error("ssh_rsa_verify: remaining bytes in signature %d", rlen); 148 error("%s: remaining bytes in signature %d", __func__, rlen);
143 free(sigblob); 149 free(sigblob);
144 return -1; 150 return -1;
145 } 151 }
146 /* RSA_verify expects a signature of RSA_size */ 152 /* RSA_verify expects a signature of RSA_size */
147 modlen = RSA_size(key->rsa); 153 modlen = RSA_size(key->rsa);
148 if (len > modlen) { 154 if (len > modlen) {
149 error("ssh_rsa_verify: len %u > modlen %u", len, modlen); 155 error("%s: len %u > modlen %u", __func__, len, modlen);
150 free(sigblob); 156 free(sigblob);
151 return -1; 157 return -1;
152 } else if (len < modlen) { 158 } else if (len < modlen) {
153 u_int diff = modlen - len; 159 u_int diff = modlen - len;
154 debug("ssh_rsa_verify: add padding: modlen %u > len %u", 160 debug("%s: add padding: modlen %u > len %u", __func__,
155 modlen, len); 161 modlen, len);
156 sigblob = xrealloc(sigblob, 1, modlen); 162 sigblob = xrealloc(sigblob, 1, modlen);
157 memmove(sigblob + diff, sigblob, len); 163 memmove(sigblob + diff, sigblob, len);
158 memset(sigblob, 0, diff); 164 memset(sigblob, 0, diff);
159 len = modlen; 165 len = modlen;
160 } 166 }
161 nid = (datafellows & SSH_BUG_RSASIGMD5) ? NID_md5 : NID_sha1; 167 /* hash the data */
162 if ((evp_md = EVP_get_digestbynid(nid)) == NULL) { 168 hash_alg = SSH_DIGEST_SHA1;
163 error("ssh_rsa_verify: EVP_get_digestbynid %d failed", nid); 169 if ((dlen = ssh_digest_bytes(hash_alg)) == 0) {
164 free(sigblob); 170 error("%s: bad hash algorithm %d", __func__, hash_alg);
171 return -1;
172 }
173 if (ssh_digest_memory(hash_alg, data, datalen,
174 digest, sizeof(digest)) != 0) {
175 error("%s: ssh_digest_memory failed", __func__);
165 return -1; 176 return -1;
166 } 177 }
167 EVP_DigestInit(&md, evp_md);
168 EVP_DigestUpdate(&md, data, datalen);
169 EVP_DigestFinal(&md, digest, &dlen);
170 178
171 ret = openssh_RSA_verify(nid, digest, dlen, sigblob, len, key->rsa); 179 ret = openssh_RSA_verify(hash_alg, digest, dlen, sigblob, len,
180 key->rsa);
172 memset(digest, 'd', sizeof(digest)); 181 memset(digest, 'd', sizeof(digest));
173 memset(sigblob, 's', len); 182 memset(sigblob, 's', len);
174 free(sigblob); 183 free(sigblob);
175 debug("ssh_rsa_verify: signature %scorrect", (ret==0) ? "in" : ""); 184 debug("%s: signature %scorrect", __func__, (ret == 0) ? "in" : "");
176 return ret; 185 return ret;
177} 186}
178 187
@@ -193,21 +202,9 @@ static const u_char id_sha1[] = {
193 0x05, 0x00, /* NULL */ 202 0x05, 0x00, /* NULL */
194 0x04, 0x14 /* Octet string, length 0x14 (20), followed by sha1 hash */ 203 0x04, 0x14 /* Octet string, length 0x14 (20), followed by sha1 hash */
195}; 204};
196/*
197 * id-md5 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840)
198 * rsadsi(113549) digestAlgorithm(2) 5 }
199 */
200static const u_char id_md5[] = {
201 0x30, 0x20, /* type Sequence, length 0x20 (32) */
202 0x30, 0x0c, /* type Sequence, length 0x09 */
203 0x06, 0x08, /* type OID, length 0x05 */
204 0x2a, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, /* id-md5 */
205 0x05, 0x00, /* NULL */
206 0x04, 0x10 /* Octet string, length 0x10 (16), followed by md5 hash */
207};
208 205
209static int 206static int
210openssh_RSA_verify(int type, u_char *hash, u_int hashlen, 207openssh_RSA_verify(int hash_alg, u_char *hash, u_int hashlen,
211 u_char *sigbuf, u_int siglen, RSA *rsa) 208 u_char *sigbuf, u_int siglen, RSA *rsa)
212{ 209{
213 u_int ret, rsasize, oidlen = 0, hlen = 0; 210 u_int ret, rsasize, oidlen = 0, hlen = 0;
@@ -216,17 +213,12 @@ openssh_RSA_verify(int type, u_char *hash, u_int hashlen,
216 u_char *decrypted = NULL; 213 u_char *decrypted = NULL;
217 214
218 ret = 0; 215 ret = 0;
219 switch (type) { 216 switch (hash_alg) {
220 case NID_sha1: 217 case SSH_DIGEST_SHA1:
221 oid = id_sha1; 218 oid = id_sha1;
222 oidlen = sizeof(id_sha1); 219 oidlen = sizeof(id_sha1);
223 hlen = 20; 220 hlen = 20;
224 break; 221 break;
225 case NID_md5:
226 oid = id_md5;
227 oidlen = sizeof(id_md5);
228 hlen = 16;
229 break;
230 default: 222 default:
231 goto done; 223 goto done;
232 } 224 }
diff --git a/ssh-sandbox.h b/ssh-sandbox.h
index dfecd5aa0..bd5fd8372 100644
--- a/ssh-sandbox.h
+++ b/ssh-sandbox.h
@@ -15,9 +15,10 @@
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 */
17 17
18struct monitor;
18struct ssh_sandbox; 19struct ssh_sandbox;
19 20
20struct ssh_sandbox *ssh_sandbox_init(void); 21struct ssh_sandbox *ssh_sandbox_init(struct monitor *);
21void ssh_sandbox_child(struct ssh_sandbox *); 22void ssh_sandbox_child(struct ssh_sandbox *);
22void ssh_sandbox_parent_finish(struct ssh_sandbox *); 23void ssh_sandbox_parent_finish(struct ssh_sandbox *);
23void ssh_sandbox_parent_preauth(struct ssh_sandbox *, pid_t); 24void ssh_sandbox_parent_preauth(struct ssh_sandbox *, pid_t);
diff --git a/ssh.0 b/ssh.0
index adc1ee421..3a6a0469d 100644
--- a/ssh.0
+++ b/ssh.0
@@ -9,9 +9,9 @@ SYNOPSIS
9 [-F configfile] [-I pkcs11] [-i identity_file] 9 [-F configfile] [-I pkcs11] [-i identity_file]
10 [-L [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec] 10 [-L [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec]
11 [-O ctl_cmd] [-o option] [-p port] 11 [-O ctl_cmd] [-o option] [-p port]
12 [-Q cipher | cipher-auth | mac | kex | key]
12 [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port] 13 [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port]
13 [-w local_tun[:remote_tun]] [user@]hostname [command] 14 [-w local_tun[:remote_tun]] [user@]hostname [command]
14 ssh -Q protocol_feature
15 15
16DESCRIPTION 16DESCRIPTION
17 ssh (SSH client) is a program for logging into a remote machine and for 17 ssh (SSH client) is a program for logging into a remote machine and for
@@ -142,13 +142,13 @@ DESCRIPTION
142 -i identity_file 142 -i identity_file
143 Selects a file from which the identity (private key) for public 143 Selects a file from which the identity (private key) for public
144 key authentication is read. The default is ~/.ssh/identity for 144 key authentication is read. The default is ~/.ssh/identity for
145 protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and 145 protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa,
146 ~/.ssh/id_rsa for protocol version 2. Identity files may also be 146 ~/.ssh/id_ed25519 and ~/.ssh/id_rsa for protocol version 2.
147 specified on a per-host basis in the configuration file. It is 147 Identity files may also be specified on a per-host basis in the
148 possible to have multiple -i options (and multiple identities 148 configuration file. It is possible to have multiple -i options
149 specified in configuration files). ssh will also try to load 149 (and multiple identities specified in configuration files). ssh
150 certificate information from the filename obtained by appending 150 will also try to load certificate information from the filename
151 -cert.pub to identity filenames. 151 obtained by appending -cert.pub to identity filenames.
152 152
153 -K Enables GSSAPI-based authentication and forwarding (delegation) 153 -K Enables GSSAPI-based authentication and forwarding (delegation)
154 of GSSAPI credentials to the server. 154 of GSSAPI credentials to the server.
@@ -222,6 +222,11 @@ DESCRIPTION
222 AddressFamily 222 AddressFamily
223 BatchMode 223 BatchMode
224 BindAddress 224 BindAddress
225 CanonicalDomains
226 CanonicalizeFallbackLocal
227 CanonicalizeHostname
228 CanonicalizeMaxDots
229 CanonicalizePermittedCNAMEs
225 ChallengeResponseAuthentication 230 ChallengeResponseAuthentication
226 CheckHostIP 231 CheckHostIP
227 Cipher 232 Cipher
@@ -261,6 +266,7 @@ DESCRIPTION
261 LocalForward 266 LocalForward
262 LogLevel 267 LogLevel
263 MACs 268 MACs
269 Match
264 NoHostAuthenticationForLocalhost 270 NoHostAuthenticationForLocalhost
265 NumberOfPasswordPrompts 271 NumberOfPasswordPrompts
266 PasswordAuthentication 272 PasswordAuthentication
@@ -270,6 +276,7 @@ DESCRIPTION
270 PreferredAuthentications 276 PreferredAuthentications
271 Protocol 277 Protocol
272 ProxyCommand 278 ProxyCommand
279 ProxyUseFdpass
273 PubkeyAuthentication 280 PubkeyAuthentication
274 RekeyLimit 281 RekeyLimit
275 RemoteForward 282 RemoteForward
@@ -294,13 +301,12 @@ DESCRIPTION
294 Port to connect to on the remote host. This can be specified on 301 Port to connect to on the remote host. This can be specified on
295 a per-host basis in the configuration file. 302 a per-host basis in the configuration file.
296 303
297 -Q protocol_feature 304 -Q cipher | cipher-auth | mac | kex | key
298 Queries ssh for the algorithms supported for the specified 305 Queries ssh for the algorithms supported for the specified
299 version 2 protocol_feature. The queriable features are: 306 version 2. The available features are: cipher (supported
300 ``cipher'' (supported symmetric ciphers), ``MAC'' (supported 307 symmetric ciphers), cipher-auth (supported symmetric ciphers that
301 message integrity codes), ``KEX'' (key exchange algorithms), 308 support authenticated encryption), mac (supported message
302 ``key'' (key types). Protocol features are treated case- 309 integrity codes), kex (key exchange algorithms), key (key types).
303 insensitively.
304 310
305 -q Quiet mode. Causes most warning and diagnostic messages to be 311 -q Quiet mode. Causes most warning and diagnostic messages to be
306 suppressed. 312 suppressed.
@@ -440,9 +446,10 @@ AUTHENTICATION
440 creates a public/private key pair for authentication purposes. The 446 creates a public/private key pair for authentication purposes. The
441 server knows the public key, and only the user knows the private key. 447 server knows the public key, and only the user knows the private key.
442 ssh implements public key authentication protocol automatically, using 448 ssh implements public key authentication protocol automatically, using
443 one of the DSA, ECDSA or RSA algorithms. Protocol 1 is restricted to 449 one of the DSA, ECDSA, ED25519 or RSA algorithms. Protocol 1 is
444 using only RSA keys, but protocol 2 may use any. The HISTORY section of 450 restricted to using only RSA keys, but protocol 2 may use any. The
445 ssl(8) contains a brief discussion of the DSA and RSA algorithms. 451 HISTORY section of ssl(8) contains a brief discussion of the DSA and RSA
452 algorithms.
446 453
447 The file ~/.ssh/authorized_keys lists the public keys that are permitted 454 The file ~/.ssh/authorized_keys lists the public keys that are permitted
448 for logging in. When the user logs in, the ssh program tells the server 455 for logging in. When the user logs in, the ssh program tells the server
@@ -452,10 +459,11 @@ AUTHENTICATION
452 459
453 The user creates his/her key pair by running ssh-keygen(1). This stores 460 The user creates his/her key pair by running ssh-keygen(1). This stores
454 the private key in ~/.ssh/identity (protocol 1), ~/.ssh/id_dsa (protocol 461 the private key in ~/.ssh/identity (protocol 1), ~/.ssh/id_dsa (protocol
455 2 DSA), ~/.ssh/id_ecdsa (protocol 2 ECDSA), or ~/.ssh/id_rsa (protocol 2 462 2 DSA), ~/.ssh/id_ecdsa (protocol 2 ECDSA), ~/.ssh/id_ed25519 (protocol 2
456 RSA) and stores the public key in ~/.ssh/identity.pub (protocol 1), 463 ED25519), or ~/.ssh/id_rsa (protocol 2 RSA) and stores the public key in
457 ~/.ssh/id_dsa.pub (protocol 2 DSA), ~/.ssh/id_ecdsa.pub (protocol 2 464 ~/.ssh/identity.pub (protocol 1), ~/.ssh/id_dsa.pub (protocol 2 DSA),
458 ECDSA), or ~/.ssh/id_rsa.pub (protocol 2 RSA) in the user's home 465 ~/.ssh/id_ecdsa.pub (protocol 2 ECDSA), ~/.ssh/id_ed25519.pub (protocol 2
466 ED25519), or ~/.ssh/id_rsa.pub (protocol 2 RSA) in the user's home
459 directory. The user should then copy the public key to 467 directory. The user should then copy the public key to
460 ~/.ssh/authorized_keys in his/her home directory on the remote machine. 468 ~/.ssh/authorized_keys in his/her home directory on the remote machine.
461 The authorized_keys file corresponds to the conventional ~/.rhosts file, 469 The authorized_keys file corresponds to the conventional ~/.rhosts file,
@@ -791,11 +799,11 @@ FILES
791 for the user, and not accessible by others. 799 for the user, and not accessible by others.
792 800
793 ~/.ssh/authorized_keys 801 ~/.ssh/authorized_keys
794 Lists the public keys (DSA/ECDSA/RSA) that can be used for 802 Lists the public keys (DSA, ECDSA, ED25519, RSA) that can be used
795 logging in as this user. The format of this file is described in 803 for logging in as this user. The format of this file is
796 the sshd(8) manual page. This file is not highly sensitive, but 804 described in the sshd(8) manual page. This file is not highly
797 the recommended permissions are read/write for the user, and not 805 sensitive, but the recommended permissions are read/write for the
798 accessible by others. 806 user, and not accessible by others.
799 807
800 ~/.ssh/config 808 ~/.ssh/config
801 This is the per-user configuration file. The file format and 809 This is the per-user configuration file. The file format and
@@ -810,6 +818,7 @@ FILES
810 ~/.ssh/identity 818 ~/.ssh/identity
811 ~/.ssh/id_dsa 819 ~/.ssh/id_dsa
812 ~/.ssh/id_ecdsa 820 ~/.ssh/id_ecdsa
821 ~/.ssh/id_ed25519
813 ~/.ssh/id_rsa 822 ~/.ssh/id_rsa
814 Contains the private key for authentication. These files contain 823 Contains the private key for authentication. These files contain
815 sensitive data and should be readable by the user but not 824 sensitive data and should be readable by the user but not
@@ -822,6 +831,7 @@ FILES
822 ~/.ssh/identity.pub 831 ~/.ssh/identity.pub
823 ~/.ssh/id_dsa.pub 832 ~/.ssh/id_dsa.pub
824 ~/.ssh/id_ecdsa.pub 833 ~/.ssh/id_ecdsa.pub
834 ~/.ssh/id_ed25519.pub
825 ~/.ssh/id_rsa.pub 835 ~/.ssh/id_rsa.pub
826 Contains the public key for authentication. These files are not 836 Contains the public key for authentication. These files are not
827 sensitive and can (but need not) be readable by anyone. 837 sensitive and can (but need not) be readable by anyone.
@@ -853,6 +863,7 @@ FILES
853 /etc/ssh/ssh_host_key 863 /etc/ssh/ssh_host_key
854 /etc/ssh/ssh_host_dsa_key 864 /etc/ssh/ssh_host_dsa_key
855 /etc/ssh/ssh_host_ecdsa_key 865 /etc/ssh/ssh_host_ecdsa_key
866 /etc/ssh/ssh_host_ed25519_key
856 /etc/ssh/ssh_host_rsa_key 867 /etc/ssh/ssh_host_rsa_key
857 These files contain the private parts of the host keys and are 868 These files contain the private parts of the host keys and are
858 used for host-based authentication. If protocol version 1 is 869 used for host-based authentication. If protocol version 1 is
@@ -932,4 +943,4 @@ AUTHORS
932 created OpenSSH. Markus Friedl contributed the support for SSH protocol 943 created OpenSSH. Markus Friedl contributed the support for SSH protocol
933 versions 1.5 and 2.0. 944 versions 1.5 and 2.0.
934 945
935OpenBSD 5.4 July 18, 2013 OpenBSD 5.4 946OpenBSD 5.4 December 7, 2013 OpenBSD 5.4
diff --git a/ssh.1 b/ssh.1
index 62292cc09..27794e2d0 100644
--- a/ssh.1
+++ b/ssh.1
@@ -33,8 +33,8 @@
33.\" (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
34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: ssh.1,v 1.334 2013/07/18 01:12:26 djm Exp $ 36.\" $OpenBSD: ssh.1,v 1.343 2013/12/07 11:58:46 naddy Exp $
37.Dd $Mdocdate: July 18 2013 $ 37.Dd $Mdocdate: December 7 2013 $
38.Dt SSH 1 38.Dt SSH 1
39.Os 39.Os
40.Sh NAME 40.Sh NAME
@@ -58,6 +58,7 @@
58.Op Fl O Ar ctl_cmd 58.Op Fl O Ar ctl_cmd
59.Op Fl o Ar option 59.Op Fl o Ar option
60.Op Fl p Ar port 60.Op Fl p Ar port
61.Op Fl Q Cm cipher | cipher-auth | mac | kex | key
61.Op Fl R Oo Ar bind_address : Oc Ns Ar port : Ns Ar host : Ns Ar hostport 62.Op Fl R Oo Ar bind_address : Oc Ns Ar port : Ns Ar host : Ns Ar hostport
62.Op Fl S Ar ctl_path 63.Op Fl S Ar ctl_path
63.Op Fl W Ar host : Ns Ar port 64.Op Fl W Ar host : Ns Ar port
@@ -65,8 +66,6 @@
65.Oo Ar user Ns @ Oc Ns Ar hostname 66.Oo Ar user Ns @ Oc Ns Ar hostname
66.Op Ar command 67.Op Ar command
67.Ek 68.Ek
68.Nm
69.Fl Q Ar protocol_feature
70.Sh DESCRIPTION 69.Sh DESCRIPTION
71.Nm 70.Nm
72(SSH client) is a program for logging into a remote machine and for 71(SSH client) is a program for logging into a remote machine and for
@@ -280,7 +279,8 @@ The default is
280.Pa ~/.ssh/identity 279.Pa ~/.ssh/identity
281for protocol version 1, and 280for protocol version 1, and
282.Pa ~/.ssh/id_dsa , 281.Pa ~/.ssh/id_dsa ,
283.Pa ~/.ssh/id_ecdsa 282.Pa ~/.ssh/id_ecdsa ,
283.Pa ~/.ssh/id_ed25519
284and 284and
285.Pa ~/.ssh/id_rsa 285.Pa ~/.ssh/id_rsa
286for protocol version 2. 286for protocol version 2.
@@ -417,6 +417,11 @@ For full details of the options listed below, and their possible values, see
417.It AddressFamily 417.It AddressFamily
418.It BatchMode 418.It BatchMode
419.It BindAddress 419.It BindAddress
420.It CanonicalDomains
421.It CanonicalizeFallbackLocal
422.It CanonicalizeHostname
423.It CanonicalizeMaxDots
424.It CanonicalizePermittedCNAMEs
420.It ChallengeResponseAuthentication 425.It ChallengeResponseAuthentication
421.It CheckHostIP 426.It CheckHostIP
422.It Cipher 427.It Cipher
@@ -456,6 +461,7 @@ For full details of the options listed below, and their possible values, see
456.It LocalForward 461.It LocalForward
457.It LogLevel 462.It LogLevel
458.It MACs 463.It MACs
464.It Match
459.It NoHostAuthenticationForLocalhost 465.It NoHostAuthenticationForLocalhost
460.It NumberOfPasswordPrompts 466.It NumberOfPasswordPrompts
461.It PasswordAuthentication 467.It PasswordAuthentication
@@ -465,6 +471,7 @@ For full details of the options listed below, and their possible values, see
465.It PreferredAuthentications 471.It PreferredAuthentications
466.It Protocol 472.It Protocol
467.It ProxyCommand 473.It ProxyCommand
474.It ProxyUseFdpass
468.It PubkeyAuthentication 475.It PubkeyAuthentication
469.It RekeyLimit 476.It RekeyLimit
470.It RemoteForward 477.It RemoteForward
@@ -489,21 +496,21 @@ For full details of the options listed below, and their possible values, see
489Port to connect to on the remote host. 496Port to connect to on the remote host.
490This can be specified on a 497This can be specified on a
491per-host basis in the configuration file. 498per-host basis in the configuration file.
492.It Fl Q Ar protocol_feature 499.It Fl Q Cm cipher | cipher-auth | mac | kex | key
493Queries 500Queries
494.Nm 501.Nm
495for the algorithms supported for the specified version 2 502for the algorithms supported for the specified version 2.
496.Ar protocol_feature . 503The available features are:
497The queriable features are: 504.Ar cipher
498.Dq cipher
499(supported symmetric ciphers), 505(supported symmetric ciphers),
500.Dq MAC 506.Ar cipher-auth
507(supported symmetric ciphers that support authenticated encryption),
508.Ar mac
501(supported message integrity codes), 509(supported message integrity codes),
502.Dq KEX 510.Ar kex
503(key exchange algorithms), 511(key exchange algorithms),
504.Dq key 512.Ar key
505(key types). 513(key types).
506Protocol features are treated case-insensitively.
507.It Fl q 514.It Fl q
508Quiet mode. 515Quiet mode.
509Causes most warning and diagnostic messages to be suppressed. 516Causes most warning and diagnostic messages to be suppressed.
@@ -751,7 +758,7 @@ key pair for authentication purposes.
751The server knows the public key, and only the user knows the private key. 758The server knows the public key, and only the user knows the private key.
752.Nm 759.Nm
753implements public key authentication protocol automatically, 760implements public key authentication protocol automatically,
754using one of the DSA, ECDSA or RSA algorithms. 761using one of the DSA, ECDSA, ED25519 or RSA algorithms.
755Protocol 1 is restricted to using only RSA keys, 762Protocol 1 is restricted to using only RSA keys,
756but protocol 2 may use any. 763but protocol 2 may use any.
757The HISTORY section of 764The HISTORY section of
@@ -778,6 +785,8 @@ This stores the private key in
778(protocol 2 DSA), 785(protocol 2 DSA),
779.Pa ~/.ssh/id_ecdsa 786.Pa ~/.ssh/id_ecdsa
780(protocol 2 ECDSA), 787(protocol 2 ECDSA),
788.Pa ~/.ssh/id_ed25519
789(protocol 2 ED25519),
781or 790or
782.Pa ~/.ssh/id_rsa 791.Pa ~/.ssh/id_rsa
783(protocol 2 RSA) 792(protocol 2 RSA)
@@ -788,6 +797,8 @@ and stores the public key in
788(protocol 2 DSA), 797(protocol 2 DSA),
789.Pa ~/.ssh/id_ecdsa.pub 798.Pa ~/.ssh/id_ecdsa.pub
790(protocol 2 ECDSA), 799(protocol 2 ECDSA),
800.Pa ~/.ssh/id_ed25519.pub
801(protocol 2 ED25519),
791or 802or
792.Pa ~/.ssh/id_rsa.pub 803.Pa ~/.ssh/id_rsa.pub
793(protocol 2 RSA) 804(protocol 2 RSA)
@@ -827,9 +838,12 @@ text, and prompts for a response.
827Protocol 2 allows multiple challenges and responses; 838Protocol 2 allows multiple challenges and responses;
828protocol 1 is restricted to just one challenge/response. 839protocol 1 is restricted to just one challenge/response.
829Examples of challenge-response authentication include 840Examples of challenge-response authentication include
830BSD Authentication (see 841.Bx
842Authentication (see
831.Xr login.conf 5 ) 843.Xr login.conf 5 )
832and PAM (some non-OpenBSD systems). 844and PAM (some
845.Pf non- Ox
846systems).
833.Pp 847.Pp
834Finally, if other authentication methods fail, 848Finally, if other authentication methods fail,
835.Nm 849.Nm
@@ -1324,8 +1338,8 @@ secret, but the recommended permissions are read/write/execute for the user,
1324and not accessible by others. 1338and not accessible by others.
1325.Pp 1339.Pp
1326.It Pa ~/.ssh/authorized_keys 1340.It Pa ~/.ssh/authorized_keys
1327Lists the public keys (DSA/ECDSA/RSA) that can be used for logging in as 1341Lists the public keys (DSA, ECDSA, ED25519, RSA)
1328this user. 1342that can be used for logging in as this user.
1329The format of this file is described in the 1343The format of this file is described in the
1330.Xr sshd 8 1344.Xr sshd 8
1331manual page. 1345manual page.
@@ -1347,6 +1361,7 @@ above.
1347.It Pa ~/.ssh/identity 1361.It Pa ~/.ssh/identity
1348.It Pa ~/.ssh/id_dsa 1362.It Pa ~/.ssh/id_dsa
1349.It Pa ~/.ssh/id_ecdsa 1363.It Pa ~/.ssh/id_ecdsa
1364.It Pa ~/.ssh/id_ed25519
1350.It Pa ~/.ssh/id_rsa 1365.It Pa ~/.ssh/id_rsa
1351Contains the private key for authentication. 1366Contains the private key for authentication.
1352These files 1367These files
@@ -1361,6 +1376,7 @@ sensitive part of this file using 3DES.
1361.It Pa ~/.ssh/identity.pub 1376.It Pa ~/.ssh/identity.pub
1362.It Pa ~/.ssh/id_dsa.pub 1377.It Pa ~/.ssh/id_dsa.pub
1363.It Pa ~/.ssh/id_ecdsa.pub 1378.It Pa ~/.ssh/id_ecdsa.pub
1379.It Pa ~/.ssh/id_ed25519.pub
1364.It Pa ~/.ssh/id_rsa.pub 1380.It Pa ~/.ssh/id_rsa.pub
1365Contains the public key for authentication. 1381Contains the public key for authentication.
1366These files are not 1382These files are not
@@ -1400,6 +1416,7 @@ The file format and configuration options are described in
1400.It Pa /etc/ssh/ssh_host_key 1416.It Pa /etc/ssh/ssh_host_key
1401.It Pa /etc/ssh/ssh_host_dsa_key 1417.It Pa /etc/ssh/ssh_host_dsa_key
1402.It Pa /etc/ssh/ssh_host_ecdsa_key 1418.It Pa /etc/ssh/ssh_host_ecdsa_key
1419.It Pa /etc/ssh/ssh_host_ed25519_key
1403.It Pa /etc/ssh/ssh_host_rsa_key 1420.It Pa /etc/ssh/ssh_host_rsa_key
1404These files contain the private parts of the host keys 1421These files contain the private parts of the host keys
1405and are used for host-based authentication. 1422and are used for host-based authentication.
diff --git a/ssh.c b/ssh.c
index 87233bc91..5de8fcf43 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.381 2013/07/25 00:29:10 djm Exp $ */ 1/* $OpenBSD: ssh.c,v 1.397 2013/12/29 05:42:16 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,11 +199,11 @@ usage(void)
199"usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]\n" 199"usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]\n"
200" [-D [bind_address:]port] [-E log_file] [-e escape_char]\n" 200" [-D [bind_address:]port] [-E log_file] [-e escape_char]\n"
201" [-F configfile] [-I pkcs11] [-i identity_file]\n" 201" [-F configfile] [-I pkcs11] [-i identity_file]\n"
202" [-L [bind_address:]port:host:hostport] [-Q protocol_feature]\n" 202" [-L [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec]\n"
203" [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]\n" 203" [-O ctl_cmd] [-o option] [-p port]\n"
204" [-R [bind_address:]port:host:hostport] [-S ctl_path]\n" 204" [-Q cipher | cipher-auth | mac | kex | key]\n"
205" [-W host:port] [-w local_tun[:remote_tun]]\n" 205" [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port]\n"
206" [user@]hostname [command]\n" 206" [-w local_tun[:remote_tun]] [user@]hostname [command]\n"
207 ); 207 );
208 exit(255); 208 exit(255);
209} 209}
@@ -231,6 +231,134 @@ tilde_expand_paths(char **paths, u_int num_paths)
231 } 231 }
232} 232}
233 233
234static struct addrinfo *
235resolve_host(const char *name, u_int port, int logerr, char *cname, size_t clen)
236{
237 char strport[NI_MAXSERV];
238 struct addrinfo hints, *res;
239 int gaierr, loglevel = SYSLOG_LEVEL_DEBUG1;
240
241 snprintf(strport, sizeof strport, "%u", port);
242 bzero(&hints, sizeof(hints));
243 hints.ai_family = options.address_family;
244 hints.ai_socktype = SOCK_STREAM;
245 if (cname != NULL)
246 hints.ai_flags = AI_CANONNAME;
247 if ((gaierr = getaddrinfo(name, strport, &hints, &res)) != 0) {
248 if (logerr || (gaierr != EAI_NONAME && gaierr != EAI_NODATA))
249 loglevel = SYSLOG_LEVEL_ERROR;
250 do_log2(loglevel, "%s: Could not resolve hostname %.100s: %s",
251 __progname, name, ssh_gai_strerror(gaierr));
252 return NULL;
253 }
254 if (cname != NULL && res->ai_canonname != NULL) {
255 if (strlcpy(cname, res->ai_canonname, clen) >= clen) {
256 error("%s: host \"%s\" cname \"%s\" too long (max %lu)",
257 __func__, name, res->ai_canonname, (u_long)clen);
258 if (clen > 0)
259 *cname = '\0';
260 }
261 }
262 return res;
263}
264
265/*
266 * Check whether the cname is a permitted replacement for the hostname
267 * and perform the replacement if it is.
268 */
269static int
270check_follow_cname(char **namep, const char *cname)
271{
272 int i;
273 struct allowed_cname *rule;
274
275 if (*cname == '\0' || options.num_permitted_cnames == 0 ||
276 strcmp(*namep, cname) == 0)
277 return 0;
278 if (options.canonicalize_hostname == SSH_CANONICALISE_NO)
279 return 0;
280 /*
281 * Don't attempt to canonicalize names that will be interpreted by
282 * a proxy unless the user specifically requests so.
283 */
284 if (options.proxy_command != NULL &&
285 options.canonicalize_hostname != SSH_CANONICALISE_ALWAYS)
286 return 0;
287 debug3("%s: check \"%s\" CNAME \"%s\"", __func__, *namep, cname);
288 for (i = 0; i < options.num_permitted_cnames; i++) {
289 rule = options.permitted_cnames + i;
290 if (match_pattern_list(*namep, rule->source_list,
291 strlen(rule->source_list), 1) != 1 ||
292 match_pattern_list(cname, rule->target_list,
293 strlen(rule->target_list), 1) != 1)
294 continue;
295 verbose("Canonicalized DNS aliased hostname "
296 "\"%s\" => \"%s\"", *namep, cname);
297 free(*namep);
298 *namep = xstrdup(cname);
299 return 1;
300 }
301 return 0;
302}
303
304/*
305 * Attempt to resolve the supplied hostname after applying the user's
306 * canonicalization rules. Returns the address list for the host or NULL
307 * if no name was found after canonicalization.
308 */
309static struct addrinfo *
310resolve_canonicalize(char **hostp, u_int port)
311{
312 int i, ndots;
313 char *cp, *fullhost, cname_target[NI_MAXHOST];
314 struct addrinfo *addrs;
315
316 if (options.canonicalize_hostname == SSH_CANONICALISE_NO)
317 return NULL;
318 /*
319 * Don't attempt to canonicalize names that will be interpreted by
320 * a proxy unless the user specifically requests so.
321 */
322 if (options.proxy_command != NULL &&
323 options.canonicalize_hostname != SSH_CANONICALISE_ALWAYS)
324 return NULL;
325 /* Don't apply canonicalization to sufficiently-qualified hostnames */
326 ndots = 0;
327 for (cp = *hostp; *cp != '\0'; cp++) {
328 if (*cp == '.')
329 ndots++;
330 }
331 if (ndots > options.canonicalize_max_dots) {
332 debug3("%s: not canonicalizing hostname \"%s\" (max dots %d)",
333 __func__, *hostp, options.canonicalize_max_dots);
334 return NULL;
335 }
336 /* Attempt each supplied suffix */
337 for (i = 0; i < options.num_canonical_domains; i++) {
338 *cname_target = '\0';
339 xasprintf(&fullhost, "%s.%s.", *hostp,
340 options.canonical_domains[i]);
341 if ((addrs = resolve_host(fullhost, options.port, 0,
342 cname_target, sizeof(cname_target))) == NULL) {
343 free(fullhost);
344 continue;
345 }
346 /* Remove trailing '.' */
347 fullhost[strlen(fullhost) - 1] = '\0';
348 /* Follow CNAME if requested */
349 if (!check_follow_cname(&fullhost, cname_target)) {
350 debug("Canonicalized hostname \"%s\" => \"%s\"",
351 *hostp, fullhost);
352 }
353 free(*hostp);
354 *hostp = fullhost;
355 return addrs;
356 }
357 if (!options.canonicalize_fallback_local)
358 fatal("%s: Could not resolve host \"%s\"", __progname, host);
359 return NULL;
360}
361
234/* 362/*
235 * Main program for the ssh client. 363 * Main program for the ssh client.
236 */ 364 */
@@ -240,14 +368,14 @@ main(int ac, char **av)
240 int i, r, opt, exit_status, use_syslog; 368 int i, r, opt, exit_status, use_syslog;
241 char *p, *cp, *line, *argv0, buf[MAXPATHLEN], *host_arg, *logfile; 369 char *p, *cp, *line, *argv0, buf[MAXPATHLEN], *host_arg, *logfile;
242 char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; 370 char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV];
371 char cname[NI_MAXHOST];
243 struct stat st; 372 struct stat st;
244 struct passwd *pw; 373 struct passwd *pw;
245 int dummy, timeout_ms; 374 int timeout_ms;
246 extern int optind, optreset; 375 extern int optind, optreset;
247 extern char *optarg; 376 extern char *optarg;
248
249 struct servent *sp;
250 Forward fwd; 377 Forward fwd;
378 struct addrinfo *addrs = NULL;
251 379
252 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ 380 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
253 sanitise_stdfd(); 381 sanitise_stdfd();
@@ -389,16 +517,22 @@ main(int ac, char **av)
389 case 'P': /* deprecated */ 517 case 'P': /* deprecated */
390 options.use_privileged_port = 0; 518 options.use_privileged_port = 0;
391 break; 519 break;
392 case 'Q': /* deprecated */ 520 case 'Q':
393 cp = NULL; 521 cp = NULL;
394 if (strcasecmp(optarg, "cipher") == 0) 522 if (strcmp(optarg, "cipher") == 0)
395 cp = cipher_alg_list(); 523 cp = cipher_alg_list('\n', 0);
396 else if (strcasecmp(optarg, "mac") == 0) 524 else if (strcmp(optarg, "cipher-auth") == 0)
397 cp = mac_alg_list(); 525 cp = cipher_alg_list('\n', 1);
398 else if (strcasecmp(optarg, "kex") == 0) 526 else if (strcmp(optarg, "mac") == 0)
399 cp = kex_alg_list(); 527 cp = mac_alg_list('\n');
400 else if (strcasecmp(optarg, "key") == 0) 528 else if (strcmp(optarg, "kex") == 0)
401 cp = key_alg_list(); 529 cp = kex_alg_list('\n');
530 else if (strcmp(optarg, "key") == 0)
531 cp = key_alg_list(0, 0);
532 else if (strcmp(optarg, "key-cert") == 0)
533 cp = key_alg_list(1, 0);
534 else if (strcmp(optarg, "key-plain") == 0)
535 cp = key_alg_list(0, 1);
402 if (cp == NULL) 536 if (cp == NULL)
403 fatal("Unsupported query \"%s\"", optarg); 537 fatal("Unsupported query \"%s\"", optarg);
404 printf("%s\n", cp); 538 printf("%s\n", cp);
@@ -595,10 +729,9 @@ main(int ac, char **av)
595 options.request_tty = REQUEST_TTY_NO; 729 options.request_tty = REQUEST_TTY_NO;
596 break; 730 break;
597 case 'o': 731 case 'o':
598 dummy = 1;
599 line = xstrdup(optarg); 732 line = xstrdup(optarg);
600 if (process_config_line(&options, host ? host : "", 733 if (process_config_line(&options, pw, host ? host : "",
601 line, "command-line", 0, &dummy, SSHCONF_USERCONF) 734 line, "command-line", 0, NULL, SSHCONF_USERCONF)
602 != 0) 735 != 0)
603 exit(255); 736 exit(255);
604 free(line); 737 free(line);
@@ -633,9 +766,9 @@ main(int ac, char **av)
633 usage(); 766 usage();
634 options.user = p; 767 options.user = p;
635 *cp = '\0'; 768 *cp = '\0';
636 host = ++cp; 769 host = xstrdup(++cp);
637 } else 770 } else
638 host = *av; 771 host = xstrdup(*av);
639 if (ac > 1) { 772 if (ac > 1) {
640 optind = optreset = 1; 773 optind = optreset = 1;
641 goto again; 774 goto again;
@@ -647,6 +780,9 @@ main(int ac, char **av)
647 if (!host) 780 if (!host)
648 usage(); 781 usage();
649 782
783 lowercase(host);
784 host_arg = xstrdup(host);
785
650 OpenSSL_add_all_algorithms(); 786 OpenSSL_add_all_algorithms();
651 ERR_load_crypto_strings(); 787 ERR_load_crypto_strings();
652 788
@@ -703,18 +839,19 @@ main(int ac, char **av)
703 */ 839 */
704 if (config != NULL) { 840 if (config != NULL) {
705 if (strcasecmp(config, "none") != 0 && 841 if (strcasecmp(config, "none") != 0 &&
706 !read_config_file(config, host, &options, SSHCONF_USERCONF)) 842 !read_config_file(config, pw, host, &options,
843 SSHCONF_USERCONF))
707 fatal("Can't open user config file %.100s: " 844 fatal("Can't open user config file %.100s: "
708 "%.100s", config, strerror(errno)); 845 "%.100s", config, strerror(errno));
709 } else { 846 } else {
710 r = snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, 847 r = snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir,
711 _PATH_SSH_USER_CONFFILE); 848 _PATH_SSH_USER_CONFFILE);
712 if (r > 0 && (size_t)r < sizeof(buf)) 849 if (r > 0 && (size_t)r < sizeof(buf))
713 (void)read_config_file(buf, host, &options, 850 (void)read_config_file(buf, pw, host, &options,
714 SSHCONF_CHECKPERM|SSHCONF_USERCONF); 851 SSHCONF_CHECKPERM|SSHCONF_USERCONF);
715 852
716 /* Read systemwide configuration file after user config. */ 853 /* Read systemwide configuration file after user config. */
717 (void)read_config_file(_PATH_HOST_CONFIG_FILE, host, 854 (void)read_config_file(_PATH_HOST_CONFIG_FILE, pw, host,
718 &options, 0); 855 &options, 0);
719 } 856 }
720 857
@@ -723,6 +860,18 @@ main(int ac, char **av)
723 860
724 channel_set_af(options.address_family); 861 channel_set_af(options.address_family);
725 862
863 /* Tidy and check options */
864 if (options.host_key_alias != NULL)
865 lowercase(options.host_key_alias);
866 if (options.proxy_command != NULL &&
867 strcmp(options.proxy_command, "-") == 0 &&
868 options.proxy_use_fdpass)
869 fatal("ProxyCommand=- and ProxyUseFDPass are incompatible");
870#ifndef HAVE_CYGWIN
871 if (original_effective_uid != 0)
872 options.use_privileged_port = 0;
873#endif
874
726 /* reinit */ 875 /* reinit */
727 log_init(argv0, options.log_level, SYSLOG_FACILITY_USER, !use_syslog); 876 log_init(argv0, options.log_level, SYSLOG_FACILITY_USER, !use_syslog);
728 877
@@ -752,16 +901,33 @@ main(int ac, char **av)
752 options.user = xstrdup(pw->pw_name); 901 options.user = xstrdup(pw->pw_name);
753 902
754 /* Get default port if port has not been set. */ 903 /* Get default port if port has not been set. */
755 if (options.port == 0) { 904 if (options.port == 0)
756 sp = getservbyname(SSH_SERVICE_NAME, "tcp"); 905 options.port = default_ssh_port();
757 options.port = sp ? ntohs(sp->s_port) : SSH_DEFAULT_PORT;
758 }
759 906
760 /* preserve host name given on command line for %n expansion */ 907 /* preserve host name given on command line for %n expansion */
761 host_arg = host;
762 if (options.hostname != NULL) { 908 if (options.hostname != NULL) {
763 host = percent_expand(options.hostname, 909 /* NB. Please keep in sync with readconf.c:match_cfg_line() */
910 cp = percent_expand(options.hostname,
764 "h", host, (char *)NULL); 911 "h", host, (char *)NULL);
912 free(host);
913 host = cp;
914 }
915
916 /* If canonicalization requested then try to apply it */
917 if (options.canonicalize_hostname != SSH_CANONICALISE_NO)
918 addrs = resolve_canonicalize(&host, options.port);
919 /*
920 * If canonicalization not requested, or if it failed then try to
921 * resolve the bare hostname name using the system resolver's usual
922 * search rules. Skip the lookup if a ProxyCommand is being used
923 * unless the user has specifically requested canonicalisation.
924 */
925 if (addrs == NULL && (options.proxy_command == NULL ||
926 options.canonicalize_hostname == SSH_CANONICALISE_ALWAYS)) {
927 if ((addrs = resolve_host(host, options.port, 1,
928 cname, sizeof(cname))) == NULL)
929 cleanup_exit(255); /* resolve_host logs the error */
930 check_follow_cname(&host, cname);
765 } 931 }
766 932
767 if (gethostname(thishost, sizeof(thishost)) == -1) 933 if (gethostname(thishost, sizeof(thishost)) == -1)
@@ -781,24 +947,6 @@ main(int ac, char **av)
781 free(cp); 947 free(cp);
782 } 948 }
783 949
784 /* force lowercase for hostkey matching */
785 if (options.host_key_alias != NULL) {
786 for (p = options.host_key_alias; *p; p++)
787 if (isupper(*p))
788 *p = (char)tolower(*p);
789 }
790
791 if (options.proxy_command != NULL &&
792 strcmp(options.proxy_command, "none") == 0) {
793 free(options.proxy_command);
794 options.proxy_command = NULL;
795 }
796 if (options.control_path != NULL &&
797 strcmp(options.control_path, "none") == 0) {
798 free(options.control_path);
799 options.control_path = NULL;
800 }
801
802 if (options.control_path != NULL) { 950 if (options.control_path != NULL) {
803 cp = tilde_expand_filename(options.control_path, 951 cp = tilde_expand_filename(options.control_path,
804 original_real_uid); 952 original_real_uid);
@@ -817,16 +965,17 @@ main(int ac, char **av)
817 timeout_ms = options.connection_timeout * 1000; 965 timeout_ms = options.connection_timeout * 1000;
818 966
819 /* Open a connection to the remote host. */ 967 /* Open a connection to the remote host. */
820 if (ssh_connect(host, &hostaddr, options.port, 968 if (ssh_connect(host, addrs, &hostaddr, options.port,
821 options.address_family, options.connection_attempts, &timeout_ms, 969 options.address_family, options.connection_attempts,
822 options.tcp_keep_alive, 970 &timeout_ms, options.tcp_keep_alive,
823#ifdef HAVE_CYGWIN 971 options.use_privileged_port) != 0)
824 options.use_privileged_port, 972 exit(255);
825#else 973
826 original_effective_uid == 0 && options.use_privileged_port, 974 if (addrs != NULL)
827#endif 975 freeaddrinfo(addrs);
828 options.proxy_command) != 0) 976
829 exit(255); 977 packet_set_timeout(options.server_alive_interval,
978 options.server_alive_count_max);
830 979
831 if (timeout_ms > 0) 980 if (timeout_ms > 0)
832 debug3("timeout: %d ms remain after connect", timeout_ms); 981 debug3("timeout: %d ms remain after connect", timeout_ms);
@@ -844,7 +993,7 @@ main(int ac, char **av)
844 sensitive_data.external_keysign = 0; 993 sensitive_data.external_keysign = 0;
845 if (options.rhosts_rsa_authentication || 994 if (options.rhosts_rsa_authentication ||
846 options.hostbased_authentication) { 995 options.hostbased_authentication) {
847 sensitive_data.nkeys = 7; 996 sensitive_data.nkeys = 9;
848 sensitive_data.keys = xcalloc(sensitive_data.nkeys, 997 sensitive_data.keys = xcalloc(sensitive_data.nkeys,
849 sizeof(Key)); 998 sizeof(Key));
850 for (i = 0; i < sensitive_data.nkeys; i++) 999 for (i = 0; i < sensitive_data.nkeys; i++)
@@ -861,21 +1010,26 @@ main(int ac, char **av)
861#endif 1010#endif
862 sensitive_data.keys[3] = key_load_private_cert(KEY_RSA, 1011 sensitive_data.keys[3] = key_load_private_cert(KEY_RSA,
863 _PATH_HOST_RSA_KEY_FILE, "", NULL); 1012 _PATH_HOST_RSA_KEY_FILE, "", NULL);
864 sensitive_data.keys[4] = key_load_private_type(KEY_DSA, 1013 sensitive_data.keys[4] = key_load_private_cert(KEY_ED25519,
1014 _PATH_HOST_ED25519_KEY_FILE, "", NULL);
1015 sensitive_data.keys[5] = key_load_private_type(KEY_DSA,
865 _PATH_HOST_DSA_KEY_FILE, "", NULL, NULL); 1016 _PATH_HOST_DSA_KEY_FILE, "", NULL, NULL);
866#ifdef OPENSSL_HAS_ECC 1017#ifdef OPENSSL_HAS_ECC
867 sensitive_data.keys[5] = key_load_private_type(KEY_ECDSA, 1018 sensitive_data.keys[6] = key_load_private_type(KEY_ECDSA,
868 _PATH_HOST_ECDSA_KEY_FILE, "", NULL, NULL); 1019 _PATH_HOST_ECDSA_KEY_FILE, "", NULL, NULL);
869#endif 1020#endif
870 sensitive_data.keys[6] = key_load_private_type(KEY_RSA, 1021 sensitive_data.keys[7] = key_load_private_type(KEY_RSA,
871 _PATH_HOST_RSA_KEY_FILE, "", NULL, NULL); 1022 _PATH_HOST_RSA_KEY_FILE, "", NULL, NULL);
1023 sensitive_data.keys[8] = key_load_private_type(KEY_ED25519,
1024 _PATH_HOST_ED25519_KEY_FILE, "", NULL, NULL);
872 PRIV_END; 1025 PRIV_END;
873 1026
874 if (options.hostbased_authentication == 1 && 1027 if (options.hostbased_authentication == 1 &&
875 sensitive_data.keys[0] == NULL && 1028 sensitive_data.keys[0] == NULL &&
876 sensitive_data.keys[4] == NULL &&
877 sensitive_data.keys[5] == NULL && 1029 sensitive_data.keys[5] == NULL &&
878 sensitive_data.keys[6] == NULL) { 1030 sensitive_data.keys[6] == NULL &&
1031 sensitive_data.keys[7] == NULL &&
1032 sensitive_data.keys[8] == NULL) {
879 sensitive_data.keys[1] = key_load_cert( 1033 sensitive_data.keys[1] = key_load_cert(
880 _PATH_HOST_DSA_KEY_FILE); 1034 _PATH_HOST_DSA_KEY_FILE);
881#ifdef OPENSSL_HAS_ECC 1035#ifdef OPENSSL_HAS_ECC
@@ -884,14 +1038,18 @@ main(int ac, char **av)
884#endif 1038#endif
885 sensitive_data.keys[3] = key_load_cert( 1039 sensitive_data.keys[3] = key_load_cert(
886 _PATH_HOST_RSA_KEY_FILE); 1040 _PATH_HOST_RSA_KEY_FILE);
887 sensitive_data.keys[4] = key_load_public( 1041 sensitive_data.keys[4] = key_load_cert(
1042 _PATH_HOST_ED25519_KEY_FILE);
1043 sensitive_data.keys[5] = key_load_public(
888 _PATH_HOST_DSA_KEY_FILE, NULL); 1044 _PATH_HOST_DSA_KEY_FILE, NULL);
889#ifdef OPENSSL_HAS_ECC 1045#ifdef OPENSSL_HAS_ECC
890 sensitive_data.keys[5] = key_load_public( 1046 sensitive_data.keys[6] = key_load_public(
891 _PATH_HOST_ECDSA_KEY_FILE, NULL); 1047 _PATH_HOST_ECDSA_KEY_FILE, NULL);
892#endif 1048#endif
893 sensitive_data.keys[6] = key_load_public( 1049 sensitive_data.keys[7] = key_load_public(
894 _PATH_HOST_RSA_KEY_FILE, NULL); 1050 _PATH_HOST_RSA_KEY_FILE, NULL);
1051 sensitive_data.keys[8] = key_load_public(
1052 _PATH_HOST_ED25519_KEY_FILE, NULL);
895 sensitive_data.external_keysign = 1; 1053 sensitive_data.external_keysign = 1;
896 } 1054 }
897 } 1055 }
@@ -1091,7 +1249,7 @@ ssh_init_stdio_forwarding(void)
1091 1249
1092 if (stdio_forward_host == NULL) 1250 if (stdio_forward_host == NULL)
1093 return; 1251 return;
1094 if (!compat20) 1252 if (!compat20)
1095 fatal("stdio forwarding require Protocol 2"); 1253 fatal("stdio forwarding require Protocol 2");
1096 1254
1097 debug3("%s: %s:%d", __func__, stdio_forward_host, stdio_forward_port); 1255 debug3("%s: %s:%d", __func__, stdio_forward_host, stdio_forward_port);
@@ -1263,7 +1421,7 @@ ssh_session(void)
1263 char *proto, *data; 1421 char *proto, *data;
1264 /* Get reasonable local authentication information. */ 1422 /* Get reasonable local authentication information. */
1265 client_x11_get_proto(display, options.xauth_location, 1423 client_x11_get_proto(display, options.xauth_location,
1266 options.forward_x11_trusted, 1424 options.forward_x11_trusted,
1267 options.forward_x11_timeout, 1425 options.forward_x11_timeout,
1268 &proto, &data); 1426 &proto, &data);
1269 /* Request forwarding with authentication spoofing. */ 1427 /* Request forwarding with authentication spoofing. */
@@ -1635,4 +1793,3 @@ main_sigchld_handler(int sig)
1635 signal(sig, main_sigchld_handler); 1793 signal(sig, main_sigchld_handler);
1636 errno = save_errno; 1794 errno = save_errno;
1637} 1795}
1638
diff --git a/ssh_config b/ssh_config
index bb4081936..03a228fbd 100644
--- a/ssh_config
+++ b/ssh_config
@@ -1,4 +1,4 @@
1# $OpenBSD: ssh_config,v 1.27 2013/05/16 02:00:34 dtucker Exp $ 1# $OpenBSD: ssh_config,v 1.28 2013/09/16 11:35:43 sthen Exp $
2 2
3# This is the ssh client system-wide configuration file. See 3# This is the ssh client system-wide configuration file. See
4# ssh_config(5) for more information. This file provides defaults for 4# ssh_config(5) for more information. This file provides defaults for
diff --git a/ssh_config.0 b/ssh_config.0
index bd9e1ad51..e9ac54bfc 100644
--- a/ssh_config.0
+++ b/ssh_config.0
@@ -38,8 +38,8 @@ DESCRIPTION
38 The possible keywords and their meanings are as follows (note that 38 The possible keywords and their meanings are as follows (note that
39 keywords are case-insensitive and arguments are case-sensitive): 39 keywords are case-insensitive and arguments are case-sensitive):
40 40
41 Host Restricts the following declarations (up to the next Host 41 Host Restricts the following declarations (up to the next Host or
42 keyword) to be only for those hosts that match one of the 42 Match keyword) to be only for those hosts that match one of the
43 patterns given after the keyword. If more than one pattern is 43 patterns given after the keyword. If more than one pattern is
44 provided, they should be separated by whitespace. A single `*' 44 provided, they should be separated by whitespace. A single `*'
45 as a pattern can be used to provide global defaults for all 45 as a pattern can be used to provide global defaults for all
@@ -55,6 +55,37 @@ DESCRIPTION
55 55
56 See PATTERNS for more information on patterns. 56 See PATTERNS for more information on patterns.
57 57
58 Match Restricts the following declarations (up to the next Host or
59 Match keyword) to be used only when the conditions following the
60 Match keyword are satisfied. Match conditions are specified
61 using one or more keyword/criteria pairs or the single token all
62 which matches all criteria. The available keywords are: exec,
63 host, originalhost, user, and localuser.
64
65 The exec keyword executes the specified command under the user's
66 shell. If the command returns a zero exit status then the
67 condition is considered true. Commands containing whitespace
68 characters must be quoted. The following character sequences in
69 the command will be expanded prior to execution: `%L' will be
70 substituted by the first component of the local host name, `%l'
71 will be substituted by the local host name (including any domain
72 name), `%h' will be substituted by the target host name, `%n'
73 will be substituted by the original target host name specified on
74 the command-line, `%p' the destination port, `%r' by the remote
75 login username, and `%u' by the username of the user running
76 ssh(1).
77
78 The other keywords' criteria must be single entries or comma-
79 separated lists and may use the wildcard and negation operators
80 described in the PATTERNS section. The criteria for the host
81 keyword are matched against the target hostname, after any
82 substitution by the Hostname option. The originalhost keyword
83 matches against the hostname as it was specified on the command-
84 line. The user keyword matches against the target username on
85 the remote host. The localuser keyword matches against the name
86 of the local user running ssh(1) (this keyword may be useful in
87 system-wide ssh_config files).
88
58 AddressFamily 89 AddressFamily
59 Specifies which address family to use when connecting. Valid 90 Specifies which address family to use when connecting. Valid
60 arguments are ``any'', ``inet'' (use IPv4 only), or ``inet6'' 91 arguments are ``any'', ``inet'' (use IPv4 only), or ``inet6''
@@ -72,6 +103,49 @@ DESCRIPTION
72 one address. Note that this option does not work if 103 one address. Note that this option does not work if
73 UsePrivilegedPort is set to ``yes''. 104 UsePrivilegedPort is set to ``yes''.
74 105
106 CanonicalDomains
107 When CanonicalizeHostname is enabled, this option specifies the
108 list of domain suffixes in which to search for the specified
109 destination host.
110
111 CanonicalizeFallbackLocal
112 Specifies whether to fail with an error when hostname
113 canonicalization fails. The default, ``yes'', will attempt to
114 look up the unqualified hostname using the system resolver's
115 search rules. A value of ``no'' will cause ssh(1) to fail
116 instantly if CanonicalizeHostname is enabled and the target
117 hostname cannot be found in any of the domains specified by
118 CanonicalDomains.
119
120 CanonicalizeHostname
121 Controls whether explicit hostname canonicalization is performed.
122 The default, ``no'', is not to perform any name rewriting and let
123 the system resolver handle all hostname lookups. If set to
124 ``yes'' then, for connections that do not use a ProxyCommand,
125 ssh(1) will attempt to canonicalize the hostname specified on the
126 command line using the CanonicalDomains suffixes and
127 CanonicalizePermittedCNAMEs rules. If CanonicalizeHostname is
128 set to ``always'', then canonicalization is applied to proxied
129 connections too.
130
131 CanonicalizeMaxDots
132 Specifies the maximum number of dot characters in a hostname
133 before canonicalization is disabled. The default, ``1'', allows
134 a single dot (i.e. hostname.subdomain).
135
136 CanonicalizePermittedCNAMEs
137 Specifies rules to determine whether CNAMEs should be followed
138 when canonicalizing hostnames. The rules consist of one or more
139 arguments of source_domain_list:target_domain_list, where
140 source_domain_list is a pattern-list of domains that may follow
141 CNAMEs in canonicalization, and target_domain_list is a pattern-
142 list of domains that they may resolve to.
143
144 For example, ``*.a.example.com:*.b.example.com,*.c.example.com''
145 will allow hostnames matching ``*.a.example.com'' to be
146 canonicalized to names in the ``*.b.example.com'' or
147 ``*.c.example.com'' domains.
148
75 ChallengeResponseAuthentication 149 ChallengeResponseAuthentication
76 Specifies whether to use challenge-response authentication. The 150 Specifies whether to use challenge-response authentication. The
77 argument to this keyword must be ``yes'' or ``no''. The default 151 argument to this keyword must be ``yes'' or ``no''. The default
@@ -95,18 +169,25 @@ DESCRIPTION
95 Ciphers 169 Ciphers
96 Specifies the ciphers allowed for protocol version 2 in order of 170 Specifies the ciphers allowed for protocol version 2 in order of
97 preference. Multiple ciphers must be comma-separated. The 171 preference. Multiple ciphers must be comma-separated. The
98 supported ciphers are ``3des-cbc'', ``aes128-cbc'', 172 supported ciphers are:
99 ``aes192-cbc'', ``aes256-cbc'', ``aes128-ctr'', ``aes192-ctr'', 173
100 ``aes256-ctr'', ``aes128-gcm@openssh.com'', 174 ``3des-cbc'', ``aes128-cbc'', ``aes192-cbc'', ``aes256-cbc'',
101 ``aes256-gcm@openssh.com'', ``arcfour128'', ``arcfour256'', 175 ``aes128-ctr'', ``aes192-ctr'', ``aes256-ctr'',
102 ``arcfour'', ``blowfish-cbc'', and ``cast128-cbc''. The default 176 ``aes128-gcm@openssh.com'', ``aes256-gcm@openssh.com'',
103 is: 177 ``arcfour128'', ``arcfour256'', ``arcfour'', ``blowfish-cbc'',
178 ``cast128-cbc'', and ``chacha20-poly1305@openssh.com''.
179
180 The default is:
104 181
105 aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128, 182 aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,
106 aes128-gcm@openssh.com,aes256-gcm@openssh.com, 183 aes128-gcm@openssh.com,aes256-gcm@openssh.com,
184 chacha20-poly1305@openssh.com,
107 aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc, 185 aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,
108 aes256-cbc,arcfour 186 aes256-cbc,arcfour
109 187
188 The list of available ciphers may also be obtained using the -Q
189 option of ssh(1).
190
110 ClearAllForwardings 191 ClearAllForwardings
111 Specifies that all local, remote, and dynamic port forwardings 192 Specifies that all local, remote, and dynamic port forwardings
112 specified in the configuration files or on the command line be 193 specified in the configuration files or on the command line be
@@ -174,9 +255,9 @@ DESCRIPTION
174 name, `%l' will be substituted by the local host name (including 255 name, `%l' will be substituted by the local host name (including
175 any domain name), `%h' will be substituted by the target host 256 any domain name), `%h' will be substituted by the target host
176 name, `%n' will be substituted by the original target host name 257 name, `%n' will be substituted by the original target host name
177 specified on the command line, `%p' the port, `%r' by the remote 258 specified on the command line, `%p' the destination port, `%r' by
178 login username, and `%u' by the username of the user running 259 the remote login username, and `%u' by the username of the user
179 ssh(1). It is recommended that any ControlPath used for 260 running ssh(1). It is recommended that any ControlPath used for
180 opportunistic connection sharing include at least %h, %p, and %r. 261 opportunistic connection sharing include at least %h, %p, and %r.
181 This ensures that shared connections are uniquely identified. 262 This ensures that shared connections are uniquely identified.
182 263
@@ -331,10 +412,11 @@ DESCRIPTION
331 ecdsa-sha2-nistp256-cert-v01@openssh.com, 412 ecdsa-sha2-nistp256-cert-v01@openssh.com,
332 ecdsa-sha2-nistp384-cert-v01@openssh.com, 413 ecdsa-sha2-nistp384-cert-v01@openssh.com,
333 ecdsa-sha2-nistp521-cert-v01@openssh.com, 414 ecdsa-sha2-nistp521-cert-v01@openssh.com,
415 ssh-ed25519-cert-v01@openssh.com,
334 ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com, 416 ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,
335 ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com, 417 ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com,
336 ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521, 418 ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
337 ssh-rsa,ssh-dss 419 ssh-ed25519,ssh-rsa,ssh-dss
338 420
339 If hostkeys are known for the destination host then this default 421 If hostkeys are known for the destination host then this default
340 is modified to prefer their algorithms. 422 is modified to prefer their algorithms.
@@ -364,14 +446,15 @@ DESCRIPTION
364 default is ``no''. 446 default is ``no''.
365 447
366 IdentityFile 448 IdentityFile
367 Specifies a file from which the user's DSA, ECDSA or RSA 449 Specifies a file from which the user's DSA, ECDSA, ED25519 or RSA
368 authentication identity is read. The default is ~/.ssh/identity 450 authentication identity is read. The default is ~/.ssh/identity
369 for protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and 451 for protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa,
370 ~/.ssh/id_rsa for protocol version 2. Additionally, any 452 ~/.ssh/id_ed25519 and ~/.ssh/id_rsa for protocol version 2.
371 identities represented by the authentication agent will be used 453 Additionally, any identities represented by the authentication
372 for authentication unless IdentitiesOnly is set. ssh(1) will try 454 agent will be used for authentication unless IdentitiesOnly is
373 to load certificate information from the filename obtained by 455 set. ssh(1) will try to load certificate information from the
374 appending -cert.pub to the path of a specified IdentityFile. 456 filename obtained by appending -cert.pub to the path of a
457 specified IdentityFile.
375 458
376 The file name may use the tilde syntax to refer to a user's home 459 The file name may use the tilde syntax to refer to a user's home
377 directory or one of the following escape characters: `%d' (local 460 directory or one of the following escape characters: `%d' (local
@@ -426,6 +509,7 @@ DESCRIPTION
426 Specifies the available KEX (Key Exchange) algorithms. Multiple 509 Specifies the available KEX (Key Exchange) algorithms. Multiple
427 algorithms must be comma-separated. The default is: 510 algorithms must be comma-separated. The default is:
428 511
512 curve25519-sha256@libssh.org,
429 ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521, 513 ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,
430 diffie-hellman-group-exchange-sha256, 514 diffie-hellman-group-exchange-sha256,
431 diffie-hellman-group-exchange-sha1, 515 diffie-hellman-group-exchange-sha1,
@@ -557,6 +641,11 @@ DESCRIPTION
557 641
558 ProxyCommand /usr/bin/nc -X connect -x 192.0.2.0:8080 %h %p 642 ProxyCommand /usr/bin/nc -X connect -x 192.0.2.0:8080 %h %p
559 643
644 ProxyUseFdpass
645 Specifies that ProxyCommand will pass a connected file descriptor
646 back to ssh(1) instead of continuing to execute and pass data.
647 The default is ``no''.
648
560 PubkeyAuthentication 649 PubkeyAuthentication
561 Specifies whether to try public key authentication. The argument 650 Specifies whether to try public key authentication. The argument
562 to this keyword must be ``yes'' or ``no''. The default is 651 to this keyword must be ``yes'' or ``no''. The default is
@@ -763,7 +852,7 @@ PATTERNS
763 A pattern-list is a comma-separated list of patterns. Patterns within 852 A pattern-list is a comma-separated list of patterns. Patterns within
764 pattern-lists may be negated by preceding them with an exclamation mark 853 pattern-lists may be negated by preceding them with an exclamation mark
765 (`!'). For example, to allow a key to be used from anywhere within an 854 (`!'). For example, to allow a key to be used from anywhere within an
766 organisation except from the ``dialup'' pool, the following entry (in 855 organization except from the ``dialup'' pool, the following entry (in
767 authorized_keys) could be used: 856 authorized_keys) could be used:
768 857
769 from="!*.dialup.example.com,*.example.com" 858 from="!*.dialup.example.com,*.example.com"
@@ -792,4 +881,4 @@ AUTHORS
792 created OpenSSH. Markus Friedl contributed the support for SSH protocol 881 created OpenSSH. Markus Friedl contributed the support for SSH protocol
793 versions 1.5 and 2.0. 882 versions 1.5 and 2.0.
794 883
795OpenBSD 5.4 June 27, 2013 OpenBSD 5.4 884OpenBSD 5.4 January 19, 2014 OpenBSD 5.4
diff --git a/ssh_config.5 b/ssh_config.5
index 5d76c6d2d..3cadcd767 100644
--- a/ssh_config.5
+++ b/ssh_config.5
@@ -33,8 +33,8 @@
33.\" (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
34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: ssh_config.5,v 1.166 2013/06/27 14:05:37 jmc Exp $ 36.\" $OpenBSD: ssh_config.5,v 1.184 2014/01/19 04:48:08 djm Exp $
37.Dd $Mdocdate: June 27 2013 $ 37.Dd $Mdocdate: January 19 2014 $
38.Dt SSH_CONFIG 5 38.Dt SSH_CONFIG 5
39.Os 39.Os
40.Sh NAME 40.Sh NAME
@@ -100,6 +100,8 @@ keywords are case-insensitive and arguments are case-sensitive):
100.It Cm Host 100.It Cm Host
101Restricts the following declarations (up to the next 101Restricts the following declarations (up to the next
102.Cm Host 102.Cm Host
103or
104.Cm Match
103keyword) to be only for those hosts that match one of the patterns 105keyword) to be only for those hosts that match one of the patterns
104given after the keyword. 106given after the keyword.
105If more than one pattern is provided, they should be separated by whitespace. 107If more than one pattern is provided, they should be separated by whitespace.
@@ -124,6 +126,73 @@ matches.
124See 126See
125.Sx PATTERNS 127.Sx PATTERNS
126for more information on patterns. 128for more information on patterns.
129.It Cm Match
130Restricts the following declarations (up to the next
131.Cm Host
132or
133.Cm Match
134keyword) to be used only when the conditions following the
135.Cm Match
136keyword are satisfied.
137Match conditions are specified using one or more keyword/criteria pairs
138or the single token
139.Cm all
140which matches all criteria.
141The available keywords are:
142.Cm exec ,
143.Cm host ,
144.Cm originalhost ,
145.Cm user ,
146and
147.Cm localuser .
148.Pp
149The
150.Cm exec
151keyword executes the specified command under the user's shell.
152If the command returns a zero exit status then the condition is considered true.
153Commands containing whitespace characters must be quoted.
154The following character sequences in the command will be expanded prior to
155execution:
156.Ql %L
157will be substituted by the first component of the local host name,
158.Ql %l
159will be substituted by the local host name (including any domain name),
160.Ql %h
161will be substituted by the target host name,
162.Ql %n
163will be substituted by the original target host name
164specified on the command-line,
165.Ql %p
166the destination port,
167.Ql %r
168by the remote login username, and
169.Ql %u
170by the username of the user running
171.Xr ssh 1 .
172.Pp
173The other keywords' criteria must be single entries or comma-separated
174lists and may use the wildcard and negation operators described in the
175.Sx PATTERNS
176section.
177The criteria for the
178.Cm host
179keyword are matched against the target hostname, after any substitution
180by the
181.Cm Hostname
182option.
183The
184.Cm originalhost
185keyword matches against the hostname as it was specified on the command-line.
186The
187.Cm user
188keyword matches against the target username on the remote host.
189The
190.Cm localuser
191keyword matches against the name of the local user running
192.Xr ssh 1
193(this keyword may be useful in system-wide
194.Nm
195files).
127.It Cm AddressFamily 196.It Cm AddressFamily
128Specifies which address family to use when connecting. 197Specifies which address family to use when connecting.
129Valid arguments are 198Valid arguments are
@@ -152,6 +221,75 @@ Note that this option does not work if
152.Cm UsePrivilegedPort 221.Cm UsePrivilegedPort
153is set to 222is set to
154.Dq yes . 223.Dq yes .
224.It Cm CanonicalDomains
225When
226.Cm CanonicalizeHostname
227is enabled, this option specifies the list of domain suffixes in which to
228search for the specified destination host.
229.It Cm CanonicalizeFallbackLocal
230Specifies whether to fail with an error when hostname canonicalization fails.
231The default,
232.Dq yes ,
233will attempt to look up the unqualified hostname using the system resolver's
234search rules.
235A value of
236.Dq no
237will cause
238.Xr ssh 1
239to fail instantly if
240.Cm CanonicalizeHostname
241is enabled and the target hostname cannot be found in any of the domains
242specified by
243.Cm CanonicalDomains .
244.It Cm CanonicalizeHostname
245Controls whether explicit hostname canonicalization is performed.
246The default,
247.Dq no ,
248is not to perform any name rewriting and let the system resolver handle all
249hostname lookups.
250If set to
251.Dq yes
252then, for connections that do not use a
253.Cm ProxyCommand ,
254.Xr ssh 1
255will attempt to canonicalize the hostname specified on the command line
256using the
257.Cm CanonicalDomains
258suffixes and
259.Cm CanonicalizePermittedCNAMEs
260rules.
261If
262.Cm CanonicalizeHostname
263is set to
264.Dq always ,
265then canonicalization is applied to proxied connections too.
266.It Cm CanonicalizeMaxDots
267Specifies the maximum number of dot characters in a hostname before
268canonicalization is disabled.
269The default,
270.Dq 1 ,
271allows a single dot (i.e. hostname.subdomain).
272.It Cm CanonicalizePermittedCNAMEs
273Specifies rules to determine whether CNAMEs should be followed when
274canonicalizing hostnames.
275The rules consist of one or more arguments of
276.Ar source_domain_list : Ns Ar target_domain_list ,
277where
278.Ar source_domain_list
279is a pattern-list of domains that may follow CNAMEs in canonicalization,
280and
281.Ar target_domain_list
282is a pattern-list of domains that they may resolve to.
283.Pp
284For example,
285.Dq *.a.example.com:*.b.example.com,*.c.example.com
286will allow hostnames matching
287.Dq *.a.example.com
288to be canonicalized to names in the
289.Dq *.b.example.com
290or
291.Dq *.c.example.com
292domains.
155.It Cm ChallengeResponseAuthentication 293.It Cm ChallengeResponseAuthentication
156Specifies whether to use challenge-response authentication. 294Specifies whether to use challenge-response authentication.
157The argument to this keyword must be 295The argument to this keyword must be
@@ -196,7 +334,8 @@ The default is
196Specifies the ciphers allowed for protocol version 2 334Specifies the ciphers allowed for protocol version 2
197in order of preference. 335in order of preference.
198Multiple ciphers must be comma-separated. 336Multiple ciphers must be comma-separated.
199The supported ciphers are 337The supported ciphers are:
338.Pp
200.Dq 3des-cbc , 339.Dq 3des-cbc ,
201.Dq aes128-cbc , 340.Dq aes128-cbc ,
202.Dq aes192-cbc , 341.Dq aes192-cbc ,
@@ -210,15 +349,23 @@ The supported ciphers are
210.Dq arcfour256 , 349.Dq arcfour256 ,
211.Dq arcfour , 350.Dq arcfour ,
212.Dq blowfish-cbc , 351.Dq blowfish-cbc ,
352.Dq cast128-cbc ,
213and 353and
214.Dq cast128-cbc . 354.Dq chacha20-poly1305@openssh.com .
355.Pp
215The default is: 356The default is:
216.Bd -literal -offset 3n 357.Bd -literal -offset 3n
217aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128, 358aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,
218aes128-gcm@openssh.com,aes256-gcm@openssh.com, 359aes128-gcm@openssh.com,aes256-gcm@openssh.com,
360chacha20-poly1305@openssh.com,
219aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc, 361aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,
220aes256-cbc,arcfour 362aes256-cbc,arcfour
221.Ed 363.Ed
364.Pp
365The list of available ciphers may also be obtained using the
366.Fl Q
367option of
368.Xr ssh 1 .
222.It Cm ClearAllForwardings 369.It Cm ClearAllForwardings
223Specifies that all local, remote, and dynamic port forwardings 370Specifies that all local, remote, and dynamic port forwardings
224specified in the configuration files or on the command line be 371specified in the configuration files or on the command line be
@@ -327,7 +474,7 @@ will be substituted by the target host name,
327will be substituted by the original target host name 474will be substituted by the original target host name
328specified on the command line, 475specified on the command line,
329.Ql %p 476.Ql %p
330the port, 477the destination port,
331.Ql %r 478.Ql %r
332by the remote login username, and 479by the remote login username, and
333.Ql %u 480.Ql %u
@@ -571,10 +718,11 @@ The default for this option is:
571ecdsa-sha2-nistp256-cert-v01@openssh.com, 718ecdsa-sha2-nistp256-cert-v01@openssh.com,
572ecdsa-sha2-nistp384-cert-v01@openssh.com, 719ecdsa-sha2-nistp384-cert-v01@openssh.com,
573ecdsa-sha2-nistp521-cert-v01@openssh.com, 720ecdsa-sha2-nistp521-cert-v01@openssh.com,
721ssh-ed25519-cert-v01@openssh.com,
574ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com, 722ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,
575ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com, 723ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com,
576ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521, 724ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
577ssh-rsa,ssh-dss 725ssh-ed25519,ssh-rsa,ssh-dss
578.Ed 726.Ed
579.Pp 727.Pp
580If hostkeys are known for the destination host then this default is modified 728If hostkeys are known for the destination host then this default is modified
@@ -616,13 +764,14 @@ offers many different identities.
616The default is 764The default is
617.Dq no . 765.Dq no .
618.It Cm IdentityFile 766.It Cm IdentityFile
619Specifies a file from which the user's DSA, ECDSA or RSA authentication 767Specifies a file from which the user's DSA, ECDSA, ED25519 or RSA authentication
620identity is read. 768identity is read.
621The default is 769The default is
622.Pa ~/.ssh/identity 770.Pa ~/.ssh/identity
623for protocol version 1, and 771for protocol version 1, and
624.Pa ~/.ssh/id_dsa , 772.Pa ~/.ssh/id_dsa ,
625.Pa ~/.ssh/id_ecdsa 773.Pa ~/.ssh/id_ecdsa ,
774.Pa ~/.ssh/id_ed25519
626and 775and
627.Pa ~/.ssh/id_rsa 776.Pa ~/.ssh/id_rsa
628for protocol version 2. 777for protocol version 2.
@@ -735,6 +884,7 @@ Specifies the available KEX (Key Exchange) algorithms.
735Multiple algorithms must be comma-separated. 884Multiple algorithms must be comma-separated.
736The default is: 885The default is:
737.Bd -literal -offset indent 886.Bd -literal -offset indent
887curve25519-sha256@libssh.org,
738ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521, 888ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,
739diffie-hellman-group-exchange-sha256, 889diffie-hellman-group-exchange-sha256,
740diffie-hellman-group-exchange-sha1, 890diffie-hellman-group-exchange-sha1,
@@ -937,6 +1087,14 @@ For example, the following directive would connect via an HTTP proxy at
937.Bd -literal -offset 3n 1087.Bd -literal -offset 3n
938ProxyCommand /usr/bin/nc -X connect -x 192.0.2.0:8080 %h %p 1088ProxyCommand /usr/bin/nc -X connect -x 192.0.2.0:8080 %h %p
939.Ed 1089.Ed
1090.It Cm ProxyUseFdpass
1091Specifies that
1092.Cm ProxyCommand
1093will pass a connected file descriptor back to
1094.Xr ssh 1
1095instead of continuing to execute and pass data.
1096The default is
1097.Dq no .
940.It Cm PubkeyAuthentication 1098.It Cm PubkeyAuthentication
941Specifies whether to try public key authentication. 1099Specifies whether to try public key authentication.
942The argument to this keyword must be 1100The argument to this keyword must be
@@ -1298,7 +1456,7 @@ Patterns within pattern-lists may be negated
1298by preceding them with an exclamation mark 1456by preceding them with an exclamation mark
1299.Pq Sq !\& . 1457.Pq Sq !\& .
1300For example, 1458For example,
1301to allow a key to be used from anywhere within an organisation 1459to allow a key to be used from anywhere within an organization
1302except from the 1460except from the
1303.Dq dialup 1461.Dq dialup
1304pool, 1462pool,
diff --git a/sshconnect.c b/sshconnect.c
index 483eb85ac..d21781ea4 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect.c,v 1.238 2013/05/17 00:13:14 djm Exp $ */ 1/* $OpenBSD: sshconnect.c,v 1.244 2014/01/09 23:26: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
@@ -59,6 +59,7 @@
59#include "misc.h" 59#include "misc.h"
60#include "dns.h" 60#include "dns.h"
61#include "roaming.h" 61#include "roaming.h"
62#include "monitor_fdpass.h"
62#include "ssh2.h" 63#include "ssh2.h"
63#include "version.h" 64#include "version.h"
64 65
@@ -78,47 +79,122 @@ extern uid_t original_effective_uid;
78static int show_other_keys(struct hostkeys *, Key *); 79static int show_other_keys(struct hostkeys *, Key *);
79static void warn_changed_key(Key *); 80static void warn_changed_key(Key *);
80 81
82/* Expand a proxy command */
83static char *
84expand_proxy_command(const char *proxy_command, const char *user,
85 const char *host, int port)
86{
87 char *tmp, *ret, strport[NI_MAXSERV];
88
89 snprintf(strport, sizeof strport, "%d", port);
90 xasprintf(&tmp, "exec %s", proxy_command);
91 ret = percent_expand(tmp, "h", host, "p", strport,
92 "r", options.user, (char *)NULL);
93 free(tmp);
94 return ret;
95}
96
97/*
98 * Connect to the given ssh server using a proxy command that passes a
99 * a connected fd back to us.
100 */
101static int
102ssh_proxy_fdpass_connect(const char *host, u_short port,
103 const char *proxy_command)
104{
105 char *command_string;
106 int sp[2], sock;
107 pid_t pid;
108 char *shell;
109
110 if ((shell = getenv("SHELL")) == NULL)
111 shell = _PATH_BSHELL;
112
113 if (socketpair(AF_UNIX, SOCK_STREAM, 0, sp) < 0)
114 fatal("Could not create socketpair to communicate with "
115 "proxy dialer: %.100s", strerror(errno));
116
117 command_string = expand_proxy_command(proxy_command, options.user,
118 host, port);
119 debug("Executing proxy dialer command: %.500s", command_string);
120
121 /* Fork and execute the proxy command. */
122 if ((pid = fork()) == 0) {
123 char *argv[10];
124
125 /* Child. Permanently give up superuser privileges. */
126 permanently_drop_suid(original_real_uid);
127
128 close(sp[1]);
129 /* Redirect stdin and stdout. */
130 if (sp[0] != 0) {
131 if (dup2(sp[0], 0) < 0)
132 perror("dup2 stdin");
133 }
134 if (sp[0] != 1) {
135 if (dup2(sp[0], 1) < 0)
136 perror("dup2 stdout");
137 }
138 if (sp[0] >= 2)
139 close(sp[0]);
140
141 /*
142 * Stderr is left as it is so that error messages get
143 * printed on the user's terminal.
144 */
145 argv[0] = shell;
146 argv[1] = "-c";
147 argv[2] = command_string;
148 argv[3] = NULL;
149
150 /*
151 * Execute the proxy command.
152 * Note that we gave up any extra privileges above.
153 */
154 execv(argv[0], argv);
155 perror(argv[0]);
156 exit(1);
157 }
158 /* Parent. */
159 if (pid < 0)
160 fatal("fork failed: %.100s", strerror(errno));
161 close(sp[0]);
162 free(command_string);
163
164 if ((sock = mm_receive_fd(sp[1])) == -1)
165 fatal("proxy dialer did not pass back a connection");
166
167 while (waitpid(pid, NULL, 0) == -1)
168 if (errno != EINTR)
169 fatal("Couldn't wait for child: %s", strerror(errno));
170
171 /* Set the connection file descriptors. */
172 packet_set_connection(sock, sock);
173
174 return 0;
175}
176
81/* 177/*
82 * Connect to the given ssh server using a proxy command. 178 * Connect to the given ssh server using a proxy command.
83 */ 179 */
84static int 180static int
85ssh_proxy_connect(const char *host, u_short port, const char *proxy_command) 181ssh_proxy_connect(const char *host, u_short port, const char *proxy_command)
86{ 182{
87 char *command_string, *tmp; 183 char *command_string;
88 int pin[2], pout[2]; 184 int pin[2], pout[2];
89 pid_t pid; 185 pid_t pid;
90 char *shell, strport[NI_MAXSERV]; 186 char *shell;
91
92 if (!strcmp(proxy_command, "-")) {
93 packet_set_connection(STDIN_FILENO, STDOUT_FILENO);
94 packet_set_timeout(options.server_alive_interval,
95 options.server_alive_count_max);
96 return 0;
97 }
98 187
99 if ((shell = getenv("SHELL")) == NULL || *shell == '\0') 188 if ((shell = getenv("SHELL")) == NULL || *shell == '\0')
100 shell = _PATH_BSHELL; 189 shell = _PATH_BSHELL;
101 190
102 /* Convert the port number into a string. */
103 snprintf(strport, sizeof strport, "%hu", port);
104
105 /*
106 * Build the final command string in the buffer by making the
107 * appropriate substitutions to the given proxy command.
108 *
109 * Use "exec" to avoid "sh -c" processes on some platforms
110 * (e.g. Solaris)
111 */
112 xasprintf(&tmp, "exec %s", proxy_command);
113 command_string = percent_expand(tmp, "h", host, "p", strport,
114 "r", options.user, (char *)NULL);
115 free(tmp);
116
117 /* Create pipes for communicating with the proxy. */ 191 /* Create pipes for communicating with the proxy. */
118 if (pipe(pin) < 0 || pipe(pout) < 0) 192 if (pipe(pin) < 0 || pipe(pout) < 0)
119 fatal("Could not create pipes to communicate with the proxy: %.100s", 193 fatal("Could not create pipes to communicate with the proxy: %.100s",
120 strerror(errno)); 194 strerror(errno));
121 195
196 command_string = expand_proxy_command(proxy_command, options.user,
197 host, port);
122 debug("Executing proxy command: %.500s", command_string); 198 debug("Executing proxy command: %.500s", command_string);
123 199
124 /* Fork and execute the proxy command. */ 200 /* Fork and execute the proxy command. */
@@ -170,8 +246,6 @@ ssh_proxy_connect(const char *host, u_short port, const char *proxy_command)
170 246
171 /* Set the connection file descriptors. */ 247 /* Set the connection file descriptors. */
172 packet_set_connection(pout[0], pin[1]); 248 packet_set_connection(pout[0], pin[1]);
173 packet_set_timeout(options.server_alive_interval,
174 options.server_alive_count_max);
175 249
176 /* Indicate OK return */ 250 /* Indicate OK return */
177 return 0; 251 return 0;
@@ -194,34 +268,18 @@ ssh_kill_proxy_command(void)
194static int 268static int
195ssh_create_socket(int privileged, struct addrinfo *ai) 269ssh_create_socket(int privileged, struct addrinfo *ai)
196{ 270{
197 int sock, gaierr; 271 int sock, r, gaierr;
198 struct addrinfo hints, *res; 272 struct addrinfo hints, *res;
199 273
200 /*
201 * If we are running as root and want to connect to a privileged
202 * port, bind our own socket to a privileged port.
203 */
204 if (privileged) {
205 int p = IPPORT_RESERVED - 1;
206 PRIV_START;
207 sock = rresvport_af(&p, ai->ai_family);
208 PRIV_END;
209 if (sock < 0)
210 error("rresvport: af=%d %.100s", ai->ai_family,
211 strerror(errno));
212 else
213 debug("Allocated local port %d.", p);
214 return sock;
215 }
216 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); 274 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
217 if (sock < 0) { 275 if (sock < 0) {
218 error("socket: %.100s", strerror(errno)); 276 error("socket: %s", strerror(errno));
219 return -1; 277 return -1;
220 } 278 }
221 fcntl(sock, F_SETFD, FD_CLOEXEC); 279 fcntl(sock, F_SETFD, FD_CLOEXEC);
222 280
223 /* Bind the socket to an alternative local IP address */ 281 /* Bind the socket to an alternative local IP address */
224 if (options.bind_address == NULL) 282 if (options.bind_address == NULL && !privileged)
225 return sock; 283 return sock;
226 284
227 memset(&hints, 0, sizeof(hints)); 285 memset(&hints, 0, sizeof(hints));
@@ -236,11 +294,28 @@ ssh_create_socket(int privileged, struct addrinfo *ai)
236 close(sock); 294 close(sock);
237 return -1; 295 return -1;
238 } 296 }
239 if (bind(sock, res->ai_addr, res->ai_addrlen) < 0) { 297 /*
240 error("bind: %s: %s", options.bind_address, strerror(errno)); 298 * If we are running as root and want to connect to a privileged
241 close(sock); 299 * port, bind our own socket to a privileged port.
242 freeaddrinfo(res); 300 */
243 return -1; 301 if (privileged) {
302 PRIV_START;
303 r = bindresvport_sa(sock, res->ai_addr);
304 PRIV_END;
305 if (r < 0) {
306 error("bindresvport_sa: af=%d %s", ai->ai_family,
307 strerror(errno));
308 goto fail;
309 }
310 } else {
311 if (bind(sock, res->ai_addr, res->ai_addrlen) < 0) {
312 error("bind: %s: %s", options.bind_address,
313 strerror(errno));
314 fail:
315 close(sock);
316 freeaddrinfo(res);
317 return -1;
318 }
244 } 319 }
245 freeaddrinfo(res); 320 freeaddrinfo(res);
246 return sock; 321 return sock;
@@ -340,33 +415,18 @@ timeout_connect(int sockfd, const struct sockaddr *serv_addr,
340 * and %p substituted for host and port, respectively) to use to contact 415 * and %p substituted for host and port, respectively) to use to contact
341 * the daemon. 416 * the daemon.
342 */ 417 */
343int 418static int
344ssh_connect(const char *host, struct sockaddr_storage * hostaddr, 419ssh_connect_direct(const char *host, struct addrinfo *aitop,
345 u_short port, int family, int connection_attempts, int *timeout_ms, 420 struct sockaddr_storage *hostaddr, u_short port, int family,
346 int want_keepalive, int needpriv, const char *proxy_command) 421 int connection_attempts, int *timeout_ms, int want_keepalive, int needpriv)
347{ 422{
348 int gaierr;
349 int on = 1; 423 int on = 1;
350 int sock = -1, attempt; 424 int sock = -1, attempt;
351 char ntop[NI_MAXHOST], strport[NI_MAXSERV]; 425 char ntop[NI_MAXHOST], strport[NI_MAXSERV];
352 struct addrinfo hints, *ai, *aitop; 426 struct addrinfo *ai;
353 427
354 debug2("ssh_connect: needpriv %d", needpriv); 428 debug2("ssh_connect: needpriv %d", needpriv);
355 429
356 /* If a proxy command is given, connect using it. */
357 if (proxy_command != NULL)
358 return ssh_proxy_connect(host, port, proxy_command);
359
360 /* No proxy command. */
361
362 memset(&hints, 0, sizeof(hints));
363 hints.ai_family = family;
364 hints.ai_socktype = SOCK_STREAM;
365 snprintf(strport, sizeof strport, "%u", port);
366 if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0)
367 fatal("%s: Could not resolve hostname %.100s: %s", __progname,
368 host, ssh_gai_strerror(gaierr));
369
370 for (attempt = 0; attempt < connection_attempts; attempt++) { 430 for (attempt = 0; attempt < connection_attempts; attempt++) {
371 if (attempt > 0) { 431 if (attempt > 0) {
372 /* Sleep a moment before retrying. */ 432 /* Sleep a moment before retrying. */
@@ -378,7 +438,8 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
378 * sequence until the connection succeeds. 438 * sequence until the connection succeeds.
379 */ 439 */
380 for (ai = aitop; ai; ai = ai->ai_next) { 440 for (ai = aitop; ai; ai = ai->ai_next) {
381 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) 441 if (ai->ai_family != AF_INET &&
442 ai->ai_family != AF_INET6)
382 continue; 443 continue;
383 if (getnameinfo(ai->ai_addr, ai->ai_addrlen, 444 if (getnameinfo(ai->ai_addr, ai->ai_addrlen,
384 ntop, sizeof(ntop), strport, sizeof(strport), 445 ntop, sizeof(ntop), strport, sizeof(strport),
@@ -411,8 +472,6 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
411 break; /* Successful connection. */ 472 break; /* Successful connection. */
412 } 473 }
413 474
414 freeaddrinfo(aitop);
415
416 /* Return failure if we didn't get a successful connection. */ 475 /* Return failure if we didn't get a successful connection. */
417 if (sock == -1) { 476 if (sock == -1) {
418 error("ssh: connect to host %s port %s: %s", 477 error("ssh: connect to host %s port %s: %s",
@@ -430,12 +489,28 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
430 489
431 /* Set the connection. */ 490 /* Set the connection. */
432 packet_set_connection(sock, sock); 491 packet_set_connection(sock, sock);
433 packet_set_timeout(options.server_alive_interval,
434 options.server_alive_count_max);
435 492
436 return 0; 493 return 0;
437} 494}
438 495
496int
497ssh_connect(const char *host, struct addrinfo *addrs,
498 struct sockaddr_storage *hostaddr, u_short port, int family,
499 int connection_attempts, int *timeout_ms, int want_keepalive, int needpriv)
500{
501 if (options.proxy_command == NULL) {
502 return ssh_connect_direct(host, addrs, hostaddr, port, family,
503 connection_attempts, timeout_ms, want_keepalive, needpriv);
504 } else if (strcmp(options.proxy_command, "-") == 0) {
505 packet_set_connection(STDIN_FILENO, STDOUT_FILENO);
506 return 0; /* Always succeeds */
507 } else if (options.proxy_use_fdpass) {
508 return ssh_proxy_fdpass_connect(host, port,
509 options.proxy_command);
510 }
511 return ssh_proxy_connect(host, port, options.proxy_command);
512}
513
439static void 514static void
440send_client_banner(int connection_out, int minor1) 515send_client_banner(int connection_out, int minor1)
441{ 516{
@@ -587,6 +662,12 @@ ssh_exchange_identification(int timeout_ms)
587 fatal("Protocol major versions differ: %d vs. %d", 662 fatal("Protocol major versions differ: %d vs. %d",
588 (options.protocol & SSH_PROTO_2) ? PROTOCOL_MAJOR_2 : PROTOCOL_MAJOR_1, 663 (options.protocol & SSH_PROTO_2) ? PROTOCOL_MAJOR_2 : PROTOCOL_MAJOR_1,
589 remote_major); 664 remote_major);
665 if ((datafellows & SSH_BUG_DERIVEKEY) != 0)
666 fatal("Server version \"%.100s\" uses unsafe key agreement; "
667 "refusing connection", remote_version);
668 if ((datafellows & SSH_BUG_RSASIGMD5) != 0)
669 logit("Server version \"%.100s\" uses unsafe RSA signature "
670 "scheme; disabling use of RSA keys", remote_version);
590 if (!client_banner_sent) 671 if (!client_banner_sent)
591 send_client_banner(connection_out, minor1); 672 send_client_banner(connection_out, minor1);
592 chop(server_version_string); 673 chop(server_version_string);
@@ -1176,7 +1257,7 @@ void
1176ssh_login(Sensitive *sensitive, const char *orighost, 1257ssh_login(Sensitive *sensitive, const char *orighost,
1177 struct sockaddr *hostaddr, u_short port, struct passwd *pw, int timeout_ms) 1258 struct sockaddr *hostaddr, u_short port, struct passwd *pw, int timeout_ms)
1178{ 1259{
1179 char *host, *cp; 1260 char *host;
1180 char *server_user, *local_user; 1261 char *server_user, *local_user;
1181 1262
1182 local_user = xstrdup(pw->pw_name); 1263 local_user = xstrdup(pw->pw_name);
@@ -1184,9 +1265,7 @@ ssh_login(Sensitive *sensitive, const char *orighost,
1184 1265
1185 /* Convert the user-supplied hostname into all lowercase. */ 1266 /* Convert the user-supplied hostname into all lowercase. */
1186 host = xstrdup(orighost); 1267 host = xstrdup(orighost);
1187 for (cp = host; *cp; cp++) 1268 lowercase(host);
1188 if (isupper(*cp))
1189 *cp = (char)tolower(*cp);
1190 1269
1191 /* Exchange protocol version identification strings with the server. */ 1270 /* Exchange protocol version identification strings with the server. */
1192 ssh_exchange_identification(timeout_ms); 1271 ssh_exchange_identification(timeout_ms);
@@ -1228,7 +1307,14 @@ ssh_put_password(char *password)
1228static int 1307static int
1229show_other_keys(struct hostkeys *hostkeys, Key *key) 1308show_other_keys(struct hostkeys *hostkeys, Key *key)
1230{ 1309{
1231 int type[] = { KEY_RSA1, KEY_RSA, KEY_DSA, KEY_ECDSA, -1}; 1310 int type[] = {
1311 KEY_RSA1,
1312 KEY_RSA,
1313 KEY_DSA,
1314 KEY_ECDSA,
1315 KEY_ED25519,
1316 -1
1317 };
1232 int i, ret = 0; 1318 int i, ret = 0;
1233 char *fp, *ra; 1319 char *fp, *ra;
1234 const struct hostkey_entry *found; 1320 const struct hostkey_entry *found;
diff --git a/sshconnect.h b/sshconnect.h
index fd7f7f7c6..0ea6e99f6 100644
--- a/sshconnect.h
+++ b/sshconnect.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect.h,v 1.27 2010/11/29 23:45:51 djm Exp $ */ 1/* $OpenBSD: sshconnect.h,v 1.28 2013/10/16 02:31:47 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -31,9 +31,9 @@ struct Sensitive {
31 int external_keysign; 31 int external_keysign;
32}; 32};
33 33
34int 34struct addrinfo;
35ssh_connect(const char *, struct sockaddr_storage *, u_short, int, int, 35int ssh_connect(const char *, struct addrinfo *, struct sockaddr_storage *,
36 int *, int, int, const char *); 36 u_short, int, int, int *, int, int);
37void ssh_kill_proxy_command(void); 37void ssh_kill_proxy_command(void);
38 38
39void ssh_login(Sensitive *, const char *, struct sockaddr *, u_short, 39void ssh_login(Sensitive *, const char *, struct sockaddr *, u_short,
diff --git a/sshconnect1.c b/sshconnect1.c
index d285e23c0..7bd6cb018 100644
--- a/sshconnect1.c
+++ b/sshconnect1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect1.c,v 1.71 2013/05/17 00:13:14 djm Exp $ */ 1/* $OpenBSD: sshconnect1.c,v 1.72 2013/09/02 22:00:34 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
@@ -542,9 +542,6 @@ ssh_kex(char *host, struct sockaddr *hostaddr)
542 542
543 derive_ssh1_session_id(host_key->rsa->n, server_key->rsa->n, cookie, session_id); 543 derive_ssh1_session_id(host_key->rsa->n, server_key->rsa->n, cookie, session_id);
544 544
545 /* Generate a session key. */
546 arc4random_stir();
547
548 /* 545 /*
549 * Generate an encryption key for the session. The key is a 256 bit 546 * Generate an encryption key for the session. The key is a 256 bit
550 * random number, interpreted as a 32-byte key, with the least 547 * random number, interpreted as a 32-byte key, with the least
diff --git a/sshconnect2.c b/sshconnect2.c
index 70e3cd8c9..8acffc5c3 100644
--- a/sshconnect2.c
+++ b/sshconnect2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect2.c,v 1.198 2013/06/05 12:52:38 dtucker Exp $ */ 1/* $OpenBSD: sshconnect2.c,v 1.201 2014/01/09 23:20:00 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.
@@ -188,11 +188,12 @@ ssh_kex2(char *host, struct sockaddr *hostaddr, u_short port)
188 } 188 }
189 if (options.hostkeyalgorithms != NULL) 189 if (options.hostkeyalgorithms != NULL)
190 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = 190 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] =
191 options.hostkeyalgorithms; 191 compat_pkalg_proposal(options.hostkeyalgorithms);
192 else { 192 else {
193 /* Prefer algorithms that we already have keys for */ 193 /* Prefer algorithms that we already have keys for */
194 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = 194 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] =
195 order_hostkeyalgs(host, hostaddr, port); 195 compat_pkalg_proposal(
196 order_hostkeyalgs(host, hostaddr, port));
196 } 197 }
197 if (options.kex_algorithms != NULL) 198 if (options.kex_algorithms != NULL)
198 myproposal[PROPOSAL_KEX_ALGS] = options.kex_algorithms; 199 myproposal[PROPOSAL_KEX_ALGS] = options.kex_algorithms;
@@ -208,6 +209,7 @@ ssh_kex2(char *host, struct sockaddr *hostaddr, u_short port)
208 kex->kex[KEX_DH_GEX_SHA1] = kexgex_client; 209 kex->kex[KEX_DH_GEX_SHA1] = kexgex_client;
209 kex->kex[KEX_DH_GEX_SHA256] = kexgex_client; 210 kex->kex[KEX_DH_GEX_SHA256] = kexgex_client;
210 kex->kex[KEX_ECDH_SHA2] = kexecdh_client; 211 kex->kex[KEX_ECDH_SHA2] = kexecdh_client;
212 kex->kex[KEX_C25519_SHA256] = kexc25519_client;
211 kex->client_version_string=client_version_string; 213 kex->client_version_string=client_version_string;
212 kex->server_version_string=server_version_string; 214 kex->server_version_string=server_version_string;
213 kex->verify_host_key=&verify_host_key_callback; 215 kex->verify_host_key=&verify_host_key_callback;
@@ -1004,7 +1006,7 @@ jpake_password_to_secret(Authctxt *authctxt, const char *crypt_scheme,
1004 debug3("%s: crypted = %s", __func__, crypted); 1006 debug3("%s: crypted = %s", __func__, crypted);
1005#endif 1007#endif
1006 1008
1007 if (hash_buffer(crypted, strlen(crypted), EVP_sha256(), 1009 if (hash_buffer(crypted, strlen(crypted), SSH_DIGEST_SHA1,
1008 &secret, &secret_len) != 0) 1010 &secret, &secret_len) != 0)
1009 fatal("%s: hash_buffer", __func__); 1011 fatal("%s: hash_buffer", __func__);
1010 1012
@@ -1488,17 +1490,31 @@ userauth_pubkey(Authctxt *authctxt)
1488 * encrypted keys we cannot do this and have to load the 1490 * encrypted keys we cannot do this and have to load the
1489 * private key instead 1491 * private key instead
1490 */ 1492 */
1491 if (id->key && id->key->type != KEY_RSA1) { 1493 if (id->key != NULL) {
1492 debug("Offering %s public key: %s", key_type(id->key), 1494 if (key_type_plain(id->key->type) == KEY_RSA &&
1493 id->filename); 1495 (datafellows & SSH_BUG_RSASIGMD5) != 0) {
1494 sent = send_pubkey_test(authctxt, id); 1496 debug("Skipped %s key %s for RSA/MD5 server",
1495 } else if (id->key == NULL) { 1497 key_type(id->key), id->filename);
1498 } else if (id->key->type != KEY_RSA1) {
1499 debug("Offering %s public key: %s",
1500 key_type(id->key), id->filename);
1501 sent = send_pubkey_test(authctxt, id);
1502 }
1503 } else {
1496 debug("Trying private key: %s", id->filename); 1504 debug("Trying private key: %s", id->filename);
1497 id->key = load_identity_file(id->filename, 1505 id->key = load_identity_file(id->filename,
1498 id->userprovided); 1506 id->userprovided);
1499 if (id->key != NULL) { 1507 if (id->key != NULL) {
1500 id->isprivate = 1; 1508 id->isprivate = 1;
1501 sent = sign_and_send_pubkey(authctxt, id); 1509 if (key_type_plain(id->key->type) == KEY_RSA &&
1510 (datafellows & SSH_BUG_RSASIGMD5) != 0) {
1511 debug("Skipped %s key %s for RSA/MD5 "
1512 "server", key_type(id->key),
1513 id->filename);
1514 } else {
1515 sent = sign_and_send_pubkey(
1516 authctxt, id);
1517 }
1502 key_free(id->key); 1518 key_free(id->key);
1503 id->key = NULL; 1519 id->key = NULL;
1504 } 1520 }
diff --git a/sshd.0 b/sshd.0
index c48b987f9..154009c9f 100644
--- a/sshd.0
+++ b/sshd.0
@@ -82,10 +82,11 @@ DESCRIPTION
82 be given if sshd is not run as root (as the normal host key files 82 be given if sshd is not run as root (as the normal host key files
83 are normally not readable by anyone but root). The default is 83 are normally not readable by anyone but root). The default is
84 /etc/ssh/ssh_host_key for protocol version 1, and 84 /etc/ssh/ssh_host_key for protocol version 1, and
85 /etc/ssh/ssh_host_dsa_key, /etc/ssh/ssh_host_ecdsa_key and 85 /etc/ssh/ssh_host_dsa_key, /etc/ssh/ssh_host_ecdsa_key.
86 /etc/ssh/ssh_host_rsa_key for protocol version 2. It is possible 86 /etc/ssh/ssh_host_ed25519_key and /etc/ssh/ssh_host_rsa_key for
87 to have multiple host key files for the different protocol 87 protocol version 2. It is possible to have multiple host key
88 versions and host key algorithms. 88 files for the different protocol versions and host key
89 algorithms.
89 90
90 -i Specifies that sshd is being run from inetd(8). sshd is normally 91 -i Specifies that sshd is being run from inetd(8). sshd is normally
91 not run from inetd because it needs to generate the server key 92 not run from inetd because it needs to generate the server key
@@ -147,9 +148,9 @@ DESCRIPTION
147AUTHENTICATION 148AUTHENTICATION
148 The OpenSSH SSH daemon supports SSH protocols 1 and 2. The default is to 149 The OpenSSH SSH daemon supports SSH protocols 1 and 2. The default is to
149 use protocol 2 only, though this can be changed via the Protocol option 150 use protocol 2 only, though this can be changed via the Protocol option
150 in sshd_config(5). Protocol 2 supports DSA, ECDSA and RSA keys; protocol 151 in sshd_config(5). Protocol 2 supports DSA, ECDSA, ED25519 and RSA keys;
151 1 only supports RSA keys. For both protocols, each host has a host- 152 protocol 1 only supports RSA keys. For both protocols, each host has a
152 specific key, normally 2048 bits, used to identify the host. 153 host-specific key, normally 2048 bits, used to identify the host.
153 154
154 Forward security for protocol 1 is provided through an additional server 155 Forward security for protocol 1 is provided through an additional server
155 key, normally 768 bits, generated when the server starts. This key is 156 key, normally 768 bits, generated when the server starts. This key is
@@ -278,15 +279,15 @@ AUTHORIZED_KEYS FILE FORMAT
278 give the RSA key for protocol version 1; the comment field is not used 279 give the RSA key for protocol version 1; the comment field is not used
279 for anything (but may be convenient for the user to identify the key). 280 for anything (but may be convenient for the user to identify the key).
280 For protocol version 2 the keytype is ``ecdsa-sha2-nistp256'', 281 For protocol version 2 the keytype is ``ecdsa-sha2-nistp256'',
281 ``ecdsa-sha2-nistp384'', ``ecdsa-sha2-nistp521'', ``ssh-dss'' or 282 ``ecdsa-sha2-nistp384'', ``ecdsa-sha2-nistp521'', ``ssh-ed25519'',
282 ``ssh-rsa''. 283 ``ssh-dss'' or ``ssh-rsa''.
283 284
284 Note that lines in this file are usually several hundred bytes long 285 Note that lines in this file are usually several hundred bytes long
285 (because of the size of the public key encoding) up to a limit of 8 286 (because of the size of the public key encoding) up to a limit of 8
286 kilobytes, which permits DSA keys up to 8 kilobits and RSA keys up to 16 287 kilobytes, which permits DSA keys up to 8 kilobits and RSA keys up to 16
287 kilobits. You don't want to type them in; instead, copy the 288 kilobits. You don't want to type them in; instead, copy the
288 identity.pub, id_dsa.pub, id_ecdsa.pub, or the id_rsa.pub file and edit 289 identity.pub, id_dsa.pub, id_ecdsa.pub, id_ed25519.pub, or the id_rsa.pub
289 it. 290 file and edit it.
290 291
291 sshd enforces a minimum RSA key modulus size for protocol 1 and protocol 292 sshd enforces a minimum RSA key modulus size for protocol 1 and protocol
292 2 keys of 768 bits. 293 2 keys of 768 bits.
@@ -512,11 +513,11 @@ FILES
512 for the user, and not accessible by others. 513 for the user, and not accessible by others.
513 514
514 ~/.ssh/authorized_keys 515 ~/.ssh/authorized_keys
515 Lists the public keys (DSA/ECDSA/RSA) that can be used for 516 Lists the public keys (DSA, ECDSA, ED25519, RSA) that can be used
516 logging in as this user. The format of this file is described 517 for logging in as this user. The format of this file is
517 above. The content of the file is not highly sensitive, but the 518 described above. The content of the file is not highly
518 recommended permissions are read/write for the user, and not 519 sensitive, but the recommended permissions are read/write for the
519 accessible by others. 520 user, and not accessible by others.
520 521
521 If this file, the ~/.ssh directory, or the user's home directory 522 If this file, the ~/.ssh directory, or the user's home directory
522 are writable by other users, then the file could be modified or 523 are writable by other users, then the file could be modified or
@@ -574,6 +575,7 @@ FILES
574 /etc/ssh/ssh_host_key 575 /etc/ssh/ssh_host_key
575 /etc/ssh/ssh_host_dsa_key 576 /etc/ssh/ssh_host_dsa_key
576 /etc/ssh/ssh_host_ecdsa_key 577 /etc/ssh/ssh_host_ecdsa_key
578 /etc/ssh/ssh_host_ed25519_key
577 /etc/ssh/ssh_host_rsa_key 579 /etc/ssh/ssh_host_rsa_key
578 These files contain the private parts of the host keys. These 580 These files contain the private parts of the host keys. These
579 files should only be owned by root, readable only by root, and 581 files should only be owned by root, readable only by root, and
@@ -583,6 +585,7 @@ FILES
583 /etc/ssh/ssh_host_key.pub 585 /etc/ssh/ssh_host_key.pub
584 /etc/ssh/ssh_host_dsa_key.pub 586 /etc/ssh/ssh_host_dsa_key.pub
585 /etc/ssh/ssh_host_ecdsa_key.pub 587 /etc/ssh/ssh_host_ecdsa_key.pub
588 /etc/ssh/ssh_host_ed25519_key.pub
586 /etc/ssh/ssh_host_rsa_key.pub 589 /etc/ssh/ssh_host_rsa_key.pub
587 These files contain the public parts of the host keys. These 590 These files contain the public parts of the host keys. These
588 files should be world-readable but writable only by root. Their 591 files should be world-readable but writable only by root. Their
@@ -637,4 +640,4 @@ CAVEATS
637 System security is not improved unless rshd, rlogind, and rexecd are 640 System security is not improved unless rshd, rlogind, and rexecd are
638 disabled (thus completely disabling rlogin and rsh into the machine). 641 disabled (thus completely disabling rlogin and rsh into the machine).
639 642
640OpenBSD 5.4 June 27, 2013 OpenBSD 5.4 643OpenBSD 5.4 December 7, 2013 OpenBSD 5.4
diff --git a/sshd.8 b/sshd.8
index b0c7ab6bd..e6a900b06 100644
--- a/sshd.8
+++ b/sshd.8
@@ -33,8 +33,8 @@
33.\" (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
34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: sshd.8,v 1.270 2013/06/27 14:05:37 jmc Exp $ 36.\" $OpenBSD: sshd.8,v 1.273 2013/12/07 11:58:46 naddy Exp $
37.Dd $Mdocdate: June 27 2013 $ 37.Dd $Mdocdate: December 7 2013 $
38.Dt SSHD 8 38.Dt SSHD 8
39.Os 39.Os
40.Sh NAME 40.Sh NAME
@@ -175,7 +175,8 @@ The default is
175.Pa /etc/ssh/ssh_host_key 175.Pa /etc/ssh/ssh_host_key
176for protocol version 1, and 176for protocol version 1, and
177.Pa /etc/ssh/ssh_host_dsa_key , 177.Pa /etc/ssh/ssh_host_dsa_key ,
178.Pa /etc/ssh/ssh_host_ecdsa_key 178.Pa /etc/ssh/ssh_host_ecdsa_key .
179.Pa /etc/ssh/ssh_host_ed25519_key
179and 180and
180.Pa /etc/ssh/ssh_host_rsa_key 181.Pa /etc/ssh/ssh_host_rsa_key
181for protocol version 2. 182for protocol version 2.
@@ -280,7 +281,7 @@ though this can be changed via the
280.Cm Protocol 281.Cm Protocol
281option in 282option in
282.Xr sshd_config 5 . 283.Xr sshd_config 5 .
283Protocol 2 supports DSA, ECDSA and RSA keys; 284Protocol 2 supports DSA, ECDSA, ED25519 and RSA keys;
284protocol 1 only supports RSA keys. 285protocol 1 only supports RSA keys.
285For both protocols, 286For both protocols,
286each host has a host-specific key, 287each host has a host-specific key,
@@ -494,6 +495,7 @@ For protocol version 2 the keytype is
494.Dq ecdsa-sha2-nistp256 , 495.Dq ecdsa-sha2-nistp256 ,
495.Dq ecdsa-sha2-nistp384 , 496.Dq ecdsa-sha2-nistp384 ,
496.Dq ecdsa-sha2-nistp521 , 497.Dq ecdsa-sha2-nistp521 ,
498.Dq ssh-ed25519 ,
497.Dq ssh-dss 499.Dq ssh-dss
498or 500or
499.Dq ssh-rsa . 501.Dq ssh-rsa .
@@ -506,6 +508,7 @@ You don't want to type them in; instead, copy the
506.Pa identity.pub , 508.Pa identity.pub ,
507.Pa id_dsa.pub , 509.Pa id_dsa.pub ,
508.Pa id_ecdsa.pub , 510.Pa id_ecdsa.pub ,
511.Pa id_ed25519.pub ,
509or the 512or the
510.Pa id_rsa.pub 513.Pa id_rsa.pub
511file and edit it. 514file and edit it.
@@ -805,8 +808,8 @@ secret, but the recommended permissions are read/write/execute for the user,
805and not accessible by others. 808and not accessible by others.
806.Pp 809.Pp
807.It Pa ~/.ssh/authorized_keys 810.It Pa ~/.ssh/authorized_keys
808Lists the public keys (DSA/ECDSA/RSA) that can be used for logging in 811Lists the public keys (DSA, ECDSA, ED25519, RSA)
809as this user. 812that can be used for logging in as this user.
810The format of this file is described above. 813The format of this file is described above.
811The content of the file is not highly sensitive, but the recommended 814The content of the file is not highly sensitive, but the recommended
812permissions are read/write for the user, and not accessible by others. 815permissions are read/write for the user, and not accessible by others.
@@ -886,6 +889,7 @@ rlogin/rsh.
886.It Pa /etc/ssh/ssh_host_key 889.It Pa /etc/ssh/ssh_host_key
887.It Pa /etc/ssh/ssh_host_dsa_key 890.It Pa /etc/ssh/ssh_host_dsa_key
888.It Pa /etc/ssh/ssh_host_ecdsa_key 891.It Pa /etc/ssh/ssh_host_ecdsa_key
892.It Pa /etc/ssh/ssh_host_ed25519_key
889.It Pa /etc/ssh/ssh_host_rsa_key 893.It Pa /etc/ssh/ssh_host_rsa_key
890These files contain the private parts of the host keys. 894These files contain the private parts of the host keys.
891These files should only be owned by root, readable only by root, and not 895These files should only be owned by root, readable only by root, and not
@@ -897,6 +901,7 @@ does not start if these files are group/world-accessible.
897.It Pa /etc/ssh/ssh_host_key.pub 901.It Pa /etc/ssh/ssh_host_key.pub
898.It Pa /etc/ssh/ssh_host_dsa_key.pub 902.It Pa /etc/ssh/ssh_host_dsa_key.pub
899.It Pa /etc/ssh/ssh_host_ecdsa_key.pub 903.It Pa /etc/ssh/ssh_host_ecdsa_key.pub
904.It Pa /etc/ssh/ssh_host_ed25519_key.pub
900.It Pa /etc/ssh/ssh_host_rsa_key.pub 905.It Pa /etc/ssh/ssh_host_rsa_key.pub
901These files contain the public parts of the host keys. 906These files contain the public parts of the host keys.
902These files should be world-readable but writable only by 907These files should be world-readable but writable only by
diff --git a/sshd.c b/sshd.c
index 174cc7a42..25380c911 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshd.c,v 1.404 2013/07/19 07:37:48 markus Exp $ */ 1/* $OpenBSD: sshd.c,v 1.414 2014/01/09 23:26: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
@@ -315,6 +315,7 @@ static void
315sighup_restart(void) 315sighup_restart(void)
316{ 316{
317 logit("Received SIGHUP; restarting."); 317 logit("Received SIGHUP; restarting.");
318 platform_pre_restart();
318 close_listen_socks(); 319 close_listen_socks();
319 close_startup_pipes(); 320 close_startup_pipes();
320 alarm(0); /* alarm timer persists across exec */ 321 alarm(0); /* alarm timer persists across exec */
@@ -371,7 +372,7 @@ grace_alarm_handler(int sig)
371 */ 372 */
372 if (getpgid(0) == getpid()) { 373 if (getpgid(0) == getpid()) {
373 signal(SIGTERM, SIG_IGN); 374 signal(SIGTERM, SIG_IGN);
374 killpg(0, SIGTERM); 375 kill(0, SIGTERM);
375 } 376 }
376 377
377 /* Log error and exit. */ 378 /* Log error and exit. */
@@ -397,7 +398,6 @@ generate_ephemeral_server_key(void)
397 verbose("RSA key generation complete."); 398 verbose("RSA key generation complete.");
398 399
399 arc4random_buf(sensitive_data.ssh1_cookie, SSH_SESSION_KEY_LENGTH); 400 arc4random_buf(sensitive_data.ssh1_cookie, SSH_SESSION_KEY_LENGTH);
400 arc4random_stir();
401} 401}
402 402
403/*ARGSUSED*/ 403/*ARGSUSED*/
@@ -480,10 +480,11 @@ sshd_exchange_identification(int sock_in, int sock_out)
480 &remote_major, &remote_minor, remote_version) != 3) { 480 &remote_major, &remote_minor, remote_version) != 3) {
481 s = "Protocol mismatch.\n"; 481 s = "Protocol mismatch.\n";
482 (void) atomicio(vwrite, sock_out, s, strlen(s)); 482 (void) atomicio(vwrite, sock_out, s, strlen(s));
483 logit("Bad protocol version identification '%.100s' "
484 "from %s port %d", client_version_string,
485 get_remote_ipaddr(), get_remote_port());
483 close(sock_in); 486 close(sock_in);
484 close(sock_out); 487 close(sock_out);
485 logit("Bad protocol version identification '%.100s' from %s",
486 client_version_string, get_remote_ipaddr());
487 cleanup_exit(255); 488 cleanup_exit(255);
488 } 489 }
489 debug("Client protocol version %d.%d; client software version %.100s", 490 debug("Client protocol version %d.%d; client software version %.100s",
@@ -491,17 +492,24 @@ sshd_exchange_identification(int sock_in, int sock_out)
491 492
492 compat_datafellows(remote_version); 493 compat_datafellows(remote_version);
493 494
494 if (datafellows & SSH_BUG_PROBE) { 495 if ((datafellows & SSH_BUG_PROBE) != 0) {
495 logit("probed from %s with %s. Don't panic.", 496 logit("probed from %s with %s. Don't panic.",
496 get_remote_ipaddr(), client_version_string); 497 get_remote_ipaddr(), client_version_string);
497 cleanup_exit(255); 498 cleanup_exit(255);
498 } 499 }
499 500 if ((datafellows & SSH_BUG_SCANNER) != 0) {
500 if (datafellows & SSH_BUG_SCANNER) {
501 logit("scanned from %s with %s. Don't panic.", 501 logit("scanned from %s with %s. Don't panic.",
502 get_remote_ipaddr(), client_version_string); 502 get_remote_ipaddr(), client_version_string);
503 cleanup_exit(255); 503 cleanup_exit(255);
504 } 504 }
505 if ((datafellows & SSH_BUG_RSASIGMD5) != 0) {
506 logit("Client version \"%.100s\" uses unsafe RSA signature "
507 "scheme; disabling use of RSA keys", remote_version);
508 }
509 if ((datafellows & SSH_BUG_DERIVEKEY) != 0) {
510 fatal("Client version \"%.100s\" uses unsafe key agreement; "
511 "refusing connection", remote_version);
512 }
505 513
506 mismatch = 0; 514 mismatch = 0;
507 switch (remote_major) { 515 switch (remote_major) {
@@ -613,6 +621,7 @@ privsep_preauth_child(void)
613 arc4random_stir(); 621 arc4random_stir();
614 arc4random_buf(rnd, sizeof(rnd)); 622 arc4random_buf(rnd, sizeof(rnd));
615 RAND_seed(rnd, sizeof(rnd)); 623 RAND_seed(rnd, sizeof(rnd));
624 bzero(rnd, sizeof(rnd));
616 625
617 /* Demote the private keys to public keys. */ 626 /* Demote the private keys to public keys. */
618 demote_sensitive_data(); 627 demote_sensitive_data();
@@ -651,7 +660,7 @@ privsep_preauth(Authctxt *authctxt)
651 pmonitor->m_pkex = &xxx_kex; 660 pmonitor->m_pkex = &xxx_kex;
652 661
653 if (use_privsep == PRIVSEP_ON) 662 if (use_privsep == PRIVSEP_ON)
654 box = ssh_sandbox_init(); 663 box = ssh_sandbox_init(pmonitor);
655 pid = fork(); 664 pid = fork();
656 if (pid == -1) { 665 if (pid == -1) {
657 fatal("fork of unprivileged child failed"); 666 fatal("fork of unprivileged child failed");
@@ -747,6 +756,7 @@ privsep_postauth(Authctxt *authctxt)
747 arc4random_stir(); 756 arc4random_stir();
748 arc4random_buf(rnd, sizeof(rnd)); 757 arc4random_buf(rnd, sizeof(rnd));
749 RAND_seed(rnd, sizeof(rnd)); 758 RAND_seed(rnd, sizeof(rnd));
759 bzero(rnd, sizeof(rnd));
750 760
751 /* Drop privileges */ 761 /* Drop privileges */
752 do_setusercontext(authctxt->pw); 762 do_setusercontext(authctxt->pw);
@@ -782,6 +792,7 @@ list_hostkey_types(void)
782 case KEY_RSA: 792 case KEY_RSA:
783 case KEY_DSA: 793 case KEY_DSA:
784 case KEY_ECDSA: 794 case KEY_ECDSA:
795 case KEY_ED25519:
785 if (buffer_len(&b) > 0) 796 if (buffer_len(&b) > 0)
786 buffer_append(&b, ",", 1); 797 buffer_append(&b, ",", 1);
787 p = key_ssh_name(key); 798 p = key_ssh_name(key);
@@ -798,6 +809,7 @@ list_hostkey_types(void)
798 case KEY_RSA_CERT: 809 case KEY_RSA_CERT:
799 case KEY_DSA_CERT: 810 case KEY_DSA_CERT:
800 case KEY_ECDSA_CERT: 811 case KEY_ECDSA_CERT:
812 case KEY_ED25519_CERT:
801 if (buffer_len(&b) > 0) 813 if (buffer_len(&b) > 0)
802 buffer_append(&b, ",", 1); 814 buffer_append(&b, ",", 1);
803 p = key_ssh_name(key); 815 p = key_ssh_name(key);
@@ -825,6 +837,7 @@ get_hostkey_by_type(int type, int need_private)
825 case KEY_RSA_CERT: 837 case KEY_RSA_CERT:
826 case KEY_DSA_CERT: 838 case KEY_DSA_CERT:
827 case KEY_ECDSA_CERT: 839 case KEY_ECDSA_CERT:
840 case KEY_ED25519_CERT:
828 key = sensitive_data.host_certificates[i]; 841 key = sensitive_data.host_certificates[i];
829 break; 842 break;
830 default: 843 default:
@@ -1139,6 +1152,7 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s)
1139 struct sockaddr_storage from; 1152 struct sockaddr_storage from;
1140 socklen_t fromlen; 1153 socklen_t fromlen;
1141 pid_t pid; 1154 pid_t pid;
1155 u_char rnd[256];
1142 1156
1143 /* setup fd set for accept */ 1157 /* setup fd set for accept */
1144 fdset = NULL; 1158 fdset = NULL;
@@ -1339,6 +1353,9 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s)
1339 * from that of the child 1353 * from that of the child
1340 */ 1354 */
1341 arc4random_stir(); 1355 arc4random_stir();
1356 arc4random_buf(rnd, sizeof(rnd));
1357 RAND_seed(rnd, sizeof(rnd));
1358 bzero(rnd, sizeof(rnd));
1342 } 1359 }
1343 1360
1344 /* child process check (or debug mode) */ 1361 /* child process check (or debug mode) */
@@ -1693,6 +1710,7 @@ main(int ac, char **av)
1693 case KEY_RSA: 1710 case KEY_RSA:
1694 case KEY_DSA: 1711 case KEY_DSA:
1695 case KEY_ECDSA: 1712 case KEY_ECDSA:
1713 case KEY_ED25519:
1696 sensitive_data.have_ssh2_key = 1; 1714 sensitive_data.have_ssh2_key = 1;
1697 break; 1715 break;
1698 } 1716 }
@@ -1859,9 +1877,6 @@ main(int ac, char **av)
1859 /* Reinitialize the log (because of the fork above). */ 1877 /* Reinitialize the log (because of the fork above). */
1860 log_init(__progname, options.log_level, options.log_facility, log_stderr); 1878 log_init(__progname, options.log_level, options.log_facility, log_stderr);
1861 1879
1862 /* Initialize the random number generator. */
1863 arc4random_stir();
1864
1865 /* Chdir to the root directory so that the current disk can be 1880 /* Chdir to the root directory so that the current disk can be
1866 unmounted if desired. */ 1881 unmounted if desired. */
1867 if (chdir("/") == -1) 1882 if (chdir("/") == -1)
@@ -1933,13 +1948,14 @@ main(int ac, char **av)
1933 dup2(STDIN_FILENO, STDOUT_FILENO); 1948 dup2(STDIN_FILENO, STDOUT_FILENO);
1934 if (startup_pipe == -1) 1949 if (startup_pipe == -1)
1935 close(REEXEC_STARTUP_PIPE_FD); 1950 close(REEXEC_STARTUP_PIPE_FD);
1936 else 1951 else if (startup_pipe != REEXEC_STARTUP_PIPE_FD) {
1937 dup2(startup_pipe, REEXEC_STARTUP_PIPE_FD); 1952 dup2(startup_pipe, REEXEC_STARTUP_PIPE_FD);
1953 close(startup_pipe);
1954 startup_pipe = REEXEC_STARTUP_PIPE_FD;
1955 }
1938 1956
1939 dup2(config_s[1], REEXEC_CONFIG_PASS_FD); 1957 dup2(config_s[1], REEXEC_CONFIG_PASS_FD);
1940 close(config_s[1]); 1958 close(config_s[1]);
1941 if (startup_pipe != -1)
1942 close(startup_pipe);
1943 1959
1944 execv(rexec_argv[0], rexec_argv); 1960 execv(rexec_argv[0], rexec_argv);
1945 1961
@@ -1950,8 +1966,6 @@ main(int ac, char **av)
1950 options.log_facility, log_stderr); 1966 options.log_facility, log_stderr);
1951 1967
1952 /* Clean up fds */ 1968 /* Clean up fds */
1953 startup_pipe = REEXEC_STARTUP_PIPE_FD;
1954 close(config_s[1]);
1955 close(REEXEC_CONFIG_PASS_FD); 1969 close(REEXEC_CONFIG_PASS_FD);
1956 newsock = sock_out = sock_in = dup(STDIN_FILENO); 1970 newsock = sock_out = sock_in = dup(STDIN_FILENO);
1957 if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { 1971 if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
@@ -2033,7 +2047,9 @@ main(int ac, char **av)
2033#endif /* LIBWRAP */ 2047#endif /* LIBWRAP */
2034 2048
2035 /* Log the connection. */ 2049 /* Log the connection. */
2036 verbose("Connection from %.500s port %d", remote_ip, remote_port); 2050 verbose("Connection from %s port %d on %s port %d",
2051 remote_ip, remote_port,
2052 get_local_ipaddr(sock_in), get_local_port());
2037 2053
2038 /* 2054 /*
2039 * We don't want to listen forever unless the other side 2055 * We don't want to listen forever unless the other side
@@ -2437,7 +2453,8 @@ do_ssh2_kex(void)
2437 packet_set_rekey_limits((u_int32_t)options.rekey_limit, 2453 packet_set_rekey_limits((u_int32_t)options.rekey_limit,
2438 (time_t)options.rekey_interval); 2454 (time_t)options.rekey_interval);
2439 2455
2440 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = list_hostkey_types(); 2456 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = compat_pkalg_proposal(
2457 list_hostkey_types());
2441 2458
2442 /* start key exchange */ 2459 /* start key exchange */
2443 kex = kex_setup(myproposal); 2460 kex = kex_setup(myproposal);
@@ -2446,6 +2463,7 @@ do_ssh2_kex(void)
2446 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server; 2463 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
2447 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server; 2464 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
2448 kex->kex[KEX_ECDH_SHA2] = kexecdh_server; 2465 kex->kex[KEX_ECDH_SHA2] = kexecdh_server;
2466 kex->kex[KEX_C25519_SHA256] = kexc25519_server;
2449 kex->server = 1; 2467 kex->server = 1;
2450 kex->client_version_string=client_version_string; 2468 kex->client_version_string=client_version_string;
2451 kex->server_version_string=server_version_string; 2469 kex->server_version_string=server_version_string;
diff --git a/sshd_config b/sshd_config
index b786361d1..e9045bc4d 100644
--- a/sshd_config
+++ b/sshd_config
@@ -1,4 +1,4 @@
1# $OpenBSD: sshd_config,v 1.90 2013/05/16 04:09:14 dtucker Exp $ 1# $OpenBSD: sshd_config,v 1.93 2014/01/10 05:59:19 djm 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.
@@ -24,6 +24,7 @@
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#HostKey /etc/ssh/ssh_host_ecdsa_key
27#HostKey /etc/ssh/ssh_host_ed25519_key
27 28
28# Lifetime and size of ephemeral version 1 server key 29# Lifetime and size of ephemeral version 1 server key
29#KeyRegenerationInterval 1h 30#KeyRegenerationInterval 1h
@@ -84,8 +85,8 @@ AuthorizedKeysFile .ssh/authorized_keys
84#GSSAPIAuthentication no 85#GSSAPIAuthentication no
85#GSSAPICleanupCredentials yes 86#GSSAPICleanupCredentials yes
86 87
87# Set this to 'yes' to enable PAM authentication, account processing, 88# Set this to 'yes' to enable PAM authentication, account processing,
88# and session processing. If this is enabled, PAM authentication will 89# and session processing. If this is enabled, PAM authentication will
89# be allowed through the ChallengeResponseAuthentication and 90# be allowed through the ChallengeResponseAuthentication and
90# PasswordAuthentication. Depending on your PAM configuration, 91# PasswordAuthentication. Depending on your PAM configuration,
91# PAM authentication via ChallengeResponseAuthentication may bypass 92# PAM authentication via ChallengeResponseAuthentication may bypass
@@ -101,6 +102,7 @@ AuthorizedKeysFile .ssh/authorized_keys
101#X11Forwarding no 102#X11Forwarding no
102#X11DisplayOffset 10 103#X11DisplayOffset 10
103#X11UseLocalhost yes 104#X11UseLocalhost yes
105#PermitTTY yes
104#PrintMotd yes 106#PrintMotd yes
105#PrintLastLog yes 107#PrintLastLog yes
106#TCPKeepAlive yes 108#TCPKeepAlive yes
@@ -127,4 +129,5 @@ Subsystem sftp /usr/libexec/sftp-server
127#Match User anoncvs 129#Match User anoncvs
128# X11Forwarding no 130# X11Forwarding no
129# AllowTcpForwarding no 131# AllowTcpForwarding no
132# PermitTTY no
130# ForceCommand cvs server 133# ForceCommand cvs server
diff --git a/sshd_config.0 b/sshd_config.0
index 5f1df7b58..5962b02b9 100644
--- a/sshd_config.0
+++ b/sshd_config.0
@@ -198,18 +198,25 @@ DESCRIPTION
198 198
199 Ciphers 199 Ciphers
200 Specifies the ciphers allowed for protocol version 2. Multiple 200 Specifies the ciphers allowed for protocol version 2. Multiple
201 ciphers must be comma-separated. The supported ciphers are 201 ciphers must be comma-separated. The supported ciphers are:
202
202 ``3des-cbc'', ``aes128-cbc'', ``aes192-cbc'', ``aes256-cbc'', 203 ``3des-cbc'', ``aes128-cbc'', ``aes192-cbc'', ``aes256-cbc'',
203 ``aes128-ctr'', ``aes192-ctr'', ``aes256-ctr'', 204 ``aes128-ctr'', ``aes192-ctr'', ``aes256-ctr'',
204 ``aes128-gcm@openssh.com'', ``aes256-gcm@openssh.com'', 205 ``aes128-gcm@openssh.com'', ``aes256-gcm@openssh.com'',
205 ``arcfour128'', ``arcfour256'', ``arcfour'', ``blowfish-cbc'', 206 ``arcfour128'', ``arcfour256'', ``arcfour'', ``blowfish-cbc'',
206 and ``cast128-cbc''. The default is: 207 ``cast128-cbc'', and ``chacha20-poly1305@openssh.com''.
208
209 The default is:
207 210
208 aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128, 211 aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,
209 aes128-gcm@openssh.com,aes256-gcm@openssh.com, 212 aes128-gcm@openssh.com,aes256-gcm@openssh.com,
213 chacha20-poly1305@openssh.com,
210 aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc, 214 aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,
211 aes256-cbc,arcfour 215 aes256-cbc,arcfour
212 216
217 The list of available ciphers may also be obtained using the -Q
218 option of ssh(1).
219
213 ClientAliveCountMax 220 ClientAliveCountMax
214 Sets the number of client alive messages (see below) which may be 221 Sets the number of client alive messages (see below) which may be
215 sent without sshd(8) receiving any messages back from the client. 222 sent without sshd(8) receiving any messages back from the client.
@@ -325,15 +332,15 @@ DESCRIPTION
325 HostKey 332 HostKey
326 Specifies a file containing a private host key used by SSH. The 333 Specifies a file containing a private host key used by SSH. The
327 default is /etc/ssh/ssh_host_key for protocol version 1, and 334 default is /etc/ssh/ssh_host_key for protocol version 1, and
328 /etc/ssh/ssh_host_dsa_key, /etc/ssh/ssh_host_ecdsa_key and 335 /etc/ssh/ssh_host_dsa_key, /etc/ssh/ssh_host_ecdsa_key,
329 /etc/ssh/ssh_host_rsa_key for protocol version 2. Note that 336 /etc/ssh/ssh_host_ed25519_key and /etc/ssh/ssh_host_rsa_key for
330 sshd(8) will refuse to use a file if it is group/world- 337 protocol version 2. Note that sshd(8) will refuse to use a file
331 accessible. It is possible to have multiple host key files. 338 if it is group/world-accessible. It is possible to have multiple
332 ``rsa1'' keys are used for version 1 and ``dsa'', ``ecdsa'' or 339 host key files. ``rsa1'' keys are used for version 1 and
333 ``rsa'' are used for version 2 of the SSH protocol. It is also 340 ``dsa'', ``ecdsa'', ``ed25519'' or ``rsa'' are used for version 2
334 possible to specify public host key files instead. In this case 341 of the SSH protocol. It is also possible to specify public host
335 operations on the private key will be delegated to an 342 key files instead. In this case operations on the private key
336 ssh-agent(1). 343 will be delegated to an ssh-agent(1).
337 344
338 HostKeyAgent 345 HostKeyAgent
339 Identifies the UNIX-domain socket used to communicate with an 346 Identifies the UNIX-domain socket used to communicate with an
@@ -391,10 +398,13 @@ DESCRIPTION
391 KexAlgorithms 398 KexAlgorithms
392 Specifies the available KEX (Key Exchange) algorithms. Multiple 399 Specifies the available KEX (Key Exchange) algorithms. Multiple
393 algorithms must be comma-separated. The default is 400 algorithms must be comma-separated. The default is
394 ``ecdh-sha2-nistp256'', ``ecdh-sha2-nistp384'', 401
395 ``ecdh-sha2-nistp521'', ``diffie-hellman-group-exchange-sha256'', 402 curve25519-sha256@libssh.org,
396 ``diffie-hellman-group-exchange-sha1'', 403 ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,
397 ``diffie-hellman-group14-sha1'', ``diffie-hellman-group1-sha1''. 404 diffie-hellman-group-exchange-sha256,
405 diffie-hellman-group-exchange-sha1,
406 diffie-hellman-group14-sha1,
407 diffie-hellman-group1-sha1
398 408
399 KeyRegenerationInterval 409 KeyRegenerationInterval
400 In protocol version 1, the ephemeral server key is automatically 410 In protocol version 1, the ephemeral server key is automatically
@@ -452,12 +462,12 @@ DESCRIPTION
452 override those set in the global section of the config file, 462 override those set in the global section of the config file,
453 until either another Match line or the end of the file. 463 until either another Match line or the end of the file.
454 464
455 The arguments to Match are one or more criteria-pattern pairs. 465 The arguments to Match are one or more criteria-pattern pairs or
456 The available criteria are User, Group, Host, LocalAddress, 466 the single token All which matches all criteria. The available
457 LocalPort, and Address. The match patterns may consist of single 467 criteria are User, Group, Host, LocalAddress, LocalPort, and
458 entries or comma-separated lists and may use the wildcard and 468 Address. The match patterns may consist of single entries or
459 negation operators described in the PATTERNS section of 469 comma-separated lists and may use the wildcard and negation
460 ssh_config(5). 470 operators described in the PATTERNS section of ssh_config(5).
461 471
462 The patterns in an Address criteria may additionally contain 472 The patterns in an Address criteria may additionally contain
463 addresses to match in CIDR address/masklen format, e.g. 473 addresses to match in CIDR address/masklen format, e.g.
@@ -477,10 +487,10 @@ DESCRIPTION
477 HostbasedAuthentication, HostbasedUsesNameFromPacketOnly, 487 HostbasedAuthentication, HostbasedUsesNameFromPacketOnly,
478 KbdInteractiveAuthentication, KerberosAuthentication, 488 KbdInteractiveAuthentication, KerberosAuthentication,
479 MaxAuthTries, MaxSessions, PasswordAuthentication, 489 MaxAuthTries, MaxSessions, PasswordAuthentication,
480 PermitEmptyPasswords, PermitOpen, PermitRootLogin, PermitTunnel, 490 PermitEmptyPasswords, PermitOpen, PermitRootLogin, PermitTTY,
481 PubkeyAuthentication, RekeyLimit, RhostsRSAAuthentication, 491 PermitTunnel, PubkeyAuthentication, RekeyLimit,
482 RSAAuthentication, X11DisplayOffset, X11Forwarding and 492 RhostsRSAAuthentication, RSAAuthentication, X11DisplayOffset,
483 X11UseLocalHost. 493 X11Forwarding and X11UseLocalHost.
484 494
485 MaxAuthTries 495 MaxAuthTries
486 Specifies the maximum number of authentication attempts permitted 496 Specifies the maximum number of authentication attempts permitted
@@ -551,6 +561,10 @@ DESCRIPTION
551 ``ethernet'' (layer 2), or ``no''. Specifying ``yes'' permits 561 ``ethernet'' (layer 2), or ``no''. Specifying ``yes'' permits
552 both ``point-to-point'' and ``ethernet''. The default is ``no''. 562 both ``point-to-point'' and ``ethernet''. The default is ``no''.
553 563
564 PermitTTY
565 Specifies whether pty(4) allocation is permitted. The default is
566 ``yes''.
567
554 PermitUserEnvironment 568 PermitUserEnvironment
555 Specifies whether ~/.ssh/environment and environment= options in 569 Specifies whether ~/.ssh/environment and environment= options in
556 ~/.ssh/authorized_keys are processed by sshd(8). The default is 570 ~/.ssh/authorized_keys are processed by sshd(8). The default is
@@ -810,4 +824,4 @@ AUTHORS
810 versions 1.5 and 2.0. Niels Provos and Markus Friedl contributed support 824 versions 1.5 and 2.0. Niels Provos and Markus Friedl contributed support
811 for privilege separation. 825 for privilege separation.
812 826
813OpenBSD 5.4 July 19, 2013 OpenBSD 5.4 827OpenBSD 5.4 December 8, 2013 OpenBSD 5.4
diff --git a/sshd_config.5 b/sshd_config.5
index 3abac6c10..3b21ea6e7 100644
--- a/sshd_config.5
+++ b/sshd_config.5
@@ -33,8 +33,8 @@
33.\" (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
34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: sshd_config.5,v 1.162 2013/07/19 07:37:48 markus Exp $ 36.\" $OpenBSD: sshd_config.5,v 1.170 2013/12/08 09:53:27 dtucker Exp $
37.Dd $Mdocdate: July 19 2013 $ 37.Dd $Mdocdate: December 8 2013 $
38.Dt SSHD_CONFIG 5 38.Dt SSHD_CONFIG 5
39.Os 39.Os
40.Sh NAME 40.Sh NAME
@@ -335,7 +335,8 @@ The default is not to
335.It Cm Ciphers 335.It Cm Ciphers
336Specifies the ciphers allowed for protocol version 2. 336Specifies the ciphers allowed for protocol version 2.
337Multiple ciphers must be comma-separated. 337Multiple ciphers must be comma-separated.
338The supported ciphers are 338The supported ciphers are:
339.Pp
339.Dq 3des-cbc , 340.Dq 3des-cbc ,
340.Dq aes128-cbc , 341.Dq aes128-cbc ,
341.Dq aes192-cbc , 342.Dq aes192-cbc ,
@@ -349,15 +350,23 @@ The supported ciphers are
349.Dq arcfour256 , 350.Dq arcfour256 ,
350.Dq arcfour , 351.Dq arcfour ,
351.Dq blowfish-cbc , 352.Dq blowfish-cbc ,
353.Dq cast128-cbc ,
352and 354and
353.Dq cast128-cbc . 355.Dq chacha20-poly1305@openssh.com .
356.Pp
354The default is: 357The default is:
355.Bd -literal -offset 3n 358.Bd -literal -offset 3n
356aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128, 359aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,
357aes128-gcm@openssh.com,aes256-gcm@openssh.com, 360aes128-gcm@openssh.com,aes256-gcm@openssh.com,
361chacha20-poly1305@openssh.com,
358aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc, 362aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,
359aes256-cbc,arcfour 363aes256-cbc,arcfour
360.Ed 364.Ed
365.Pp
366The list of available ciphers may also be obtained using the
367.Fl Q
368option of
369.Xr ssh 1 .
361.It Cm ClientAliveCountMax 370.It Cm ClientAliveCountMax
362Sets the number of client alive messages (see below) which may be 371Sets the number of client alive messages (see below) which may be
363sent without 372sent without
@@ -531,7 +540,8 @@ The default is
531.Pa /etc/ssh/ssh_host_key 540.Pa /etc/ssh/ssh_host_key
532for protocol version 1, and 541for protocol version 1, and
533.Pa /etc/ssh/ssh_host_dsa_key , 542.Pa /etc/ssh/ssh_host_dsa_key ,
534.Pa /etc/ssh/ssh_host_ecdsa_key 543.Pa /etc/ssh/ssh_host_ecdsa_key ,
544.Pa /etc/ssh/ssh_host_ed25519_key
535and 545and
536.Pa /etc/ssh/ssh_host_rsa_key 546.Pa /etc/ssh/ssh_host_rsa_key
537for protocol version 2. 547for protocol version 2.
@@ -542,7 +552,8 @@ It is possible to have multiple host key files.
542.Dq rsa1 552.Dq rsa1
543keys are used for version 1 and 553keys are used for version 1 and
544.Dq dsa , 554.Dq dsa ,
545.Dq ecdsa 555.Dq ecdsa ,
556.Dq ed25519
546or 557or
547.Dq rsa 558.Dq rsa
548are used for version 2 of the SSH protocol. 559are used for version 2 of the SSH protocol.
@@ -651,13 +662,14 @@ The default is
651Specifies the available KEX (Key Exchange) algorithms. 662Specifies the available KEX (Key Exchange) algorithms.
652Multiple algorithms must be comma-separated. 663Multiple algorithms must be comma-separated.
653The default is 664The default is
654.Dq ecdh-sha2-nistp256 , 665.Bd -literal -offset indent
655.Dq ecdh-sha2-nistp384 , 666curve25519-sha256@libssh.org,
656.Dq ecdh-sha2-nistp521 , 667ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,
657.Dq diffie-hellman-group-exchange-sha256 , 668diffie-hellman-group-exchange-sha256,
658.Dq diffie-hellman-group-exchange-sha1 , 669diffie-hellman-group-exchange-sha1,
659.Dq diffie-hellman-group14-sha1 , 670diffie-hellman-group14-sha1,
660.Dq diffie-hellman-group1-sha1 . 671diffie-hellman-group1-sha1
672.Ed
661.It Cm KeyRegenerationInterval 673.It Cm KeyRegenerationInterval
662In protocol version 1, the ephemeral server key is automatically regenerated 674In protocol version 1, the ephemeral server key is automatically regenerated
663after this many seconds (if it has been used). 675after this many seconds (if it has been used).
@@ -750,7 +762,9 @@ line or the end of the file.
750.Pp 762.Pp
751The arguments to 763The arguments to
752.Cm Match 764.Cm Match
753are one or more criteria-pattern pairs. 765are one or more criteria-pattern pairs or the single token
766.Cm All
767which matches all criteria.
754The available criteria are 768The available criteria are
755.Cm User , 769.Cm User ,
756.Cm Group , 770.Cm Group ,
@@ -811,6 +825,7 @@ Available keywords are
811.Cm PermitEmptyPasswords , 825.Cm PermitEmptyPasswords ,
812.Cm PermitOpen , 826.Cm PermitOpen ,
813.Cm PermitRootLogin , 827.Cm PermitRootLogin ,
828.Cm PermitTTY ,
814.Cm PermitTunnel , 829.Cm PermitTunnel ,
815.Cm PubkeyAuthentication , 830.Cm PubkeyAuthentication ,
816.Cm RekeyLimit , 831.Cm RekeyLimit ,
@@ -940,6 +955,12 @@ and
940.Dq ethernet . 955.Dq ethernet .
941The default is 956The default is
942.Dq no . 957.Dq no .
958.It Cm PermitTTY
959Specifies whether
960.Xr pty 4
961allocation is permitted.
962The default is
963.Dq yes .
943.It Cm PermitUserEnvironment 964.It Cm PermitUserEnvironment
944Specifies whether 965Specifies whether
945.Pa ~/.ssh/environment 966.Pa ~/.ssh/environment
diff --git a/uidswap.c b/uidswap.c
index 26d17f93a..1f09d5887 100644
--- a/uidswap.c
+++ b/uidswap.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: uidswap.c,v 1.35 2006/08/03 03:34:42 deraadt Exp $ */ 1/* $OpenBSD: uidswap.c,v 1.36 2013/11/08 11:15:19 dtucker 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
@@ -20,6 +20,7 @@
20#include <string.h> 20#include <string.h>
21#include <unistd.h> 21#include <unistd.h>
22#include <stdarg.h> 22#include <stdarg.h>
23#include <stdlib.h>
23 24
24#include <grp.h> 25#include <grp.h>
25 26
@@ -133,7 +134,9 @@ temporarily_use_uid(struct passwd *pw)
133void 134void
134permanently_drop_suid(uid_t uid) 135permanently_drop_suid(uid_t uid)
135{ 136{
137#ifndef HAVE_CYGWIN
136 uid_t old_uid = getuid(); 138 uid_t old_uid = getuid();
139#endif
137 140
138 debug("permanently_drop_suid: %u", (u_int)uid); 141 debug("permanently_drop_suid: %u", (u_int)uid);
139 if (setresuid(uid, uid, uid) < 0) 142 if (setresuid(uid, uid, uid) < 0)
@@ -196,8 +199,10 @@ restore_uid(void)
196void 199void
197permanently_set_uid(struct passwd *pw) 200permanently_set_uid(struct passwd *pw)
198{ 201{
202#ifndef HAVE_CYGWIN
199 uid_t old_uid = getuid(); 203 uid_t old_uid = getuid();
200 gid_t old_gid = getgid(); 204 gid_t old_gid = getgid();
205#endif
201 206
202 if (pw == NULL) 207 if (pw == NULL)
203 fatal("permanently_set_uid: no user given"); 208 fatal("permanently_set_uid: no user given");
diff --git a/verify.c b/verify.c
new file mode 100644
index 000000000..1671a4132
--- /dev/null
+++ b/verify.c
@@ -0,0 +1,49 @@
1/* $OpenBSD: verify.c,v 1.3 2013/12/09 11:03:45 markus Exp $ */
2
3/*
4 * Public Domain, Author: Daniel J. Bernstein
5 * Copied from nacl-20110221/crypto_verify/32/ref/verify.c
6 */
7
8#include "includes.h"
9
10#include "crypto_api.h"
11
12int crypto_verify_32(const unsigned char *x,const unsigned char *y)
13{
14 unsigned int differentbits = 0;
15#define F(i) differentbits |= x[i] ^ y[i];
16 F(0)
17 F(1)
18 F(2)
19 F(3)
20 F(4)
21 F(5)
22 F(6)
23 F(7)
24 F(8)
25 F(9)
26 F(10)
27 F(11)
28 F(12)
29 F(13)
30 F(14)
31 F(15)
32 F(16)
33 F(17)
34 F(18)
35 F(19)
36 F(20)
37 F(21)
38 F(22)
39 F(23)
40 F(24)
41 F(25)
42 F(26)
43 F(27)
44 F(28)
45 F(29)
46 F(30)
47 F(31)
48 return (1 & ((differentbits - 1) >> 8)) - 1;
49}
diff --git a/version.h b/version.h
index 39033ed3e..83d70c6fc 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
1/* $OpenBSD: version.h,v 1.68 2013/11/08 01:38:11 djm Exp $ */ 1/* $OpenBSD: version.h,v 1.69 2014/01/16 07:32:00 djm Exp $ */
2 2
3#define SSH_VERSION "OpenSSH_6.4" 3#define SSH_VERSION "OpenSSH_6.5"
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
diff --git a/xmalloc.c b/xmalloc.c
index 92f781fd0..2f1cd2306 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: xmalloc.c,v 1.28 2013/05/17 00:13:14 djm Exp $ */ 1/* $OpenBSD: xmalloc.c,v 1.29 2014/01/04 17:50:55 tedu 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
@@ -33,7 +33,7 @@ xmalloc(size_t size)
33 fatal("xmalloc: zero size"); 33 fatal("xmalloc: zero size");
34 ptr = malloc(size); 34 ptr = malloc(size);
35 if (ptr == NULL) 35 if (ptr == NULL)
36 fatal("xmalloc: out of memory (allocating %lu bytes)", (u_long) size); 36 fatal("xmalloc: out of memory (allocating %zu bytes)", size);
37 return ptr; 37 return ptr;
38} 38}
39 39
@@ -48,8 +48,8 @@ xcalloc(size_t nmemb, size_t size)
48 fatal("xcalloc: nmemb * size > SIZE_T_MAX"); 48 fatal("xcalloc: nmemb * size > SIZE_T_MAX");
49 ptr = calloc(nmemb, size); 49 ptr = calloc(nmemb, size);
50 if (ptr == NULL) 50 if (ptr == NULL)
51 fatal("xcalloc: out of memory (allocating %lu bytes)", 51 fatal("xcalloc: out of memory (allocating %zu bytes)",
52 (u_long)(size * nmemb)); 52 size * nmemb);
53 return ptr; 53 return ptr;
54} 54}
55 55
@@ -68,8 +68,8 @@ xrealloc(void *ptr, size_t nmemb, size_t size)
68 else 68 else
69 new_ptr = realloc(ptr, new_size); 69 new_ptr = realloc(ptr, new_size);
70 if (new_ptr == NULL) 70 if (new_ptr == NULL)
71 fatal("xrealloc: out of memory (new_size %lu bytes)", 71 fatal("xrealloc: out of memory (new_size %zu bytes)",
72 (u_long) new_size); 72 new_size);
73 return new_ptr; 73 return new_ptr;
74} 74}
75 75