Skip to content

Commit

Permalink
Add explicit type cast to avoid truncation warning
Browse files Browse the repository at this point in the history
`mbedtls_rsa_deduce_primes` implicitly casts the result of a call to
`mbedtls_mpi_lsb` to a `uint16_t`. This is safe because of the size
of MPI's used in the library, but still may have compilers complain
about it. This commit makes the cast explicit.
  • Loading branch information
Hanno Becker committed Jan 3, 2018
1 parent a47023e commit 4952e7a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion library/rsa_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ int mbedtls_rsa_deduce_primes( mbedtls_mpi const *N,
MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T, D, E ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &T, &T, 1 ) );

if( ( order = mbedtls_mpi_lsb( &T ) ) == 0 )
if( ( order = (uint16_t) mbedtls_mpi_lsb( &T ) ) == 0 )
{
ret = MBEDTLS_ERR_MPI_BAD_INPUT_DATA;
goto cleanup;
Expand Down

0 comments on commit 4952e7a

Please sign in to comment.