Improved modular exponentiation (automatic window optimisation if there is enough...
[BearSSL] / src / inner.h
index 8ada612..2bb8192 100644 (file)
 #include "config.h"
 #include "bearssl.h"
 
 #include "config.h"
 #include "bearssl.h"
 
+/*
+ * On MSVC, disable the warning about applying unary minus on an
+ * unsigned type: it is standard, we do it all the time, and for
+ * good reasons.
+ */
+#if _MSC_VER
+#pragma warning( disable : 4146 )
+#endif
+
 /*
  * Maximum size for a RSA modulus (in bits). Allocated stack buffers
  * depend on that size, so this value should be kept small. Currently,
 /*
  * Maximum size for a RSA modulus (in bits). Allocated stack buffers
  * depend on that size, so this value should be kept small. Currently,
@@ -300,7 +309,7 @@ static inline void
 br_multihash_copyimpl(br_multihash_context *dst,
        const br_multihash_context *src)
 {
 br_multihash_copyimpl(br_multihash_context *dst,
        const br_multihash_context *src)
 {
-       memcpy(dst->impl, src->impl, sizeof src->impl);
+       memcpy((void *)dst->impl, src->impl, sizeof src->impl);
 }
 
 /* ==================================================================== */
 }
 
 /* ==================================================================== */
@@ -1093,6 +1102,9 @@ void br_i15_to_monty(uint16_t *x, const uint16_t *m);
 void br_i15_modpow(uint16_t *x, const unsigned char *e, size_t elen,
        const uint16_t *m, uint16_t m0i, uint16_t *t1, uint16_t *t2);
 
 void br_i15_modpow(uint16_t *x, const unsigned char *e, size_t elen,
        const uint16_t *m, uint16_t m0i, uint16_t *t1, uint16_t *t2);
 
+uint32_t br_i15_modpow_opt(uint16_t *x, const unsigned char *e, size_t elen,
+       const uint16_t *m, uint16_t m0i, uint16_t *tmp, size_t twlen);
+
 void br_i15_encode(void *dst, size_t len, const uint16_t *x);
 
 uint32_t br_i15_decode_mod(uint16_t *x,
 void br_i15_encode(void *dst, size_t len, const uint16_t *x);
 
 uint32_t br_i15_decode_mod(uint16_t *x,