makinako / OpenFIPS201

An open source reference card application for NIST FIPS 201-2 / NIST SP800-73-4, targeting Javacard 3.0.4+
Other
72 stars 34 forks source link

Support for multibyte tags in TLVWriter #61

Open dmercer-google opened 1 year ago

dmercer-google commented 1 year ago

TLVWriter doesn't offer good support for multibyte tags. It should also have a writeTag(byte[] tag) method.

I also noticed that writeTag(short tag) doesn't set a multibyte indicator byte nor does it set the continuation bit on the high byte.

Regarding how the multibyte indicator is added and continuation bit(s) are set or not set, this should be clearly documented in the API comments.

Regardless of your choice of supporting writeTag(byte[] tag) you should clearly document how the various writeTag methods work with respect to setting the multibyte indicator byte and if the user is expected to set the continuation bit.

makinako commented 1 year ago

As described in issue #60, the expectation is that the values are already constructed with the required class/multibyte indicators. it makes for a terrible general purpose TLV encoder but does the job for PIV, which has very simple requirements for its responses. The point is taken here that it is worth at least documenting the implementation decisions and constraints. I'll do that.