Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

_parse_tlv_size when tlv[1] <= 128 #43

Open
tomciopp opened this issue Oct 16, 2017 · 2 comments
Open

_parse_tlv_size when tlv[1] <= 128 #43

tomciopp opened this issue Oct 16, 2017 · 2 comments

Comments

@tomciopp
Copy link

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.

@software-opal
Copy link

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

@tomciopp
Copy link
Author

tomciopp commented Jun 5, 2018

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants