Two new Poly1305 implementations: ctmul32 uses pure 32-bit multiplications (MUL15, constant-time on about everything); i15 uses the generic i15 big integers (MUL15 again), which is quite slow but also small.

This commit is contained in:
Thomas Pornin 2017-01-05 19:47:00 +01:00
parent 28e4e120b8
commit 7fc1ef315f
7 changed files with 655 additions and 11 deletions

View file

@ -571,16 +571,17 @@ MUL31_lo(uint32_t x, uint32_t y)
#endif
/*
* Multiply two words together; each word may contain up to 15 bits of
* data. If BR_CT_MUL15 is non-zero, then the macro will contain some
* extra operations that help in making the operation constant-time on
* some platforms, where the basic 32-bit multiplication is not
* constant-time.
* Multiply two words together; the sum of the lengths of the two
* operands must not exceed 31 (for instance, one operand may use 16
* bits if the other fits on 15). If BR_CT_MUL15 is non-zero, then the
* macro will contain some extra operations that help in making the
* operation constant-time on some platforms, where the basic 32-bit
* multiplication is not constant-time.
*/
#if BR_CT_MUL15
#define MUL15(x, y) (((uint32_t)(x) | (uint32_t)0x80000000) \
* ((uint32_t)(y) | (uint32_t)0x80000000) \
& (uint32_t)0x3FFFFFFF)
& (uint32_t)0x7FFFFFFF)
#else
#define MUL15(x, y) ((uint32_t)(x) * (uint32_t)(y))
#endif