python-u2flib-server
python-u2flib-server copied to clipboard
`_parse_tlv_size` when tlv[1] <= 128
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.
I think this is a bug; but that code path is never exercised so it's never surfaced.
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.