summaryrefslogtreecommitdiffstats
path: root/kernel/lib/mpi/mpi-pow.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/lib/mpi/mpi-pow.c')
-rw-r--r--kernel/lib/mpi/mpi-pow.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/lib/mpi/mpi-pow.c b/kernel/lib/mpi/mpi-pow.c
index 5464c8744..e24388a86 100644
--- a/kernel/lib/mpi/mpi-pow.c
+++ b/kernel/lib/mpi/mpi-pow.c
@@ -64,8 +64,13 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod)
if (!esize) {
/* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0
* depending on if MOD equals 1. */
- rp[0] = 1;
res->nlimbs = (msize == 1 && mod->d[0] == 1) ? 0 : 1;
+ if (res->nlimbs) {
+ if (mpi_resize(res, 1) < 0)
+ goto enomem;
+ rp = res->d;
+ rp[0] = 1;
+ }
res->sign = 0;
goto leave;
}