openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libgcrypt/1.8.4-r0/libgcrypt-1.8.4/mpi/ec.c
static void montgomery_ladder(mpi_point_t prd, mpi_point_t sum, mpi_point_t p1,
                              mpi_point_t p2, gcry_mpi_t dif_x, mpi_ec_t ctx)
{
    ec_addm(sum->x, p2->x, p2->z, ctx);
    ec_subm(p2->z, p2->x, p2->z, ctx);
    ec_addm(prd->x, p1->x, p1->z, ctx);
    ec_subm(p1->z, p1->x, p1->z, ctx);
    ec_mulm(p2->x, p1->z, sum->x, ctx);
    ec_mulm(p2->z, prd->x, p2->z, ctx);
    ec_pow2(p1->x, prd->x, ctx);
    ec_pow2(p1->z, p1->z, ctx);
    ec_addm(sum->x, p2->x, p2->z, ctx);
    ec_subm(p2->z, p2->x, p2->z, ctx);
    ec_mulm(prd->x, p1->x, p1->z, ctx);
    ec_subm(p1->z, p1->x, p1->z, ctx);
    ec_pow2(sum->x, sum->x, ctx);
    ec_pow2(sum->z, p2->z, ctx);
    ec_mulm(prd->z, p1->z, ctx->a, ctx); /* CTX->A: (a-2)/4 */
    ec_mulm(sum->z, sum->z, dif_x, ctx);
    ec_addm(prd->z, p1->x, prd->z, ctx);
    ec_mulm(prd->z, prd->z, p1->z, ctx);
}
/* Compute a step of Montgomery Ladder (only use X and Z in the point).
   Inputs:  P1, P2, and x-coordinate of DIF = P1 - P1.
   Outputs: PRD = 2 * P1 and  SUM = P1 + P2. */
Compute a step of Montgomery Ladder (only use X and Z in the point).
Compute a step of Montgomery Ladder ( only use X and Z in the point ) .
static void montgomery_ladder(mpi_point_t prd, mpi_point_t sum, mpi_point_t p1,
                              mpi_point_t p2, gcry_mpi_t dif_x, mpi_ec_t ctx)
{
    ec_addm(sum->x, p2->x, p2->z, ctx);
    ec_subm(p2->z, p2->x, p2->z, ctx);
    ec_addm(prd->x, p1->x, p1->z, ctx);
    ec_subm(p1->z, p1->x, p1->z, ctx);
    ec_mulm(p2->x, p1->z, sum->x, ctx);
    ec_mulm(p2->z, prd->x, p2->z, ctx);
    ec_pow2(p1->x, prd->x, ctx);
    ec_pow2(p1->z, p1->z, ctx);
    ec_addm(sum->x, p2->x, p2->z, ctx);
    ec_subm(p2->z, p2->x, p2->z, ctx);
    ec_mulm(prd->x, p1->x, p1->z, ctx);
    ec_subm(p1->z, p1->x, p1->z, ctx);
    ec_pow2(sum->x, sum->x, ctx);
    ec_pow2(sum->z, p2->z, ctx);
    ec_mulm(prd->z, p1->z, ctx->a, ctx); 
    ec_mulm(sum->z, sum->z, dif_x, ctx);
    ec_addm(prd->z, p1->x, prd->z, ctx);
    ec_mulm(prd->z, prd->z, p1->z, ctx);
}
static void montgomery_ladder ( mpi_point_t prd , mpi_point_t sum , mpi_point_t p1 , mpi_point_t p2 , gcry_mpi_t dif_x , mpi_ec_t ctx ) { ec_addm ( sum -> x , p2 -> x , p2 -> z , ctx ) ; ec_subm ( p2 -> z , p2 -> x , p2 -> z , ctx ) ; ec_addm ( prd -> x , p1 -> x , p1 -> z , ctx ) ; ec_subm ( p1 -> z , p1 -> x , p1 -> z , ctx ) ; ec_mulm ( p2 -> x , p1 -> z , sum -> x , ctx ) ; ec_mulm ( p2 -> z , prd -> x , p2 -> z , ctx ) ; ec_pow2 ( p1 -> x , prd -> x , ctx ) ; ec_pow2 ( p1 -> z , p1 -> z , ctx ) ; ec_addm ( sum -> x , p2 -> x , p2 -> z , ctx ) ; ec_subm ( p2 -> z , p2 -> x , p2 -> z , ctx ) ; ec_mulm ( prd -> x , p1 -> x , p1 -> z , ctx ) ; ec_subm ( p1 -> z , p1 -> x , p1 -> z , ctx ) ; ec_pow2 ( sum -> x , sum -> x , ctx ) ; ec_pow2 ( sum -> z , p2 -> z , ctx ) ; ec_mulm ( prd -> z , p1 -> z , ctx -> a , ctx ) ; ec_mulm ( sum -> z , sum -> z , dif_x , ctx ) ; ec_addm ( prd -> z , p1 -> x , prd -> z , ctx ) ; ec_mulm ( prd -> z , prd -> z , p1 -> z , ctx ) ; }
Compute a step of Montgomery Ladder (only use X and Z in the point).
Compute a step of Montgomery Ladder ( only use X and Z in the point ) .
/* CTX->A: (a-2)/4 */