libzahl

big integer library
git clone git://git.suckless.org/libzahl
Log | Files | Refs | README | LICENSE

zmodmul.c (365B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include "internals.h"
      3 
      4 
      5 void
      6 zmodmul(z_t a, z_t b, z_t c, z_t d)
      7 {
      8 	/* TODO Montgomery modular multiplication */
      9 	/* TODO Kochanski multiplication */
     10 	if (unlikely(a == d)) {
     11 		zset(libzahl_tmp_modmul, d);
     12 		zmul(a, b, c);
     13 		zmod(a, a, libzahl_tmp_modmul);
     14 	} else {
     15 		zmul(a, b, c);
     16 		zmod(a, a, d);
     17 	}
     18 }