Add little endian export to Bignum
The function `mbedtls_mpi_write_binary()` writes big endian byte order, but we need to be able to write little endian in some caseses. (For example when handling keys corresponding to Montgomery curves.) Used `echo xx | tac -rs ..` to transform the test data to little endian.
This commit is contained in:
parent
171a7efd02
commit
e344d0f6fc
4 changed files with 97 additions and 0 deletions
|
@ -522,6 +522,24 @@ int mbedtls_mpi_read_binary_le( mbedtls_mpi *X,
|
|||
int mbedtls_mpi_write_binary( const mbedtls_mpi *X, unsigned char *buf,
|
||||
size_t buflen );
|
||||
|
||||
/**
|
||||
* \brief Export X into unsigned binary data, little endian.
|
||||
* Always fills the whole buffer, which will end 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
|
||||
* \p buflen Bytes.
|
||||
* \param buflen The size of the output buffer \p buf in Bytes.
|
||||
*
|
||||
* \return \c 0 if successful.
|
||||
* \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p buf isn't
|
||||
* large enough to hold the value of \p X.
|
||||
* \return Another negative error code on different kinds of failure.
|
||||
*/
|
||||
int mbedtls_mpi_write_binary_le( const mbedtls_mpi *X,
|
||||
unsigned char *buf, size_t buflen );
|
||||
|
||||
/**
|
||||
* \brief Perform a left-shift on an MPI: X <<= count
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue