Skip to content
Snippets Groups Projects
  1. Aug 04, 2020
    • Simon Tatham's avatar
      New script contrib/plinkfs. · 334d8725
      Simon Tatham authored
      This is a small wrapper on 'sshfs' which allows it to use Plink as its
      transport. Mostly useful for when I've already got a PuTTY session
      open to a given host with connection sharing enabled, and want to
      tunnel over that rather than painstakingly re-establishing a separate
      connection.
      334d8725
  2. Jun 14, 2020
    • Simon Tatham's avatar
      kh2reg: stop using deprecated base64.decodestring. · fade8e81
      Simon Tatham authored
      Python 3 gave me a warning that I should have been using decodebytes
      instead.
      
      (cherry picked from commit 1efded20)
      fade8e81
    • Simon Tatham's avatar
      kh2reg: fix Python 3 iterator bug with multiple hostnames. · ee26ab86
      Simon Tatham authored
      A known_hosts line can have multiple comma-separated hostnames on it,
      or more usually a hostname and an IP address.
      
      In the RSA and DSA key handlers, I was making a list of the integer
      parameters of the public key by using the 'map' function, and then
      iterating over it once per hostname on the line. But in Python 3, the
      'map' function returns an iterator, not a list, so after you've
      iterated to its end once, it's empty, and iterating over it a second
      time stops immediately. As a result, the registry line for the second
      hostname was coming out empty.
      
      (cherry picked from commit 143f8a2d)
      ee26ab86
  3. Mar 09, 2020
    • Simon Tatham's avatar
      kh2reg: stop using deprecated base64.decodestring. · 1efded20
      Simon Tatham authored
      Python 3 gave me a warning that I should have been using decodebytes
      instead.
      1efded20
    • Simon Tatham's avatar
      kh2reg: fix Python 3 iterator bug with multiple hostnames. · 143f8a2d
      Simon Tatham authored
      A known_hosts line can have multiple comma-separated hostnames on it,
      or more usually a hostname and an IP address.
      
      In the RSA and DSA key handlers, I was making a list of the integer
      parameters of the public key by using the 'map' function, and then
      iterating over it once per hostname on the line. But in Python 3, the
      'map' function returns an iterator, not a list, so after you've
      iterated to its end once, it's empty, and iterating over it a second
      time stops immediately. As a result, the registry line for the second
      hostname was coming out empty.
      143f8a2d
  4. Mar 04, 2020
    • Simon Tatham's avatar
      Migrate all Python scripts to Python 3. · 2ec2b796
      Simon Tatham authored
      Most of them are now _mandatory_ P3 scripts, because I'm tired of
      maintaining everything to be compatible with both versions.
      
      The current exceptions are gdb.py (which has to live with whatever gdb
      gives it), and kh2reg.py (which is actually designed for other people
      to use, and some of them might still be stuck on P2 for the moment).
      2ec2b796
  5. Mar 02, 2020
    • Simon Tatham's avatar
      Support the new "ssh-ed448" key type. · a085acba
      Simon Tatham authored
      This is standardised by RFC 8709 at SHOULD level, and for us it's not
      too difficult (because we use general-purpose elliptic-curve code). So
      let's be up to date for a change, and add it.
      
      This implementation uses all the formats defined in the RFC. But we
      also have to choose a wire format for the public+private key blob sent
      to an agent, and since the OpenSSH agent protocol is the de facto
      standard but not (yet?) handled by the IETF, OpenSSH themselves get to
      say what the format for a key should or shouldn't be. So if they don't
      support a particular key method, what do you do?
      
      I checked with them, and they agreed that there's an obviously right
      format for Ed448 keys, which is to do them exactly like Ed25519 except
      that you have a 57-byte string everywhere Ed25519 had a 32-byte
      string. So I've done that.
      a085acba
  6. Sep 08, 2019
    • Simon Tatham's avatar
      Whitespace rationalisation of entire code base. · 5d718ef6
      Simon Tatham authored
      The number of people has been steadily increasing who read our source
      code with an editor that thinks tab stops are 4 spaces apart, as
      opposed to the traditional tty-derived 8 that the PuTTY code expects.
      
      So I've been wondering for ages about just fixing it, and switching to
      a spaces-only policy throughout the code. And I recently found out
      about 'git blame -w', which should make this change not too disruptive
      for the purposes of source-control archaeology; so perhaps now is the
      time.
      
      While I'm at it, I've also taken the opportunity to remove all the
      trailing spaces from source lines (on the basis that git dislikes
      them, and is the only thing that seems to have a strong opinion one
      way or the other).
          
      Apologies to anyone downstream of this code who has complicated patch
      sets to rebase past this change. I don't intend it to be needed again.
      5d718ef6
  7. Apr 21, 2019
  8. Jan 25, 2019
    • Simon Tatham's avatar
      Replace all uses of Perl <> with <<>>. · 98cb60ef
      Simon Tatham authored
      I've only just found out that it has the effect of treating the argv
      words not as plain filenames, but as arguments to Perl default 'open',
      i.e. if they end in | then the text before that is treated as a
      command. That's not what was intended in any of these contexts!
      
      Fortunately, in this project it only comes up in non-critical
      'contrib' scripts.
      98cb60ef
  9. Jan 03, 2019
    • Simon Tatham's avatar
      Move eccref.py into the test directory. · c3ae739e
      Simon Tatham authored
      The test suite I'm writing for ecc.c will live in that directory and
      want to use it to check answers.
      c3ae739e
    • Simon Tatham's avatar
      Fix two misstatements of the Montgomery curve equation. · 992f98d5
      Simon Tatham authored
      I got it right in all the serious code (or else my Curve25519 key
      exchange wouldn't have worked), but I wrote it down wrongly in the
      comment in ecc.h, putting the coefficient b on the RHS x term rather
      than the LHS y^2. Then I repeated the same error in the point
      decompression function in eccref.py.
      992f98d5
  10. Dec 31, 2018
    • Simon Tatham's avatar
      Complete rewrite of PuTTY's bignum library. · 25b034ee
      Simon Tatham authored
      The old 'Bignum' data type is gone completely, and so is sshbn.c. In
      its place is a new thing called 'mp_int', handled by an entirely new
      library module mpint.c, with API differences both large and small.
      
      The main aim of this change is that the new library should be free of
      timing- and cache-related side channels. I've written the code so that
      it _should_ - assuming I haven't made any mistakes - do all of its
      work without either control flow or memory addressing depending on the
      data words of the input numbers. (Though, being an _arbitrary_
      precision library, it does have to at least depend on the sizes of the
      numbers - but there's a 'formal' size that can vary separately from
      the actual magnitude of the represented integer, so if you want to
      keep it secret that your number is actually small, it should work fine
      to have a very long mp_int and just happen to store 23 in it.) So I've
      done all my conditionalisation by means of computing both answers and
      doing bit-masking to swap the right one into place, and all loops over
      the words of an mp_int go up to the formal size rather than the actual
      size.
      
      I haven't actually tested the constant-time property in any rigorous
      way yet (I'm still considering the best way to do it). But this code
      is surely at the very least a big improvement on the old version, even
      if I later find a few more things to fix.
      
      I've also completely rewritten the low-level elliptic curve arithmetic
      from sshecc.c; the new ecc.c is closer to being an adjunct of mpint.c
      than it is to the SSH end of the code. The new elliptic curve code
      keeps all coordinates in Montgomery-multiplication transformed form to
      speed up all the multiplications mod the same prime, and only converts
      them back when you ask for the affine coordinates. Also, I adopted
      extended coordinates for the Edwards curve implementation.
      
      sshecc.c has also had a near-total rewrite in the course of switching
      it over to the new system. While I was there, I've separated ECDSA and
      EdDSA more completely - they now have separate vtables, instead of a
      single vtable in which nearly every function had a big if statement in
      it - and also made the externally exposed types for an ECDSA key and
      an ECDH context different.
      
      A minor new feature: since the new arithmetic code includes a modular
      square root function, we can now support the compressed point
      representation for the NIST curves. We seem to have been getting along
      fine without that so far, but it seemed a shame not to put it in,
      since it was suddenly easy.
      
      In sshrsa.c, one major change is that I've removed the RSA blinding
      step in rsa_privkey_op, in which we randomise the ciphertext before
      doing the decryption. The purpose of that was to avoid timing leaks
      giving away the plaintext - but the new arithmetic code should take
      that in its stride in the course of also being careful enough to avoid
      leaking the _private key_, which RSA blinding had no way to do
      anything about in any case.
      
      Apart from those specific points, most of the rest of the changes are
      more or less mechanical, just changing type names and translating code
      into the new API.
      25b034ee
  11. Nov 16, 2018
    • Simon Tatham's avatar
      gdb.py: support functions for container_of and tree234. · 4262ce45
      Simon Tatham authored
      The gdb version of container_of can do better than the C function,
      because you don't have to specify the structure field name if it can
      be inferred from the type of the input expression.
      
      And $list234 can be made to automatically list the contents of each
      tree element, not just a pointer to it - just the thing for looking
      quickly through sktree or s->channels to find the one you're after.
      4262ce45
  12. Nov 03, 2018
    • Simon Tatham's avatar
      Adopt C99 <stdbool.h>'s true/false. · a6f1709c
      Simon Tatham authored
      This commit includes <stdbool.h> from defs.h and deletes my
      traditional definitions of TRUE and FALSE, but other than that, it's a
      100% mechanical search-and-replace transforming all uses of TRUE and
      FALSE into the C99-standardised lowercase spellings.
      
      No actual types are changed in this commit; that will come next. This
      is just getting the noise out of the way, so that subsequent commits
      can have a higher proportion of signal.
      a6f1709c
  13. Oct 06, 2018
  14. Oct 04, 2018
    • Simon Tatham's avatar
      Get rid of lots of implicit pointer types. · 96ec2c25
      Simon Tatham authored
      All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
      describe structure types themselves rather than pointers to them. The
      same goes for the codebase-wide trait types Socket and Plug, and the
      supporting types SockAddr and Pinger.
      
      All those things that were typedefed as pointers are older types; the
      newer ones have the explicit * at the point of use, because that's
      what I now seem to be preferring. But whichever one of those is
      better, inconsistently using a mixture of the two styles is worse, so
      let's make everything consistent.
      
      A few types are still implicitly pointers, such as Bignum and some of
      the GSSAPI types; generally this is either because they have to be
      void *, or because they're typedefed differently on different
      platforms and aren't always pointers at all. Can't be helped. But I've
      got rid of the main ones, at least.
      96ec2c25
  15. Jun 09, 2018
    • Simon Tatham's avatar
      gdb.py: add a 'memdump' command. · 734ada9b
      Simon Tatham authored
      This makes it easier for me to examine the contents of binary memory
      buffers, while debugging through code that does crypto or packet
      marshalling.
      734ada9b
  16. Jun 04, 2018
    • Simon Tatham's avatar
      Add a GDB Python script to pretty-print Bignum. · 10a4f115
      Simon Tatham authored
      I've been playing around with GDB's Python scripting system recently,
      and this is a thing I've always thought it would be nice to be able to
      do: if you load this script (which, on Ubuntu 18.04's gdb, is as
      simple as 'source contrib/gdb.py' at the gdb prompt, or similar), then
      variables of type Bignum will be printed as (e.g.) 'Bignum(0x12345)',
      or 'Bignum(NULL)' if they're null pointers, or a fallback
      representation if they're non-null pointers but gdb can't read
      anything sensible from them.
      10a4f115
  17. May 26, 2018
    • Simon Tatham's avatar
      Make lots of generic data parameters into 'void *'. · 7babe66a
      Simon Tatham authored
      This is a cleanup I started to notice a need for during the BinarySink
      work. It removes a lot of faffing about casting things to char * or
      unsigned char * so that some API will accept them, even though lots of
      such APIs really take a plain 'block of raw binary data' argument and
      don't care what C thinks the signedness of that data might be - they
      may well reinterpret it back and forth internally.
      
      So I've tried to arrange for all the function call APIs that ought to
      have a void * (or const void *) to have one, and those that need to do
      pointer arithmetic on the parameter internally can cast it back at the
      top of the function. That saves endless ad-hoc casts at the call
      sites.
      7babe66a
  18. Apr 26, 2018
  19. Apr 11, 2018
    • Simon Tatham's avatar
      logparse.pl: fix a Perl warning. · f41d3650
      Simon Tatham authored
      Used the wrong kind of brackets when initialising the actual hash (as
      opposed to hash ref) %disc_reasons. Not sure how I didn't notice the
      warning in yesterday's testing!
      f41d3650
  20. Apr 10, 2018
    • Simon Tatham's avatar
      logparse.pl: document the -e option. · 4989447e
      Simon Tatham authored
      I'm increasingly wishing I'd written this parsing program in Python,
      and yet another reason why is that using argparse for the command-line
      handling makes it a lot harder to forget to write the --help text when
      you add an extra option.
      4989447e
  21. Apr 09, 2018
    • Simon Tatham's avatar
      logparse.pl: option to pass through Event Log entries. · 44dc5168
      Simon Tatham authored
      This makes it more feasible to use logparse.pl as an output filter on
      a PuTTY SSH log file and discard the original file.
      
      In particular, ever since commit b4fde270, I've been finding it
      useful when testing new code to direct my SSH logs to a named pipe and
      have another terminal window give a real-time dump of them by running
      'while cat $named_pipe; do :; done'. Now I can replace the 'cat' in
      that shell command with 'logparse.pl -ve' and still get the Event Log
      messages as well as the unpacked contents of all the packets.
      44dc5168
    • Simon Tatham's avatar
      logparse.pl: add verbose dumping for transport protocol. · ec29d354
      Simon Tatham authored
      This includes picking apart the various asymmetric crypto formats
      (public keys, signatures, elliptic-curve point encodings) as far as
      possible, but since the verbose decoder system in logparse.pl
      currently has to work without benefit of statefulness, it's not always
      possible - some of the ECC formats depend for their decoding on
      everyone remembering _which_ ECC protocol was negotiated by the
      KEXINITs.
      ec29d354
  22. Apr 05, 2018
    • Simon Tatham's avatar
      logparse.pl: fix a thinko in &parse. · e090e551
      Simon Tatham authored
      The type code for an mpint in the input format string is "m", not
      "mpint". This hasn't come up yet as far as I can see, but as and when
      I add verbose dump routines for packet types that involve asymmetric
      crypto, it will.
      e090e551
    • Simon Tatham's avatar
      logparse.pl: add a verbose dump system. · 48625ece
      Simon Tatham authored
      This allows me to request a verbose dump of the contents of some
      particular packet type, or for all packet types.
      
      Currently, the only packet type for which I've written a verbose dump
      function is KEXINIT, but the framework is there to add further verbose
      dumpers as and when they're needed.
      48625ece
    • Simon Tatham's avatar
      logparse.pl: more sensible option-parsing. · 20478008
      Simon Tatham authored
      Switched to Getopt::Long in place of the previous ad-hockery, which
      will make it easier to add more (and more complicated) options.
      20478008
  23. May 07, 2017
  24. Apr 08, 2017
    • Simon Tatham's avatar
      Fix bug in Poly1305 bigval_final_reduce(). · d2653e79
      Simon Tatham authored
      Mark Wooding pointed out that my comment in make1305.py was completely
      wrong, and that the stated strategy for reducing a value mod 2^130-5
      would not in fact completely reduce all inputs in the range - for the
      most obvious reason, namely that the numbers between 2^130-5 and 2^130
      would never have anything subtracted at all.
      
      Implemented a replacement strategy which my tests suggest will do the
      right thing for all numbers in the expected range that are anywhere
      near an integer multiple of the modulus.
      d2653e79
  25. Mar 17, 2017
  26. Sep 19, 2016
  27. May 03, 2016
    • Simon Tatham's avatar
      Rework samplekex.py to use the new -proxycmd. · cc9d920c
      Simon Tatham authored
      It now expects its standard input to be connected to the same PuTTY
      its standard output is talking to, i.e. expects to be invoked as a
      proxy command. It conducts the same sample key exchange as it used to,
      but now reads the SSH greeting and first couple of packets back from
      PuTTY and minimally checks that they're something like what it was
      expecting.
      
      (In the process, I've also fixed a mistake in the Python message code
      enumeration, which caused one of those expect() calls to fail.)
      cc9d920c
  28. Mar 25, 2016
Loading