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

244 Коммитов

Автор SHA1 Сообщение Дата
Simon Tatham f274b56a57 Const-correctness in the base64 functions. 2015-05-12 14:56:38 +01:00
Simon Tatham 3935cc3af1 Support loading public-key-only files in Unix PuTTYgen.
The rsakey_pubblob() and ssh2_userkey_loadpub() functions, which
expected to be given a private key file and load only the unencrypted
public half, now also cope with any of the public-only formats I know
about (SSH-1 only has one, whereas SSH-2 has the RFC 4716 format and
OpenSSH's one-line format) and return an appropriate public key blob
from each of those too.

cmdgen now supports this functionality, by permitting public key files
to be loaded and used by any operation that doesn't need the private
key: so you can convert back and forth between the SSH-2 public
formats, or list the file's fingerprint.
2015-05-12 12:19:57 +01:00
Simon Tatham 9971da40c3 Utility function: bignum_from_decimal. 2015-05-12 12:14:45 +01:00
Simon Tatham 8c4ce6d8c6 Const-correctness in key-loading functions.
The passphrase parameter should be a const char *.
2015-05-11 15:49:09 +01:00
Simon Tatham 90af5bed04 Sort out the mess with OpenSSH key file formats.
When I implemented reading and writing of the new format a couple of
weeks ago, I kept them strictly separate in the UI, so you have to ask
for the format you want when exporting. But in fact this is silly,
because not every key type can be saved in both formats, and OpenSSH
itself has the policy of using the old format for key types it can
handle, unless specifically asked to use the new one.

So I've now arranged that the key file format enum has three values
for OpenSSH: PEM, NEW and AUTO. Files being loaded are identified as
either PEM or NEW, which describe the two physical file formats. But
exporting UIs present either AUTO or NEW, where AUTO is the virtual
format meaning 'save in the old format if possible, otherwise the new
one'.
2015-05-10 13:11:43 +01:00
Chris Staite 76a4b576e5 Support public keys using the "ssh-ed25519" method.
This introduces a third system of elliptic curve representation and
arithmetic, namely Edwards form.
2015-05-09 15:14:35 +01:00
Chris Staite 541abf9258 Support ECDH key exchange using the 'curve25519' curve.
This is the kex protocol id "curve25519-sha256@libssh.org", so called
because it's over the prime field of order 2^255 - 19.

Arithmetic in this curve is done using the Montgomery representation,
rather than the Weierstrass representation. So 'struct ec_curve' has
grown a discriminant field and a union of subtypes.
2015-05-09 15:07:14 +01:00
Chris Staite 7d6bf4a6ca Provide a little-endian version of bignum_from_bytes(). 2015-05-09 15:02:50 +01:00
Simon Tatham 1f4dc6faa7 Remove the list of key algorithms in pageant.c.
The only reason those couldn't be replaced with a call to the
centralised find_pubkey_alg is because that function takes a zero-
terminated string and instead we had a (length,pointer) string. Easily
fixed; there's now a find_pubkey_alg_len(), and we call that.

This also fixes a string-matching bug in which the sense of memcmp was
reversed by mistake for ECDSA keys!
2015-05-07 19:59:07 +01:00
Simon Tatham a53e4e2cb6 Const-correctness in x11_setup_display.
The 'display' parameter should have been a const char *. No call sites
affected.
2015-05-05 20:16:18 +01:00
Simon Tatham bcfcb169ef Const-correctness in public-key functions.
Several of the functions in ssh2_signkey, and one or two SSH-1 key
functions too, were still taking assorted non-const buffer parameters
that had never been properly constified. Sort them all out.
2015-05-05 20:16:17 +01:00
Simon Tatham 6b30316922 Use find_pubkey_alg in openssh_read_new().
This is better than listing all the algorithm names in yet another
place that will then need updating when a new key format is added.
However, that also means I need to find a new place to put the
'npieces' value I was previously setting up differently per key type;
since that's a fundamental property of the key format, I've moved it
to a constant field in the ssh_signkey structure, and filled that
field in for all the existing key types with the values from the
replaced code in openssh_read_new().
2015-05-02 15:11:41 +01:00
Simon Tatham 79bbf37c9e Separate key-type enum values for old and new OpenSSH keys.
It's all very well for these two different formats to share a type
code as long as we're only loading them and not saving, but as soon as
we need to save one or the other, we'll need different type codes
after all.

This commit introduces the openssh_new_write() function, but for the
moment, it always returns failure.
2015-04-28 19:48:43 +01:00
Simon Tatham d637528181 Implementation of OpenSSH's bcrypt.
This isn't the same as the standard bcrypt; it's OpenSSH's
modification that they use for their new-style key format.

In order to implement this, I've broken up blowfish_setkey() into two
subfunctions, and provided one of them with an extra optional salt
parameter, which is NULL in ordinary Blowfish but used by bcrypt.
Also, I've exposed some of sshblowf.c's internal machinery for the new
sshbcrypt.c to use.
2015-04-27 20:48:29 +01:00
Simon Tatham a8658edb17 Paste error in comment.
SSH2_MSG_KEX_DH_GEX_REQUEST_OLD and SSH2_MSG_KEX_DH_GEX_REQUEST were
correctly _defined_ as different numbers, but the comments to the
right containing the hex representations of their values were
accidentally the same.
2015-04-27 06:54:21 +01:00
Simon Tatham 183a9ee98b Support OpenSSH encrypt-then-MAC protocol extension.
This causes the initial length field of the SSH-2 binary packet to be
unencrypted (with the knock-on effect that now the packet length not
including MAC must be congruent to 4 rather than 0 mod the cipher
block size), and then the MAC is applied over the unencrypted length
field and encrypted ciphertext (prefixed by the sequence number as
usual). At the cost of exposing some information about the packet
lengths to an attacker (but rarely anything they couldn't have
inferred from the TCP headers anyway), this closes down any
possibility of a MITM using the client as a decryption oracle, unless
they can _first_ fake a correct MAC.

ETM mode is enabled by means of selecting a different MAC identifier,
all the current ones of which are constructed by appending
"-etm@openssh.com" to the name of a MAC that already existed.

We currently prefer the original SSH-2 binary packet protocol (i.e. we
list all the ETM-mode MACs last in our KEXINIT), on the grounds that
it's better tested and more analysed, so at the moment the new mode is
only activated if a server refuses to speak anything else.
2015-04-26 23:30:32 +01:00
Simon Tatham 62a1bce7cb Support RFC 4419.
PuTTY now uses the updated version of Diffie-Hellman group exchange,
except for a few old OpenSSH versions which Darren Tucker reports only
support the old version.

FIXME: this needs further work because the Bugs config panel has now
overflowed.
2015-04-25 10:54:18 +01:00
Simon Tatham 808e414130 Merge branch 'pre-0.64' 2015-02-28 07:57:58 +00:00
Simon Tatham 174476813f Enforce acceptable range for Diffie-Hellman server value.
Florent Daigniere of Matta points out that RFC 4253 actually
_requires_ us to refuse to accept out-of-range values, though it isn't
completely clear to me why this should be a MUST on the receiving end.

Matta considers this to be a security vulnerability, on the grounds
that if a server should accidentally send an obviously useless value
such as 1 then we will fail to reject it and agree a key that an
eavesdropper could also figure out. Their id for this vulnerability is
MATTA-2015-002.
2015-02-28 07:57:35 +00:00
Simon Tatham bb09a3936e Fix some rogue // comments.
That's what you get for changing things at the last minute...
2014-11-03 18:41:56 +00:00
Chris Staite 2bf8688355 Elliptic-curve cryptography support.
This provides support for ECDSA public keys, for both hosts and users,
and also ECDH key exchange. Supported curves are currently just the
three NIST curves required by RFC 5656.
2014-11-02 18:16:54 +00:00
Chris Staite 7d1c30cd50 Some extra bignum functions: modsub, lshift, random_in_range. 2014-11-02 18:16:54 +00:00
Chris Staite 66970c4258 Provide SHA-384 and SHA-512 as hashes usable in SSH KEX.
SHA-384 was previously not implemented at all, but is a trivial
adjustment to SHA-512 (different starting constants, and truncate the
output hash). Both are now exposed as 'ssh_hash' structures so that
key exchange methods can ask for them.
2014-11-02 18:16:54 +00:00
Simon Tatham a2b64dca47 Factor out the DSA deterministic k generator.
It's now a separate function, which you call with an identifying
string to be hashed into the generation of x. The idea is that other
DSA-like signature algorithms can reuse the same function, with a
different id string.

As a minor refinement, we now also never return k=1.
2014-11-02 18:16:54 +00:00
Simon Tatham bb78583ad2 Implement connection sharing between instances of PuTTY.
The basic strategy is described at the top of the new source file
sshshare.c. In very brief: an 'upstream' PuTTY opens a Unix-domain
socket or Windows named pipe, and listens for connections from other
PuTTYs wanting to run sessions on the same server. The protocol spoken
down that socket/pipe is essentially the bare ssh-connection protocol,
using a trivial binary packet protocol with no encryption, and the
upstream has to do some fiddly transformations that I've been
referring to as 'channel-number NAT' to avoid resource clashes between
the sessions it's managing.

This is quite different from OpenSSH's approach of using the Unix-
domain socket as a means of passing file descriptors around; the main
reason for that is that fd-passing is Unix-specific but this system
has to work on Windows too. However, there are additional advantages,
such as making it easy for each downstream PuTTY to run its own
independent set of port and X11 forwardings (though the method for
making the latter work is quite painful).

Sharing is off by default, but configuration is intended to be very
easy in the normal case - just tick one box in the SSH config panel
and everything else happens automatically.

[originally from svn r10083]
2013-11-17 14:05:41 +00:00
Simon Tatham e5a3e28eec Get rid of the error-return mechanism from x11_init.
Now that it doesn't actually make a network connection because that's
deferred until after the X authorisation exchange, there's no point in
having it return an error message and write the real output through a
pointer argument. Instead, we can just have it return xconn directly
and simplify the call sites.

[originally from svn r10081]
2013-11-17 14:05:23 +00:00
Simon Tatham 94e8f97d3f Refactor the construction of X protocol greetings.
I've moved it out into a separate function, preparatory to calling it
from somewhere completely different in changes to come. Also, we now
retain the peer address sent from the SSH server in string form,
rather than translating it immediately into a numeric IP address, so
that its original form will be available later to pass on elsewhere.

[originally from svn r10080]
2013-11-17 14:05:17 +00:00
Simon Tatham cc4fbe33bc Prepare to have multiple X11 auth cookies valid at once.
Rather than the top-level component of X forwarding being an
X11Display structure which owns some auth data, it's now a collection
of X11FakeAuth structures, each of which owns a display. The idea is
that when we receive an X connection, we wait to see which of our
available auth cookies it matches, and then connect to whatever X
display that auth cookie identifies. At present the tree will only
have one thing in it; this is all groundwork for later changes.

[originally from svn r10079]
2013-11-17 14:05:10 +00:00
Simon Tatham 01085358e4 Decouple X socket opening from x11_init().
Now we wait to open the socket to the X server until we've seen the
authorisation data. This prepares us to do something else with the
channel if we see different auth data, which will come up in
connection sharing.

[originally from svn r10078]
2013-11-17 14:05:04 +00:00
Simon Tatham 961503e449 Add missing 'const' in the des_*_xdmauth functions.
[originally from svn r10077]
2013-11-17 14:05:01 +00:00
Simon Tatham 9cbcd17651 Refactor ssh.c's APIs to x11fwd.c and portfwd.c.
The most important change is that, where previously ssh.c held the
Socket pointer for each X11 and port forwarding, and the support
modules would find their internal state structure by calling
sk_get_private_ptr on that Socket, it's now the other way round. ssh.c
now directly holds the internal state structure pointer for each
forwarding, and when the support module needs the Socket it looks it
up in a field of that. This will come in handy when I decouple socket
creation from logical forwarding setup, so that X forwardings can
delay actually opening a connection to an X server until they look at
the authentication data and see which server it has to be.

However, while I'm here, I've also taken the opportunity to clean up a
few other points, notably error message handling, and also the fact
that the same kind of state structure was used for both
connection-type and listening-type port forwardings. Now there are
separate PortForwarding and PortListener structure types, which seems
far more sensible.

[originally from svn r10074]
2013-11-17 14:04:41 +00:00
Simon Tatham 0bc76b8252 Move SSH protocol enumerations out into ssh.h.
This permits packet type codes and other magic numbers to be accessed
from modules other than ssh.c.

[originally from svn r10064]
2013-11-17 14:03:29 +00:00
Simon Tatham 8e7b0d0e4b Pass an error message through to sshfwd_unclean_close.
We have access to one at every call site, so there's really no reason
not to send it through to ssh.c to be logged.

[originally from svn r10038]
2013-09-08 07:14:56 +00:00
Simon Tatham 808df44e54 Add an assortment of missing consts I've just noticed.
[originally from svn r9972]
2013-07-27 18:35:48 +00:00
Ben Harris 8f3cc4a9bf Add support for HMAC-SHA-256 as an SSH-2 MAC algorithm ("hmac-sha2-256")
as specified in RFC 6668.  This is not so much because I think it's 
necessary, but because scrypt uses HMAC-SHA-256 and once we've got it we 
may as well use it.

Code very closely derived from the HMAC-SHA-1 code.

Tested against OpenSSH 5.9p1 Debian-5ubuntu1.

[originally from svn r9759]
2013-02-20 23:30:55 +00:00
Simon Tatham 9604c2b367 Generate keys more carefully, so that when the user asks for an n-bit
key they always get an n-bit number instead of n-1. The latter was
perfectly harmless but kept confusing users.

[originally from svn r9421]
2012-03-04 00:24:49 +00:00
Simon Tatham 49927f6c4d Introduce a function sshfwd_unclean_close(), supplied by ssh.c to
subsidiary network modules like portfwd.c. To be called when the
subsidiary module experiences a socket error: it sends an emergency
CHANNEL_CLOSE (not just outgoing CHANNEL_EOF), and immediately deletes
the local side of the channel. (I've invented a new channel type in
ssh.c called CHAN_ZOMBIE, for channels whose original local side has
already been thrown away and they're just hanging around waiting to
receive the acknowledging CHANNEL_CLOSE.)

As a result of this and the last few commits, I can now run a port
forwarding session in which a local socket error occurs on a forwarded
port, and PuTTY now handles it apparently correctly, closing both the
SSH channel and the local socket and then actually recognising that
it's OK to terminate when all _other_ channels have been closed.
Previously the channel corresponding to the duff connection would
linger around (because of net_pending_errors never being called), and
keep being selected on (hence chewing CPU), and inhibit program
termination at the end of the session (because not all channels were
closed).

[originally from svn r9364]
2011-12-08 19:15:58 +00:00
Simon Tatham 947962e0b9 Revamp of EOF handling in all network connections, pipes and other
data channels. Should comprehensively fix 'half-closed', in principle,
though it's a big and complicated change and so there's a good chance
I've made at least one mistake somewhere.

All connections should now be rigorous about propagating end-of-file
(or end-of-data-stream, or socket shutdown, or whatever) independently
in both directions, except in frontends with no mechanism for sending
explicit EOF (e.g. interactive terminal windows) or backends which are
basically always used for interactive sessions so it's unlikely that
an application would be depending on independent EOF (telnet, rlogin).

EOF should now never accidentally be sent while there's still buffered
data to go out before it. (May help fix 'portfwd-corrupt', and also I
noticed recently that the ssh main session channel can accidentally
have MSG_EOF sent before the output bufchain is clear, leading to
embarrassment when it subsequently does send the output).

[originally from svn r9279]
2011-09-13 11:44:03 +00:00
Simon Tatham a1f3b7a358 Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.

User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).

One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.

[originally from svn r9214]
2011-07-14 18:52:21 +00:00
Jacob Nevins 74c5f7dda9 Implement zlib@openssh.com, using the rekey-after-userauth method suggested in
the wishlist entry.

[originally from svn r9120]
[this svn revision also touched putty-website,putty-wishlist]
2011-03-04 22:34:47 +00:00
Simon Tatham fa85085640 Implement the Chinese Remainder Theorem optimisation for speeding up
RSA private key operations by making use of the fact that we know the
factors of the modulus.

[originally from svn r9095]
2011-02-18 08:25:39 +00:00
Simon Tatham 99fffd6ed3 Patch from Alejandro Sedeno, somewhat modified by me, which
reorganises the GSSAPI support so that it handles alternative
implementations of the GSS-API. In particular, this means PuTTY can
now talk to MIT Kerberos for Windows instead of being limited to
SSPI. I don't know for sure whether further tweaking will be needed
(to the UI, most likely, or to automatic selection of credentials),
but testing reports suggest it's now at least worth committing to
trunk to get it more widely tested.

[originally from svn r8952]
2010-05-19 18:22:17 +00:00
Simon Tatham 108791e15c Support importing of new-style OpenSSH private keys (encrypted by
AES rather than 3DES).

[originally from svn r8916]
2010-04-12 10:55:31 +00:00
Ben Harris 86c183f8e8 Mitigation for VU#958563: When using a CBC-mode server-to-client cipher
under SSH-2, don't risk looking at the length field of an incoming packet
until we've successfully MAC'ed the packet.

This requires a change to the MAC mechanics so that we can calculate MACs
incrementally, and output a MAC for the packet so far while still being
able to add more data to the packet later.

[originally from svn r8334]
2008-11-26 12:49:25 +00:00
Simon Tatham ca6fc3a4da Revamp of the local X11 connection code. We now parse X display
strings more rigorously, and then we look up the local X authority
data in .Xauthority _ourself_ rather than delegating to an external
xauth program. This is (negligibly) more efficient on Unix, assuming
I haven't got it wrong in some subtle way, but its major benefit is
that we can now support X authority lookups on Windows as well
provided the user points us at an appropriate X authority file in
the standard format. A new Windows-specific config option has been
added for this purpose.

[originally from svn r8305]
2008-11-17 18:38:09 +00:00
Simon Tatham 14d825d42f OS X Leopard, it turns out, has a new and exciting strategy for
addressing X displays. Update PuTTY's display-name-to-Unix-socket-
path translation code to cope with it, thus causing X forwarding to
start working again on Leopard.

[originally from svn r8020]
2008-05-28 19:23:57 +00:00
Ben Harris dad558a1e5 Add support for RFC 4432 RSA key exchange, the patch for which has been
lying around in my home directory for _years_.

[originally from svn r7496]
2007-04-30 22:09:26 +00:00
Jacob Nevins cd94e3bc3c Patch from Colin Watson intended to give a clean Unix compile with GCC 4.
(Since we choose to compile with -Werror, this is particularly important.)

I haven't yet checked that the resulting source actually compiles cleanly with
GCC 4, hence not marking `gcc4-warnings' as fixed just yet.

[originally from svn r7041]
2006-12-30 23:00:14 +00:00
Jacob Nevins 078c516a45 Dimitry Andric spotted that DH gex with SHA-256 was overflowing a buffer.
Fixed, and added paranoia so that this shouldn't happen again.

[originally from svn r6606]
[this svn revision also touched putty-wishlist]
2006-03-12 19:24:05 +00:00
Jacob Nevins 2cf27e43bb Log the hash used for DH kex (now there's a choice).
[originally from svn r6605]
2006-03-12 15:39:19 +00:00
Jacob Nevins c14f259ba2 Allow rsakey_pubblob() to return the key comment.
(like r6433 but for SSH-1)

[originally from svn r6434]
[r6433 == 49d2cf19ac]
2005-10-30 15:16:42 +00:00
Jacob Nevins 49d2cf19ac Add ability for ssh2_userkey_loadpub() to return the key comment.
(Not actually used currently, but it makes life easier for a patch I'm
working on.)

[originally from svn r6433]
2005-10-30 13:42:36 +00:00
Ben Harris c0d36aa00a Implement hmac-sha1-96. It's RECOMMENDED in the current transport draft,
and we don't have any strong reason not to implement it, for all that it's
rather pointless.

[originally from svn r6284]
2005-09-10 16:19:53 +00:00
Ben Harris a42d103cf9 Restructure things so that a single entry in the KEX preference list can
correspond to multiple SSH-2 KEX algorithms.  We already do the equivalent
for cipher algorithms.

[originally from svn r6262]
2005-09-03 13:41:43 +00:00
Ben Harris 8d0c333946 SHA-256 implementation, for use in future KEX algorithms, in particular
diffie-hellman-group-exchange-sha256, which the last DHGEX draft defined.
Code lifted from Simon's "crypto" directory, with changes to make it look
more like sshsh512.c.

[originally from svn r6252]
2005-08-31 21:48:22 +00:00
Ben Harris a59356aa74 Add infrastructure for supporting multiple hashes in key exchange.
Nothing very surprising here.

[originally from svn r6251]
2005-08-31 20:43:06 +00:00
Ben Harris 11d5c791ac Rename ssh_md5 and ssh_sha1 to ssh_hmac_md5 and ssh_hmac_sha1 respectively.
This is to make room for a hash abstraction that's likely to want to use
ssh_sha1, at least.

[originally from svn r6249]
2005-08-31 19:11:19 +00:00
Ben Harris f2b0335c48 Now that we've got at least some SDCTR modes working (and aes256-ctr is our
default preferred cipher), add code to inject SSH_MSG_IGNOREs to randomise
the IV when using CBC-mode ciphers.  Each cipher has a flag to indicate
whether it needs this workaround, and the SSH packet output maze has gained
some extra complexity to implement it.

[originally from svn r5659]
2005-04-23 16:22:51 +00:00
Ben Harris 09951c6078 Implement my experimental arcfour modes. The 256-bit version is disabled
until I can test it against someone else's implementation.

[originally from svn r5633]
2005-04-14 22:58:29 +00:00
Jacob Nevins 5aa719d16e Consistently use a single notation to refer to SSH protocol versions, as
discussed. Use Barrett and Silverman's convention of "SSH-1" for SSH protocol
version 1 and "SSH-2" for protocol 2 ("SSH1"/"SSH2" refer to ssh.com
implementations in this scheme). <http://www.snailbook.com/terms.html>

[originally from svn r5480]
2005-03-10 16:36:05 +00:00
Jacob Nevins bd6eadd196 Improvements to PuTTYgen error reporting:
- will now display a reason when it fails to load a key
 - uses existing error return from native keys
 - import.c had a lot of error descriptions which weren't going anywhere;
   since the strings are probably taking up space in the binary, we
   may as well use them

[originally from svn r5408]
2005-02-27 23:01:11 +00:00
Simon Tatham 5e2305bdc9 Owen tells me the Mac compiler complains at a char / unsigned char
mismatch in the invocation of hmacmd5_key(). Do it properly with a
void * argument.

[originally from svn r5117]
2005-01-16 14:02:56 +00:00
Simon Tatham 6daf6faede Integrate unfix.org's IPv6 patches up to level 10, with rather a lot
of polishing to bring them to what I think should in principle be
release quality. Unlike the unfix.org patches themselves, this
checkin enables IPv6 by default; if you want to leave it out, you
have to build with COMPAT=-DNO_IPV6.

I have tested that this compiles on Visual C 7 (so the nightlies
_should_ acquire IPv6 support without missing a beat), but since I
don't have IPv6 set up myself I haven't actually tested that it
_works_. It still seems to make correct IPv4 connections, but that's
all I've been able to verify for myself. Further testing is needed.

[originally from svn r5047]
[this svn revision also touched putty-wishlist]
2004-12-30 16:45:11 +00:00
Simon Tatham 81df0d4253 SSH port forwarding is now configurable in mid-session. After doing
Change Settings, the port forwarding setup function is run again,
and tags all existing port forwardings as `do not keep'. Then it
iterates through the config in the normal way; when it encounters a
port forwarding which is already in the tree, it tags it `keep'
rather than setting it up from scratch. Finally, it goes through the
tree and removes any that haven't been labelled `keep'. Hence,
editing the list of forwardings in Change Settings has the effect of
cancelling any forwardings you remove, and adding any new ones.

The SSH panel now appears in the reconfig box, and is empty apart
from a message explaining that it has to be there for subpanels of
it to exist. Better wording for this message would be welcome.

[originally from svn r5030]
2004-12-28 14:07:05 +00:00
Simon Tatham 56d5dc7eec Support diffie-hellman-group14-sha1 group exchange. Tested against
locally built OpenSSH 3.9, and seems to work fine.

[originally from svn r5018]
2004-12-22 10:53:58 +00:00
Jacob Nevins 98028c746f X forwarding changes:
- new function platform_get_x_display() to find a sensible local display.
   On Unix, the Gtk apps weren't taking account of --display when
   determining where to send forwarded X traffic.
 - explicitly document that leaving X display location blank in config tries
   to do something sensible (and that it's now blank by default)
 - don't override X11Display setting in plink, since that's more properly
   done later

[originally from svn r4604]
2004-10-06 22:31:07 +00:00
Jacob Nevins fb92f118bd Mention the negotiated SSH-2 MAC algorithm(s) in the Event Log.
(It should be possible to at least see what MAC is in use without going to a
SSH packet log.)

[originally from svn r4591]
2004-09-29 23:57:03 +00:00
Simon Tatham 3af7d33340 Malcolm Smith's patch to support CHAP (digest-based) authentication
when talking to SOCKS 5 proxies. Configures itself transparently (if
the proxy offers CHAP it will use it, otherwise it falls back to
ordinary cleartext passwords).

[originally from svn r4517]
2004-08-30 13:11:17 +00:00
Simon Tatham 4217269931 Merged SSH1 robustness changes from 0.55 release branch on to trunk.
[originally from svn r4379]
2004-08-01 12:07:11 +00:00
Simon Tatham a2acc6ae0d RJK's patch to enable PuTTY's X forwarding to connect to local X
servers using Unix sockets (on Unix only, obviously!).

[originally from svn r4263]
2004-05-31 14:01:52 +00:00
Simon Tatham 2d1287b9ca Added a command-line key generation tool. Currently builds and runs
on Linux, but the (very few) platform-specific bits are already
abstracted out of the main code, so it should port to other
platforms with a minimum of fuss.

[originally from svn r3762]
2004-01-22 19:15:32 +00:00
Jacob Nevins eebc7529ed Work towards wish `keyfile-diagnostic'. Many sshpubk.c keyfile-loading
functions have sprouted `**errorstr' arguments, which if non-NULL can
return a textual error message. The interface additions are patchy and
ad-hoc since this seemed to suit the style of the existing interfaces.

I've since realised that most of this is masked by sanity-checking that
gets done before these functions are called, but it will at least report
MAC failures and the like (tested on Unix), which was the original point
of the exercise.

Note that not everyone who could be using this information is at the
moment.

[originally from svn r3430]
2003-08-29 22:52:57 +00:00
Simon Tatham 06e6997a74 Rename crc32() to crc32_compute(), to avoid clashing catastrophically
with the crc32() function in the zlib interface. (Not that PuTTY
itself _uses_ zlib, but on Unix it's linked against libgtk which
uses libpng which uses zlib. And zlib has poor namespace management
so it defines this ridiculously intrusive function name. Arrrrgh.)

[originally from svn r3191]
2003-05-13 18:23:43 +00:00
Simon Tatham 6bb121ecb9 Colin's const-fixing Patch Of Death. Seems to build fine on Windows
as well as Unix, so it can go in.

[originally from svn r3162]
2003-05-04 14:18:18 +00:00
Simon Tatham afd4b4d662 Added framework to sshbn.c to make it possible to vary the
underlying integer type forming the Bignum. Using this, arranged
that gcc/x86 uses 32-bit chunks rather than the guaranteed ANSI-
portable 16-bit chunks. This has gained another 30% on key exchanges
by my measurements, but I'm not yet convinced that it's all
perfectly robust - it seems to work fine for SSH1 and SSH2/RSA but
I haven't ensured that every bignum routine is actually being
tested, so it may yet show up problems in DSA or key generation.

[originally from svn r3135]
2003-04-23 14:48:57 +00:00
Simon Tatham 8a3ff2bf3e Dynamic port forwarding by means of a local SOCKS server. Fully
supports SOCKS 4, SOCKS 4A and SOCKS 5 (well, actually IPv6 in SOCKS
5 isn't supported, but it'll be no difficulty once I actually get
round to it). Thanks to Chas Honton for his `stone soup' patch: I
didn't end up actually using any of his code, but it galvanised me
into doing it properly myself :-)

[originally from svn r3055]
2003-04-05 11:45:21 +00:00
Simon Tatham f26b7aa0d3 Created new data types `Filename' and `FontSpec', intended to be
opaque to all platform-independent modules and only handled within
per-platform code. `Filename' is there because the Mac has a magic
way to store filenames (though currently this checkin doesn't
support it!); `FontSpec' is there so that all the auxiliary stuff
such as font height and charset and so on which is needed under
Windows but not Unix can be kept where it belongs, and so that I can
have a hope in hell of dealing with a font chooser in the forthcoming
cross-platform config box code, and best of all it gets the horrid
font height wart out of settings.c and into the Windows code where
it should be.
The Mac part of this checkin is a bunch of random guesses which will
probably not quite compile, but which look roughly right to me.
Sorry if I screwed it up, Ben :-)

[originally from svn r2765]
2003-02-01 12:54:40 +00:00
Ben Harris 694aafa071 Add the ability to close sessions. This adds *_free() functions to most
areas of the code.  Not all back-ends have been tested, but Telnet and SSH
behave reasonably.

Incidentally, almost all of this patch was written through Mac PuTTY,
admittedly over a Telnet connection.

[originally from svn r2615]
2003-01-15 23:30:21 +00:00
Simon Tatham 952857fca3 proxy.c now no longer refers to `cfg'. Instead, each of the three
proxy-indirection network functions (name_lookup, new_connection,
new_listener) takes a `const Config *' as an argument, and extracts
enough information from it before returning to handle that
particular network operation in accordance with the proxy settings
it specifies. This involved {win,ux}net.c due to a `const'
repercussion.

[originally from svn r2567]
2003-01-12 15:26:10 +00:00
Simon Tatham 5ecbac2441 There's no real need for portfwd.c to reference `cfg' directly, when
it only needs one item from it and that can easily be passed in from
the call site in ssh.c.

[originally from svn r2564]
2003-01-12 14:56:19 +00:00
Simon Tatham fee1624c69 Support for XDM-AUTHORIZATION-1 at the SSH server end, making use of
the remote IP/port data provided by the server for forwarded
connections. Disabled by default, since it's incompatible with SSH2,
probably incompatible with some X clients, and tickles a bug in
at least one version of OpenSSH.

[originally from svn r2554]
2003-01-12 14:11:38 +00:00
Ben Harris 3aec19fa72 Move the prototype for platform_get_x11_auth() from x11fwd.c to ssh.h so that
it can be checked against the implementation.

[originally from svn r2542]
2003-01-11 14:20:00 +00:00
Simon Tatham 87f9446a26 Support XDM-AUTHORIZATION-1 for connecting to local X servers. If
we're going to be a security program, we can at least make a token
effort to use the most secure local X auth available! And I'm still
half-tempted to see if I can support it for remote X servers too...

[originally from svn r2537]
2003-01-11 09:31:54 +00:00
Simon Tatham 86977efa81 Introduce framework for authenticating with the local X server.
Windows and Mac backends have acquired auth-finding functions which
do nothing; Unix backend has acquired one which actually works, so
Plink can now do X forwarding believably.
(This checkin stretches into some unlikely parts of the code because
there have been one or two knock-on effects involving `const'. Bah.)

[originally from svn r2536]
2003-01-10 18:33:35 +00:00
Ben Harris a6c994ca94 Move prototypes for base64_decode_atom(), base64_lines(), and base64_encode()
from import.c to ssh.h, so that the implementation can see them.  This
necessitates ssh.h's including <stdio.h>.
Also remove a spare prototype for base64_encode_atom() from import.c.

[originally from svn r2481]
2003-01-05 23:28:02 +00:00
Ben Harris 3f055f22d8 Move x11fwd and portfwd prototypes from ssh.c into ssh.h so they can be seen
by (and checked against) the definitions.

[originally from svn r2474]
2003-01-05 22:53:23 +00:00
Simon Tatham 4756c15fc9 Yet more global-removal. The static variables in logging.c are now
absent, and also (I think) all the frontend request functions (such
as request_resize) take a context pointer, so that multiple windows
can be handled sensibly. I wouldn't swear to this, but I _think_
that only leaves the Unicode stuff as the last stubborn holdout.

[originally from svn r2147]
2002-10-26 12:58:13 +00:00
Simon Tatham 24530b945e Port forwarding module now passes backend handles around properly.
As a result I've now been able to turn the global variables `back'
and `backhandle' into module-level statics in the individual front
ends. Now _that's_ progress!

[originally from svn r2142]
2002-10-26 10:33:59 +00:00
Simon Tatham 5df8e45c2e The Zlib module now uses dynamically allocated contexts. I think
that completes the static-removal in the crypto library. Ooh.

[originally from svn r2136]
2002-10-25 13:26:33 +00:00
Simon Tatham db7196c174 Diffie-Hellman key exchange now uses a dynamically allocated context.
[originally from svn r2135]
2002-10-25 13:08:01 +00:00
Simon Tatham 107d1d875d SSH CRC attack detector now uses a dynamically allocated context.
[originally from svn r2132]
2002-10-25 12:58:21 +00:00
Simon Tatham 8f91f07599 SSH2 MACs now use dynamically allocated contexts.
[originally from svn r2131]
2002-10-25 12:51:28 +00:00
Simon Tatham 9848062b86 SSH ciphers now use dynamically allocated contexts.
[originally from svn r2130]
2002-10-25 12:35:22 +00:00
Simon Tatham 72ff571148 Major destabilisation, phase 2. This time it's the backends' turn:
each backend now stores all its internal variables in a big struct,
and each backend function gets a pointer to this struct passed to
it. This still isn't the end of the work - lots of subsidiary things
still use globals, notably all the cipher and compressor modules and
the X11 forwarding authentication stuff. But ssh.c itself has now
been transformed, and that was the really painful bit, so from here
on it all ought to be a sequence of much smaller and simpler pieces
of work.

[originally from svn r2127]
2002-10-25 11:30:33 +00:00
Simon Tatham ed29fdc91c Add some basic framework code preparatory to adding key export.
[originally from svn r1675]
2002-05-13 16:56:11 +00:00
Simon Tatham 9a8c58a64b Added a framework for importing foreign key formats, and implemented
importing of OpenSSH SSH2 private key files (both encrypted and
unencrypted). Seems to work fine.

[originally from svn r1668]
2002-05-11 16:45:29 +00:00
Simon Tatham 8c3a0eb50b Improved error messages if you use the wrong key type: you should
now be told that the key is the wrong type, _and_ what type it is,
rather than being given a blanket `unable to read key file' message.

[originally from svn r1662]
2002-05-11 12:13:42 +00:00
Simon Tatham d237773599 Add the CRC32 compensation attack detector that all other SSH
clients have had for ages and I forgot about. Of course I've got the
version with the buffer overflow fixed!

[originally from svn r1535]
2002-01-08 11:57:32 +00:00
Simon Tatham cf356a9a5f Pageant is now able to avoid asking for the passphrase when asked to
load a key that is already loaded. This makes command lines such as
`pageant mykey -c mycommand' almost infinitely more useful.

[originally from svn r1522]
2001-12-30 15:58:17 +00:00
Simon Tatham 6608016fc2 INCOMPATIBLE CHANGE to the SSH2 private key file format. There is
now a passphrase-keyed MAC covering _all_ important data in the
file, including the public blob and the key comment. Should
conclusively scupper any attacks based on nobbling the key file in
an attempt to sucker the machine that decrypts it. MACing the
comment field also protects against a key-substitution attack (if
someone's worked out a way past our DSA protections and can extract
the private key from a signature, swapping key files and
substituting comments might just enable them to get the signature
they need to do this. Paranoid, but might as well).

[originally from svn r1413]
2001-11-25 14:31:46 +00:00
Simon Tatham b49fde9410 Add single-DES support in SSH2
[originally from svn r1396]
2001-11-21 23:06:10 +00:00
Simon Tatham 5f096142a7 Remember to initialise p->nphases to zero in progress report structure.
[originally from svn r1378]
2001-11-12 09:19:57 +00:00
Simon Tatham d345ebc2a5 Add support for DSA authentication in SSH2, following clever ideas
on how to get round the problem of generating a good k.

[originally from svn r1284]
2001-09-22 20:52:21 +00:00
Simon Tatham abee2a59ab Cygwin build fixes: update the dependencies, add -DNO_SECURITY to
the Cygwin CFLAGS, and declare `struct ssh_channel' in ssh.h to
prevent gcc warning about scope-confined-to-parameter-list.

[originally from svn r1268]
2001-09-15 14:58:26 +00:00
Simon Tatham ff9a038cdd PSCP now uses the modern SFTP protocol if it can, and falls back to
scp1 if it can't. Currently not very tested - I checked it in as
soon as it completed a successful recursive copy in both directions.
Also, one known bug: you can't specify a remote wildcard, because by
the nature of SFTP we'll need to implement the wildcard engine on
the client side. I do intend to do this (and use the same wildcard
engine in PSFTP as well) but I haven't got round to it yet.

[originally from svn r1208]
2001-08-26 18:32:28 +00:00
Simon Tatham c87fa98d09 Extensive changes that _should_ fix the socket buffering problems,
by ceasing to listen on input channels if the corresponding output
channel isn't accepting data. Has had basic check-I-didn't-actually-
break-anything-too-badly testing, but hasn't been genuinely tested
in stress conditions (because concocting stress conditions is non-
trivial).

[originally from svn r1198]
2001-08-25 17:09:23 +00:00
Simon Tatham 50766ce729 SSH port forwarding! How cool is that?
Only currently works on SSH1; SSH2 should be doable but it's late
and I have other things to do tonight. The Cool Guy award for this
one goes to Nicolas Barry, for doing most of the work and actually
understanding the code he was adding to.

[originally from svn r1176]
2001-08-08 20:44:35 +00:00
Simon Tatham 3730ada5ce Run entire source base through GNU indent to tidy up the varying
coding styles of the various contributors! Woohoo!

[originally from svn r1098]
2001-05-06 14:35:20 +00:00
Simon Tatham 3abea3d4ea Having now compiled the last few days' changes with MSVC, it's turned
up a bunch of warnings, mostly unused variables. All fixed.

[originally from svn r1058]
2001-04-17 08:24:29 +00:00
Simon Tatham 522f130391 Pageant interface changes. You can now do `pageant -c command' to
spawn another command after starting Pageant. Also, if Pageant is
already running, `pageant keyfile' and `pageant -c command' will do
the Right Thing, that is, add the key to the _first_ Pageant and/or
run a command and then exit. The only time you now get the `Pageant
is already running' error is if you try to start the second copy
with no arguments.
NB the affected files in this checkin are rather wide-ranging
because I renamed the not really SSH1-specific
`ssh1_bignum_bitcount' function to just `bignum_bitcount'.

[originally from svn r1044]
2001-04-16 11:16:58 +00:00
Simon Tatham 3a78d9dd09 Fix a couple of silly compiler warnings
[originally from svn r1022]
2001-03-23 09:20:43 +00:00
Simon Tatham 080d59422b At long last: PuTTY will now report its version to the server
sensibly, as a release or a snapshot or a local build. With any luck
this should make bug reporting easier to handle, because anyone who
sends their Event Log should automatically include the version :-)

[originally from svn r1003]
2001-03-15 12:15:02 +00:00
Simon Tatham d823077f18 Add support for using Diffie-Hellman with short exponents (sshdh.c
contains a reference to a paper on the subject). Reduces time taken
for DH group exchange to the point where it's viable to enable it
all the time, so I have. :-)

[originally from svn r991]
2001-03-10 11:04:07 +00:00
Simon Tatham aaeecbb4ea Make the SSH2 traffic analysis defence robust in the face of Zlib
compression. This involves introducing an option to disable Zlib
compression (that is, continue to work within the Zlib format but
output an uncompressed block) for the duration of a single packet.

[originally from svn r982]
2001-03-05 16:38:42 +00:00
Simon Tatham 245cf9c8c9 SSH2 can now use Pageant to obtain keys from
[originally from svn r977]
2001-03-03 15:56:39 +00:00
Simon Tatham 1f168926d7 Add support for the OpenSSH SSH2 agent protocol.
[originally from svn r976]
2001-03-03 15:31:35 +00:00
Simon Tatham 28b1fc766c Preliminary support for RSA user authentication in SSH2! Most of the
error messages are currently wrong, and Pageant doesn't yet support
the new key type, and I haven't thoroughly tested that falling back
to password authentication and trying invalid keys etc all work. But
what I have here has successfully performed a public key
authentication, so it's working to at least some extent.

[originally from svn r973]
2001-03-03 11:54:34 +00:00
Simon Tatham b182356f99 Support for selecting AES from the GUI. In the process, I've had to
introduce another layer of abstraction in SSH2 ciphers, such that a
single `logical cipher' (as desired by a user) can equate to more
than one `physical cipher'. This is because AES comes in several key
lengths (PuTTY will pick the highest supported by the remote end)
and several different SSH2-protocol-level names (aes*-cbc,
rijndael*-cbc, and an unofficial one rijndael-cbc@lysator.liu.se).

[originally from svn r967]
2001-03-02 13:55:23 +00:00
Simon Tatham cc9d7ba87e Diffie-Hellman group exchange in SSH2. Currently #ifdeffed out
(change the sense of #ifdef DO_DIFFIE_HELLMAN_GEX in ssh.c) because
it's _far_ too slow. Will be re-enabled once the bignum routines
work a bit faster (or rather a _lot_ faster).

[originally from svn r962]
2001-03-01 17:55:40 +00:00
Simon Tatham 862d6a496d Add a key length indication to each SSH2 cipher structure, in
preparation for needing to know how much key material each cipher
needs in order to select a suitable Diffie-Hellman group.

[originally from svn r961]
2001-03-01 17:45:31 +00:00
Simon Tatham f72b5aa95f Remove the last lingering knowledge, outside sshbn.c, of the
internal structure of the Bignum type. Bignum is now a fully opaque
type unless you're inside sshbn.c.

[originally from svn r960]
2001-03-01 17:41:26 +00:00
Simon Tatham d5240d4157 Make memory management uniform: _everything_ now goes through the
smalloc() macros and thence to the safemalloc() functions in misc.c.
This should allow me to plug in a debugging allocator and track
memory leaks and segfaults and things.

[originally from svn r818]
2000-12-12 10:33:13 +00:00
Simon Tatham 8eca227b92 Improve SSH2 host key abstraction into a generic `signing key'
abstraction, so as to be able to re-use the same abstraction for
user authentication keys and probably in the SSH2 agent (when that
happens) as well.

[originally from svn r815]
2000-12-02 12:48:15 +00:00
Simon Tatham 462063cdc5 Implement Zlib compression, in both SSH1 and SSH2.
[originally from svn r792]
2000-11-01 21:34:21 +00:00
Simon Tatham e51b4da9f7 Make the frankly ridiculous prototypes for modpow() and modmul() more sane
[originally from svn r752]
2000-10-23 16:11:31 +00:00
Simon Tatham 8d0bee8629 PuTTYgen initial version. Still to do are basic user-friendliness
features (prompt for passphrase twice, prompt before overwriting a
file, check the key file was actually saved OK), testing of the
generated keys to make sure I got the file format right, and support
for a variable key size. I think what's already here is basically
sound though.

[originally from svn r715]
2000-10-19 15:43:08 +00:00
Simon Tatham 8e7a270f7f Miscellaneous cleanups and reorgs in preparation for building
PuTTYgen. In particular, moved self-managing controls stuff out of
windlg.c into the new and reusable winctrls.c.

[originally from svn r714]
2000-10-18 15:36:32 +00:00
Simon Tatham e41344c544 RSA key generation routines, and the bignum enhancements required to
support them. A key generation tool will be forthcoming soon.

[originally from svn r712]
2000-10-18 15:00:36 +00:00
Simon Tatham aad0a52dfb Rationalised host key storage. Also started code reorg: persistent-state
routines have been moved out into a replaceable module winstore.c.

[originally from svn r639]
2000-09-27 15:21:04 +00:00
Simon Tatham 355cdbd5e8 Implement OpenSSH-compatible RSA key fingerprints and use them throughout
[originally from svn r637]
2000-09-26 14:26:21 +00:00
Simon Tatham 673f2e48a7 Rationalise ordering of authentication operations. Still some work to do,
but at least pscp no longer hangs when prompting for a passphrase

[originally from svn r621]
2000-09-25 10:14:53 +00:00
Simon Tatham c366174cc2 Added Pageant, a first-attempt PuTTY authentication agent
[originally from svn r589]
2000-09-14 15:02:50 +00:00
Simon Tatham d9af8f4b90 RSA key authentication in ssh1 works; SSH2 is nearly there
[originally from svn r572]
2000-09-07 16:33:49 +00:00
Simon Tatham 36a499a7f1 Second attempt. Can successfully decrypt the _first block_ of a packet.
[originally from svn r570]
2000-09-05 16:23:36 +00:00
Simon Tatham 35205e5cb7 SSH 2 support, phase 1, debugging. Currently does Diffie-Hellman and gets
the same results as the server, which is a pretty good start.

[originally from svn r569]
2000-09-05 14:28:17 +00:00
Simon Tatham 300b778092 Oops - now let's get that MD5 change _right_ :-)
[originally from svn r438]
2000-04-04 14:51:17 +00:00
Simon Tatham 50b0f49eaf Replace MD5 implementation with my own code
[originally from svn r437]
2000-04-04 14:47:22 +00:00
Simon Tatham 9922072a8d Peter Schellenbach's patch: re-implement the PuTTY cryptographic
functions as calls to the MS Crypto API. Not integrated into the
Makefile yet, but should eventually allow building of an SSH-enabled
PuTTY which contains no native crypto code, so it can be used
everywhere (and anyone who can get the MS encryption pack can still
use the SSH parts).

[originally from svn r425]
2000-03-24 09:45:49 +00:00
Simon Tatham fe500c4d01 New CRC32 implementation, from scratch, not copyrighted by somebody else!
Removed Gary S Brown's name from copyrights. Only Eric Young's DES left :-)

[originally from svn r397]
2000-03-08 16:13:32 +00:00
Simon Tatham f6c63320ea Changes from executor:
- NetHack keypad mode (Shift only works with NumLock off)
 - Alt-Space handling (best I could manage; not too bad considering)
 - Event Log rather than Telnet Negotiation Log

[originally from svn r284]
1999-11-09 11:10:04 +00:00
Simon Tatham 2d6fcb0a7a Single-DES encryption, patch courtesy of Murphy Lam
[originally from svn r253]
1999-10-25 08:59:40 +00:00
Simon Tatham 585c14f365 Add encryption selection, and Blowfish as second option
[originally from svn r175]
1999-07-06 19:42:57 +00:00
Simon Tatham 60ab6a5d82 John Sullivan's patches plus more fixes:
- Stop using the identifier `environ' as some platforms make it a macro
  - Fix silly error box at end of connection in FWHACK mode
  - Fix GPF on maximise-then-restore
  - Use SetCapture to allow drag-selecting outside the window
  - Correctly update window title when iconic and in win_name_always mode

[originally from svn r12]
1999-01-08 13:10:19 +00:00
Simon Tatham c74130d423 Initial checkin: beta 0.43
[originally from svn r11]
1999-01-08 13:02:13 +00:00