mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-05 19:35:48 +03:00
@@ -71,21 +71,21 @@ void mbedtls_unaligned_access(int size, int offset)
|
|||||||
|
|
||||||
/* Define expected result by manually aligning the raw bytes, and
|
/* Define expected result by manually aligning the raw bytes, and
|
||||||
* reading back with a normal pointer access. */
|
* reading back with a normal pointer access. */
|
||||||
uint64_t raw_aligned;
|
uint64_t raw_aligned_64;
|
||||||
memcpy(&raw_aligned, ((uint8_t*)&raw) + offset, size / 8);
|
uint16_t *raw_aligned_16 = (uint16_t *) &raw_aligned_64;
|
||||||
|
uint32_t *raw_aligned_32 = (uint32_t *) &raw_aligned_64;
|
||||||
|
memcpy(&raw_aligned_64, ((uint8_t *) &raw) + offset, size / 8);
|
||||||
/* Make a 16/32/64 byte read from the aligned location, and copy to expected */
|
/* Make a 16/32/64 byte read from the aligned location, and copy to expected */
|
||||||
uint64_t expected = 0;
|
uint64_t expected = 0;
|
||||||
switch (size) {
|
switch (size) {
|
||||||
case 16:
|
case 16:
|
||||||
uint16_t *e16 = (uint16_t *) &raw_aligned;
|
expected = *raw_aligned_16;
|
||||||
expected = *e16;
|
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
uint32_t *e32 = (uint32_t *) &raw_aligned;
|
expected = *raw_aligned_32;
|
||||||
expected = *e32;
|
|
||||||
break;
|
break;
|
||||||
case 64:
|
case 64:
|
||||||
expected = raw_aligned;
|
expected = raw_aligned_64;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user