mbedtls_mpi_safe_cond_assign() is only used within mbedTLS.
 
Symbols
loading...
Files
loading...
CodeScopeSTM32 Libraries and SamplesmbedTLSmbedtls_mpi_safe_cond_assign()

mbedtls_mpi_safe_cond_assign() function

Perform a safe conditional copy of MPI which doesn't reveal whether the condition was true or not.

Syntax

int mbedtls_mpi_safe_cond_assign( mbedtls_mpi *X,     const mbedtls_mpi *Y,     unsigned char assign );
Implemented in bignum.c:249

Arguments

X

The MPI to conditionally assign to. This must point to an initialized MPI.

Y

The MPI to be assigned from. This must point to an initialized MPI.

assign

The condition deciding whether to perform the assignment or not. Possible values: * \c 1: Perform the assignment `X = Y`. * \c 0: Keep the original value of \p X.

Return value

\c 0 if successful. #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. Another negative error code on other kinds of failure.

Notes

This function is equivalent to `if( assign ) mbedtls_mpi_copy( X, Y );` except that it avoids leaking any information about whether the assignment was done or not (the above code may leak information through branch prediction and/or memory access patterns analysis).

References

LocationReferrerText
bignum.c:249
int mbedtls_mpi_safe_cond_assign( mbedtls_mpi *X, const mbedtls_mpi *Y, unsigned char assign )
bignum.h:291
int mbedtls_mpi_safe_cond_assign( mbedtls_mpi *X, const mbedtls_mpi *Y, unsigned char assign );
ecp.c:1239ecp_safe_invert_jac()
MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_assign( &Q->Y, &mQY, inv & nonzero ) );
ecp.c:1764ecp_select_comb()
MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_assign( &R->X, &T[j].X, j == ii ) );
ecp.c:1765ecp_select_comb()
MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_assign( &R->Y, &T[j].Y, j == ii ) );
ecp.c:1884ecp_comb_recode_scalar()
MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_assign( &M, &mm, *parity_trick ) );

Call Tree

Functions calling mbedtls_mpi_safe_cond_assign()
Functions called by mbedtls_mpi_safe_cond_assign()
mbedtls_mpi_safe_cond_assign()
all items filtered out
Data read by mbedtls_mpi_safe_cond_assign()
Data written by mbedtls_mpi_safe_cond_assign()
mbedtls_mpi_safe_cond_assign()
mbedtls_mpi_safe_cond_assign()::ret
mbedtls_mpi_safe_cond_assign()::i
all items filtered out
Type of mbedtls_mpi_safe_cond_assign()
mbedtls_mpi_safe_cond_assign()
size_t
all items filtered out