diff options
author | Rob Austein <sra@hactrn.net> | 2015-06-19 10:08:04 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2015-06-19 10:08:04 -0400 |
commit | 1a719b00709d4a3934aa3d975dc13d0c9fde0e06 (patch) | |
tree | c9032abe3ba6ae99eedb3f429b23162893b1e113 /rsa.c | |
parent | a615b134c498f8d88e0dab047f40c7096a2f9e03 (diff) |
Add replacement for fp_exptmod() using our ModExp core, so we don't
drag in all of TFM's Montgomery just to support the Miller-Rabin test.
Diffstat (limited to 'rsa.c')
-rw-r--r-- | rsa.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -62,7 +62,7 @@ * to support at compile time. This should not be a serious problem. */ -#include "tfm.h" +#include <tfm.h> /* * Whether we want debug output. @@ -192,6 +192,21 @@ static hal_error_t modexp(fp_int *msg, fp_int *exp, fp_int *mod, fp_int *res) } /* + * Wrapper to let us export our modexp function as a replacement for + * TFM's, to avoid dragging all of the TFM montgomery code in when we + * use TFM's Miller-Rabin test code. + * + * This code is here rather than in a separate module because of the + * error handling: TFM's error codes aren't really capable of + * expressing all the things that could go wrong here. + */ + +int fp_exptmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d) +{ + return modexp(a, b, c, d) == HAL_OK ? FP_OKAY : FP_VAL; +} + +/* * Create blinding factors. There are various schemes for amortizing * the cost of this over multiple RSA operations, at present we don't * try. Come back to this if it looks like a bottleneck. |