MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / Decode

Method Decode

src/cryptlib/integer.cpp:1363–1384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1361}
1362
1363void Integer::Decode(const byte *input, unsigned int inputLen, Signedness s)
1364{
1365 sign = ((s==SIGNED) && (input[0] & 0x80)) ? NEGATIVE : POSITIVE;
1366
1367 while (input[0]==0 && inputLen>0)
1368 {
1369 input++;
1370 inputLen--;
1371 }
1372
1373 reg.CleanNew(RoundupSize(bytesToWords(inputLen)));
1374
1375 for (unsigned i=0; i<inputLen; i++)
1376 reg[i/WORD_SIZE] |= input[inputLen-1-i] << (i%WORD_SIZE)*8;
1377
1378 if (sign == NEGATIVE)
1379 {
1380 for (unsigned i=inputLen; i<reg.size*WORD_SIZE; i++)
1381 reg[i/WORD_SIZE] |= 0xff << (i%WORD_SIZE)*8;
1382 TwosComplement(reg, reg.size);
1383 }
1384}
1385
1386unsigned int Integer::MinEncodedSize(Signedness signedness) const
1387{

Callers 2

util_TestUnprintableFunction · 0.45

Calls 4

RoundupSizeFunction · 0.85
bytesToWordsFunction · 0.85
TwosComplementFunction · 0.85
CleanNewMethod · 0.80

Tested by

no test coverage detected