Fix UI display of signed negative integers smaller than 256 bits

This commit is contained in:
Alexandre Paillier
2022-06-08 18:30:25 +02:00
parent bbcfe5abc3
commit d5603857b3
3 changed files with 60 additions and 4 deletions

View File

@@ -34,6 +34,16 @@ void array_hexstr(char *strbuf, const void *bin, unsigned int len) {
*strbuf = 0; // EOS
}
void convertUint64BEto128(const uint8_t *const data, uint32_t length, uint128_t *const target) {
uint8_t tmp[INT128_LENGTH];
int64_t value;
value = u64_from_BE(data, length);
memset(tmp, ((value < 0) ? 0xff : 0), sizeof(tmp) - length);
memmove(tmp + sizeof(tmp) - length, data, length);
readu128BE(tmp, target);
}
void convertUint128BE(const uint8_t *const data, uint32_t length, uint128_t *const target) {
uint8_t tmp[INT128_LENGTH];