Skip to content

Commit

Permalink
Merge pull request #5706 from hanno-arm/bn_mul_cleanup
Browse files Browse the repository at this point in the history
Simplify structure of bignum inline assembly
  • Loading branch information
mpg authored Apr 19, 2022
2 parents 09dc05b + 606cb16 commit 46435f0
Show file tree
Hide file tree
Showing 2 changed files with 179 additions and 139 deletions.
52 changes: 10 additions & 42 deletions library/bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -1377,54 +1377,22 @@ mbedtls_mpi_uint mbedtls_mpi_core_mla( mbedtls_mpi_uint *d, size_t d_len,
mbedtls_mpi_uint c = 0; /* carry */
size_t excess_len = d_len - s_len;

#if defined(MULADDC_HUIT)
for( ; s_len >= 8; s_len -= 8 )
{
MULADDC_INIT
MULADDC_HUIT
MULADDC_STOP
}
size_t steps_x8 = s_len / 8;
size_t steps_x1 = s_len & 7;

for( ; s_len > 0; s_len-- )
while( steps_x8-- )
{
MULADDC_INIT
MULADDC_CORE
MULADDC_STOP
}
#else /* MULADDC_HUIT */
for( ; s_len >= 16; s_len -= 16 )
{
MULADDC_INIT
MULADDC_CORE MULADDC_CORE
MULADDC_CORE MULADDC_CORE
MULADDC_CORE MULADDC_CORE
MULADDC_CORE MULADDC_CORE

MULADDC_CORE MULADDC_CORE
MULADDC_CORE MULADDC_CORE
MULADDC_CORE MULADDC_CORE
MULADDC_CORE MULADDC_CORE
MULADDC_STOP
}

for( ; s_len >= 8; s_len -= 8 )
{
MULADDC_INIT
MULADDC_CORE MULADDC_CORE
MULADDC_CORE MULADDC_CORE

MULADDC_CORE MULADDC_CORE
MULADDC_CORE MULADDC_CORE
MULADDC_STOP
MULADDC_X8_INIT
MULADDC_X8_CORE
MULADDC_X8_STOP
}

for( ; s_len > 0; s_len-- )
while( steps_x1-- )
{
MULADDC_INIT
MULADDC_CORE
MULADDC_STOP
MULADDC_X1_INIT
MULADDC_X1_CORE
MULADDC_X1_STOP
}
#endif /* MULADDC_HUIT */

while( excess_len-- )
{
Expand Down
Loading

0 comments on commit 46435f0

Please sign in to comment.