SSP21-CPP
Static Public Member Functions | List of all members
ssp21::VLength Class Reference

#include <ssp21/crypto/VLength.h>

Static Public Member Functions

static FormatError write (uint32_t value, wseq32_t &dest)
 
static ParseError read (uint32_t &value, seq32_t &src)
 
static size_t size_in_bytes (uint32_t value)
 

Detailed Description

Variable-length unsigned 32-bit integer encoding/decoding

num bytes | # bits | max value | encoding


1 | 7 | 127 | { 0x7F } 2 | 14 | 16383 | { 0xFF, 0x7F } 3 | 21 | 2097151 | { 0xFF, 0xFF, 0x7F } 4 | 28 | 268435455 | { 0xFF, 0xFF, 0xFF, 0x7F }

We can only use the bottom 4 bits of the 5th byte.

2^32 - 1 encodes to { 0xFF, 0xFF, 0xFF, 0xFF, 0x0F }

Therefore, the 5th byte can NEVER be > than 0x0F

Definition at line 28 of file VLength.h.