I'm currently developing Javacard and generate the cap file using Ant script(the file name be like demo.cap), and now I want to construct the GP(GlobalPlatform) command to run the LOAD process on a samrt card. But it's encapsulated into cap format. Is there any way I can convert the cap file to its corresponding btye stream so I can truncate it and construct the data field of GP LOAD command, just like the figure link shown below? Load File Structure
CodePudding user response:
There is no such thing as a "hex format" - at least not in the way that you are using the term. A hex or hexadecimal format would be indicating a way to show hex on the screen, such as a1
, or A1
, or 0xA1
(etc.).
What you see is the human representation of bytes using hexadecimals. So if you see E2
then this is a byte with value E2
, or 1110 0010
in binary, or 242 in decimals (assuming that it represents a positive number).
I strongly recommend understanding the difference between binary (bit / byte) values and their representation / encoding techniques before diving deeper into Java Card. Lookup a few tutorials and check the tags encoding (binary to text) and character-encoding (text to binary) on Stack Overflow.
All the conversion to/from those particular command and response APDU's will be performed by a GP library or application, such as GlobalPlatformPro (Open Source in Java) or GP Shell (Open Source in C). Those libraries will just pick up the file and create the (usually encrypted) APDU's around them.
I have no affiliation with either project
When sending they may show the transmitted bytes as hexadecimals on your screen - if that kind of logging is enabled. The APDU's themselves are transmitted as binary - as opposed to text.
CodePudding user response:
As @Maarten kindly says -- have a look at GlobalPlatformPro, where LOAD commands are built and its related project CAPFile, where data stream for load is constructed.
Good luck with your project!