From 1a719b00709d4a3934aa3d975dc13d0c9fde0e06 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Fri, 19 Jun 2015 10:08:04 -0400 Subject: 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. --- rsa.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/rsa.c b/rsa.c index 28365ae..cda0f7f 100644 --- a/rsa.c +++ b/rsa.c @@ -62,7 +62,7 @@ * to support at compile time. This should not be a serious problem. */ -#include "tfm.h" +#include /* * Whether we want debug output. @@ -191,6 +191,21 @@ static hal_error_t modexp(fp_int *msg, fp_int *exp, fp_int *mod, fp_int *res) return err; } +/* + * 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 -- cgit v1.2.3