1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 09:27:59 +00:00
putty-source/contrib
Simon Tatham c2ec13c7e9 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.
2015-12-16 14:13:21 +00:00
..
cygtermd Fix a controlling-terminal bug reported by Anthony Heading: Cygwin 2012-08-28 17:42:47 +00:00
encodelib.py New 'contrib' tool: a script for faking initial KEX. 2015-02-28 07:58:29 +00:00
kh2reg.py Make kh2reg.py compatible with modern Python. 2015-02-24 10:30:18 +00:00
logparse.pl Elliptic-curve cryptography support. 2014-11-02 18:16:54 +00:00
logrewrap.pl New 'contrib' script to sort out email-corrupted packet logs. 2015-08-05 18:44:37 +01:00
make1305.py Relegate BignumDblInt to an implementation detail of sshbn.h. 2015-12-16 14:13:21 +00:00
nice-ibeam.cur Commit my replacement Windows I-beam mouse pointer. 2015-05-28 18:14:14 +01:00
samplekex.py New 'contrib' tool: a script for faking initial KEX. 2015-02-28 07:58:29 +00:00