Update signature of BE conversion functions

This commit is contained in:
Arto Kinnunen 2019-09-06 16:59:00 +03:00
parent 0b62ce8ed4
commit ee9bfca823
2 changed files with 22 additions and 22 deletions

View file

@ -30,7 +30,7 @@
#else #else
#include MBEDTLS_CONFIG_FILE #include MBEDTLS_CONFIG_FILE
#endif #endif
#include <stdint.h>
#include <stddef.h> #include <stddef.h>
#if defined(MBEDTLS_HAVE_TIME_DATE) #if defined(MBEDTLS_HAVE_TIME_DATE)
#include "platform_time.h" #include "platform_time.h"
@ -193,43 +193,43 @@ struct tm *mbedtls_platform_gmtime_r( const mbedtls_time_t *tt,
* \brief Convert 32-bit number to big endian format. * \brief Convert 32-bit number to big endian format.
* *
* This function converts 32-bit number to big endian format and * This function converts 32-bit number to big endian format and
* writes it to given buffer. * writes it to the given buffer.
* *
* \param buf Address where converted number is written. * \param buf Address where converted number is written.
* \param num Number that needs to be converted to big endian. * \param num Number that needs to be converted to big endian.
* *
* \return Address to end of buffer where number is written. * \return Address to end of buffer where number is written.
*/ */
unsigned char * mbedtls_platform_put_uint32_be( unsigned char *buf, unsigned char* mbedtls_platform_put_uint32_be( unsigned char *buf,
unsigned long num ); uint32_t num );
/** /**
* \brief Convert 24-bit number to big endian format. * \brief Convert 24-bit number to big endian format.
* *
* This function converts 24-bit number to big endian format and * This function converts 24-bit number to big endian format and
* writes it to given buffer. * writes it to the given buffer.
* *
* \param buf Address where converted number is written. * \param buf Address where converted number is written.
* \param num Number that needs to be converted to big endian. * \param num Number that needs to be converted to big endian.
* *
* \return Address to end of buffer where number is written. * \return Address to end of buffer where number is written.
*/ */
unsigned char * mbedtls_platform_put_uint24_be( unsigned char *buf, unsigned char* mbedtls_platform_put_uint24_be( unsigned char *buf,
unsigned long num ); uint32_t num );
/** /**
* \brief Convert 16-bit number to big endian format. * \brief Convert 16-bit number to big endian format.
* *
* This function converts 16-bit number to big endian format and * This function converts 16-bit number to big endian format and
* writes it to given buffer. * writes it to the given buffer.
* *
* \param buf Address where converted number is written. * \param buf Address where converted number is written.
* \param num Number that needs to be converted to big endian. * \param num Number that needs to be converted to big endian.
* *
* \return Address to end of buffer where number is written. * \return Address to end of buffer where number is written.
*/ */
unsigned char * mbedtls_platform_put_uint16_be( unsigned char *buf, unsigned char* mbedtls_platform_put_uint16_be( unsigned char *buf,
unsigned long num ); uint32_t num );
/** /**
* \brief Convert 32-bit number from big endian format. * \brief Convert 32-bit number from big endian format.
@ -241,7 +241,7 @@ unsigned char * mbedtls_platform_put_uint16_be( unsigned char *buf,
* *
* \return Converted number. * \return Converted number.
*/ */
unsigned int mbedtls_platform_get_uint32_be( const unsigned char *buf ); uint32_t mbedtls_platform_get_uint32_be( const unsigned char *buf );
/** /**
* \brief Convert 24-bit number from big endian format. * \brief Convert 24-bit number from big endian format.
@ -253,7 +253,7 @@ unsigned int mbedtls_platform_get_uint32_be( const unsigned char *buf );
* *
* \return Converted number. * \return Converted number.
*/ */
unsigned int mbedtls_platform_get_uint24_be( const unsigned char *buf ); uint32_t mbedtls_platform_get_uint24_be( const unsigned char *buf );
/** /**
* \brief Convert 16-bit number from big endian format. * \brief Convert 16-bit number from big endian format.
@ -265,7 +265,7 @@ unsigned int mbedtls_platform_get_uint24_be( const unsigned char *buf );
* *
* \return Converted number. * \return Converted number.
*/ */
unsigned short mbedtls_platform_get_uint16_be( const unsigned char *b ); uint16_t mbedtls_platform_get_uint16_be( const unsigned char *buf );
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -135,8 +135,8 @@ struct tm *mbedtls_platform_gmtime_r( const mbedtls_time_t *tt,
} }
#endif /* MBEDTLS_HAVE_TIME_DATE && MBEDTLS_PLATFORM_GMTIME_R_ALT */ #endif /* MBEDTLS_HAVE_TIME_DATE && MBEDTLS_PLATFORM_GMTIME_R_ALT */
unsigned char * mbedtls_platform_put_uint32_be( unsigned char *buf, unsigned char* mbedtls_platform_put_uint32_be( unsigned char *buf,
unsigned long num) uint32_t num )
{ {
*buf++ = (unsigned char) ( num >> 24 ); *buf++ = (unsigned char) ( num >> 24 );
*buf++ = (unsigned char) ( num >> 16 ); *buf++ = (unsigned char) ( num >> 16 );
@ -146,8 +146,8 @@ unsigned char * mbedtls_platform_put_uint32_be( unsigned char *buf,
return buf; return buf;
} }
unsigned char * mbedtls_platform_put_uint24_be( unsigned char *buf, unsigned char* mbedtls_platform_put_uint24_be( unsigned char *buf,
unsigned long num ) uint32_t num )
{ {
*buf++ = (unsigned char) ( num >> 16 ); *buf++ = (unsigned char) ( num >> 16 );
*buf++ = (unsigned char) ( num >> 8 ); *buf++ = (unsigned char) ( num >> 8 );
@ -156,8 +156,8 @@ unsigned char * mbedtls_platform_put_uint24_be( unsigned char *buf,
return buf; return buf;
} }
unsigned char * mbedtls_platform_put_uint16_be( unsigned char *buf, unsigned char* mbedtls_platform_put_uint16_be( unsigned char *buf,
unsigned long num ) uint32_t num )
{ {
*buf++ = (unsigned char) ( num >> 8 ); *buf++ = (unsigned char) ( num >> 8 );
*buf++ = (unsigned char) ( num ); *buf++ = (unsigned char) ( num );
@ -165,7 +165,7 @@ unsigned char * mbedtls_platform_put_uint16_be( unsigned char *buf,
return buf; return buf;
} }
unsigned int mbedtls_platform_get_uint32_be( const unsigned char *buf ) uint32_t mbedtls_platform_get_uint32_be( const unsigned char *buf )
{ {
return ( ( (unsigned int) buf[0] << 24 ) | return ( ( (unsigned int) buf[0] << 24 ) |
( (unsigned int) buf[1] << 16 ) | ( (unsigned int) buf[1] << 16 ) |
@ -173,14 +173,14 @@ unsigned int mbedtls_platform_get_uint32_be( const unsigned char *buf )
( (unsigned int) buf[3] ) ); ( (unsigned int) buf[3] ) );
} }
unsigned int mbedtls_platform_get_uint24_be( const unsigned char *buf ) uint32_t mbedtls_platform_get_uint24_be( const unsigned char *buf )
{ {
return ( ( buf[0] << 16 ) | return ( ( buf[0] << 16 ) |
( buf[1] << 8) | ( buf[1] << 8) |
( buf[2] ) ); ( buf[2] ) );
} }
unsigned short mbedtls_platform_get_uint16_be( const unsigned char *buf ) uint16_t mbedtls_platform_get_uint16_be( const unsigned char *buf )
{ {
return ( ( buf[0] << 8 ) | return ( ( buf[0] << 8 ) |
( buf[1] ) ); ( buf[1] ) );