Add little endian import to Bignum
The function `mbedtls_mpi_read_binary()` expects big endian byte order, but we need to be able to read from little endian in some caseses. (For example when handling keys corresponding to Montgomery curves.) Used `echo xx | tac -rs .. | tr [a-z] [A-Z]` to transform the test data to little endian and `echo "ibase=16;xx" | bc` to convert to decimal.
This commit is contained in:
parent
3081629de4
commit
a778a94b7d
4 changed files with 68 additions and 2 deletions
|
@ -490,8 +490,24 @@ int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf,
|
|||
size_t buflen );
|
||||
|
||||
/**
|
||||
* \brief Export an MPI into unsigned big endian binary data
|
||||
* of fixed size.
|
||||
* \brief Import X from unsigned binary data, little endian
|
||||
*
|
||||
* \param X The destination MPI. This must point to an initialized MPI.
|
||||
* \param buf The input buffer. This must be a readable buffer of length
|
||||
* \p buflen Bytes.
|
||||
* \param buflen The length of the input buffer \p p in Bytes.
|
||||
*
|
||||
* \return \c 0 if successful.
|
||||
* \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed.
|
||||
* \return Another negative error code on different kinds of failure.
|
||||
*/
|
||||
int mbedtls_mpi_read_binary_le( mbedtls_mpi *X,
|
||||
const unsigned char *buf, size_t buflen );
|
||||
|
||||
/**
|
||||
* \brief Export X into unsigned binary data, big endian.
|
||||
* Always fills the whole buffer, which will start with zeros
|
||||
* if the number is smaller.
|
||||
*
|
||||
* \param X The source MPI. This must point to an initialized MPI.
|
||||
* \param buf The output buffer. This must be a writable buffer of length
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue