-1

I'm currently developing c# dll for machine to load applet into java card. I tried to convert file into bytes but the bytes are not the same as the bytes from pyapdutool.

From PYAPDUTOOL

<<80 E8 00 00 FA C4 82 53 AB 01 00 27 DE CA FF ED 02 02 04 00 01 0A A0 00 00 00 74 4D 79 54 00 10 12 63 6F 6D 2F 70 6E 6D 62 2F 6D 79 74 65 6E 74 65 72 61 02 00 21 00 27 00 21 00 35 00 29 02 DA 00 9A 25 80 25 56 04 A0 00 00 07 C1 3E C7 00 6A 00 19 25 01 04 04 00 04 00 29 04 03 01 07 A0 00 00 00 62 01 01 03 01 07 A0 00 00 00 62 02 01 03 01 07 A0 00 00 00 62 01 02 00 01 07 A0 00 00 00 62 00 01 03 00 35 04 0A A0 00 00 00 74 4A 50 4E 00 10 11 6B 0A A0 00 00 00 74 49 4D 4D 00 10 00 80 0A A0 00 00 00 74 4A 50 4A 00 10 08 F4 0A A0 00 00 00 74 4B 4B 4D 00 10 1A B2 06 00 9A 00 00 00 80 03 0B 00 0B 04 0E 00 00 00 9C FF FF 00 94 00 A3 02 03 02 5D 02 72 03 71 04 54 04 9C 04 E2 05 45 05 CF 06 9A 00 80 03 0B 00 0B 04 0E 00 00 09 10 FF FF 09 08 09 17 0A 77 0A D1 0A E6 0B 01

From convert .cap file into bytes

50 4B 03 04 14 00 08 08 08 00 94 74 F8 4C 00 00 00 00 00 00 00 00 00 00 00 00 14 00 04 00 4D 45 54 41 2D 49 4E 46 2F 4D 41 4E 49 46 45 53 54 2E 4D 46 FE CA 00 00 95 93 DF 6F 9B 30 10 C7 DF ....

From what i know 1st byte (C4) is compulsory for gp and followed by .cap file length (82 53 AB). how can i get the same apdu data as shown in pyapdutool?

vlp
  • 7,811
  • 2
  • 23
  • 51
Bya
  • 11
  • 2
  • 1
    Adding more details increases the chance to get useful answers and reduces probability for downvotes. For a start: Which file? Which pyadutool? How different are the results? – guidot Aug 21 '18 at 06:51
  • @Bya I edited and answered your question. Feel free to improve or revert my edit (to return back to your version there is a rollback button in [revision history](https://stackoverflow.com/posts/51941292/revisions))..Good luck with your project! – vlp Aug 23 '18 at 07:18

1 Answers1

2

Cap file is basically a jar file (which in turn resembles a zip file) and its format is described in "Virtual Machine Specification. Java Card Platform Version 3.0.5", section 6 "The CAP File Format" (available here).

It consists of several components (parts) which need to be loaded into the card in correct order (see section 6.3 in the above-mentioned document) -- you can't just take cap file bytes and send them to card.

Loading process is described in "GlobalPlatform Card Specification" (available here) -- see INSTALL and LOAD commands (you may want to check older versions of this document if your card uses it).

An alternative (and much simpler) way is to have a look at GlobalPlatformPro sources, (e.g. here and here).

Good luck!

vlp
  • 7,811
  • 2
  • 23
  • 51
  • Thank you so much for your reply.. i really appreciate it.. i will study more on this.. – Bya Aug 24 '18 at 07:05