mirror of
https://github.com/yuzu-emu/mbedtls
synced 2024-11-24 10:38:41 +00:00
Fix endianity issue when reading uint32
The uint32 is given as a bigendian stream, in the tests, however, the char buffer that collected the stream read it as is, without converting it. Add a temporary buffer, to call `greentea_getc()` 8 times, and then put it in the correct endianity for input to `unhexify()`.
This commit is contained in:
parent
2ad73aa388
commit
6e76108e15
1 changed files with 14 additions and 13 deletions
|
@ -75,7 +75,7 @@ uint8_t receive_byte()
|
|||
c[1] = greentea_getc();
|
||||
c[2] = '\0';
|
||||
|
||||
assert( unhexify( &byte, c ) != 2 );
|
||||
TEST_HELPER_ASSERT( unhexify( &byte, c ) != 2 );
|
||||
return( byte );
|
||||
}
|
||||
|
||||
|
@ -90,18 +90,19 @@ uint8_t receive_byte()
|
|||
uint32_t receive_uint32()
|
||||
{
|
||||
uint32_t value;
|
||||
const uint8_t c[9] = { greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
'\0'
|
||||
};
|
||||
assert( unhexify( &value, c ) != 8 );
|
||||
return( (uint32_t)value );
|
||||
uint8_t c_be[8] = { greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc()
|
||||
};
|
||||
const uint8_t c[9] = { c_be[6], c_be[7], c_be[4], c_be[5], c_be[2],
|
||||
c_be[3], c_be[0], c_be[1], '\0' };
|
||||
TEST_HELPER_ASSERT( unhexify( (uint8_t*)&value, c ) != 8 );
|
||||
return( value );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue