]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: lib/mpi - Use swap() in mpi_ec_mul_point()
authorJiapeng Chong <jiapeng.chong@linux.alibaba.com>
Fri, 14 Jun 2024 03:09:11 +0000 (11:09 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 21 Jun 2024 12:04:17 +0000 (22:04 +1000)
Use existing swap() function rather than duplicating its implementation.

./lib/crypto/mpi/ec.c:1291:20-21: WARNING opportunity for swap().
./lib/crypto/mpi/ec.c:1292:20-21: WARNING opportunity for swap().

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9328
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
lib/crypto/mpi/ec.c

index e16dca1e23d520a2f5199fe076acfba8ce7943a0..4781f00982efe5f3724bfac6dfa0aacb1b132f9d 100644 (file)
@@ -1285,14 +1285,12 @@ void mpi_ec_mul_point(MPI_POINT result,
                sum = &p2_;
 
                for (j = nbits-1; j >= 0; j--) {
-                       MPI_POINT t;
-
                        sw = mpi_test_bit(scalar, j);
                        point_swap_cond(q1, q2, sw, ctx);
                        montgomery_ladder(prd, sum, q1, q2, point->x, ctx);
                        point_swap_cond(prd, sum, sw, ctx);
-                       t = q1;  q1 = prd;  prd = t;
-                       t = q2;  q2 = sum;  sum = t;
+                       swap(q1, prd);
+                       swap(q2, sum);
                }
 
                mpi_clear(result->y);