mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Rework mbedtls_test_unhexify()
Rework mbedtls_test_unhexify to extend its scope of usage. Return in error when the function detects an error instead of calling mbedtls_exit(). Improve safety by checking the output buffer is not overrun. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
@ -54,7 +54,29 @@
|
||||
int mbedtls_test_platform_setup( void );
|
||||
void mbedtls_test_platform_teardown( void );
|
||||
|
||||
int mbedtls_test_unhexify( unsigned char *obuf, const char *ibuf );
|
||||
/**
|
||||
* \brief This function translates an ASCII string encoding an
|
||||
* hexadecimal number into the encoded hexadecimal number. The
|
||||
* hexadecimal number is represented as an array of
|
||||
* unsigned char.
|
||||
*
|
||||
* \note The output buffer can be the same as the input buffer. For
|
||||
* any other overlapping of the input and output buffers, the
|
||||
* behavior is undefined.
|
||||
*
|
||||
* \param obuf Output buffer.
|
||||
* \param obufmax Size in number of bytes of \p obuf.
|
||||
* \param ibuf Input buffer.
|
||||
* \param len The number of unsigned char written in \p obuf. This must
|
||||
* not be \c NULL.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
* \return \c -1 if the output buffer is too small or the input string
|
||||
* is not a valid ASCII encoding of an hexadecimal number.
|
||||
*/
|
||||
int mbedtls_test_unhexify( unsigned char *obuf, size_t obufmax,
|
||||
const char *ibuf, size_t *len );
|
||||
|
||||
void mbedtls_test_hexify( unsigned char *obuf,
|
||||
const unsigned char *ibuf,
|
||||
int len );
|
||||
|
Reference in New Issue
Block a user