martinpaljak / GlobalPlatformPro

🌐 🔐 Manage applets and keys on JavaCard-s like a pro (via command line or from your Java project)
https://javacard.pro/globalplatform
GNU Lesser General Public License v3.0
679 stars 210 forks source link

Incorrect length in install for install #242

Closed xavo95 closed 3 years ago

xavo95 commented 3 years ago

Fix #241

martinpaljak commented 3 years ago

Things to consider:

So encoding all lengths "properly" as default is OK. Just need to check the specs if there are fancy corner cases, because GPC 2.2.1 11.1.5 tells:

All length fields of GlobalPlatform messages and data objects defined in this specification, except for Lc and Le, are coded as defined for ASN.1 BER-TLV (see ISO 8825-1): 1 byte for a length up to 127, 2 bytes for a length up to 255, and 3 bytes for a length up to 65535, except where otherwise stated.

and there were corner cases for one byte encoding with keys at least.

martinpaljak commented 3 years ago

eg gpc 2.2.1 11.5.2.3.1

"The length field for a Load Token is as defined for ASN.1 BER-TLV (see ISO 8825-1) except that the length 128 may also be coded on one byte as '80'."

xavo95 commented 3 years ago

Okay I cant today but I will try to look at it too during this week, if its okay with you

martinpaljak commented 3 years ago

Sure, a PR is welcome, but I'd anyway fix it when working on GP at some point, thus keeipng it open.

martinpaljak commented 3 years ago

The issue is fixed by #246 whereas the UX to warn nicely will happen at a later time.