/src/sqr/fp_sqrmod.c

http://github.com/libtom/tomsfastmath · C · 12 lines · 8 code · 1 blank · 3 comment · 0 complexity · 9107021fb4bf56df06b6e54e5835cae6 MD5 · raw file

  1. /* TomsFastMath, a fast ISO C bignum library. -- Tom St Denis */
  2. /* SPDX-License-Identifier: Unlicense */
  3. #include <tfm_private.h>
  4. /* c = a * a (mod b) */
  5. int fp_sqrmod(fp_int *a, fp_int *b, fp_int *c)
  6. {
  7. fp_int tmp;
  8. fp_zero(&tmp);
  9. fp_sqr(a, &tmp);
  10. return fp_mod(&tmp, b, c);
  11. }