From 50546921ac8250d1884c41fd9dc7a645007d4103 Mon Sep 17 00:00:00 2001
From: Paul Bakker
Date: Sat, 19 May 2012 08:40:49 +0000
Subject: [PATCH] - Moved to prevent uninitialized exit var
---
library/bignum.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/library/bignum.c b/library/bignum.c
index e73a810b32..08cbf8c684 100644
--- a/library/bignum.c
+++ b/library/bignum.c
@@ -1396,19 +1396,6 @@ int mpi_exp_mod( mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR )
if( mpi_cmp_int( E, 0 ) < 0 )
return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
- /*
- * Compensate for negative A (and correct at the end)
- */
- neg = ( A->s == -1 );
-
- mpi_init( &Apos );
- if( neg )
- {
- MPI_CHK( mpi_copy( &Apos, A ) );
- Apos.s = 1;
- A = &Apos;
- }
-
/*
* Init temps and window size
*/
@@ -1429,6 +1416,19 @@ int mpi_exp_mod( mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR )
MPI_CHK( mpi_grow( &W[1], j ) );
MPI_CHK( mpi_grow( &T, j * 2 ) );
+ /*
+ * Compensate for negative A (and correct at the end)
+ */
+ neg = ( A->s == -1 );
+
+ mpi_init( &Apos );
+ if( neg )
+ {
+ MPI_CHK( mpi_copy( &Apos, A ) );
+ Apos.s = 1;
+ A = &Apos;
+ }
+
/*
* If 1st call, pre-compute R^2 mod N
*/