NCBI C++ ToolKit
|
Utility code for dealing with unaligned memory accesses. More...
Go to the source code of this file.
Go to the SVN repository for this file.
Macros | |
#define | MBEDTLS_BYTE_0(x) ((uint8_t) ((x) & 0xff)) |
Byte Reading Macros. More... | |
#define | MBEDTLS_BYTE_1(x) ((uint8_t) (((x) >> 8) & 0xff)) |
#define | MBEDTLS_BYTE_2(x) ((uint8_t) (((x) >> 16) & 0xff)) |
#define | MBEDTLS_BYTE_3(x) ((uint8_t) (((x) >> 24) & 0xff)) |
#define | MBEDTLS_BYTE_4(x) ((uint8_t) (((x) >> 32) & 0xff)) |
#define | MBEDTLS_BYTE_5(x) ((uint8_t) (((x) >> 40) & 0xff)) |
#define | MBEDTLS_BYTE_6(x) ((uint8_t) (((x) >> 48) & 0xff)) |
#define | MBEDTLS_BYTE_7(x) ((uint8_t) (((x) >> 56) & 0xff)) |
#define | MBEDTLS_BSWAP16 mbedtls_bswap16 |
#define | MBEDTLS_BSWAP32 mbedtls_bswap32 |
#define | MBEDTLS_BSWAP64 mbedtls_bswap64 |
#define | MBEDTLS_IS_BIG_ENDIAN (*((unsigned char *) (&mbedtls_byte_order_detector)) == 0x01) |
#define | MBEDTLS_GET_UINT32_BE(data, offset) |
Get the unsigned 32 bits integer corresponding to four bytes in big-endian order (MSB first). More... | |
#define | MBEDTLS_PUT_UINT32_BE(n, data, offset) |
Put in memory a 32 bits unsigned integer in big-endian order. More... | |
#define | MBEDTLS_GET_UINT32_LE(data, offset) |
Get the unsigned 32 bits integer corresponding to four bytes in little-endian order (LSB first). More... | |
#define | MBEDTLS_PUT_UINT32_LE(n, data, offset) |
Put in memory a 32 bits unsigned integer in little-endian order. More... | |
#define | MBEDTLS_GET_UINT16_LE(data, offset) |
Get the unsigned 16 bits integer corresponding to two bytes in little-endian order (LSB first). More... | |
#define | MBEDTLS_PUT_UINT16_LE(n, data, offset) |
Put in memory a 16 bits unsigned integer in little-endian order. More... | |
#define | MBEDTLS_GET_UINT16_BE(data, offset) |
Get the unsigned 16 bits integer corresponding to two bytes in big-endian order (MSB first). More... | |
#define | MBEDTLS_PUT_UINT16_BE(n, data, offset) |
Put in memory a 16 bits unsigned integer in big-endian order. More... | |
#define | MBEDTLS_GET_UINT24_BE(data, offset) |
Get the unsigned 24 bits integer corresponding to three bytes in big-endian order (MSB first). More... | |
#define | MBEDTLS_PUT_UINT24_BE(n, data, offset) |
Put in memory a 24 bits unsigned integer in big-endian order. More... | |
#define | MBEDTLS_GET_UINT24_LE(data, offset) |
Get the unsigned 24 bits integer corresponding to three bytes in little-endian order (LSB first). More... | |
#define | MBEDTLS_PUT_UINT24_LE(n, data, offset) |
Put in memory a 24 bits unsigned integer in little-endian order. More... | |
#define | MBEDTLS_GET_UINT64_BE(data, offset) |
Get the unsigned 64 bits integer corresponding to eight bytes in big-endian order (MSB first). More... | |
#define | MBEDTLS_PUT_UINT64_BE(n, data, offset) |
Put in memory a 64 bits unsigned integer in big-endian order. More... | |
#define | MBEDTLS_GET_UINT64_LE(data, offset) |
Get the unsigned 64 bits integer corresponding to eight bytes in little-endian order (LSB first). More... | |
#define | MBEDTLS_PUT_UINT64_LE(n, data, offset) |
Put in memory a 64 bits unsigned integer in little-endian order. More... | |
Functions | |
static uint16_t | mbedtls_get_unaligned_uint16 (const void *p) |
Read the unsigned 16 bits integer from the given address, which need not be aligned. More... | |
static void | mbedtls_put_unaligned_uint16 (void *p, uint16_t x) |
Write the unsigned 16 bits integer to the given address, which need not be aligned. More... | |
static uint32_t | mbedtls_get_unaligned_uint32 (const void *p) |
Read the unsigned 32 bits integer from the given address, which need not be aligned. More... | |
static void | mbedtls_put_unaligned_uint32 (void *p, uint32_t x) |
Write the unsigned 32 bits integer to the given address, which need not be aligned. More... | |
static uint64_t | mbedtls_get_unaligned_uint64 (const void *p) |
Read the unsigned 64 bits integer from the given address, which need not be aligned. More... | |
static void | mbedtls_put_unaligned_uint64 (void *p, uint64_t x) |
Write the unsigned 64 bits integer to the given address, which need not be aligned. More... | |
static uint16_t | mbedtls_bswap16 (uint16_t x) |
static uint32_t | mbedtls_bswap32 (uint32_t x) |
static uint64_t | mbedtls_bswap64 (uint64_t x) |
Variables | |
static const uint16_t | mbedtls_byte_order_detector = { 0x100 } |
Utility code for dealing with unaligned memory accesses.
Definition in file alignment.h.
#define MBEDTLS_BSWAP16 mbedtls_bswap16 |
Definition at line 350 of file alignment.h.
#define MBEDTLS_BSWAP32 mbedtls_bswap32 |
Definition at line 362 of file alignment.h.
#define MBEDTLS_BSWAP64 mbedtls_bswap64 |
Definition at line 378 of file alignment.h.
#define MBEDTLS_BYTE_0 | ( | x | ) | ((uint8_t) ((x) & 0xff)) |
Byte Reading Macros.
Given a multi-byte integer x
, MBEDTLS_BYTE_n retrieves the n-th byte from x, where byte 0 is the least significant byte.
Definition at line 268 of file alignment.h.
#define MBEDTLS_BYTE_1 | ( | x | ) | ((uint8_t) (((x) >> 8) & 0xff)) |
Definition at line 269 of file alignment.h.
#define MBEDTLS_BYTE_2 | ( | x | ) | ((uint8_t) (((x) >> 16) & 0xff)) |
Definition at line 270 of file alignment.h.
#define MBEDTLS_BYTE_3 | ( | x | ) | ((uint8_t) (((x) >> 24) & 0xff)) |
Definition at line 271 of file alignment.h.
#define MBEDTLS_BYTE_4 | ( | x | ) | ((uint8_t) (((x) >> 32) & 0xff)) |
Definition at line 272 of file alignment.h.
#define MBEDTLS_BYTE_5 | ( | x | ) | ((uint8_t) (((x) >> 40) & 0xff)) |
Definition at line 273 of file alignment.h.
#define MBEDTLS_BYTE_6 | ( | x | ) | ((uint8_t) (((x) >> 48) & 0xff)) |
Definition at line 274 of file alignment.h.
#define MBEDTLS_BYTE_7 | ( | x | ) | ((uint8_t) (((x) >> 56) & 0xff)) |
Definition at line 275 of file alignment.h.
Get the unsigned 16 bits integer corresponding to two bytes in big-endian order (MSB first).
data | Base address of the memory to get the two bytes from. |
offset | Offset from data of the first and most significant byte of the two bytes to build the 16 bits unsigned integer from. |
Definition at line 521 of file alignment.h.
Get the unsigned 16 bits integer corresponding to two bytes in little-endian order (LSB first).
data | Base address of the memory to get the two bytes from. |
offset | Offset from data of the first and least significant byte of the two bytes to build the 16 bits unsigned integer from. |
Definition at line 485 of file alignment.h.
Get the unsigned 24 bits integer corresponding to three bytes in big-endian order (MSB first).
data | Base address of the memory to get the three bytes from. |
offset | Offset from data of the first and most significant byte of the three bytes to build the 24 bits unsigned integer from. |
Definition at line 557 of file alignment.h.
Get the unsigned 24 bits integer corresponding to three bytes in little-endian order (LSB first).
data | Base address of the memory to get the three bytes from. |
offset | Offset from data of the first and least significant byte of the three bytes to build the 24 bits unsigned integer from. |
Definition at line 589 of file alignment.h.
Get the unsigned 32 bits integer corresponding to four bytes in big-endian order (MSB first).
data | Base address of the memory to get the four bytes from. |
offset | Offset from data of the first and most significant byte of the four bytes to build the 32 bits unsigned integer from. |
Definition at line 412 of file alignment.h.
Get the unsigned 32 bits integer corresponding to four bytes in little-endian order (LSB first).
data | Base address of the memory to get the four bytes from. |
offset | Offset from data of the first and least significant byte of the four bytes to build the 32 bits unsigned integer from. |
Definition at line 448 of file alignment.h.
Get the unsigned 64 bits integer corresponding to eight bytes in big-endian order (MSB first).
data | Base address of the memory to get the eight bytes from. |
offset | Offset from data of the first and most significant byte of the eight bytes to build the 64 bits unsigned integer from. |
Definition at line 621 of file alignment.h.
Get the unsigned 64 bits integer corresponding to eight bytes in little-endian order (LSB first).
data | Base address of the memory to get the eight bytes from. |
offset | Offset from data of the first and least significant byte of the eight bytes to build the 64 bits unsigned integer from. |
Definition at line 657 of file alignment.h.
#define MBEDTLS_IS_BIG_ENDIAN (*((unsigned char *) (&mbedtls_byte_order_detector)) == 0x01) |
Definition at line 390 of file alignment.h.
Put in memory a 16 bits unsigned integer in big-endian order.
n | 16 bits unsigned integer to put in memory. |
data | Base address of the memory where to put the 16 bits unsigned integer in. |
offset | Offset from data where to put the most significant byte of the 16 bits unsigned integer n . |
Definition at line 536 of file alignment.h.
Put in memory a 16 bits unsigned integer in little-endian order.
n | 16 bits unsigned integer to put in memory. |
data | Base address of the memory where to put the 16 bits unsigned integer in. |
offset | Offset from data where to put the least significant byte of the 16 bits unsigned integer n . |
Definition at line 500 of file alignment.h.
Put in memory a 24 bits unsigned integer in big-endian order.
n | 24 bits unsigned integer to put in memory. |
data | Base address of the memory where to put the 24 bits unsigned integer in. |
offset | Offset from data where to put the most significant byte of the 24 bits unsigned integer n . |
Definition at line 573 of file alignment.h.
Put in memory a 24 bits unsigned integer in little-endian order.
n | 24 bits unsigned integer to put in memory. |
data | Base address of the memory where to put the 24 bits unsigned integer in. |
offset | Offset from data where to put the least significant byte of the 24 bits unsigned integer n . |
Definition at line 605 of file alignment.h.
Put in memory a 32 bits unsigned integer in big-endian order.
n | 32 bits unsigned integer to put in memory. |
data | Base address of the memory where to put the 32 bits unsigned integer in. |
offset | Offset from data where to put the most significant byte of the 32 bits unsigned integer n . |
Definition at line 427 of file alignment.h.
Put in memory a 32 bits unsigned integer in little-endian order.
n | 32 bits unsigned integer to put in memory. |
data | Base address of the memory where to put the 32 bits unsigned integer in. |
offset | Offset from data where to put the least significant byte of the 32 bits unsigned integer n . |
Definition at line 464 of file alignment.h.
Put in memory a 64 bits unsigned integer in big-endian order.
n | 64 bits unsigned integer to put in memory. |
data | Base address of the memory where to put the 64 bits unsigned integer in. |
offset | Offset from data where to put the most significant byte of the 64 bits unsigned integer n . |
Definition at line 636 of file alignment.h.
Put in memory a 64 bits unsigned integer in little-endian order.
n | 64 bits unsigned integer to put in memory. |
data | Base address of the memory where to put the 64 bits unsigned integer in. |
offset | Offset from data where to put the least significant byte of the 64 bits unsigned integer n . |
Definition at line 672 of file alignment.h.
Definition at line 344 of file alignment.h.
Definition at line 354 of file alignment.h.
Definition at line 366 of file alignment.h.
Read the unsigned 16 bits integer from the given address, which need not be aligned.
p | pointer to 2 bytes of data |
Definition at line 115 of file alignment.h.
References r().
Read the unsigned 32 bits integer from the given address, which need not be aligned.
p | pointer to 4 bytes of data |
Definition at line 167 of file alignment.h.
References r().
Referenced by mbedtls_ct_memcpy_if(), mbedtls_xor(), and mbedtls_xor_no_simd().
Read the unsigned 64 bits integer from the given address, which need not be aligned.
p | pointer to 8 bytes of data |
Definition at line 219 of file alignment.h.
References r().
Referenced by mbedtls_ct_memcpy_if(), mbedtls_xor(), and mbedtls_xor_no_simd().
Write the unsigned 16 bits integer to the given address, which need not be aligned.
p | pointer to 2 bytes of data |
x | data to write |
Definition at line 142 of file alignment.h.
Write the unsigned 32 bits integer to the given address, which need not be aligned.
p | pointer to 4 bytes of data |
x | data to write |
Definition at line 194 of file alignment.h.
Referenced by mbedtls_ct_memcpy_if(), mbedtls_xor(), and mbedtls_xor_no_simd().
Write the unsigned 64 bits integer to the given address, which need not be aligned.
p | pointer to 8 bytes of data |
x | data to write |
Definition at line 246 of file alignment.h.
Referenced by mbedtls_ct_memcpy_if(), mbedtls_xor(), and mbedtls_xor_no_simd().
Definition at line 389 of file alignment.h.