MCPcopy Create free account
hub / github.com/LUX-Core/lux / BERLengthDecode

Function BERLengthDecode

src/cryptopp/asn.cpp:38–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38bool BERLengthDecode(BufferedTransformation &bt, lword &length, bool &definiteLength)
39{
40 byte b;
41
42 if (!bt.Get(b))
43 return false;
44
45 if (!(b & 0x80))
46 {
47 definiteLength = true;
48 length = b;
49 }
50 else
51 {
52 unsigned int lengthBytes = b & 0x7f;
53
54 if (lengthBytes == 0)
55 {
56 definiteLength = false;
57 return true;
58 }
59
60 definiteLength = true;
61 length = 0;
62 while (lengthBytes--)
63 {
64 if (length >> (8*(sizeof(length)-1)))
65 BERDecodeError(); // length about to overflow
66
67 if (!bt.Get(b))
68 return false;
69
70 length = (length << 8) | b;
71 }
72 }
73 return true;
74}
75
76bool BERLengthDecode(BufferedTransformation &bt, size_t &length)
77{

Callers 8

BERDecodeNullFunction · 0.85
BERDecodeOctetStringFunction · 0.85
BERDecodeTextStringFunction · 0.85
BERDecodeBitStringFunction · 0.85
BERDecodeMethod · 0.85
PutMethod · 0.85
InitMethod · 0.85
BERDecodeUnsignedFunction · 0.85

Calls 3

BERDecodeErrorFunction · 0.85
SafeConvertFunction · 0.85
GetMethod · 0.45

Tested by

no test coverage detected