blob: 258a543fd7ae6d28bfe54f6a7b26ca94b6749490 [file] [log] [blame]
kasunath7ffd30a2022-05-10 18:11:34 -07001#include "rde_common.h"
2
3uint64_t rdeGetUnsignedInteger(const uint8_t* bytes, uint8_t numOfBytes)
4{
5 uint64_t num = 0;
6 for (uint8_t i = 0; i < numOfBytes; ++i)
7 {
8 num |= (uint64_t)(*(bytes + i)) << (i * 8);
9 }
10 return num;
11}
12
13uint64_t rdeGetNnint(const uint8_t* nnint)
14{
15 // In nnint, first byte indicate how many bytes are there. Remaining bytes
16 // represent the value in little-endian format.
17 const uint8_t size = *nnint;
18 return rdeGetUnsignedInteger(nnint + sizeof(uint8_t), size);
19}
20
21uint8_t rdeGetNnintSize(const uint8_t* nnint)
22{
23 // In nnint, first byte indicate how many bytes are there.
24 return *nnint + sizeof(uint8_t);
25}