Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Javaカードの世界 / The world of Java Card

moznion
September 07, 2018
13k

Javaカードの世界 / The world of Java Card

slides for #builderscon tokyo 2018

moznion

September 07, 2018
Tweet

More Decks by moznion

Transcript

  1. The world of Java Card The world of SIM Card?

    builderscon tokyo 2018 @moznion
  2. C

  3. Smart Card - ISO 7816 Ͱఆٛ͞Ε͍ͯΔ - λΠϓ͸2छྨ - Intelligent

    Smart Card - Memory Card - Java Card ͸ Intelligent Smart Card
  4. Smart Card Memory - Card্ʹ͸3λΠϓͷϝϞϦ͕৐͍ͬͯΔ - Persistent Immutable Memory: ROM

    - Persistent Mutable Memory: EPROM - Non-Persistent Mutable Memory: RAM
  5. Smart Card Interface - ֎քͱ͸Card Acceptance Device (CAD) ͱ
 Card্ͷContact

    PointsΛհͯ͠ߦ͏ - Card͸֎ͷੈքͱ͸ಠࣗͷϓϩτίϧʹ
 ΑΓσʔλͷ΍ΓऔΓΛߦ͏ => APDU
  6. APDU - APDU: Application Protocol Data Units - Smart Card͸APDUʹΑͬͯ


    ίϛϡχέʔγϣϯΛ
 ߦ͏͜ͱ͕Ͱ͖Δ OFCOM: Reprogrammable SIMs: Technology, Evolution and Implications
  7. APDU - APDU͸جຊతʹରʹͳ͍ͬͯΔ - Command (Request) APDU - Response APDU

    - Command͸ResponseͷৄࡉΛ஌͍ͬͯΔඞཁ͕͋Δ
  8. Command APDU Mandatory Header Optional body CLA INS P1 P2

    Lc Data field Le - CLA (1 byte): class (application) ͷࣝผࢠ - INS (1 byte): ໋ྩίʔυɽ͜ΕͰಈ࡞Λ੾ସ - P1/P2 (1 byte/1 byte): ໋ྩύϥϝʔλ - Lc (1 byte): Data fieldͷόΠτ௕ - Data field (Lc byte): ೚ҙͷόΠτྻ - Le (1 byte): ϨεϙϯεͷData fieldʹڐ͞ΕΔ࠷େόΠτ௕
  9. Response APDU Optional body Mandatory trailer Data field SW1 SW2

    - Data field(Le bytes): ϨεϙϯεσʔλͷόΠτྻ - SW1/SW2 (1 byte/1 byte): εςʔλεϫʔυ
  10. UICC (Universal Integrated Circuit Card) - Intelligent Smart CardͷҰछ -

    ͋Δఔ౓ͷԋࢉॲཧ͕Մೳ - Java Card (3.0.1Ҏ߱) ͷ࣮ߦج൫
  11. UICC (Universal Integrated Circuit Card) - CPU 32bit - ిؾಛੑ:

    1.8 / 3 / 5V - ΫϩοΫ: 1~5MHz - ROM: 16KB~ - EEPROM 8KB~ - RAM: 256B~
  12. Core O.S UICC Card Manager and Security domains Remote Applet

    Management Core Applications (USIM) File System servers Toolkit and Javacard runtime environment Javacard packages Javacard Applet UICC API and USIM API Javacard Toolkit Applet UICC Architecture
  13. Java Cardͷྺ࢙ https://en.wikipedia.org/wiki/Java_Card Version 2.1 (07.06.1999) Version 2.1.1 (18.05.2000) Version

    2.2 (11.2002) Version 2.2.1 (10.2003) Version 2.2.2 (03.2006) Version 3.0.1 (15.06.2009) Version 3.0.4 (06.08.2011) Version 3.0.5 (03.06.2015) -RSA without padding. -AES cryptography key encapsulation -CRC algorithms, -ECC key encapsulation, -Diffie-Hellman key exchange - Improved Logical Channels support (20) - SHA-256, SHA-384, SHA-512 - ISO9796-2, - HMAC, - Korean SEED MAC NOPAD, - Korean SEED NOPAD -Classic and Connected editions -SHA-224, SHA-2 for all signature algorithms -DES MAC8 ISO9797. - Diffie-Hellman modular exponentiation - Domain Data Conservation for Diffie- Hellman - Elliptic Curve and DSA keys, - RSA-3072 - SHA3 - plain ECDSA - AES CMAC - AES CTR. - Added the AppletEvent interface with the uninstall method. - Added the isAppletActive method to the JCSystem class
  14. - ੍ݶ͞Ε͍ͯΔػೳͷྫ - Dynamic class loading - Security Manager -

    Thread - Object cloning - Finalization - Large primitive data types - جຊతʹ16bitΛ্ݶͱͯ͠ಈ࡞͢Δ (ྫ֎͋Γ) - primitive type - native methods Java Card Restrictions
  15. - Initialization phase - Immutable memory (ROM) ྖҬʹॻ͖ࠐΉ - e.g.

    ൃߦऀ໊, ੡଄ऀ໊ͳͲ - Personalization phase - Immutable memory (ROM) ྖҬʹॻ͖ࠐΉ - e.g. Ϣʔβʔ໊, 伴, PINͳͲ - ੜΧʔυΛߪೖͨ͠ࡍ͸initialization phase·ͰࡁΜͰ͍Δ͜ͱ͕ଟ͍ Java Card Lifecycle
  16. Core O.S UICC Card Manager and Security domains Remote Applet

    Management Core Applications (USIM) File System servers Toolkit and Javacard runtime environment Javacard packages Javacard Applet UICC API and USIM API Javacard Toolkit Applet UICC Architecture
  17. Core O.S UICC Card Manager and Security domains Remote Applet

    Management Core Applications (USIM) File System servers Toolkit and Javacard runtime environment Javacard packages Javacard Applet UICC API and USIM API Javacard Toolkit Applet UICC Architecture
  18. - ͍ΘΏΔJava AppletͰ͸ͳ͍ - Java Card RuntimeͰಈ͔͢ΞϓϦέʔγϣϯͷ୯Ґ - Java Card্ʹ͸ෳ਺ͷAppletΛ֨ೲͰ͖Δ

    - ෳ਺ͷAppletΛಉ࣌ʹ࣮ߦ͢Δ͜ͱ͸Ͱ͖ͳ͍ - select()/deselect()Ͱಈ͔͢appletΛ੾Γସ͑Δ Applet
  19. Extreme Environment - int͕࢖͑Δͷ͸ඇৗʹݶఆతͳঢ়گͷΈ - Java Card 3.0Ҏ߱ (ClassicͰ͸࢖͑ͳ͍) -

    ಛघͳࣄ৘͕ͳ͍ݶΓshortΛ࢖͏ - float΍double͸࢖͑·ͤΜ - String΋࢖͑·ͤΜ - (࣮͸ϞμϯͳJava Card؀ڥͩͱ࢖͑Δ) - ୅ΘΓʹόΠτ഑ྻ (byte[]) Λ࢖͏ - ଟ࣍ݩ഑ྻ΋࢖͑·ͤΜ
  20. Extreme Environment - Πϯελϯεม਺͸EEPROMʹอଘ͞ΕΔ - EEPROMͷण໋͸͍͍ͩͨ100,000 writes - ॻ͖ࠐΈ·͘ΔͱͿͬյΕ·͢ -

    ϩʔΧϧม਺͸RAMʹอଘ͞ΕΔ - ͨͩ͠native typeʹݶΔ - Ͳ͏ͯ͠΋RAMʹอଘ͍ͨ͠ͱ͖͸ʁ - transient arrayΛ࢖͏ - JCSystem.makeTransientByteArray((short)255,JCSystem.CLEAR_ON_RESET); - ͜ΕΛEEPROMʹ໭͢͜ͱ͸Ͱ͖ͳ͍
  21. Compilation and bytecode conversion class .exp COMPILE .java CONVERT .cap

    .jca ͍ΘΏΔී௨ͷJDK (1.6͕҆ఆ͍ͯ͠Δ……)
  22. Compilation and bytecode conversion class .exp COMPILE .java CONVERT .cap

    .jca Java Card Development Kit όΠτίʔυΛม׵͢Δ
  23. Tool chain - IDE: Eclipse - javacard plugin͕͋Δ།ҰͷIDE? - JDK:

    JDK 1.6 (or later?) - JCDK: Java Card Development Kit
 (JCDK͸Java Cardͷόʔδϣϯʹ߹ΘͤΔ)
  24. Tool chain - Loading onto card: Smart Card Reader Writer

    - Live testing: NomadLAB Contact Spy, etc...
  25. ·ͱΊ - Smart Card͕Θ͔Γ·ͨ͠ - APDU͕Θ͔Γ·ͨ͠ - Java Card͕Θ͔Γ·ͨ͠ -

    Java Card (JCRE) Ͱಈ࡞͢ΔAppletΛॻ͚Δ
 Α͏ʹͳΓ·ͨ͠
  26. Q?

  27. Referenced docs - ISO 7816-4 - https://www.iso.org/standard/54550.html - Java Card

    Platform Specification - https://docs.oracle.com/javacard - How to write a Java Card applet: A developer's guide - https://www.javaworld.com/article/2076450/client-side-java/ how-to-write-a-java-card-applet--a-developer-s-guide.html