Project

General

Profile

Actions

Bug #1927

closed

Bad TLV nonNegativeInteger encoding of 253 through 255

Added by Anonymous over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Start date:
08/25/2014
Due date:
% Done:

0%

Estimated time:

Description

To reproduce, compile and run:

Interest interest = new Interest();
interest.setMinSuffixComponents(255);
interest.setNonce(new Blob(new byte[4]));
System.out.println(interest.wireEncode().toHex());

Expected output:

050f070009050d01ff12000a0400000000

The TLV for the non-negative integer MinSuffixComponents (type 0x0d) should be 0d01ff. Actual output:

0510070009060d0200ff12000a0400000000

Instead, it is encoded as 0d0200ff, using two bytes for the non-negative integer.

Analysis: the code for writeNonNegativeInteger was copied from the code for writeVarNumber which uses two bytes to encode integers staring from 253. But a non-negative integer uses one byte to encode integers 253 through 255.

Actions #1

Updated by Anonymous over 9 years ago

  • Status changed from New to Closed
Actions

Also available in: Atom PDF