- Make A only smaller if it is larger than |X| - 1

diff --git a/library/bignum.c b/library/bignum.c
index 78e9384..55188b7 100644
--- a/library/bignum.c
+++ b/library/bignum.c
@@ -1746,8 +1746,11 @@
         for( j = 0; j < A.n * ciL; j++ )
             *p++ = (unsigned char) f_rng( p_rng );
 
-        j = mpi_msb( &A ) - mpi_msb( &W );
-        MPI_CHK( mpi_shift_r( &A, j + 1 ) );
+        if( mpi_cmp_mpi( &A, &W ) >= 0 )
+        {
+            j = mpi_msb( &A ) - mpi_msb( &W );
+            MPI_CHK( mpi_shift_r( &A, j + 1 ) );
+        }
         A.p[0] |= 3;
 
         /*