Shore up the `grand' protocol.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 15 May 2016 23:25:05 +0000 (00:25 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 16 May 2016 08:20:02 +0000 (09:20 +0100)
commit44ff6c114bdcd5cef753d2788d029ce46e35727a
tree2e48c78c128311f23910f13fbd6c9214bb9ee093
parentba57d6526b809146b9c22d8f166b51d22e3bdb68
Shore up the `grand' protocol.

This is a bit of a mess, really.  There are two main problems.

  * Firstly, the business of comparing function pointers simply doesn't
    work on Windows, because the dynamic linker is too hopeless.  If the
    class implementation is in a different module from Catacomb itself,
    then the vtable may have a pointer to an import-library stub, which
    won't compare equal to the library's idea of the default method
    function.

    It's basically a mistake to have tried to use the same functions as
    both user interface and default implementation.  Split the two
    apart.  Leave the hacky function-pointer comparisons in the user-
    interface functions for compatibility with existing out-of-tree
    generators, which will carry on working about as well as they ever
    did.

    Note, however, that the defaulting strategy is now less `clever',
    and implementations which don't provide native versions of all the
    methods may end up suffering more than they used to.

  * The `grand_range' function was simply broken if the `raw' method's
    output is too small.  Synthesizing a full uniform-value-in-range
    from a narrow primitive generator in single precision arithmetic is
    rather difficult, so rather than do that I've decided to insist that
    all `raw' methods have a range of at least a byte's worth, so we can
    synthesize a word generator out of bytes if necessary, and then use
    that to satisfy the original larger range request.

This is all a bit unsatisfactory, really.  I must remember to revisit it
when all of these gets made out of a proper object system.
15 files changed:
pub/bbs-rand.c
rand/dsarand.c
rand/grand.c
rand/grand.h
rand/lcrand.c
rand/rand.c
rand/sslprf.c
rand/tlsprf.c
symm/chacha.c
symm/counter-def.h
symm/mgf-def.h
symm/ofb-def.h
symm/rc4.c
symm/salsa20.c
symm/seal.c