mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-03-26 10:05:24 +00:00
Refactor get_byte function
Change implementation of `get_byte()` to call `unhexify()`.
This commit is contained in:
parent
64e45950de
commit
b220489422
|
@ -69,27 +69,13 @@ int verify_dependencies( uint8_t count, uint8_t * dep_p )
|
||||||
uint8_t receive_byte()
|
uint8_t receive_byte()
|
||||||
{
|
{
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
uint8_t c;
|
uint8_t c[3];
|
||||||
|
char *endptr;
|
||||||
|
c[0] = greentea_getc();
|
||||||
|
c[1] = greentea_getc();
|
||||||
|
c[2] = '\0';
|
||||||
|
|
||||||
c = greentea_getc();
|
assert( unhexify( &byte, &c ) != 2 );
|
||||||
if( c >= '0' && c <= '9' )
|
|
||||||
c -= '0';
|
|
||||||
else if( c >= 'a' && c <= 'f' )
|
|
||||||
c = ( c -'a' ) + 10;
|
|
||||||
else if( c >= 'A' && c <= 'F' )
|
|
||||||
c = ( c - 'A' ) + 10;
|
|
||||||
|
|
||||||
byte = c * 0x10;
|
|
||||||
|
|
||||||
c = greentea_getc();
|
|
||||||
if( c >= '0' && c <= '9' )
|
|
||||||
c -= '0';
|
|
||||||
else if( c >= 'a' && c <= 'f' )
|
|
||||||
c = ( c -'a' ) + 10;
|
|
||||||
else if( c >= 'A' && c <= 'F' )
|
|
||||||
c = ( c - 'A' ) + 10;
|
|
||||||
|
|
||||||
byte += c ;
|
|
||||||
return( byte );
|
return( byte );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue