mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-28 08:37:25 +00:00
Add GET/PUT_UINT24_BE/LE
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
parent
148d3d7de0
commit
643d11606a
@ -226,6 +226,78 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the unsigned 24 bits integer corresponding to four bytes in
|
||||
* big-endian order (MSB first).
|
||||
*
|
||||
* \param data Base address of the memory to get the four bytes from.
|
||||
* \param offset Offset from \p base of the first and most significant
|
||||
* byte of the four bytes to build the 24 bits unsigned
|
||||
* integer from.
|
||||
*/
|
||||
#ifndef MBEDTLS_GET_UINT24_BE
|
||||
#define MBEDTLS_GET_UINT24_BE( data , offset ) \
|
||||
( \
|
||||
( (uint32_t) ( data )[( offset ) ] << 16 ) \
|
||||
| ( (uint32_t) ( data )[( offset ) + 1] << 8 ) \
|
||||
| ( (uint32_t) ( data )[( offset ) + 2] ) \
|
||||
)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Put in memory a 24 bits unsigned integer in big-endian order.
|
||||
*
|
||||
* \param n 24 bits unsigned integer to put in memory.
|
||||
* \param data Base address of the memory where to put the 24
|
||||
* bits unsigned integer in.
|
||||
* \param offset Offset from \p base where to put the most significant
|
||||
* byte of the 24 bits unsigned integer \p n.
|
||||
*/
|
||||
#ifndef MBEDTLS_PUT_UINT24_BE
|
||||
#define MBEDTLS_PUT_UINT24_BE( n, data, offset ) \
|
||||
{ \
|
||||
( data )[( offset ) ] = MBEDTLS_BYTE_2( n ); \
|
||||
( data )[( offset ) + 1] = MBEDTLS_BYTE_1( n ); \
|
||||
( data )[( offset ) + 2] = MBEDTLS_BYTE_0( n ); \
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the unsigned 24 bits integer corresponding to four bytes in
|
||||
* little-endian order (LSB first).
|
||||
*
|
||||
* \param data Base address of the memory to get the four bytes from.
|
||||
* \param offset Offset from \p base of the first and least significant
|
||||
* byte of the four bytes to build the 24 bits unsigned
|
||||
* integer from.
|
||||
*/
|
||||
#ifndef MBEDTLS_GET_UINT24_LE
|
||||
#define MBEDTLS_GET_UINT24_LE( data, offset ) \
|
||||
( \
|
||||
( (uint32_t) ( data )[( offset ) ] ) \
|
||||
| ( (uint32_t) ( data )[( offset ) + 1] << 8 ) \
|
||||
| ( (uint32_t) ( data )[( offset ) + 2] << 16 ) \
|
||||
)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Put in memory a 24 bits unsigned integer in little-endian order.
|
||||
*
|
||||
* \param n 24 bits unsigned integer to put in memory.
|
||||
* \param data Base address of the memory where to put the 24
|
||||
* bits unsigned integer in.
|
||||
* \param offset Offset from \p base where to put the least significant
|
||||
* byte of the 24 bits unsigned integer \p n.
|
||||
*/
|
||||
#ifndef MBEDTLS_PUT_UINT24_LE
|
||||
#define MBEDTLS_PUT_UINT24_LE( n, data, offset ) \
|
||||
{ \
|
||||
( data )[( offset ) ] = MBEDTLS_BYTE_0( n ); \
|
||||
( data )[( offset ) + 1] = MBEDTLS_BYTE_1( n ); \
|
||||
( data )[( offset ) + 2] = MBEDTLS_BYTE_2( n ); \
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the unsigned 64 bits integer corresponding to eight bytes in
|
||||
* big-endian order (MSB first).
|
||||
|
Loading…
x
Reference in New Issue
Block a user