python-u2flib-server icon indicating copy to clipboard operation
python-u2flib-server copied to clipboard

`_parse_tlv_size` when tlv[1] <= 128

Open tomciopp opened this issue 7 years ago • 2 comments

I am running through implementing a u2f server in elixir and have been using this library as a guide. I have a question about the following line of code: _parse_tlv_size

I am bit new to DER encoding, but I have found the following link to be useful

After going through the implementation I don't quite understand why n_bytes is being initialized to 1 instead of 0. When the value of the length triplet is 128 or less, shouldn't we just have an offset of 2 bytes (1 for tag and 1 for length) with the value being calculated based on the second byte? Perhaps I am misunderstanding something, but I was curious as to why an additional byte was necessary.

tomciopp avatar Oct 16 '17 23:10 tomciopp

I think this is a bug; but that code path is never exercised so it's never surfaced.

software-opal avatar Jun 05 '18 12:06 software-opal

Yeah, I think that code path which is why I don't think anyone has suggested to correct it. However, I'm fairly certain that it is incorrect as I wrote a DER encoder for elixir where that code path is hit. Not a huge issue IMO but I'd like to see it corrected so other reference implementations are correct.

tomciopp avatar Jun 05 '18 15:06 tomciopp