Skip to content
Snippets Groups Projects
  1. Mar 13, 2021
    • Simon Tatham's avatar
      cmdgen: support configurable key fingerprint type. · ef5540c1
      Simon Tatham authored
      I've added the -E option, similar to ssh-keygen's, and cgtest checks
      it against the OpenSSH version to ensure they match.
      ef5540c1
    • Simon Tatham's avatar
      Introduce OpenSSH-compatible SHA256 key fingerprinting. · 1da353e6
      Simon Tatham authored
      There's a new enumeration of fingerprint types, and you tell
      ssh2_fingerprint() or ssh2_fingerprint_blob() which of them to use.
      
      So far, this is only implemented behind the scenes, and exposed for
      testcrypt to test. All the call sites of ssh2_fingerprint pass a fixed
      default fptype, which is still set to the old MD5. That will change
      shortly.
      1da353e6
    • Simon Tatham's avatar
      Console host key prompt: accept 'q' for 'abandon'. · 0bc78dea
      Simon Tatham authored
      During testing just now, I found I kept absentmindedly expecting it to
      work, and I don't see any reason I shouldn't indulge that expectation.
      0bc78dea
    • Simon Tatham's avatar
      uxcons: add some missing postmsg(). · cb4f78e6
      Simon Tatham authored
      These would have left the terminal in the wrong termios state, if a
      batch-mode Plink was run from a terminal and had to abort the
      connection due to a weak crypto primitive.
      cb4f78e6
    • Simon Tatham's avatar
      Factor out some common code in {ux,win}cons.c. · 3c6ab5bb
      Simon Tatham authored
      The assorted host-key and warning prompt messages have no reason to
      differ between the two platforms, so let's centralise them. Also,
      while I'm here, some basic support functions that are the same in both
      modules.
      3c6ab5bb
    • Simon Tatham's avatar
      Windows: new custom host-key verification dialogs. · 670f9d86
      Simon Tatham authored
      I've replaced the old versions using the standard MessageBox with new
      versions using custom-drawn dialog templates and dialog procedures.
      
      The visible changes are that the acceptance buttons have custom text
      describing the actions they'll take, like the GTK versions, instead of
      having to stick with bog-standard "Yes" and "No" and hope the user
      reads the explanation in the main box text.
      
      Also, this gives me the opportunity to spiff up the looks a bit, by
      making the "POTENTIAL SECURITY BREACH" in the wrong-host-key dialog
      larger and boldface.
      
      But those are minor cosmetic side effects of my real purpose, which is
      to make it possible to add further controls to these boxes in future.
      670f9d86
  2. Mar 08, 2021
    • Simon Tatham's avatar
      Make pterm's default window title more sensible. · ca48e204
      Simon Tatham authored
      In the rework last month, term_setup_window_titles made a centralised
      decision about whether to make the default window title just the
      application name, or the hostname and application name separated by a
      dash. Unfortunately it based that decision on whether the hostname was
      NULL, whereas I'd meant to include a _empty_ hostname as not worth
      printing.
      
      As a result, the default window title for pterm became " - pterm", not
      just "pterm". Easily fixed.
      ca48e204
  3. Mar 06, 2021
  4. Mar 04, 2021
  5. Feb 28, 2021
    • Simon Tatham's avatar
      Remove border on Windows GUI About box. · cc6ab00b
      Simon Tatham authored
      The About text is in a readonly edit control rather than a static
      control, so that it can be copy-pasted. Previously, I haven't managed
      to avoid the side effect of the edit control being surrounded by a
      border - but now I've finally found out how you can do it: clear all
      the border styles and _then_ use SetWindowPos to force a redraw of the
      frame.
      cc6ab00b
  6. Feb 23, 2021
    • Simon Tatham's avatar
      PuTTYgen: option to control Argon2 flavour. · c289ad36
      Simon Tatham authored
      I left this out of yesterday's collection of cmdgen CLI options and
      GUI PuTTYgen dialog box, but only because I forgot about it. I don't
      know off the top of my head why someone would particularly want to
      configure this detail, but given that it _is_ configurable, it seems
      like no extra trouble to expose it along with the rest of the
      parameters, just in case.
      c289ad36
    • Simon Tatham's avatar
      Fix cgtest again. · ee6b0724
      Simon Tatham authored
      When I added the fmt_version field to ppk_save_parameters, I forgot to
      fill it in in the special version of that struct used by cgtest.
      Without that, it defaulted to 0, triggering an assertion failure.
      ee6b0724
  7. Feb 22, 2021
    • Simon Tatham's avatar
      Windows PuTTYgen: configurable PPK save parameters. · c10aff8a
      Simon Tatham authored
      The GUI key generator doesn't need a --reencrypt option, because you
      can already just click Load and then Save without changing anything in
      between. But it does need a dialog box with all the fiddly Argon2
      settings in it, plus a setting to go back to PPK v2.
      c10aff8a
    • Simon Tatham's avatar
      cmdgen: command-line control of PPK save parameters. · 117cee8e
      Simon Tatham authored
      This allows you to manually adjust the Argon2 parameters so that you
      can trade off CPU requirements in legitimate use against difficulty of
      brute-force attack. It also allows downgrading the key file version
      back to the widespread PPK v2, so you can manually back-port a key
      that you accidentally generated too new.
      117cee8e
    • Simon Tatham's avatar
      cmdgen: add a --reencrypt option. · b8f3fc4b
      Simon Tatham authored
      This allows you to load and save the same key without making any
      semantic changes to it. Currently, you can only do that by pretending
      to make a change, like changing the passphrase or the comment to the
      same thing it was before.
      
      With two key file formats now supported, and a bunch of reconfigurable
      parameters in the v3 key derivation, it's now more likely that you'd
      want to re-encrypt the same key in a different way, to upgrade or
      downgrade or tinker with it. (Or perhaps even just re-randomise the
      salt, so that someone reading the key file doesn't know _whether_
      you've changed the passphrase!)
      b8f3fc4b
    • Simon Tatham's avatar
      Restore the ability to write out PPK v2. · e9aa28fe
      Simon Tatham authored
      This commit adds the capability in principle to ppk_save_sb, by adding
      a fmt_version field in the save parameters structure. As yet it's not
      connected up to any user interface in PuTTYgen, but I think I'll need
      to, because currently there's no way at all to convert PPK v3 back to
      v2, and surely people will need to interoperate with older
      installations of PuTTY, or with other PPK-consuming software.
      e9aa28fe
    • Jacob Nevins's avatar
      Fix typo in application description. · 66983e24
      Jacob Nevins authored
      66983e24
  8. Feb 21, 2021
    • Jacob Nevins's avatar
      Remove NULL initialisers in BackendVtables. · ad3c907a
      Jacob Nevins authored
      Backends were inconsistent about whether unused function members were
      explicitly initialised to NULL or it was left to implicit static
      initialisation. Standardise on the latter. No intended functional change.
      ad3c907a
    • Simon Tatham's avatar
      Fix determinism failures in cgtest. · 8eb4cd56
      Simon Tatham authored
      Thanks to Pavel and his CI for pointing out what I'd forgotten: the
      automated test of cmdgen.c expects that round-tripping a PPK file to
      some other format and back will regenerate the identical file. Of
      course, with a randomised salt in the new-look password hash, that
      isn't true any more in normal usage.
      
      Fixed by adding an option in the existing parameters structure to
      provide a salt override. That shouldn't be used anywhere except
      cgtest, but in cgtest, it restores the determinism we need.
      
      Another potential (but not guaranteed) source of difference is the
      automatic time-scaling of the Argon2 parameter choice. So I've turned
      that off too, while I'm at it.
      8eb4cd56
    • Jacob Nevins's avatar
      Document new backend command-line options. · 342972ee
      Jacob Nevins authored
      (-supdup and -ssh-connection. The latter concept still needs more
      documentation.)
      342972ee
    • Jacob Nevins's avatar
      Tweaks to SUPDUP documentation. · 557164b0
      Jacob Nevins authored
      Including noting that it can't be used with Plink, and better indexing.
      557164b0
    • Jacob Nevins's avatar
      Fix Plink-doesn't-support-SUPDUP messages. · 9492c9dd
      Jacob Nevins authored
      It's the backend that needs terminal emulation, not Plink.
      9492c9dd
    • Jacob Nevins's avatar
      Mention any extant downstreams in close warning. · 0ec45782
      Jacob Nevins authored
      Suggested by Brian Rak.
      0ec45782
    • Simon Tatham's avatar
      Fix premature exit if 'plink -shareexists' happens early. · a8599556
      Simon Tatham authored
      A user reported a phenomenon where running 'plink -shareexists' very
      early in the connection would cause the receiving upstream PuTTY to
      exit cleanly with the message 'All channels closed' in the log.
      
      That wasn't hard to track down: that happens as a result of the
      connection layer callback sharing_no_more_downstreams(), which causes
      the connection layer to check whether it has any channels left open,
      and if not, to terminate the connection on the grounds that everything
      has finished. But it's premature to draw that conclusion if the reason
      no channels are open if we haven't _started_ yet! Now we have a
      'started' flag which is set when we initialise mainchan, and the
      'we're all done now' check will never fire before that flag is set.
      
      But in the course of investigating that, I found a second problem in
      the same area: at an even earlier stage of an SSH connection, the
      connshare system doesn't _even_ have the real ConnectionLayer pointer
      yet. Instead, it has a pointer to a dummy one provided by the
      top-level ssh.c, which contains a NULL vtable pointer. So if it calls
      sharing_no_more_downstreams on _that_ ConnectionLayer, it will
      dereference NULL and crash. So I've filled in cl_dummy's vtable
      pointer with a trivial vtable, containing only the one callback
      sharing_no_more_downstreams, which itself is a no-op function.
      
      Hopefully that should all be stable now.
      a8599556
    • Simon Tatham's avatar
      Fix embarrassing goof in memxor at low sizes. · f47e351c
      Simon Tatham authored
      Ahem. Called with size < 16, that could have underrun the internal
      counter and looped over all of memory. Fortunately I've so far only
      used it for 1024 bytes at a time!
      f47e351c
  9. Feb 20, 2021
    • Simon Tatham's avatar
      Introduce PPK file format version 3. · 08d17140
      Simon Tatham authored
      This removes both uses of SHA-1 in the file format: it was used as the
      MAC protecting the key file against tamperproofing, and also used in
      the key derivation step that converted the user's passphrase to cipher
      and MAC keys.
      
      The MAC is simply upgraded from HMAC-SHA-1 to HMAC-SHA-256; it is
      otherwise unchanged in how it's applied (in particular, to what data).
      
      The key derivation is totally reworked, to be based on Argon2, which
      I've just added to the code base. This should make stolen encrypted
      key files more resistant to brute-force attack.
      
      Argon2 has assorted configurable parameters for memory and CPU usage;
      the new key format includes all those parameters. So there's no reason
      we can't have them under user control, if a user wants to be
      particularly vigorous or particularly lightweight with their own key
      files. They could even switch to one of the other flavours of Argon2,
      if they thought side channels were an especially large or small risk
      in their particular environment. In this commit I haven't added any UI
      for controlling that kind of thing, but the PPK loading function is
      all set up to cope, so that can all be added in a future commit
      without having to change the file format.
      
      While I'm at it, I've also switched the CBC encryption to using a
      random IV (or rather, one derived from the passphrase along with the
      cipher and MAC keys). That's more like normal SSH-2 practice.
      08d17140
    • Simon Tatham's avatar
      Add implementation of the Argon2 password hash. · 0faeb82c
      Simon Tatham authored
      This is going to be used in the new version of the PPK file format. It
      was the winner of the Password Hashing Context, which I think makes it
      a reasonable choice.
      
      Argon2 comes in three flavours: one with no data dependency in its
      memory addressing, one with _deliberate_ data dependency (intended to
      serialise computation, to hinder parallel brute-forcing), and a hybrid
      form that starts off data-independent and then switches over to the
      dependent version once the sensitive input data has been adequately
      mixed around. I test all three in the test suite; the side-channel
      tester can only expect Argon2i to pass; and, following the spec's
      recommendation, I'll be using Argon2id for the actual key file
      encryption.
      0faeb82c
    • Simon Tatham's avatar
      Add an implementation of BLAKE2b. · 5c8f3bf9
      Simon Tatham authored
      I have no plans to use this directly, but it's a component of Argon2,
      which I'm about to add in the next commit.
      5c8f3bf9
    • Simon Tatham's avatar
      Refactoring to prepare for changes in the PPK format. · 6f025c0b
      Simon Tatham authored
      'bool old_fmt' in ppk_load_s has now given way to a numeric version
      field, which will allow it to be set to 3 in future, instead of just 1
      or 2. The ad-hoc integer variable 'cipher' is replaced with a pointer
      to a small struct that mentions individual details like key lengths,
      to aid parametrisation.
      
      The old ssh2_ppk_derivekey is now a larger function that derives all
      three of the key components used in the private-blob protection: not
      just the cipher key, but the cipher IV and the MAC key as well. The
      main part of it is a switch on the file-format version, which
      currently has only one case (PPK v1 and v2 don't differ in the key
      derivation), but gives me a handy place to drop in a new case in a
      future commit, changing the derivation of all those things.
      
      All the key material is stored end-to-end in a single strbuf, with
      ptrlens pointing into it. That makes it easy to free all in one go
      later.
      6f025c0b
    • Simon Tatham's avatar
      Add an IV argument to aes_{en,de}crypt_pubkey. · c61158aa
      Simon Tatham authored
      No functional change: currently, the IV passed in is always zero
      (except in the test suite). But this prepares to change that in a
      future revision of the key file format.
      c61158aa
    • Simon Tatham's avatar
      Add utility function 'memxor'. · 609502b0
      Simon Tatham authored
      609502b0
    • Simon Tatham's avatar
      testcrypt: ability to handle more function parameters. · 09fa3f0e
      Simon Tatham authored
      I'm about to add a function of particularly large arity.
      09fa3f0e
    • Simon Tatham's avatar
      Fix duplicated exit code in ppk_load_s. · 29b8e26f
      Simon Tatham authored
      There's no need to have one bunch of free operations before returning
      success and another version before returning error. Easier to just set
      up the state in the former case so that we can fall through to the
      latter.
      29b8e26f
    • Simon Tatham's avatar
      Correct documentation of PPK key derivation. · ce60ca72
      Simon Tatham authored
      When I transcribed the code into this document, I misread 'put_data'
      as 'put_string' in several places, and documented SSH-style string
      length headers that do not actually exist in the format.
      ce60ca72
  10. Feb 16, 2021
  11. Feb 15, 2021
    • Simon Tatham's avatar
      Add another missing window-border recalculation. · 4eff9ab9
      Simon Tatham authored
      This one is triggered by the following sequence:
       - fill up the terminal window with text ('ls -l /dev' or similar)
       - Win+Right then Win+Up to snap to the top right quadrant
       - interactively drag away from the top right quadrant with the title
         bar, which returns the window to its pre-snap size.
      
      After the snap, the window border will have been recomputed to take
      account of the window size not being an integer number of character
      cells. So it needs recomputing back again the next time the window
      size changes to something that _is_ an integer number - which happens
      (or rather, we process it in a deferred manner) at the EXITSIZEMOVE.
      So that's where we need to recompute the border (again).
      4eff9ab9
    • Simon Tatham's avatar
      Move PPK format documentation into a manual appendix. · 147adf4e
      Simon Tatham authored
      Somebody on comp.security.ssh asked about it recently, and I decided
      that storing it in a comment in the key file was not really good
      enough. Also, that comment was incomplete (it listed the private key
      formats for RSA and DSA but not any of the newer ECC key types, simple
      as their private-key formats may be).
      147adf4e
  12. Feb 13, 2021
  13. Feb 12, 2021
    • Simon Tatham's avatar
      Move CSET_OEMCP and CSET_ACP into Unicode surrogate space. · 438c980c
      Simon Tatham authored
      Each of these #defines represents a block of 256 code values that are
      used, internally to the terminal code, to indicate that a character is
      in one of the currently selected single-byte character sets. One
      effect of this is that reconfiguring the character set in mid-session
      causes all the text already on screen to be redrawn.
      
      Unfortunately, those 512 code points were allocated at 0xF000-0xF1FF,
      which is inside the Unicode private-use area. So if a font uses that
      area to define actually useful glyphs, then those glyphs won't be
      displayed correctly by PuTTY; instead, outputting 0xF000+'A' (for
      example) will display as 'A'. A user recently reported this problem
      with the 'Hack' font from https://github.com/ryanoasis/nerd-fonts .
      
      RDB's comment next to the #defines suggested that this was done on
      purpose for consistency with Linux (though it's not clear what part of
      Linux; perhaps the virtual console driver used to work this way?). But
      now it's getting in the way of actually useful Unicode characters,
      that consistency doesn't seem like the most important thing. (Also, it
      just seems wrong to me that you even _can_ cause PuTTY's terminal
      emulator to use these special internal character representations by
      sending legal UTF-8.)
      
      So I've moved this block of 512 characters to 0xDC00, which is in the
      Unicode surrogate space, and hence can't be stored in the terminal by
      sending UTF-8 at all (since our UTF-8 decoder rejects that range, as
      per spec). That's where we were already keeping other magic blocks
      like CSET_LINEDRW and CSET_SCOACS, and there's still room for two
      more.
      
      The net effect should be that in Windows PuTTY, U+F000 to U+F1FF are
      now displayed as whatever your font wants to show.
      438c980c
Loading