Граф коммитов

5731 Коммитов

Автор SHA1 Сообщение Дата
Simon Tatham 235f5bf8ae Check for auxv.h and hwcap.h before including them.
uClibc-ng does not provide <sys/auxv.h>, and a non-Linux-kernel-based
Unixlike system running on Arm will probably not provide
<asm/hwcap.h>. Now we check for both of those headers at autoconf
time, and if either one is absent, we don't do the runtime test for
Arm crypto acceleration.

This should only make a difference on systems where this module
previously failed to compile at all. But obviously it would be nicer
to find alternative ways to check for crypto acceleration on such
systems; patches welcome.
2019-03-26 19:19:28 +00:00
Simon Tatham 94f955fa90 Add an autoconf test and workaround for futimes(3).
Not every system provides it (e.g. uClibc-ng); if one does not, the
Uppity SFTP server should now degrade sensibly to refusing attempts to
set the utimes on an already-open file.
2019-03-26 18:44:19 +00:00
Simon Tatham e9f0abad2e uxpoll.c: cope with missing #defines in poll.h.
Baruch Siach reports that in a uClibc-ng build environment, POLLRDNORM
and friends are only defined by poll.h if you #define _XOPEN_SOURCE
before including it. So now we do that, in case it helps - and we also
cope with those #defines still being absent, in case on some other
system even that doesn't help.
2019-03-26 18:44:19 +00:00
Jacob Nevins 464e351c7b Remove most traces of WinHelp support.
Remove the 'winhelp-topic' IDs from the Halibut source, and from the
code. Now we have one fewer name to think of every time we add a
setting.

I've left the HELPCTX system in place, with the vague notion that it
might be a useful layer of indirection for some future help system on a
platform like Mac OS X.

(I've left the putty.hlp target in doc/Makefile, if nothing else because
this is a convenient test case for Halibut's WinHelp support. But the
resulting help file will no longer support context help.)
2019-03-26 00:27:04 +00:00
Jacob Nevins 7ad08649a2 Fix compilation with NO_GSSAPI.
This is a fairly shallow patch, which removes the UI and interactions
with external libraries. Some other machinery (which is dead code in
this configuration) is left in place.

Adapted by me from a patch by Jeroen Roovers.
2019-03-25 23:46:59 +00:00
Simon Tatham fe408562fa portfwdmgr_config: null out pointers we're destroying.
In particular, a report today pointed out that the call to
pfl_terminate(pfr->local) directly from portfwdmgr_config() was then
repeated from inside pfr_free(pfr) which we called four lines later,
leading to a double-free crash. Now we null out pfr->local the first
time, so the call in pfr_free is skipped.

While I'm at it, I've nulled out pfr->remote similarly; that doesn't
cause any crash that I can see, but it's a good habit to get into for
futureproofing.
2019-03-25 20:49:04 +00:00
Simon Tatham 8c710dddc5 cgtest: update OpenSSH fingerprinting mechanism.
We can only get fingerprints compatible with our own system by passing
the '-E md5' option to ssh-keygen. Also, we must strip the "MD5:"
prefix from the hash component of the returned fingerprint.

Since that hash appears in the middle of the string we were previously
extracting, I've reworked the whole cleanup_fp function to use the new
ptrlen_get_word, which makes it easy to extract two words from the
string and then strip a prefix off the second one.
2019-03-24 14:13:37 +00:00
Simon Tatham d159a6efac cgtest: destroy the global PRNG after every cmdgen_main().
This prevents an assertion failure when random_ref() tries to create
a new PRNG instance and finds there already is one. It also exposes
bugs in which some code path forgot to initialise the PRNG when it
was going to need it, such as the one fixed in the previous commit.
2019-03-24 14:13:37 +00:00
Simon Tatham 692238cc5f cgtest: call random_ref() before saving private keys.
The save functions do need some random data (for padding encrypted
blocks), so we must ensure a PRNG is available to generate that data.
2019-03-24 14:13:37 +00:00
Simon Tatham 6cae94be7e cgtest: add a 'verbose' flag.
Activated by setting CGTEST_VERBOSE in the environment, since we
already use the whole cgtest command line for other purposes.
2019-03-24 14:13:37 +00:00
Simon Tatham 7ae5c35419 New utility function: ptrlen_get_word().
This is similar to strtok, only it operates on a ptrlen. Therefore it
can be properly stateless, or rather, it stores its state by
overwriting the input ptrlen to point to a tail of its previous value.

Also in this commit I add a clarifying comment about when
ptrlen_{starts,ends}with will write through its 'tail' pointer.
2019-03-24 14:13:37 +00:00
Jacob Nevins 190761a272 Rework copy/paste documentation a bit.
Try harder to distinguish PuTTY's behaviour when run on Windows and on
Unix.
2019-03-24 13:30:41 +00:00
Simon Tatham a956da6e5b cryptsuite: add a general test of ssh_key methods.
This is the test that would have caught the bug described in 867e69187
if I'd got round to writing it before releasing 0.71. Stable door now
shut.
2019-03-24 10:20:44 +00:00
Simon Tatham 7f9aba638f Handle crashes in the testcrypt binary more cleanly.
Previously, if the testcrypt subprocess suffered any kind of crash or
assertion failure during a run of the Python-based test system, the
effect would be that ChildProcess.read_line() would get EOF, ignore
it, and silently return the empty string. Then it would carry on doing
that for the rest of the program, leading to a long string of error
reports in tests that were nowhere near the code that actually caused
the crash.

Now ChildProcess.read_line() detects EOF and raises an exception, so
that the test suite won't heedlessly carry on trying to do things once
it's noticed that its subprocess has gone away.

This is more fiddly than it sounds, however, because of the wrinkle
that sometimes that function can be called while a Python __del__
method is asking testcrypt to free something. If that happens, the
exception can't be propagated out of the __del__ (analogously to the
rule that it's a really terrible idea for C++ destructors to throw).
So you get an annoying warning message on standard error, and then the
next command sent to testcrypt will be back in the same position.
Worse still, this can also happen if testcrypt has _already_ crashed,
because the __del__ methods will still run.

To protect against _that_, ChildProcess caches the exception after
throwing it, and then each subsequent write_line() will rethrow it.
And __del__ catches and explicitly ignores the exception (to avoid the
annoying warning if Python has to do the same).

The combined result should be that if testcrypt crashes in normal
(non-__del__) context, we should get a single exception that
terminates the run cleanly without cascade failures, and whose
backtrace localises the problem to the actual operation that caused
the crash. If testcrypt crashes in __del__, we can't quite do that
well, but we can still terminate with an exception at the next
opportunity, avoiding multiple cascade failures.

Also in this commit, I've got rid of the try-finally in
cryptsuite.py's (trivial) main program.
2019-03-24 10:18:16 +00:00
Simon Tatham 6ecc16fc4b cryptsuite: clean up exit handling.
Now we only run the final memory-leak check if we didn't already have
some other error to report, or some other exception that terminated
the process.

Also, we wait for the subprocess to terminate before returning control
to the shell, so that any last-minute complaints from Leak Sanitiser
appear before rather than after the shell prompt comes back.

While I'm here, I've also made check_return_status tolerate the case
in which the child process never got started at all. That way, if a
failure manages to occur before even getting _that_ far, there won't
be a cascade failure from check_return_status getting confused
afterwards.
2019-03-24 10:18:16 +00:00
Simon Tatham c0e62e97bb Curve25519: add test vectors from RFC 7748.
My API for ECDH KEX doesn't provide a function to input the random
bytes from which the private key is derived, but conveniently, the
existing call to random_read() in ssh_ecdhkex_m_setup treats the
provided bytes in exactly the way that these test vectors expect.

One of these tests also exercises the 'reduction mod 2^255' case that
I just added.
2019-03-23 08:42:21 +00:00
Simon Tatham e400e93bcc Reduce Curve25519 public values mod 2^255.
I just spotted this requirement in RFC 7748. A _sensible_ Ed25519
public value is an integer less than p=2^255-19, but the transport
format allows encoding of numbers up to 2^256, and RFC 7748 has a
specific recommendation for what to do with overlarge ones: namely,
ignore the topmost bit if it is set (i.e. reduce mod 2^255), and deal
with the remaining 19 overlarge values by reducing mod p.

Apparently the purpose is to 'increase resistance to implementation
fingerprinting', so the lack of this step wasn't a serious
interoperability or security issue.
2019-03-23 08:39:04 +00:00
Simon Tatham 7fa0749fcb Generalise the Montgomery-curve DH support.
This gets rid of the magic constants we apply to the top and bottom
bytes of the random data to make the Curve25519 private DH value. Or
rather, one of the magic constants is completely gone (we can infer it
from curve->fieldBits), and the other is moved into the curve
structure instead of being hardwired into the private-key-inventing
function.

With this change, it will be easy to add the similar Curve448 kex
method, because it's now just a matter of adding the protocol names
and curve constants.
2019-03-23 08:39:04 +00:00
Jacob Nevins 319d4b5075 Fix double space in '-unsafe' message. 2019-03-23 08:32:13 +00:00
Simon Tatham fdf7de4a1c sessprep: fix detection of unbracketed IPv6 literals.
The centralisation I did in commit e3796cb77 introduced a foolish
sense error, in which I was supposed to be treating an unbracketed
colon in CONF_hostname as separating host name from a port-number-
shaped suffix if it _was_ the only one, and instead, accidentally did
so if it _wasn't_.
2019-03-22 16:32:41 +00:00
Simon Tatham f433c82cc2 Translate more _MSC_VER values in build info.
Thanks to Sean Kain for pointing out MS's web page listing all the
known _MSC_VER values and their translations.

To make it an easier and more mechanical process to update the list in
future, I've completely replaced our previous text for each version
with a straight paste of the exact string translations from that web
page (plus Sean Kain's extra value for VS2019, which isn't listed on
that page yet). That changes the exact wording of all the previous
translations, mostly cosmetically (although it also fixes the version
number for _MSC_VER=1912).

Since many of the new translations end with a version number in
parentheses, I've removed the parens around the following explicit
statement of _MSC_VER, so they don't look silly next to each other.
2019-03-22 07:19:36 +00:00
Simon Tatham 1d8b48fd22 pscp -scp: fix spurious newlines at end of filenames.
Commit d07d7d66f introduced this bug: I replaced a manually grown
string buffer with a strbuf, and failed to replicate the part where
after I'd finished appending wire data to the string I removed the
terminating \n. That string was used as the local file name, when
downloading in SCP mode using a wildcard, so you'd get lots of local
files whose names ended inconveniently in a newline character.

Fixed by terminating the loop before we push the \n on to the strbuf
in the first place.
2019-03-21 15:23:51 +00:00
Sven Strickroth 674219b115 Use sgrowarray_nm in GetDlgItemText_alloc
GetDlgItemText_alloc is often used to get passwords from text fields,
so the memory should be freed and erased properly. Otherwise parts
of passwords might leak in memory.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2019-03-21 12:57:09 +00:00
Simon Tatham 7631875d41 Re-enable trust sigils on Restart Session.
In my eagerness to make sure we didn't _accidentally_ change the
seat's trust status back to trusted at any point, I forgot to do it on
purpose if a second SSH login phase is legitimately run in the same
terminal after the first session has ended.
2019-03-20 15:07:32 +00:00
Simon Tatham f6d1fef2d7 Handle <limits.h> not defining PIPE_BUF.
According to POSIX, this can legally not be defined 'where the [...]
value is equal to or greater than the stated minimum, but where the
value can vary depending on the file to which it is applied'. So if
limits.h hasn't defined PIPE_BUF, we define it ourself to the stated
minimum, to wit, _POSIX_PIPE_BUF.

Apparently it is actually undefined by <limits.h> on GNU/Hurd: Debian
has been carrying this patch downstream for that reason.
2019-03-20 13:09:34 +00:00
Simon Tatham 582284fa6c Fix generation of one-bit-short RSA keys.
I carefully tested commit 801ab68ea's rewrite of invent_firstbits in
every way I could think of to ensure that I really was generating two
values whose product was at least 'minproduct'. But unfortunately the
value of 'minproduct' itself was off by a factor of two, which made
the entire system pointless!
2019-03-20 11:50:45 +00:00
Colin Watson 6ce6fe5712 Use the SELECT_* enum for a few more uxsel flags.
This cleans up some spots that were missed in 47202c4e16.
2019-03-20 11:39:05 +00:00
Simon Tatham 867e691874 Fix crash when adding an ECDSA key to Pageant.
The new_priv_openssh method for ECDSA keys was trying to initialise
the key as if it was EdDSA, leading to an assertion failure at setup
time.

This is what I get for not having taken cryptsuite.py all the way to
testing every top-level signature algorithm.
2019-03-20 08:00:03 +00:00
Simon Tatham 93c29b2277 sign.sh: add Windows on Arm builds to the signing list.
Oops - completely forgot to sign those!
2019-03-20 08:00:03 +00:00
Jacob Nevins 142427afae Fix for MIT KfW and user-specified GSS DLLs.
Fill in all the function pointers for 3rd party Windows GSS DLLs, not
just some of them. These were missed out when GSS key exchange was added
in d515e4f1a3.
2019-03-19 23:55:26 +00:00
Jacob Nevins c7c6bc8f93 Acknowledge Unix pageant. 2019-03-18 23:09:24 +00:00
Jacob Nevins d7c1f894d6 Acknowledge Windows-on-Arm builds. 2019-03-18 23:08:09 +00:00
Jacob Nevins 4f3abe5215 FIXME about Windows resource CHMfulness hint.
The thing I added in 8b7458119f turns out not to be visible in
Explorer's UI, at least. Oh well, maybe it'll be useful to someone.
2019-03-18 22:02:13 +00:00
Jacob Nevins 7c0242459c Remove note about .CHM on network drives.
Should be more or less moot since 67d3791de8.
2019-03-18 21:53:45 +00:00
Jacob Nevins 65d3afcaa1 Remove all trace of the Inno Setup installer.
(Hopefully.)
We haven't even built it for the past two releases.
2019-03-18 21:53:45 +00:00
Jacob Nevins a60d455c27 Grow the Windows Licence dialog.
It was cutting off the last line or so, on some fairly standard
Win7/Win10 installations.
2019-03-18 20:32:55 +00:00
Jacob Nevins 57020eef82 Grow PuTTYgen and Pageant About boxes.
To match a2b040ee09 for PuTTY/PuTTYtel.
2019-03-18 20:32:06 +00:00
Jacob Nevins c78f59fd9d Document ACL restriction options for Pageant.
These are just cross-references to the existing descriptions in the
"Using PuTTY" section.
2019-03-17 15:17:52 +00:00
Jacob Nevins 6d98399a27 Document Unix puttygen /dev/urandom default.
This changed in 025599ec99 (before 0.71).
2019-03-17 15:08:37 +00:00
Jacob Nevins 627d95e365 Document new Unix Pageant features in 0.71.
Better late than never.
These originated in:
 - e6b06c900f: --gui-prompt, --tty-prompt
 - 4467fa4d2a: --askpass
 - 0603256964: -L
2019-03-17 14:58:55 +00:00
Jacob Nevins 63b63b6243 Set trust status appropriately for rlogin.
Previously, all output in an rlogin session had spurious trust sigils.
2019-03-17 13:40:56 +00:00
Simon Tatham bda765dbd2 Post-0.71 checklist updates. 2019-03-16 16:58:51 +00:00
Simon Tatham c1fa520f98 release.pl: allow for installer-only sha*sums.
Now there are lines in the checksum lists that don't correspond
directly to files we uploaded as part of the main release process,
release.pl needs to ignore them to avoid embarrassing upload failures.
2019-03-16 16:46:50 +00:00
Simon Tatham abfc751c3e Update version number for 0.71 release. 2019-03-16 12:26:06 +00:00
Simon Tatham c081f3e234 Reorganise the default cipher preference order.
After all the side-channel removal work I've done, I'm demoting
Blowfish and Arcfour right to the bottom of the pile, because they're
the ciphers that still have cache and timing leaks in them. (Neither
one can be sanitised without making it _extremely_ slow - the factor
of 4.5 slowdown in DES would be small by comparison).

Single-DES is also still below the warning threshold for simply being
too weak (irrespective of side channels), but it's above the other two.
2019-03-16 12:25:23 +00:00
Simon Tatham 31b4c6ad9c Draft FAQ entries for the spoofing defences. 2019-03-16 12:25:23 +00:00
Simon Tatham 514796b7e4 Add an interactive anti-spoofing prompt in Plink.
At the point when we change over the seat's trust status to untrusted
for the last time, to finish authentication, Plink will now present a
final interactive prompt saying 'Press Return to begin session'. This
is a hint that anything after that that resembles an auth prompt
should be treated with suspicion, because _PuTTY_ thinks it's finished
authenticating.

This is of course an annoying inconvenience for interactive users, so
I've tried to reduce its impact as much as I can. It doesn't happen in
GUI PuTTY at all (because the trust sigil system is used instead); it
doesn't happen if you use plink -batch (because then the user already
knows that they _never_ expect an interactive prompt); and it doesn't
happen if Plink's standard input is being redirected from anywhere
other than the terminal / console (because then it would be pointless
for the server to try to scam passphrases out of the user anyway,
since the user isn't in a position to enter one in response to a spoof
prompt). So it should only happen to people who are using Plink in a
terminal for interactive login purposes, and that's not _really_ what
I ever intended Plink to be used for (which is why it's never had any
out-of-band control UI like OpenSSH's ~ system).

If anyone _still_ doesn't like this new prompt, it can also be turned
off using the new -no-antispoof flag, if the user is willing to
knowingly assume the risk.
2019-03-16 12:25:23 +00:00
Simon Tatham 76d8d363be Seat method to set the current trust status.
In terminal-based GUI applications, this is passed through to
term_set_trust_status, to toggle whether lines are prefixed with the
new trust sigil. In console applications, the function returns false,
indicating to the backend that it should employ some other technique
for spoofing protection.
2019-03-16 12:25:23 +00:00
Simon Tatham 9c367eba4c Add a per-line 'trusted' status in Terminal.
This indicates that a line contains trusted information (originated by
PuTTY) or untrusted (from the server). Trusted lines are prefixed by a
three-column signature consisting of the trust sigil (i.e. PuTTY icon)
and a separating space.

To protect against a server using escape sequences to move the cursor
back up to a trusted line and overwrite its contents, any attempt to
write to a termline is preceded by a call to check_trust_status(),
which clears the line completely if the terminal's current trust
status is different from the previous state of that line.

In the terminal data structures, the trust sigil is represented by
0xDFFE (an otherwise unused value, because it's in the surrogate
space). For bidi purposes I've arranged to treat that value as
direction-neutral, so that it will appear on the right if a terminal
line needs it to. (Not that that's currently likely to happen, with
PuTTY not being properly localised, but it's a bit of futureproofing.)

The bidi system is also where I actually insert the trust sigil: the
_logical_ terminal data structures don't include it. term_bidi_line
was a convenient place to add it, because that function was already
transforming a logical terminal line into a physical one in a way that
also generates a logical<->physical mapping table for handling mouse
clicks and cursor positioning; so that function now adds the trust
sigil as well as running the bidi algorithm.

(A knock-on effect of _that_ is that the log<->phys position map now
has to have a value for 'no correspondence', because if the user does
click on the trust sigil, there's no logical terminal position
corresponding to that. So the map can now contain the special value
BIDI_CHAR_INDEX_NONE, and anyone looking things up in it has to be
prepared to receive that as an answer.)

Of course, this terminal-data transformation can't be kept _wholly_
within term_bidi_line, because unlike proper bidi, it actually reduces
the number of visible columns on the line. So the wrapping code
(during glyph display and also copy and paste) has to take account of
the trusted status and use it to ignore the last 3 columns of the
line. This is probably not done absolutely perfectly, but then, it
doesn't need to be - trusted lines will be filled with well-controlled
data generated from the SSH code, which won't be doing every trick in
the book with escape sequences. Only untrusted terminal lines will be
using all the terminal's capabilities, and they don't have this sigil
getting in the way.
2019-03-16 12:25:23 +00:00
Simon Tatham 2a5d8e05e8 Add a TermWin method to draw a 'trust sigil'.
This is not yet used by anything, but the idea is that it'll be a
graphic in the terminal window that can't be replicated by a server
sending escape sequences, and hence can be used as a reliable
indication that the text on a particular terminal line is generated by
PuTTY itself and not passed through from the server. This will make it
possible to detect a malicious server trying to mimic local prompts to
trick you out of information that shouldn't be sent over the wire
(such as private-key passphrases).

The trust sigil I've picked is a small copy of the PuTTY icon, which
is thematically nice (it can be read as if the PuTTY icon is the name
of the speaker in a dialogue) and also convenient because we had that
graphic available already on all platforms. (Though the contortions I
had to go through to make the GTK 1 code draw it were quite annoying.)

The trust sigil has the same dimensions as a CJK double-width
character, i.e. it's 2 character cells wide by 1 high.
2019-03-16 12:25:23 +00:00