simon-git: putty (master): Simon Tatham

Commits to Tartarus CVS repository. tartarus-commits at lists.tartarus.org
Wed Dec 16 14:24:29 GMT 2015


TL;DR:
  c2ec13c Relegate BignumDblInt to an implementation detail of sshbn.h.
  84cd309 Add a case to sshbn.h for 64-bit Visual Studio.

Repository:     git://git.tartarus.org/simon/putty.git
On the web:     http://tartarus.org/~simon-git/gitweb/?p=putty.git
Branch updated: master
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2015-12-16 14:24:29

commit c2ec13c7e98a2dd0c40161e5d16284bcaf6ec62b
web diff http://tartarus.org/~simon-git/gitweb/?p=putty.git;a=commitdiff;h=c2ec13c7e98a2dd0c40161e5d16284bcaf6ec62b;hp=482b4ab872cc4987bce862c8af0de1e9bfc4c696
Author: Simon Tatham <anakin at pobox.com>
Date:   Wed Dec 16 14:12:26 2015 +0000

    Relegate BignumDblInt to an implementation detail of sshbn.h.
    
    As I mentioned in the previous commit, I'm going to want PuTTY to be
    able to run sensibly when compiled with 64-bit Visual Studio,
    including handling bignums in 64-bit chunks for speed. Unfortunately,
    64-bit VS does not provide any type we can use as BignumDblInt in that
    situation (unlike 64-bit gcc and clang, which give us __uint128_t).
    The only facilities it provides are compiler intrinsics to access an
    add-with-carry operation and a 64x64->128 multiplication (the latter
    delivering its product in two separate 64-bit output chunks).
    
    Hence, here's a substantial rework of the bignum code to make it
    implement everything in terms of _those_ primitives, rather than
    depending throughout on having BignumDblInt available to use ad-hoc.
    BignumDblInt does still exist, for the moment, but now it's an
    internal implementation detail of sshbn.h, only declared inside a new
    set of macros implementing arithmetic primitives, and not accessible
    to any code outside sshbn.h (which confirms that I really did catch
    all uses of it and remove them).
    
    The resulting code is surprisingly nice-looking, actually. You'd
    expect more hassle and roundabout circumlocutions when you drop down
    to using a more basic set of primitive operations, but actually, in
    many cases it's turned out shorter to write things in terms of the new
    BignumADC and BignumMUL macros - because almost all my uses of
    BignumDblInt were implementing those operations anyway, taking several
    lines at a time, and now they can do each thing in just one line.
    
    The biggest headache was Poly1305: I wasn't able to find any sensible
    way to adapt the existing Python script that generates the various
    per-int-size implementations of arithmetic mod 2^130-5, and so I had
    to rewrite it from scratch instead, with nothing in common with the
    old version beyond a handful of comments. But even that seems to have
    worked out nicely: the new version has much more legible descriptions
    of the high-level algorithms, by virtue of having a 'Multiprecision'
    type which wraps up the division into words, and yet Multiprecision's
    range analysis allows it to automatically drop out special cases such
    as multiplication by 5 being much easier than multiplication by
    another multi-word integer.

 contrib/make1305.py |  589 +++++++++++++----------
 sshbn.c             |  285 +++++------
 sshbn.h             |  205 ++++++--
 sshccp.c            | 1301 ++++++++++++++++++++-------------------------------
 4 files changed, 1165 insertions(+), 1215 deletions(-)

commit 84cd309295c12e7a8a3a7bc37280f8d7859b4a8b
web diff http://tartarus.org/~simon-git/gitweb/?p=putty.git;a=commitdiff;h=84cd309295c12e7a8a3a7bc37280f8d7859b4a8b;hp=c2ec13c7e98a2dd0c40161e5d16284bcaf6ec62b
Author: Simon Tatham <anakin at pobox.com>
Date:   Wed Dec 16 14:12:36 2015 +0000

    Add a case to sshbn.h for 64-bit Visual Studio.
    
    This commit fulfills the promise of the previous one: now one of the
    branches of sshbn.h's big ifdef _doesn't_ define a BignumDblInt, and
    instead provides implementations of the primitive arithmetic macros in
    terms of Visual Studio's x86-64 compiler intrinsics. So now, when this
    codebase is compiled with 64-bit VS, it can use a 64-bit BignumInt and
    everything still seems to work.

 sshbn.h |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)



More information about the tartarus-commits mailing list