JavaCard简介(中文版)
- 格式:doc
- 大小:921.00 KB
- 文档页数:15
Java Card CAP文件分析JAVA卡的可执行文件(CAP 文件)是编译多个应用程序(Applet)的生成结果,包含了一个包中定义的所有类和接口,与包之间是一一对应的关系。
实际发卡操作时,首先需要将该可执行文件下载至卡片中,并安装需要的应用实例;用户使用该安装的应用实例执行操作功能。
CAP文件包含12个组件:注意:一个完整的CAP文件,除COMPONET_Applet、COMPONET_Export 和COMPONET_Debug组件是可选外,其他均为必选。
每个组件封装成一个CAP包,包含在Jar包中。
最后在卡上只保留了5个组件:COMPONET_Method,COMPONET_Class,COMPONET_ConstantPool,COMPONET_StaticField和COMPONET_Export。
其余的组件只是安装时提取有用信息而不在卡中保存。
12个组件中,类class组件保存本应用声明的所有类和接口的信息;方法method 组件保存本应用声明的所有方法和接口,method中利用2字节索引index引用类、方法和域;常数池constant pool组件保存method组件引用的所有类、方法和域信息,分为类、实例域、虚方法、父方法、静态域和静态方法6类,每组信息为4个字节;相关地址reference location组件保存method组件中索引的偏移。
对于Java Card而言,应用程序的下载过程是即CAP文件写入到EEPROM的过程,即是对CAP文件的下载过程。
在CAP文件的下载过程中,需要将一部分组件进行解析,同时对reference location中指定的位置进行链接,能够链接到method 组件中的一个索引号,并根据索引号查找constant pool中保存的、与该索引号对应的类、方法或域在EEPROM中的实际地址,调用实际地址中存储的数据。
也就是说,方法的调用其实是需要两个步骤来实现的:1.根据reference location中指定的位置进行链接,获取method组件中的索引号;2.根据索引号查找constant pool中保存的、与该索引号对应的类、方法或域在EEPROM中的实际地址,调用实际地址中存储的数据。
Java Card™Platform Virtual Machine Specification, Classic EditionVersion 3.2January 2023Java Card Platform Virtual Machine Specification, Classic Edition Version 3.2Copyright © 1998, 2023, Oracle and/or its affiliates. All rights reserved.The Specification provided herein is provided to you only under the Oracle Technology Network Developer License included herein as Annex A - Oracle Technology Network Developer License Terms.License Restrictions Warranty/Consequential Damages DisclaimerThis software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.Warranty DisclaimerThe information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing.Restricted Rights NoticeIf this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable:U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, shall be subject to license terms and license restrictions applicable to the programs. No other rights are granted to the U.S. Government.Hazardous Applications NoticeThis software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications.Trademark NoticeOracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group.Third-Party Content, Products, and Services DisclaimerThis software or hardware and documentation may provide access to or information about content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services, except as set forth in an applicable agreement between you and Oracle.Documentation AccessibilityFor information about Oracle's commitment to accessibility, visit the Oracle Accessibility Program website at /pls/topic/lookup?ctx=acc&id=docacc.Access to Oracle SupportOracle customers that have purchased support have access to electronic support through My Oracle Support. For information, visit /pls/topic/lookup?ctx=acc&id=info or visit/pls/topic/lookup?ctx=acc&id=trs if you are hearing impaired.ContentsPreface (19)Who Should Use This Specification (19)Before You Read This Specification (19)Shell Prompts (19)Typographic Conventions (20)Related Documentation (20)Third-Party Web Sites (20)Documentation Accessibility (21)Access to Oracle Support (21)Oracle Welcomes Your Comments (21)1Introduction (22)1.1 Motivation (22)1.2 The Java Card Virtual Machine (23)1.3 Java Language Security (25)1.4 Java Card Runtime Environment Security (25)2 A Subset of the Java Virtual Machine (27)2.1 Why a Subset is Needed (27)2.2 Java Card Platform Language Subset (27)2.2.1 Unsupported Items (27)2.2.1.1 Unsupported Features (27)2.2.1.1.1 Dynamic Class Loading (27)2.2.1.1.2 Security Manager (28)2.2.1.1.3 Finalization (28)2.2.1.1.4 Threads (28)2.2.1.1.5 Cloning (28)2.2.1.1.6 Access Control in Java Packages (28)2.2.1.1.7 Typesafe Enums (28)2.2.1.1.8 Enhanced for Loop (29)2.2.1.1.10 Runtime Visible Metadata (Annotations) (29)2.2.1.1.11 Assertions (29)2.2.1.2 Unsupported Keywords (29)2.2.1.3 Unsupported Types (29)2.2.1.4 Unsupported Classes (29)2.2.1.4.1 System (30)2.2.2 Supported Items (30)2.2.2.1 Supported Features (30)2.2.2.1.1 Packages (30)2.2.2.1.2 Dynamic Object Creation (30)2.2.2.1.3 Virtual Methods (30)2.2.2.1.4 Interfaces (30)2.2.2.1.5 Exceptions (30)2.2.2.1.6 Generics (31)2.2.2.1.7 Static Import (31)2.2.2.1.8 Runtime Invisible Metadata (Annotations) (31)2.2.2.2 Supported Keywords (31)2.2.2.3 Supported Types (32)2.2.2.4 Supported Classes (32)2.2.2.4.1 Object (32)2.2.2.4.2 Throwable (32)2.2.3 Optionally Supported Items (32)2.2.3.1 Integer Data Type (33)2.2.3.2 Object Deletion Mechanism (33)2.2.4 Limitations of the Java Card Virtual Machine (33)2.2.4.1 Limitations of Packages (33)2.2.4.1.1 Packages in a Java Card CAP file (33)2.2.4.1.2 Package References (33)2.2.4.1.3 Package Name (33)2.2.4.2 Limitations of Classes (34)2.2.4.2.1 Classes in a Package (34)2.2.4.2.3 Static Fields (34)2.2.4.2.4 Static Methods (34)2.2.4.3 Limitations of Objects (34)2.2.4.3.1 Methods (34)2.2.4.3.2 Class Instances (34)2.2.4.3.3 Arrays (34)2.2.4.4 Limitations of Methods (34)2.2.4.5 Limitations of Switch Statements (35)2.2.4.6 Limitations of Class Initialization (35)2.2.5 Multiselectable Applets Restrictions (35)2.2.6 Java Card Platform Remote Method Invocation (RMI) Restrictions (35)2.2.6.1 Remote Classes and Remote Interfaces (36)2.2.6.2 Access Control of Remote Interfaces (36)2.2.6.3 Parameters and Return Values (36)2.3 Java Card VM Subset (36)2.3.1 Class File Subset (37)2.3.1.1 Not Supported in Class Files (37)2.3.1.1.1 Class Access Flags (37)2.3.1.1.2 Field Descriptors (37)2.3.1.1.3 Constant Pool (37)2.3.1.1.4 Fields (37)2.3.1.1.5 Methods (37)2.3.1.2 Supported in Class Files (37)2.3.1.2.1 ClassFile (37)2.3.1.2.2 Field Descriptors (37)2.3.1.2.3 Method Descriptors (38)2.3.1.2.4 Constant Pool (38)2.3.1.2.5 Fields (38)2.3.1.2.6 Methods (38)2.3.1.2.7 Attributes (38)2.3.2 Bytecode Subset (38)2.3.2.2 Supported Bytecodes (40)2.3.2.3 Static Restrictions on Bytecodes (42)2.3.2.3.1 ldc, ldc_w (42)2.3.2.3.2 lookupswitch (42)2.3.2.3.3 tableswitch (42)2.3.2.3.4 wide (42)2.3.3 Exceptions (43)2.3.3.1 Uncaught and Uncatchable Exceptions (43)2.3.3.2 Checked Exceptions (43)2.3.3.3 Runtime Exceptions (44)2.3.3.4 Errors (44)3Structure of the Java Card Virtual Machine (46)3.1 Data Types and Values (46)3.2 Words (46)3.3 Runtime Data Areas (47)3.4 Contexts (47)3.5 Frames (47)3.6 Representation of Objects (48)3.7 Special Initialization Methods (48)3.8 Exceptions (48)3.9 Binary File Formats (48)3.10 Instruction Set Summary (48)3.10.1 Types and the Java Card Virtual Machine (49)4Binary Representation (51)4.1 Java Card Platform File Formats (51)4.1.1 Export File Format (51)4.1.2 CAP File Format (52)4.1.3 JAR File Container (52)4.2 AID-based Naming (53)4.2.1 The AID Format (53)4.2.2 AID Usage (53)4.2.2.2 Applet AID namespace (53)4.2.2.3 Package AID namespace (54)4.2.2.3 Custom Component AID namespace (54)4.3 Token-based Linking (54)4.3.1 Externally Visible Items (54)4.3.2 Private Tokens (55)4.3.3 The Export File and Conversion (55)4.3.4 References – External and Internal (55)4.3.5 Installation and Linking (56)4.3.6 Token Assignment (56)4.3.7 Token Details (56)4.3.7.1 Package (56)4.3.7.2 Classes and Interfaces (56)4.3.7.3 Static Fields (57)4.3.7.4 Static Methods and Constructors (57)4.3.7.5 Instance Fields (57)4.3.7.6 Virtual Methods (58)4.3.7.7 Interface Methods (58)4.4 Binary Compatibility (59)4.5 CAP and Package Versions (60)4.5.1 Assigning (60)4.5.2 Linking (60)5The Export File Format (62)5.1 Export File Name (62)5.2 Containment in a JAR File (62)5.3 Ownership (62)5.4 Hierarchies Represented (63)5.5 Export File (63)5.6 Constant Pool (65)5.6.1 CONSTANT_Package (65)5.6.2 CONSTANT_Classref (67)5.6.4 CONSTANT_Utf8 (68)5.7 Classes and Interfaces (68)5.8 Fields (71)5.9 Methods (73)5.10 Attributes (75)5.10.1 ConstantValue Attribute (75)6The CAP File Format (77)6.1 CAP File Overview (77)6.2 Component Model (78)6.2.1 Containment in a JAR File (79)6.2.2 Defining New Components (80)6.3 Installation (81)6.4 Header Component (81)6.5 Directory Component (85)6.6 Applet Component (90)6.7 Import Component (92)6.8 Constant Pool Component (93)6.8.1 CONSTANT_Classref (95)6.8.2 CONSTANT_InstanceFieldref, CONSTANT_VirtualMethodref, CONSTANT_SuperMethodref (96)6.8.3 CONSTANT_StaticFieldref and CONSTANT_StaticMethodref (98)6.9 Class Component (100)6.9.1 type_descriptor (102)6.9.2 interface_info, class_info_compact and class_info_extended (104)6.9.2.1 interface_info, class_info_compact and class_info_extended Shared Items (105)6.9.2.2 interface_info Items (106)6.9.2.3 class_info_compact and class_info_extended Items (107)6.9.2.4 method_block_info (111)6.9.2.5 implemented_interface_info (112)6.9.2.6 remote_interface_info (113)6.9.2.7 public_virtual_method_token_mapping (115)6.10 Method Component (116)6.10.1 method_component_block (117)6.10.2 Exception Handler Example (118)6.10.3 exception_handler_info (119)6.10.4 method_info (121)6.11 Static Field Component (123)6.12 Reference Location Component (127)6.12.1 reference_location_component_block (128)6.13 Export Component (130)6.14 Descriptor Component (133)6.14.1 package_descriptor_info (135)6.14.2 class_descriptor_info_compact and class_descriptor_info_extended (135)6.14.3 field_descriptor_info (137)6.14.4 method_descriptor_info_compact and method_descriptor_info_extended (139)6.14.5 type_descriptor_info (142)6.15 Debug Component (143)6.15.1 package_debug_info_compact and package_debug_info_extended Structures (145)6.15.2 The class_debug_info_compact and class_debug_info_extended Structures (145)6.15.2.1 The field_debug_info Structure (148)6.15.2.2 The method_debug_info_compact and method_debug_info_extended Structures (150)6.16 Static Resource Component (154)7Java Card Virtual Machine Instruction Set (157)7.1 Assumptions: The Meaning of “Must” (157)7.2 Reserved Opcodes (157)7.3 Virtual Machine Errors (157)7.4 Security Exceptions (158)7.5 The Java Card Virtual Machine Instruction Set (159)7.5.1 aaload (160)7.5.2 aastore (161)7.5.3 aconst_null (163)7.5.4 aload (163)7.5.5 aload_<n> (164)7.5.6 anewarray (165)7.5.8 arraylength (166)7.5.9 astore (166)7.5.10 astore_<n> (167)7.5.11 athrow (168)7.5.12 baload (169)7.5.13 bastore (169)7.5.14 bipush (170)7.5.15 bspush (171)7.5.16 checkcast (171)7.5.17 dup (173)7.5.18 dup_x (174)7.5.19 dup2 (175)7.5.20 getfield_<t> (175)7.5.21 getfield_<t>_this (176)7.5.22 getfield_<t>_w (178)7.5.23 getstatic_<t> (179)7.5.24 goto (180)7.5.25 goto_w (181)7.5.26 i2b (181)7.5.27 i2s (182)7.5.28 iadd (182)7.5.29 iaload (183)7.5.30 iand (184)7.5.31 iastore (184)7.5.32 icmp (185)7.5.33 iconst_<i> (186)7.5.34 idiv (186)7.5.35 if_acmp<cond> (187)7.5.36 if_acmp<cond>_w (188)7.5.37 if_scmp<cond> (189)7.5.38 if_scmp<cond>_w (189)7.5.40 if<cond>_w (191)7.5.41 ifnonnull (192)7.5.42 ifnonnull_w (193)7.5.43 ifnull (193)7.5.44 ifnull_w (194)7.5.45 iinc (194)7.5.46 iinc_w (195)7.5.47 iipush (195)7.5.48 iload (196)7.5.49 iload_<n> (197)7.5.50 ilookupswitch (197)7.5.51 imul (198)7.5.52 ineg (199)7.5.53 instanceof (200)7.5.54 invokeinterface (202)7.5.54.1 Interface Method Resolution (203)7.5.55 invokespecial (204)7.5.56 invokestatic (205)7.5.56.1 Super Method Resolution (206)7.5.57 invokevirtual (206)7.5.57.1 Virtual Method Resolution (207)7.5.58 ior (208)7.5.59 irem (208)7.5.60 ireturn (209)7.5.61 ishl (210)7.5.62 ishr (210)7.5.63 istore (211)7.5.64 istore_<n> (211)7.5.65 isub (212)7.5.66 itableswitch (213)7.5.67 iushr (214)7.5.69 jsr (215)7.5.70 new (216)7.5.71 newarray (216)7.5.72 nop (217)7.5.73 pop (218)7.5.74 pop2 (218)7.5.75 putfield_<t> (219)7.5.76 putfield_<t>_this (220)7.5.77 putfield_<t>_w (222)7.5.78 putstatic_<t> (223)7.5.79 ret (224)7.5.80 return (225)7.5.81 s2b (225)7.5.82 s2i (226)7.5.83 sadd (226)7.5.84 saload (227)7.5.85 sand (228)7.5.86 sastore (228)7.5.87 sconst_<s> (229)7.5.88 sdiv (229)7.5.89 sinc (230)7.5.90 sinc_w (231)7.5.91 sipush (231)7.5.92 sload (232)7.5.93 sload_<n> (232)7.5.94 slookupswitch (233)7.5.95 smul (234)7.5.96 sneg (234)7.5.97 sor (235)7.5.98 srem (235)7.5.99 sreturn (236)7.5.101 sshr (237)7.5.102 sspush (238)7.5.103 sstore (238)7.5.104 sstore_<n> (239)7.5.105 ssub (239)7.5.106 stableswitch (240)7.5.107 sushr (241)7.5.108 swap_x (241)7.5.109 sxor (242)8Tables of Instructions (244)8.1 Instructions by Opcode Value (244)8.2 Instructions by Opcode Mnemonic (248)Glossary (254)Annex A - Oracle Technology Network Developer License Terms (269)FiguresFigure 1-1: Java Card Application or Library Conversion (23)Figure 1-2: Java Card Application or Library Installation (24)Figure 4-1: Mapping Package Identifiers to AIDs (54)Figure 4-2: Binary Compatibility Example (59)TablesTable 2-1: Unsupported Java Constant Pool Tags (37)Table 2-2: Supported Java Constant Pool Tags (38)Table 2-3: Support of Java Checked Exceptions (43)Table 2-4: Support of Java Runtime Exceptions (44)Table 2-5: Support of Java Errors (44)Table 3-1: Type Support in the Java Card Virtual Machine Instruction Set (49)Table 3-2: Storage Types and Computational Types (50)Table 4-1: AID Format (53)Table 4-2: Token Range, Type and Scope (56)Table 4-3: Tokens For Instance Fields (57)Table 5-1: Export File Constant Pool Tags (65)Table 5-2: Export File Package Flags (66)Table 5-3: Export File Class Access and Modifier Flags (69)Table 5-4: Export File Field Access and Modifier Flags (72)Table 5-5: Export File Method Access and Modifier Flags (74)Table 6-1: CAP File Component Tags (79)Table 6-2: CAP File Component File Names (79)Table 6-3: CAP File Flags (83)Table 6-4: CAP File Constant Pool Tags (94)Table 6-5: Type Descriptor Values (102)Table 6-6: Encoded Reference Type p1.c1 (103)Table 6-7: Encoded Byte Array Type (103)Table 6-8: Encoded Reference Array Type p1.c1 (103)Table 6-9: Encoded Method Signature ()V (104)Table 6-10: Encoded Method Signature (Lp1.ci;)S (104)Table 6-11: CAP File Interface and Class Flags (106)Table 6-12: CAP File Method Flags (122)Table 6-13: Segments of a Static Field Image (124)Table 6-14: Static Field Sizes (124)Table 6-15: Array Types (126)Table 6-16: One-byte Reference Location Example (129)Table 6-17: CAP File Class Descriptor Flags (136)Table 6-18: CAP File Field Descriptor Flags (138)Table 6-19: Primitive Type Descriptor Values (139)Table 6-20: CAP File Method Descriptor Flags (140)Table 6-21: Class Access and Modifier Flags (146)Table 6-22: Field Access and Modifier Flags (149)Table 6-23: Method Modifier Flags (151)Table 7-1: Example Instruction Entry (159)Table 7-2: Array Values (172)Table 7-3: Array Values (200)Table 7-4: Array Values (217)Table 8-1: Instructions by Opcode Value (244)Table 8-2: Instructions by Opcode Mnemonic (248)PrefaceJava Card technology combines a subset of the Java programming language with a runtime environment optimized for secure elements, such as smart cards and other tamper-resistant security chips. Java Card technology offers a secure and interoperable execution platform that can store and update multiple applications on a single resource-constrained device, while retaining the highest certification levels and compatibility with standards. Java Card developers can build, test, and deploy applications and services rapidly and securely. This accelerated process reduces development costs, increases product differentiation, and enhances value to customers.The Classic Edition of the Java Card Platform is defined by three specifications:∙Virtual Machine Specification, Java Card Platform, Version 3.2, Classic Edition,∙Runtime Environment Specification, Java Card Platform, Version 3.2, Classic Edition,∙Application Programming Interface, Java Card Platform, Version 3.2, Classic Edition.This document is a specification of the Classic Edition of the Java Card Platform, Version 3.2, Virtual Machine (Java Card VM).In this book, Java Card Platform refers to version 3.2 to distinguish it from all earlier versions. A vendor of a Java Card technology-enabled device provides an implementation of the Java Card RE. An implementation within the context of this specification refers to a vendor's implementation of the Java Card Virtual Machine (or Java Card VM), the Java Card Application Programming Interface (API), or other component, based on the Java Card technology specifications. A "reference implementation" is an implementation produced by Oracle. Application software written for the Java Card platform is referred to as a Java Card technology-based applet (Java Card applet or card applet).Who Should Use This SpecificationThis specification is intended to assist implementers of the Java Card RE in creating an implementation, developing a specification to extend the Java Card technology specifications, or in creating an extension to the runtime environment for the Java Card platform. This specification is also intended for Java Card applet developers who want a greater understanding of the Java Card technology specifications.Before You Read This SpecificationBefore reading this guide, you should be familiar with the Java programming language, the other Java Card technology specifications, and smart card technology. A good resource for becoming familiar with Java technology and Java Card technology located at:/technetwork/java/javacard/overview/Shell PromptsShell PromptC shell machine-name%C shell superuser machine-name#Bourne shell and Korn shell $Bourne shell and Korn shell superuser #Typographic ConventionsThe settings on your browser might differ from these settings. Typeface Meaning ExamplesAaBbCc123 The names of commands,files, and directories; on-screen computer output Edit your .login file. Use ls -a to list all files. % You have mail.AaBbCc123 What you type, whencontrasted with on-screen computer output %su Password:AaBbCc123 Book titles, new words orterms, words to beemphasized. Replacecommand-line variableswith real names orvalues. Read Chapter 6 in the User's Guide. These are called class options. You must be superuser to do this. To delete a file, type rm filename.Related DocumentationReferences to various documents or products are made in this guide, so you might want to have them available:∙Application Programming Interface, Java Card Platform, Version 3.2, Classic Edition∙Runtime Environment Specification, Java Card Platform, Version 3.2, Classic Edition∙The Java Language Specification (https:///javase/specs/)∙ISO 7816 Specification Parts 1-6. (https://)Third-Party Web SitesOracle is not responsible for the availability of third-party web sites mentioned in this document. Oracle does not endorse and is not responsible or liable for any content, advertising, products, or other materials that are available on or through such sites or resources. Oracle will not be responsible or liable for any actual or alleged damage or loss caused by or in connection with the use of or reliance on any such content, goods, or services that are available on or through such sites or resources.Documentation AccessibilityFor information about Oracle's commitment to accessibility, visit the Oracle Accessibility Program website at:/pls/topic/lookup?ctx=acc&id=docacc.Access to Oracle SupportOracle customers that have purchased support have access to electronic support through My Oracle Support. For information, visit:/pls/topic/lookup?ctx=acc&id=infoOr, if you are hearing impaired, visit:/pls/topic/lookup?ctx=acc&id=trsOracle Welcomes Your CommentsOracle is interested in improving its documentation and welcomes your comments and suggestions.Please include the title of your document with your feedback:Virtual Machine Specification, Java Card Platform, v3.2, Classic Edition1IntroductionThis document specifies the Java Card Virtual Machine features required by the Classic Edition ofJava Card technology.∙It defines the subset of the Java Virtual Machine used for the Java Card Virtual Machine and list the supported and unsupported features.∙It defines the binary representation of the application code, the role and structure of the Export and CAP file formats and their use in the verification and linking process.∙It specifies the Java Card Virtual Machine byte-code set and its detailed behavior.1.1 MotivationJava Card technology enables programs written in the Java programming language to be run on secure elements such as smart cards and other tamper-resistant security chips. Developers can build and test programs using standard software development tools and environments, then convert them into a form that can be installed onto a Java Card technology-enabled device. Application software for the Java Card platform is called an applet, or more specifically, a Java Card applet (to distinguish it from browser applets).While Java Card technology enables programs written in the Java programming language to run on small devices such as smart cards, those are far too under-powered to support the full functionality of the Java platform. Therefore, the Java Card platform supports only a carefully chosen, customized subset of the features of the Java platform. This subset provides features that are well-suited for writing programs for small devices and preserves the object-oriented capabilities of the Java programming language.A simple approach to specifying a Java Card virtual machine would be to describe the subset of the features of the Java virtual machine that must be supported to allow for portability of source code across all Java Card technology enabled devices. Combining that subset specification and the information in Java Virtual Machine Specification, smart card and secure elements manufacturers could construct their own Java Card technology-based implementations (“Java Card implementations”). While that approach is feasible, it has a serious drawback. The resultant platform would be missing the important feature of binary portability of Java Card applets.The standards that define the Java platform allow for binary portability of Java programs across all Java platform implementations. This “write once, run anywhere” quality of Java programs is perhaps the most significant feature of the platform. Part of the motivation for the creation of the Java Cardplatform was to bring just this kind of binary portability to the embedded security and smart card industry. In a world with billions of secure elements with varying processors and configurations, the costs of supporting multiple binary formats for software distribution could be overwhelming.This Virtual Machine Specification, Java Card Platform, v3.2, Classic Edition is the key to providing binary portability. One way of understanding what this specification does is to compare it to its counterpart in the Java platform. The Java virtual machine specification defines a Java virtual machine as an engine that loads Java class files and executes them with a particular set of semantics. The class file is a central piece of the Java architecture, and it is the standard for the binary compatibility of the Java platform. The Virtual Machine Specification, Java Card Platform, v3.2, Classic Edition also defines a file format that is the standard for binary compatibility for the Java Card platform: the CAP file format is the form in which software is deployed to be loaded onto devices which implement a Java Card virtual machine.1.2 The Java Card Virtual MachineThe role of the Java Card virtual machine is best understood in the context of the process for production and deployment of software for the Java Card platform. There are several components that make up a Java Card system, including the Java Card virtual machine, the Converter for the Java Card platform (“Java Card Converter”), a terminal installation tool, and an installation program that runs on the device, as shown in Figure 1-1 and Figure 1-2.Figure 1-1: Java Card Application or Library ConversionFigure 1-2: Java Card Application or Library InstallationDevelopment of a Java Card applet begins as with any other Java program: a developer writes one or more Java classes, and compiles the source code with a Java compiler, producing one or more class files. The applet is run, tested and debugged on a workstation using simulation tools to emulate the device environment. Then, when an applet is ready to be downloaded to a device, the class files comprising the applet are converted to a CAP (converted applet) file using a Java Card Converter.The Java Card Converter takes as input all of the class files in one or more Java packages which make up a Java Card CAP file. A Java package that contains one or more non-abstract subclasses, direct or indirect, of the javacard.framework.Applet class is referred to as an applet package. Otherwise the package is referred to as a library package. A Java Card CAP file may contain only applet packages, only library packages or a combination of applet and library packages. Additionally, both applet and library packages in a Java Card CAP file can be public or private.A private library package in a Java Card CAP file is not listed in the Export Component (6.13 Export Component) of the CAP file and is therefore not visible outside the Java Card CAP file. Similarly, a private applet package in a Java Card CAP file is not listed in the Export Component (6.13 Export Component) of the CAP file, however, non-abstract direct or indirect subclasses of thejavacard.framework.Applet class are listed in the Applet Component (6.6 Applet Component) of the CAP file. For a public applet package in a Java Card CAP file, only public interfaces extending javacard.framework.Shareable are listed in the Export Component (6.13 Export Component) of the CAP file and are therefore visible outside the Java Card CAP file. For further details see The CAP File Format.The Java Card Converter also takes as input one or more export files. An export file contains name and link information for the contents of other packages that are imported by the classes being converted. The converter can also produce export files for the public applet and library packages in a CAP file.After conversion, the CAP file is copied to a terminal, such as a desktop computer with a card reader peripheral. Then an installation tool on the terminal loads the CAP file and transmits it to the Java Card technology-enabled device. An installation program on the device receives the contents of the CAP file。
1、简介Java Card 3 平台由两个版本组成Classic Edition和Connected Edition:Classic Edition是一个基于 2.2.2版本的前端兼容的演化平台,针对资源有限的设备仅支持applet-based应用。
如果你只对Classic Edition中提供的功能感兴趣的话就可以忽略Connected Edition。
Connected Edition提供了一个显著增强的运行时环境和一个新的虚拟机。
包含了一些新的面向网络的应用,例如提供了针对web应用的Servlet APIs,并且支持一些新的applet功能增强。
一个Connected Edition的应用可能会用到Classic Edition提供的特性,因此这两个版本的规范应用一起使用。
1.1动机Java Card技术使得用Java编程语言编写的程序可以运行在智能卡和其他小的资源紧张的设备上。
开发人员可以用标准的软件开发工具和环境来编译和调试程序,然后把程序转化成能被Java Card支持的格式。
Java Card上的应用程序被称为Applet,或者更明确的称为Java Card Applet 或者Card Applet(为了和浏览器Applets做区分)。
Java Card技术使得用Java语言编写的程序可以在智能卡上运行,然而如此小的设备远不足以支持Java平台的全部功能。
因此,Java Card平台仅仅支持一个被仔细挑选,定制的Java平台属性的的子集。
这个子集使得写的程序在小设备上有更好适应性,并且保持了Java语言的面向对象的特性。
一个简单的途径是定义一个代码可以在所有Java Card环境下移植的Java虚拟机的子集。
结合JVM的子集规定和信息,智能卡提供商可以在Java Card规范上构建自己的工具。
虽然手段是可行的,但有一个严重的缺点,目标平台将会丧失字节码的移植性。
Java平台的规范允许Java的代码在所有Java平台上移植,Java的“写一次,所有地方运行”的属性或许是平台的最重要的特性。
java说明文档中文版篇一:java说明文档中文版Java SE Platform 软件包java.applet 提供创建applet 所必需的类和applet 用来与其applet 上下文通信的类。
java.awt 包含用于创建用户界面和绘制图形图像的所有类。
java.awt.color 提供用于颜色空间的类。
java.awt.datatransfer 提供在应用程序之间和在应用程序内部传输数据的接口和类。
java.awt.dnd Drag 和Drop 是一种直接操作动作,在许多图形用户界面系统中都会遇到它,它提供了一种机制,能够在两个与GUI 中显示元素逻辑相关的实体之间传输信息。
java.awt.event 提供处理由AWT 组件所激发的各类事件的接口和类。
java.awt.font 提供与字体相关的类和接口。
java.awt.geom 提供用于在与二维几何形状相关的对象上定义和执行操作的Java 2D 类。
java.awt.im 提供输入方法框架所需的类和接口。
java.awt.im.spi 提供启用可以与Java 运行时环境一起使用的输入方法开发的接口。
java.awt.image 提供创建和修改图像的各种类。
java.awt.image.renderable 提供用于生成与呈现无关的图像的类和接口。
java.awt.print 为通用的打印API 提供类和接口。
java.beans 包含与开发beans 有关的类,即基于JavaBeansTM 架构的组件。
java.beans.beancontext 提供与bean 上下文有关的类和接口。
java.io 通过数据流、序列化和文件系统提供系统输入和输出。
ng 提供利用Java 编程语言进行程序设计的基础类。
ng.annotation 为Java 编程语言注释设施提供库支持。
ng.instrument 提供允许Java 编程语言代理检测篇二:java说明文档中文版JA VA开发人员必备是CHM格式的,中文版,就是详细介绍java(j2se平台)系统包,类库的文档JavaTM 2 Platform Standard Edition 6API 规范本文档是Java 2 Platform Standard Edition 6.0 的API 规范。
GlobalPlatform卡片规范版本2.22006年5月目录1 介绍 (7)1.1 受众 (8)1.2 标准参考规范 (8)1.3 术语及定义 (10)1.4 缩写和符号 (13)2 系统架构 (17)3 卡片架构 (18)3.1 安全域 (18)3.2 全局服务应用 (19)3.3 运行时环境 (19)3.4 可信任框架 (19)3.5 GlobalPlatform环境(OPEN) (19)3.6 GlobalPlatform API (20)3.7 卡片内容 (20)3.8 卡片管理器 (20)4 安全架构 (21)4.1 目标 (21)4.2 安全职责和要求 (21)4.2.1 发卡方的职责 (21)4.2.2 应用提供方的职责 (22)4.2.3 授权管理者的职责 (22)4.2.4 卡片组件的安全性要求 (22)4.2.4.1 运行时环境的安全性要求 (22)4.2.4.2 可信任框架的安全性要求 (22)4.2.4.3 OPEN的安全性要求 (22)4.2.4.4 安全域的的安全性要求 (23)4.2.4.5 全局服务应用的安全性要求 (23)4.2.4.6 应用的安全性要求 (23)4.2.5 后台系统的安全性要求 (23)4.3 加密支持 (23)4.3.1 安全的卡片内容管理 (24)4.3.1.1 加载文件数据块散列值 (24)4.3.1.2 加载文件数据块签名(DAP) (24)4.3.1.3 委托管理令牌 (24)4.3.1.4 收条 (24)4.3.2 安全通信 (24)5 生命周期模型 (27)5.1 卡片生命周期 (27)5.1.1 卡片生命周期状态 (27)5.1.1.1 卡片生命周期状态OP_READY (27)5.1.1.2 卡片生命周期状态INITIALIZED (28)5.1.1.3 卡片生命周期状态SECURED (28)5.1.1.4 卡片生命周期状态CARD_LOCKED (28)5.1.1.5 卡片生命周期状态TERMINATED (28)5.1.2 卡片生命周期状态的迁移 (28)5.2 可执行加载文件和可执行模块生命周期 (29)5.2.1 可执行加载文件生命周期 (29)5.2.1.1 Executable Load Life Cycle LOADED (29)5.2.1.2 可执行加载文件的删除 (30)5.2.2 可执行模块的生命周期 (30)5.3 应用和安全域的生命周期 (30)5.3.1 应用生命周期状态 (30)5.3.1.1 应用生命周期状态INSTALLED (30)5.3.1.2 应用生命周期状态SELECTABLE (31)5.3.1.3 应用生命周期状态LOCKED (31)5.3.1.4 应用的删除 (31)5.3.1.5 应用自定义的生命周期状态 (31)5.3.1.6 应用生命周期状态的迁移 (31)5.3.2 安全域生命周期状态 (32)5.3.2.1 安全域生命周期状态INSTALLED (32)5.3.2.2 安全域生命周期状态SELECTABLE (33)5.3.2.3 安全域生命周期状态PERSONALIZED (33)5.3.2.4 安全域生命周期状态LOCKED (33)5.3.2.5 安全域的删除 (33)5.3.2.6 安全域生命周期状态的迁移 (33)5.4 生命周期图解 (34)6 GlobalPlatform环境(OPEN) (36)6.1 综述 (37)6.2 OPEN服务 (38)6.3 命令分发 (38)6.4 逻辑通道和应用选择 (39)6.4.1 隐式选择的分派 (39)6.4.2 基本逻辑通道 (39)6.4.2.1 基本逻辑通道的应用选择 (39)6.4.2.1.1 基本逻辑通道上应用的隐式选择 (39)6.4.2.1.2 基本逻辑通道上应用的显式选择 (40)6.4.2.2 基本逻辑通道上的逻辑通道管理 (41)6.4.2.3 基本逻辑通道上的应用命令分发 (41)6.4.3 补充逻辑通道 (41)6.4.3.1 补充逻辑通道的应用选择 (41)6.4.3.1.1 补充逻辑通道上应用的隐式选择 (42)6.4.3.1.2 补充逻辑通道上应用的显式选择 (42)6.4.3.2 补充逻辑通道上的逻辑通道管理 (43)6.4.3.3 补充逻辑通道上的应用命令分发 (43)6.5 GlobalPlatform注册表 (43)6.5.1 应用/可执行加载文件/可执行模块等数据元素 (44)6.5.1.1 应用/可执行加载文件/可执行模块的AID (44)6.5.1.2 应用/可执行加载文件/可执行模块的生命周期 (44)6.5.1.3 内存资源管理参数 (44)6.5.1.4 权限 (44)6.5.1.5 隐式应用选择参数 (44)6.5.1.6 关联安全域的AID (44)6.5.1.7 应用提供方ID (44)6.5.1.8 服务参数 (44)6.5.2 卡片级数据 (45)6.6 权限 (45)6.6.1 权限定义 (45)6.6.2 权限分配 (46)6.6.3 权限管理 (47)6.7 GlobalPlatform可信任框架 (47)7 安全域 (49)7.1 概要描述 (49)7.1.1 发卡方安全域 (49)7.2 关联到安全域 (50)7.3 安全域服务 (51)7.3.1 应用对安全域服务的访问 (51)7.3.2 安全域对应用的访问 (52)7.3.3 个人化支持 (52)7.3.4 运行时消息的支持 (53)7.4 安全域数据 (54)7.4.1 发卡方安全域 (54)7.4.1.1 发卡方标识编号 (54)7.4.1.2卡片映像编号 (55)7.4.1.3 卡片标识数据 (55)7.4.2 补充安全域 (55)7.4.2.1 安全域提供方标识编号 (55)7.4.2.2 安全域映像编号 (55)7.4.2.3 安全域管理数据 (55)7.5 安全域密钥 (56)7.5.1 密钥信息 (56)7.5.2 密钥访问条件 (56)7.6 数据和密钥管理 (57)8 全局平台服务 (58)8.1 全局服务应用 (58)8.1.1 注册全局服务 (58)8.1.2 应用对全局服务的访问 (58)8.1.3 全局服务参数 (59)8.2 持卡方验证方法(CVM)应用 (59)8.2.1 应用对CVM服务的访问 (60)8.2.2 CVM管理 (60)8.2.2.1 注册CVM (60)8.2.2.2 CVM状态 (60)8.2.2.2.1 CVM状态ACTIVE (61)8.2.2.2.2 CVM状态INV ALID_SUBMISSION (61)8.2.2.2.3 CVM状态V ALIDATED (61)8.2.2.2.4 CVM状态BLOCKED (61)8.2.2.3 CVM格式 (61)9 卡片和应用的管理 (62)9.1 卡片内容管理 (62)9.1.1 概述 (62)9.1.2 对OPEN的要求 (62)9.1.3 对安全域的要求 (63)9.1.3.1 具备“令牌验证权限”的安全域 (63)9.1.3.2 具备“授权管理权限”的安全域 (63)9.1.3.3 具备“委托管理权限”的安全域 (63)9.1.3.4 具备“全局删除权限”的安全域 (63)9.1.3.5 具备“全局锁定权限”的安全域 (63)9.1.3.6 具备“收条创建权限”的安全域 (64)9.2 卡片内容的授权和管理 (64)9.2.1 数据鉴别(DAP)模式验证 (64)9.2.2 加载文件数据块的散列值 (64)9.2.3 令牌 (64)9.3 卡片内容的加载、安装和可选择化 (64)9.3.1 概述 (64)9.3.2 卡片内容的加载 (65)9.3.3 卡片内容的安装 (66)9.3.4 卡片内容的加载、安装和可选择化联合操作 (66)9.3.5 卡片内容加载过程 (66)9.3.6 卡片内容的安装过程 (69)9.3.7 卡片内容的可选择化过程 (70)9.3.8 卡片内容的加载、安装和可选择化联合操作过程 (71)9.3.9 加载和安装流程的示例 (73)9.4 内容的让渡和注册表的更新 (76)9.4.1 内容的让渡 (76)9.4.2 注册表的更新 (78)9.4.2.1 普通的注册表更新 (78)9.4.2.2 注册表更新中的让渡操作 (79)9.5 内容的删除 (80)9.5.1 应用删除 (81)9.5.2 可执行加载文件的删除 (82)9.5.3 可执行加载文件和相关应用的删除 (83)9.6 安全管理 (85)9.6.1 生命周期管理 (85)9.6.2 应用的锁定和解锁 (85)9.6.3 卡片的锁定和解锁 (86)9.6.4 卡片终结 (87)9.6.5 应用状况的查询 (88)9.6.6 卡片状况的查询 (88)9.6.7 操作的频度检测 (88)9.6.7.1 内容加载和安装 (88)9.6.7.2 异常 (89)9.6.8 跟踪和事件日志 (89)9.7 内存资源管理 (89)10 安全通信 (90)10.1 安全通信 (91)10.2 显式和隐式安全通道 (91)10.2.1 显式安全通道的开启 (91)10.2.2 隐式安全通道的开启 (91)10.2.3 安全通道的终止 (91)10.3 安全通道协议的直接处理和间接处理 (92)10.4 实体认证 (92)10.4.1 对称加密算法下的认证 (92)10.4.2 非对称加密下的认证 (92)10.5 安全的消息传送 (93)10.6 安全级别 (93)10.7 安全通道协议标识符 (93)第一部介绍1 介绍GlobalPlatform是一家由支付和通信业的领先厂商、政府相关部门以及供应商社区共同建立的一个组织,并率先提出了一个跨行业的智能卡全局基础架构及其实现,其目标是为了减少隐藏在快速增长的跨行业、多应用的智能卡背后的障碍,使得发卡商在各种各样的卡片、终端和后台系统前,继续享有选择的自由。
java card标准
Java Card是Java的一个子集,专为智能卡等资源受限设备设计。
其以Java Card Platform specifications(爪哇卡平台规格)为依循标准,此技术规格标准由升阳电脑所研发。
Java Card的主要特点及诉求在于移携性与安全性。
在语言级别,Java Card的所有语言结构都存在于Java中并且行为相同。
这意味着Java Card程序能被Java编译器编译成Java类文件,类文件由特定于Java Card平台的工具进行后续的处理。
但是Java Card 不支持许多Java语言功能,例如char、double、float和long类型,以及对象的finalization、对象克隆等。
此外,Java Card的字节码是由Java Card虚拟机运行的Java Card 字节码,是标准Java虚拟机运行的Java字节码的功能子集,但具有不同的编码以优化大小。
与通过编译相同Java源代码获得的Java小程序相比,Java Card小程序通常使用更少的字节码。
这节省了内存,这是资源受限设备(如智能卡)的必需品。
同时,作为设计权衡,不支持某些Java语言功能和大小限制。
存在克服大小限制的技术,例如将应用程序的代码分成低于64K限制的包。
以上内容仅供参考,建议查阅关于java card标准的资料获取更全面和准确的信息。
JavaCard开发教程之规范多年以前,Sun微系统公司实现了智能卡和类似的资源约束设备的潜能,并且定义了一组Java技术子集规范来为它们创建应用程序,Java Card小应用程序。
支持这些规范的设备称为Java Card平台。
在一个Java Card平台上,来自不同的供应商的多个应用程序可以安全地共存。
一个典型的Java Card设备有一个8或16位的运行在3.7MHz的中央处理器,带有1K 的RAM和多于16K的非易失性存储器(可编程只读存储器或者闪存)。
高性能的智能卡带有单独的处理器和加密芯片,以及用于加密的内存,并且有一些还带有32位的中央处理器。
Java Card技术规范目前是2.2版,由三部分组成:·Java Card虚拟机规范,定义了用于智能卡的Java程序语言的一个子集和虚拟机。
·Java Card运行时环境规范,进一步定义了用于基于Java的智能卡的运行期行为。
·Java Card应用编程接口规范,定义了用于智能卡应用程序核心框架和扩展Java程序包和类。
Sun还提供了Java Card开发工具箱(JCDK) /products/javacard/,包含了Java Card运行期环境和Java Card虚拟机的引用实现,和其它帮助开发Java Card 小应用程序的工具。
本文的第二部分将详细讲述JCDK。
Java Card技术和J2ME平台让我们比较一下Java Card和J2ME平台技术:图. Java Card技术和J2ME平台CDC和CLDC配置以及它们JavaCard开发教程之程序元素完整的Java Card应用程序由一个后端应用程序和系统、一个主机(卡外)应用程序、一个接口设备(读卡器)和卡上小应用程序、用户证书和支持软件组成。
所有的这些元素共同组成一个安全的端到端应用程序:图1. Java Card应用程序的体系结构一个典型的Java Card应用程序不是孤立的,而是包含卡端、读取端和后端元素。
JA V A卡技术概述---------------------------------------------------------------------------------------------------------------------- 编辑整理:编辑:王鹏来源:门禁关键字:JA V A爪哇卡(JavaCard)技术可使以爪哇语言所写成的程序,在智能卡和其它资源受限装置上执行。
本文将让您一览爪哇卡技术,包括该系统的结构和组件。
本概述的目的在让您对爪哇卡技术有一个整体性了解,并介绍有关爪哇卡系统的重点和基本概念,以利程序开发者设计程序之用。
一、爪哇卡技术之组件爪哇卡技术包括下列部分:*精简后之爪哇程序语言以及适合智能卡应用的虚拟机(JavaCardVirtualMachine,JCVM)定义*核心之爪哇卡应用程序接口(ApplicationProgrammingInterface,API)及其延伸部分*爪哇卡之执行时期环境(JavaCardRuntimeEnvironment,JCRE)爪哇卡应用程序接口和执行时期环境是以智能卡工业标准ISO7816为模型而设计,因此,爪哇卡平台可轻易支持跟ISO7816第一到第六部分兼容的智能卡系统和应用。
爪哇卡应用程序被称为applets。
爪哇卡平台可支持多重应用(multiapplication)环境。
爪哇卡应用程序则是在爪哇之执行时期环境内处理和执行。
二、精简之爪哇卡语言若智能卡的程序可使用爪哇程序语言的所有功能写成当然最好,不过对智能卡和其它资源受限装置来说,由于运算资源有限,要完全支持爪哇程序语言是不可能也不切实际的事。
一般智能卡是以1K的随机存取内存(RAM),以及16K的非挥发性内存(EEPROM或RAM)和24K的只读存储器(ROM)规格出现,因此,爪哇卡平台仅能支持经小心选取且已规格化而有精简功能的爪哇语言。
此精简爪哇语言包含之功能,适于设计智能卡以及其它小型装置的程序,同时还能保留爪哇程序语言以对象为导向(object-oriented)的能力。
JavaCard应用开发(一)之前在CSDN博客上看到一个人写的Java Card应用开发的教程,感觉很好,网址如下:/gszhy/article/details/40779949#comments。
有兴趣的可以参考。
这里是我根据自己开发过程中遇到的问题重新整理的,和前面这位同学的内容大体相同,只是个别选项有所区别,这个可能是和自己的编译器有关系吧。
开发环境的搭建有兴趣的可以参考/menghnhhuan/article/details/7616690,这里就不多说啦。
下面来介绍一下如何在搭建好的环境中建立一个正常的工程。
1. 新建一个JavaCard项目。
点击“下一步”。
2. 输入项目名称,一般用小写,点击“下一步”3. 勾选以下两项,点击“下一步”。
4. 在“Create a Jave Card application using one of the templates”前打勾,并选择“Basic Java Card applet”,点击“下一步”。
5. 输入Package的名称和Applet class的名称,点击“下一步”。
注意包的名称小写,类的名称第一个字母一般大写。
6. 设置Package和Applet的AID,设置完成后点击“完成”。
7. 此时包资源管理器中出现了刚刚新建的工程“jcproj”。
9. 左键选中新建的工程,在“项目”中单击“属性”,出现下面的对话框,在对话框中选择“Java 构建路径”那一项,在“Java Card [Custom]”前打勾。
最后点击右下角“确定”。
10. 下面进行调试设置。
点击“debug”(绿色小虫子)右边的倒三角,在下拉菜单中选择“调试配置”。
在调试配置对话框中找到“Java Card Application”选项,在该项上右键单击,选择“新建”,就会发现这个菜单下面多出了一个你刚刚建立的工程名字哦。
然后单击“调试”。
这里需要注意的是,如果一个工程中有不止一个Applet ,那么在此处的“Package Upload选项卡中”需要安装全部的Applet。
/ Docs & Support实际上,您使用熟Java Programming LanguageOracle Development Tools Choose page language4. 安装插件后,需要重新启动 IDE 才能继续执行下面的教程步骤。
注册 Java Card 平台如果从插件管理器下载了 Java Card 3.0.2 Runtime Bundle,则已将 Java Card SDK 设置为平台。
但是,如果从下载并安装了平台,则可以使用 "Tools"(工具)> "Java Platforms"(Java 平台)菜单将 Java Card 平台添加到 IDE 中,具体的操作方法与注册任何 Java 平台相同。
设置 Java Card 平台后,IDE 的 "Services"(服务)标签中会列出该平台。
如果未显示 "Services"(服务)标签,请从菜单中选择"Windows"(窗口)> "Services"(服务)。
一个“平台”可以有多台“设备”。
您可以将项目部署到特定平台的特定设备上。
了解 Java Card 项目类型从菜单中选择 "File"(文件)> "New Project"(新建项目,然后单击 "Java Card" 类别。
此处有多种 Java Card 项目可供您创建。
所有这些项目与 NetBeans Java SE 项目一样,都使用Apache Ant生成。
传统的 Applet 项目为较小的设备创建传统的 Java Card Applet,这与 Java Card 2.0 和更早版本中使用的 Applet 类似。
传统的库项目类似于传统的 Applet 项目,它没有 Applet,是您希望存放在设备上且可在 Applet 之间共享的一些代码。
Java Card 技术简介:第 1 部分许多关于无线Java站点的文章都以 J2ME 平台为重点。
本系列文章(共分为两部分)将介绍另一种重要的移动Java技术:支持智能卡编程的 Java Card 。
由于这些可移植技术具有非常强的专用性,因此本系列文章涵盖了相当广泛的内容。
本系列文章的第一部分将介绍智能卡、Java Card 技术和 Java Card 小应用程序(applet)元素。
第二部分将介绍 Java Card 技术的开发部分。
简介Java Card 技术适用于 Java 平台,可应用于环境高度专用化、内存和处理约束比 J2ME 设备更苛刻的智能卡和其他设备。
智能卡在个人安全领域发挥着举足轻重的作用。
它们可以用于添加身份验证,并对安全级别很高的信息系统提供安全访问。
存储在智能卡中的信息是可移植的。
借助 Java Card 技术,您可以携带有价值且敏感的个人信息,例如病历、信用卡号或者存储在压缩但非常安全的介质中的电子现金余额。
什么是智能卡?智能卡不是什么新鲜事物。
早在 20 年前,欧洲就以(非智能形式)内存卡的形式引入了智能卡的概念,使用它保存重要的电话信息,其作用是减少盗打付费电话的可能。
智能卡技术由一项国际标准组织(ISO)和国际电工委员会(IEC)组成的联合技术委员会(JTC1)定义并管理的工业标准。
1987年推出的ISO/IEC 7816国际标准系列在2003年推出了它的最新的升级版本,界定了智能卡的方方面面,包括物理特性、物理接触界面、电子信号和传输协议、命令、安全体系、应用程序标识符和公用数据元素等。
智能卡是一个含有嵌入式集成电路(IC)的塑料卡片。
类似于一张信用卡。
当用作 SIM 卡时,这个塑料卡片很小,但大小刚好能插入手机中。
智能卡从设计上保证高度安全性,窜改一点点内容都会导致毁坏它所包含的信息。
在智能卡使用的某些领域中,它们仅仅提供受保护的非易失性存储。
更高级的智能卡还有用于安全处理和存储的微处理器和内存,可以用于使用公钥或共享密钥算法的安全应用程序。
Nxp Java Card 开发目录▪ 1 安装要求2 安装和配置2.1 安装JDK2.2 安装eclipse2.3 安装NXP Java Card 开发插件3 开始第一个Applet3.1 新建项目3.2 插件激活3.3 构建3.4 调试▪ 4 常见问题及注意事项安装要求需要准备安装文件包括▪eclipse 3.5 或更高版本下载▪JDK1.6 下载▪NXP Java Card开发工具(eclipse 插件) 下载▪NXP Java Card开发工具激活插件(eclipse 插件) 下载在Nxp Java Card 开发安装文件目录中可以找到以上四个文件安装和配置安装JDK安装eclipse安装NXP Java Card 开发插件在eclipse 中选择菜单Help -> Install New Software不要勾选'Contract all update sites during install to find required software'点击Add... -> Local...在弹出的选择NXP Java C ard 开发eclipse 插件所在的目录点击OK勾选JCOP Dev elopment T ools下一步下一步文件:Nxp javacard plugin next2.png 选择接受协议,并点击finish在证书列表中选中NXP的证书,并点击O K重启eclipse开始第一个Applet新建项目在eclipse 中选择File -> New -> Other -> Java Card -> Java Card Project在第一次使用插件建立项目时,需要对插件进行插件激活输入项目的名字选择JavaCard的版本和Global Platform的版本选择使用模板输入包名和Applet Class的名字输入package id和applet idpackage id最小为5 个字节,applet 惯用法是在package id 后添加字节demo程序内容:<source lang="java"> import javacard.framework.APDU; import javacard.framework.ISO7816; import javacard.framework.Applet; import javacard.framework.ISOException; import javacard.framework.Util;public class FirstDemo extends Applet { public static void install(byte[] bArray, short bOffset, b yte bLength) { // GP-compliant JavaCard applet registration new com.demo.FirstDemo().register(bArray, (short) (bOffset + 1), bArray[bOffset]); }public void process(APDU apdu) { // Good practice: Return 9000 on SELEC T if (selectingApplet()) { return; }byte[] myText={'h','e','l','l','o','w','o','r','l','d'};byte[] buf = apdu.getBuffer(); if(buf[ISO7816.OFFSET_CLA]!=(byte)0x80) ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPOR TED); switch (buf[ISO7816.OFFSET_INS]) { case (byte) 0x00: break; case (byte) 0x50: apdu.setIncomingAndReceive(); Util.arrayC opyNonAtomic(myText, (short) 0, buf, (short) 0, (short) 0x0A); apdu.setOu tgoingAndSend((short)0, (short)0x0a); b reak; default: // good practice: If you d on't know the INStruction, say so: ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPOR TED); } } } </source>插件激活在第一次使用插件新建项目时,eclipse弹出插件激活框1点击下一步,并选择激活方式2选择激活空间所在的目录3激活完成4构建在eclipse 中选中新建的project -> 属性-> Java Card Settings 选中Generate debugging information在eclipse 中选中新建的project -> 属性-> Java Compiler 中设置class 的版本为1.5调试在eclipse 的debug -> Debug Configurations 中双击Java Card Application在右侧target -> Java Card Simulation 中选择JCOP on NXP SmartMX点击configure,在弹出的配置窗口中选择JCOP OS V ersion 为2.4.1 R3,Type为J3A081 v2.4.1 R3(B1)点击【finish】完成点击【Apply】【Debug】开始调试在JCOP Shell(可以通过wind ow -> show view -> JCOP Shell 显示,并将该视图右上角的"Trace APDUs"按钮打开)中输出如下:cm> /term "Remote|localhost:3265"--Opening terminal> /card -a a000000003000000 -c com.ibm.jc.CardManagerresetCard with timeout: 0 (ms)--Waiting for card...ATR=3B F8 13 00 00 81 31 FE 45 4A 43 4F 50 76 32 34 ;.....1.EJCOP v2431 B7 1.IOCTL().ATR: T=1, FI=1/DI=3 (93clk/etu), N=0, IFSC=254, BWI=4/CWI=5, Hist="JCOP v241"<= 6F 65 84 08 A0 00 00 00 03 00 00 00 A5 59 9F 65 01 FF 9F 6E 06 47 91 01 18 34 00 73 4A 06 07 2A 86 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86 FC 6B 02 02 01 01 63 09 06 07 2A 86 48 86 FC 6B 03 64 0B 06 09 2A 86 48 86 FC 6B 04 02 15 65 0B 06 09 2B 85 10 86 48 64 02 01 03 66 0C 06 0A 2B 06 01 04 01 2A 02 6E 01 02 90 00 Status: No Error cm> set-keyoe...........Y.e ...n.G...4.sJ..* .H..k.`...*.H..k ....c...*.H..k.d ...*.H..k...e... +...Hd...f...+....*.n....255/1/DES-ECB/404142434445464748494a4b4c4d4e4f255/2/DES-ECB/404142434445464748494a4b4c4d4e4f 255/3/DES-ECB/404142434445464748494a4b4c4d4e4f cm> init-update 255 .P....{,...<..=> 80 50 00 00 08 BF 7B 2C 10 9A F9 3C FE 00 (5067 usec) <= 00 00 74 74 6E 6E 6E 62 62 62 FF 02 00 00 3D 02 9C 31 C7 89 96 CA E6 9B 47 59 06 7F 90 00 Status: No Error cm> ext-auth plain..ttnnnbbb....=. .1......GY....=> 84 82 00 00 10 61 B5 96 44 85 99 48 E7 ED F1 F4 71 B4 A2 D3 8B (5679 usec) <= 90 00 Status: No Error cm> delete -r 010******* .. q.........a..D..H....=> 80 E4 00 80 07 4F 05 01 02 03 04 06 00 (2738 usec) <= 6A 88 Status: Reference data not found jcshell: Error code: 6a88 (Reference data not found) jcshell: Wrong response APDU: 6A88 Ignoring expected error cm> j......O.......upload -c -d -b 250 "D:\eclipse\workspace\demo\bin\com\demo\javacard\demo.cap" ................=> 80 E6 02 00 12 05 01 02 03 04 06 08 A0 00 00 00 03 00 00 00 00 00 00 00 (6888 usec) <= 00 90 00 Status: No Error Start loading Header.cap (31 byte) => 80 E8 00 00 1F C4 82 03 B0 01 00 18 DE CA FF ED 02 02 04 00 01 05 01 02 03 04 06 08 63 6F 6D 2F 64 65 6D 6F 00 (5421 usec) <= 00 90 00 Status: No Error Header.cap loaded (31 byte) ... demo. ... ........................ /Start loading Directory.cap (36 byte) => 80 E8 00 01 24 02 00 21 00 18 00 21 00 0A 00 0B 00 2A 00 0E 00 A1 00 0A 00 0F 00 00 00 5C 01 F3 00 00 00 00 00 00 01 01 00 00 (6751 usec) <= 00 90 00 Status: No Error Directory.cap loaded (36 byte) Start loading Import.cap (14 byte) => 80 E8 00 02 0E 04 00 0B 01 03 01 07 A0 00 00 00 62 01 01 00 (4964 usec) <= 00 90 00 Status: No Error Import.cap loaded (14 byte) Start loading Applet.cap (13 byte) => 80 E8 00 03 0D 03 00 0A 01 06 01 02 03 04 06 01 00 08 00 (3393 usec) <= 00 90 00 Status: No Error Applet.cap loaded (13 byte) Start loading Class.cap (17 byte) => 80 E8 00 04 11 06 00 0E 00 00 00 80 03 00 FF 00 07 01 00 00 00 1C 00 (5393 usec) <= 00 90 00 Status: No Error Class.cap loaded (17 byte) Start loading Method.cap (164 byte) => 80 E8 00 05 A4 07 00 A1 00 01 10 18 8C 00 05 7A 05 30 8F 00 03 3D 8C 00 08 18 1D 04 41 18 1D 25 8B 00 04 7A 05 22 18 8B 00 07 60 03 7A 10 0A 90 0B 3D 03 10 68 38 3D 04 10 65 38 3D 05 10 6C 38 3D 06 10 6C 38 3D 07 10 6F 38 3D 08 10 77 38 3D 10 06 10 6F 38 3D 10 07 10 72 38 3D 10 08 10 6C 38 3D 10 09 10 64 38 2D 19 8B 00 00 2E 1B 03 25 10 80 6A 08 11 6D 00 8D 00 06 1B 04 25 75 00 25 00 02 00 00 00 2B 00 50 00 0D 19 8B 00 09 3B 1A 03 1B 03 10 0A 8D 00 01 3B 19 03 10 0A 8B 00 02 70 08 11 6D 00 8D 00 06 7A 00 (3792 usec) <= 00 90 00 Status: No Error ... ...............z .0...=......A..% ...z."....`.z... .=..h8=..e8=..l8 =..l8=..o8=..w8= ...o8=...r8=...l 8=...d8-.......% ..j..m......%u.% .....+.P......;. ........;....... p..m....z. ... ....... ................ ... ... ................ ... b... ................ ... ....$..!...!.... .*...........\............Method.cap loaded (164 byte) Start loading StaticField.cap (13 byte) => 80 E8 00 06 0D 08 00 0A 00 00 00 00 00 00 00 00 00 00 00 (3549 usec) <= 00 90 00 Status: No Error StaticField.cap loaded (13 byte) Start loading ConstantPool.cap (45 byte) => 80 E8 00 07 2D 05 00 2A 00 0A 03 80 0A 01 06 80 10 02 03 80 0A 08 01 00 02 00 03 80 03 02 06 80 03 00 06 80 07 01 03 80 03 03 06 00 00 01 03 80 0A 06 00 (13838 usec) <= 00 90 00 Status: No Error ConstantPool.cap loaded (45 byte) Start loading RefLocation.cap (18 byte) => 80 E8 00 08 12 09 00 0F 00 00 00 0B 05 06 04 0A 07 42 0E 14 0A 08 08 00 (9636 usec) <= 00 90 00 Status: No Error RefLocation.cap loaded (18 byte) Start loading Descriptor.cap (95 byte) => 80 E8 00 09 5F 0B 00 5C 01 00 01 00 02 00 00 00 00 03 00 81 00 01 00 16 00 05 00 00 00 00 01 09 00 08 00 18 00 12 00 00 00 00 07 01 00 1C 00 1B 00 83 00 00 00 00 00 0A 00 1F 00 21 00 25 FF FF 00 18 00 16 00 28 00 2A 00 16 00 2C 01 10 04 B4 31 06 68 00 A1 01 B0 06 B4 B4 44 03 44 10 02 41 01 20 01 40 00 (3302 usec) <= 00 90 00 Status: No Error Descriptor.cap loaded (95 byte) Start loading Debug.cap (502 byte) => 80 E8 00 0A FA 0C 01 F3 00 16 00 12 63 6F 6D 2F 64 65 6D 6F 2F 46 69 72 73 74 44 65 6D 6F 00 19 6A 61 76 61 63 61 72 64 2F 66 72 61 6D 65 77 6F 72 6B 2F 41 70 70 6C 65 74 00 0E 46 69 72 73 74 44 65 6D 6F 2E 6A 61 76 61 00 06 3C 69 6E 69 74 3E 00 03 28 29 56 00 04 74 68 69 73 00 14 4C 63 6F 6D 2F 64 65 6D 6F 2F 46 69 72 73 74 44 65 6D / demo/FirstDemo.. javacard/framewo rk/Applet..First Demo.java..<init >..()V..this..Lc om/demo/FirstDem ... . .@. ...._..\........ ................ ................ ...........!.%.. .....(.*...,.... 1.h.......D.D..A ... .B...... ................ ... ... ....-..*........ ................ ................ ... ... ................6F 3B 00 07 69 6E 73 74 61 6C 6C 00 07 28 5B 42 53 42 29 56 00 06 62 41 72 72 61 79 00 02 5B 42 00 07 62 4F 66 66 73 65 74 00 01 53 00 07 62 4C 65 6E 67 74 68 00 01 42 00 07 70 72 6F 63 65 73 73 00 1C 28 4C 6A 61 76 61 63 61 72 64 2F 66 72 61 6D 65 77 6F 72 6B 2F 41 50 44 55 3B 29 56 00 04 61 70 64 75 00 19 4C 6A 61 76 61 63 61 72 64 2F 66 72 61 6D 65 77 6F 72 6B 2F 41 50 44 55 3B 00 06 6D 79 54 65 78 74 00 03 62 75 66 00 08 00 (3041 usec) <= 00 90 00 Status: No Error => 80 E8 00 0B FA 63 6F 6D 2F 64 65 6D 6F 00 15 00 01 00 00 00 01 00 02 00 01 00 02 00 00 00 00 03 00 03 00 04 00 01 00 01 02 00 05 00 01 00 01 00 00 05 00 06 00 00 00 05 00 00 00 04 00 10 00 07 00 08 00 09 00 08 02 00 12 00 03 00 04 00 00 09 00 0A 00 00 00 12 01 00 0B 00 0C 00 00 00 12 02 00 0D 00 0E 00 00 00 12 00 00 00 0A 00 13 00 0B 00 0D 00 14 00 0E 00 10 00 13 00 11 00 11 00 15 00 0F 00 10 00 01 00 1C 02 00 83 00 04 00 0D 00 00 05 00 06 00 00 00 83 01 00 11 00 12 00 00 00 83 02 00 13 00 0A 00 42 00 41 03 00 14 00 0A 00 47 00 3C 00 00 00 05 00 19 00 06 00 06 00 1A 00 07 00 41 00 1D 00 42 00 46 00 1F 00 47 00 4D 00 20 00 4E 00 53 00 21 00 54 00 63 00 22 00 64 00 68 00 26 00 69 00 72 00 27 00 73 00 79 00 28 00 7A 00 7B 00 29 00 7C 00 81 00 2C 00 82 00 82 00 (2798 usec) <= 00 90 00 Status: No Error => 80 E8 80 0C 02 00 2E 00 (6973 usec) <= 00 90 00 Status: No Error Debug.cap loaded (502 byte) Load report: 948 bytes loaded in 0.0 seconds effective code size on card: + package AID + applet AIDs + classes + methods + statics 0 5 13 17 164 ... ... ...o;..install..([B SB)V..bArray..[B ..bOffset..S..bL ength..B..proces s..(Ljavacard/fr amework/APDU;)V. .apdu..Ljavacard /framework/APDU; ..myText..buf.../demo... ................ ................ ................ ................ ................ ................ ................ ................ ................ .......B.A...... G.<............. ..A...B.F...G.M. .N.S.!.T.c.".d. h.&.i.r.'.s.y.(. z.{.).|...,.............+ exports0-----------------------------overall cm> 199 bytes -q C9#() 010******* 010********* ................ ................install -i 010*********=> 80 E6 0C 00 1A 05 01 02 03 04 06 06 01 02 03 04 06 01 06 01 02 03 04 06 01 01 00 02 C9 00 00 00 (10050 usec) <= 00 90 00 Status: No Error cm> card-info .....O.. ...=> 80 F2 80 00 02 4F 00 00 (2302 usec) <= 08 A0 00 00 00 03 00 00 00 01 9E 90 00 Status: No Error => 80 F2 40 00 02 4F 00 00 (2510 usec) <= 06 01 02 03 04 06 01 07 00 90 00 Status: No Error => 80 F2 10 00 02 4F 00 00 (4618 usec)...............@..O..................O..<= 07 A0 00 00 00 03 53 50 01 00 01 08 A0 00 00 00 03 53 50 41 05 01 02 03 04 06 01 00 01 06 01 02 03 04 06 01 90 00 Status: No Error ............SP........ .SPA............Card Manager AID:A000000003000000Card Manager state : OP_READYApplication: Load File Module Load File Module : : : :SELECTABLE (--------) 010********* LOADED (--------) A0000000035350 A000000003535041 LOADED (--------) 010******* 010********* (Security Domain)通过/select 选择 FirstDemo Applet,并通过/send 发送 APDU 指令,产生 helloworld 的输出,JCOP Shell 中输出内容如下: cm> /select 010********* ............=> 00 A4 04 00 06 01 02 03 04 06 01 00 (753727 nsec) <= 90 00 Status: No Error cm> /send 80500000 .P.. ..=> 80 50 00 00 (1062 usec)<= 68 65 6C 6C 6F 77 6F 72 6C 64 90 00 Status: No Errorhelloworld..常见问题及注意事项1个分类: 损坏的文件的链接的页面本页面最后修订于2011年9月23日 (星期五) 14:25。
Java Card Development KitTools Release NotesVersion 3.1.0u4F12191-07January 2021Table of Contents•Introduction•What's New•System Requirements•Installation•Known Issues•Documentation•Product InformationIntroductionJava Card enables secure elements, such as smart cards and other tamper-resistantsecurity chips, to host applications, called applets, which employ Java technology.Java Card technology offers a secure and interoperable execution platform that canstore and update multiple applications on a single resource constrained device,while retaining the highest certification levels and compatibility with standards. JavaCard developers can build, test, and deploy applications and services rapidly andsecurely. This accelerated process reduces development costs, increases productdifferentiation, and enhances value to customers.The Java Card Development Kit is a suite of tools for designing implementations ofJava Card technology and developing applets based on the Java Card Specifications.It is available as two independent downloads:•The Java Card Development Kit Tools are used to convert and verify Java Cardapplications.•The Java Card Development Kit Simulator offers a testing and debuggingreference for Java Card applications. It includes a Java Card simulationenvironment and Eclipse plug-in.Together, these two downloads provide a complete, stand-alone developmentenvironment in which applications written for the Java Card platform can be developedand tested.These release notes describe the Java Card Development Kit Tools for the JavaCard Platform. The Java Card Development Kit Tools convert and verify Java Card applications. You can use the Java Card Development Kit Tools with products based on version 3.1, 3.0.5, and 3.0.4 of the Java Card Specification Classic Edition, as a stand-alone, or in conjunction with the Java Card Development Kit Simulator. What's NewThis topic contains the new features and changes in the Java Card Development Kit Tools.The following are the changes in the Java Card Development Kit Tools, version3.1.0u4:•New features and improvements in the converter and verifier tools:–When specifying the -target option, the converter and verifier tools are automatically using an internal copy of the export files to ensure the use of the correct version of the export files•New features and improvements in the converter tool:–Fixed conversion failure when using invoke-virtual on specific methods with package visibility•New features and improvements in the verifier tool:–Improved the usage of the -target parameter by automatically adding the Java Card platform export files into the verification process, according to thevalue of the parameter–Improved the binary compatibility checks for CAP files targeted for the 3.0.4 and 3.0.5 Java Card platforms–Added support for the -target parameter in the verifier ant task–Fixed incorrect verification of SuperMethodRef in large hierarchies of classes–Fixed incorrect verification of class implemented interfaces, when combining the use of version 2.2 and 2.3 of export files formatThe following are the changes in the Java Card Development Kit Tools, version3.1.0u3:•When running the verifier tool in the verbose mode, a warning is added to notify users, when the verification on a CAP file is done with an export file of an imported package, which has a newer version compared to the version that is actuallyimported•The following are the bug fixes in the verifier tool:–Improved checks of the dup_x and swap_x instructions–Fixed an incorrect restriction added on the virtual mapping table–Fixed issues in the detection of binary incompatibilities when extending Signature, RandomData, Cipher classes or the ECKey interface•The following are the bug fixes in the converter tool:–Fixed an incorrect NullPointerException preventing in some specific cases from creating extended CAP files–Fixed the help message for the –target command line optionThe following are the changes in the Java Card Development Kit Tools, version3.1.0u1:•Improved CAP file verification by the verifier tool•Bug fixes in the converter toolThe following are the new features and changes in the Java Card Development Kit Tools, version 3.1:•Improved API Extensibility Using Virtual Method Mapping Table•Support for large CAP file that may comprise multiple packages•Support for static resources in CAP files•Support for creating CAP files targeting previous releases of Java Card platform, such as version 3.0.5.•Java Card Development Kit Tools and Java Card Development Kit Simulator are two independent bundles, which can be downloaded separately, enabling easier evolution of the Development Kit Tools.For a complete list of supported features, refer to the Java Card Development Kit User Guide and Java Card Platform Specification Release Notes.System RequirementsThis product is targeted for use on a PC running the Microsoft Windows 7, Windows 8, and Windows 10 operating system.The following software must be installed for the Java Card Development Kit Tools to work:•Java Development Kit (JDK) – This release has been verified and tested with Oracle JDK 11 (64 bit version) and OpenJDK 11 (64 bit version). Download the JDK software from:/technetwork/java/javase/downloadsInstall it according to the instructions on the website.•Apache Ant – This release has been verified and tested with Ant 1.9.13.Download and install Ant from:InstallationThe Java Card specifications, Development Kit Simulator, and Development Kit Tools must be downloaded and installed individually.•See the Downloading the Specification Documents topic of the Java Card Platform Specification Release Notes, for more details on how to download the Java Card Specification bundle.•See the Installation topic of the Java Card Platform Development Kit Simulator Release Notes, for more details on how to download and install the Java Card Development Kit Simulator bundle.•See the Installation topic of the Java Card Development Kit User Guide, for more details on how to install the Java Card Development Kit Simulator and Java Card Development Kit Tools.•The Java Card Development Kit Tools bundle is provided on the Oracle Technology Network download website (https:///technetwork/java/embedded/javacard/overview/index.html). You must extract the downloaded .zip file to the directory where you have installed the Simulator.Contents of Java Card Development Kit ToolsThis release of the Java Card Development Kit Tools contain development tools that are used to convert and verify CAP files.The following table describes the files and directories that are installed in the root installation directory (JC_RI_HOME_TOOLS).Directory/File Descriptionapi_export_files_3.0.4Contains the export files for the Java Card3.0.4 API packages. For the Development KitSimulator bundles that include cryptography, italso includes the directoryapi_export_files_3.0.4\javacardx\crypto.api_export_files_3.0.5Contains the export files for the Java Card3.0.5 API packages. For the Development KitSimulator bundles that include cryptography, italso includes the directoryapi_export_files_3.0.5\javacardx\crypto.Directory/File Descriptionapi_export_files_3.1.0Contains the export files for the Java Card 3.1API packages. For the Development KitSimulator bundles that include cryptography, italso includes the directoryapi_export_files_3.1.0\javacardx\crypto.bin Contains all shell scripts or batch filesfor running the tools (such as capdump,converter, and so on).legal Contains license files.lib Contains all Java programming language JARfiles required for running tools by using theshell scripts or batch files, provided in the bindirectory.Known IssuesThere are no known bugs or issues in this release. DocumentationThe Java Card Documentation web site provides online product documentation for the Java Card Platform.Document DescriptionJava Card Development Kit User Guide This document describes how to use the JavaCard Development Kit to develop applicationsfor Java Card Platform. It is available in HTMLand PDF formats.Java Card Platform Specifications.The following specification documents areavailable for the Java Card Platform:•Java Card Platform Runtime EnvironmentSpecification, Classic Edition, Version 3.1(PDF format)•Java Card Platform Virtual MachineSpecification, Classic Edition, Version 3.1(PDF format)•Java Card Platform ApplicationProgramming Interface, Classic Edition,Version 3.1 (HTML format)•Java Card Platform Specification ReleaseNotes, Version 3.1 (HTML and PDFformats)Product InformationThe Java Card Technology website provides useful information about the Java Card product.Visit the Java Card Technology website to access the most up-to-date information on the following:•Product news and reviews•Release notes and product documentation Documentation AccessibilityFor information about Oracle's commitment to accessibility, visit theOracle Accessibility Program website at /pls/topic/lookup?ctx=acc&id=docacc.Access to Oracle SupportOracle customers that have purchased support have access to electronic support through My Oracle Support. For information, visit /pls/topic/ lookup?ctx=acc&id=info or visit /pls/topic/lookup?ctx=acc&id=trs if you are hearing impaired.Java Card Development Kit Tools Release Notes, Version 3.1.0u4F12191-07Copyright © 1998, 2021, Oracle and/or its affiliates. All rights reserved.Tools release notes for Java Card Development Kit, Version 3.1.0u4.This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing.If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable:U.S. GOVERNMENT END USERS: Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs) and Oracle computer documentation or other Oracle data delivered to or accessed by U.S. Government end users are "commercial computer software" or "commercial computer software documentation" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, reproduction, duplication, release, display, disclosure, modification, preparation of derivative works, and/or adaptation of i) Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs), ii) Oracle computer documentation and/or iii) other Oracle data, is subject to the rights and limitations specified in the license contained in the applicable contract. The terms governing the U.S. Government’s use of Oracle cloud services are defined by the applicable contract for such services. No other rights are granted to the U.S. Government.This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications.Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.Intel and Intel Inside are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Epyc, and the AMD logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group.This software or hardware and documentation may provide access to or information about content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use ofthird-party content, products, or services, except as set forth in an applicable agreement between you and Oracle.。
收稿日期:2000-03-14; 定稿日期:2000-05-24基金项目:黑龙江省博士后专项科研基金资助第30卷第6期2000年12月微电子学Microelectronics V o l .30,№6Dec .2000文章编号:1004-3365(2000)-06-0402-04Java 卡的研究与实现刘嵩岩,毛志刚,叶以正(哈尔滨工业大学 微电子中心,黑龙江 哈尔滨 150001)摘 要: Jav a 卡是一种新的智能卡,它基于Java 语言和虚拟机。
Jav a 卡应用程序(applet)可以运行于Java 卡运行环境——JCRE (Jav a Card Runtim e Environment )中,JCRE 包含Java 卡虚拟机——JCV M (Jav a Card Vir tual Machine )、核心API 类库和相关的本地方法。
JCVM 由两部分组成:卡外虚拟机和卡内虚拟机。
主要介绍了卡内虚拟机的解释执行、异常处理、堆栈模型以及堆的存储器组织。
关键词: Jav a 卡;JCRE ;JCVM ;智能卡;IC 卡中图分类号: TP312文献标识码: AA Study on Java Card and Its ImplementationLIU So ng -yan,M AO Zhi-g ang ,YE Yi-zheng(Microelectronic center ,Harbin Institute of Technology ,Harbin ,Heilongjiang 150001,P .R .China )Abstract: Jav a card is a new system fo r pr og ram ming smar t car ds,w hich is based o n the J av a lang uag e and Vir tua l Ma chine.Jav a ca rd pro g rams(applets)run in Java Card Runtime Env iro nment (JCR E),w hich includes the J av a Ca rd V ir tual M achine (JCV M ),the fra mewo rk ,the associa ted na tiv e methods and th e AP I .JCV M is implemented as tw o separ ate pieces :off-ca rd V M (V ir tual M a chine )and o n-ca rd V M.O ur interpre ter techno log y ,stack model a nd heap memo ry o rg anization used by o n-card V M a re presented in the pa pe r.Because resour ces a re limited within sma rt ca rd envir onment and ga rbage co llectio n is not suppo r ted in JCV M ,the prefer red w ay ofex ception handling does no t directly inv olv e the use of th row ,a ltho ug h the keyw o rd thro w is suppo r ted .Key words : Jav a ca rd;JCRE;JCV M;Smar t card;IC ca rdEEAC C : 1130B 1 引 言Jav a 卡是一种能运行J av a 语言程序的智能卡,它在资源有限的智能卡环境中支持Jav a 语言的一个子集,是J av a 嵌入到智能卡中的一种新的应用[1]。
1、简介Java Card 3 平台由两个版本组成Classic Edition和Connected Edition:Classic Edition是一个基于 2.2.2版本的前端兼容的演化平台,针对资源有限的设备仅支持applet-based应用。
如果你只对Classic Edition中提供的功能感兴趣的话就可以忽略Connected Edition。
Connected Edition提供了一个显著增强的运行时环境和一个新的虚拟机。
包含了一些新的面向网络的应用,例如提供了针对web应用的Servlet APIs,并且支持一些新的applet功能增强。
一个Connected Edition的应用可能会用到Classic Edition提供的特性,因此这两个版本的规范应用一起使用。
1.1动机Java Card技术使得用Java编程语言编写的程序可以运行在智能卡和其他小的资源紧张的设备上。
开发人员可以用标准的软件开发工具和环境来编译和调试程序,然后把程序转化成能被Java Card支持的格式。
Java Card上的应用程序被称为Applet,或者更明确的称为Java Card Applet 或者Card Applet(为了和浏览器Applets做区分)。
Java Card技术使得用Java语言编写的程序可以在智能卡上运行,然而如此小的设备远不足以支持Java平台的全部功能。
因此,Java Card平台仅仅支持一个被仔细挑选,定制的Java平台属性的的子集。
这个子集使得写的程序在小设备上有更好适应性,并且保持了Java语言的面向对象的特性。
一个简单的途径是定义一个代码可以在所有Java Card环境下移植的Java虚拟机的子集。
结合JVM的子集规定和信息,智能卡提供商可以在Java Card规范上构建自己的工具。
虽然手段是可行的,但有一个严重的缺点,目标平台将会丧失字节码的移植性。
Java平台的规范允许Java的代码在所有Java平台上移植,Java的“写一次,所有地方运行”的属性或许是平台的最重要的特性。
部分Java Card平台创建的工作就是为了把这种代码移植性带到智能卡行业。
在世界上有千百万的不同处理器和配置的智能卡,为支持软件派发所支持的多种代码格式的代价是不能承受的。
这个Java Card的虚拟机规范(版本3.0.1Classic Edition)是提供代码移植性的关键。
理解这个规范做了什么的一个方法是和Java平台的对应副本进行比较。
Java虚拟机规范定义了一个引导和按指令集执行Java类文件的引擎。
类文件是Java体系结构里面核心的部分,并且是代码移植性的支柱。
Java Card的虚拟机规范(版本3.0.1Classic Edition)仍然定义了一个实现了Java Card平台代码移植性的文件格式:CAP文件格式是软件被导入到实现了Java Card虚拟机规范的设备的格式。
1.2The Java Card Virtual MachineJava Card虚拟机的角色在Java Card平台的生产和开发流程下很好理解。
Java Card虚拟机和若干个组件组成一个Java Card系统,一个Converter(转换器),一个终端安装工具,和一个运行在设备上的安装程序。
如下图1-1和1-2。
开发一个Java Card应用和开发其它的Java程序一样:一个开发者写出一个或者多个类文件,应用使用模拟设备环境的模拟器模拟运行,测试和调试,包含应用的类文件被Java Card Coverter 转化成一个CAP文件。
Converter把构成一个Java包的所有类作为输入。
一个包含了一个或者多个非抽象的直接或者非直接的javacard.framework.Applet的子类的包被称作一个应用包(appet package)。
否则被称为一个库包(library package)。
Converter也可以把一个或者多个导出文件(export file)作为输入。
一个导出文件包含了被转化类需要的导入的其它类的名字和链接信息。
当一个应用或者库包被转化,转化器也可以产生这个包的导出文件。
经过转化,CAP文件被拷贝到一个卡片终端,例如一个带有读卡器设备的桌面计算机。
然后一个在终端上的安装工具载入CAP文件并且传输到Java Card设备里。
一个存在于Java Card设备上的安装程序接收CAP文件的内容并且准备好被Java Card虚拟机运行的应用。
虚拟机自己不需要导入或者操作CAP文件,它只需要执行在被安装程序导入的CAP文件中发现的应用的代码。
Java Card虚拟机和安装程序工程的区分使得两者都更小,安装程序可以被实现为一个Java程序并且在Java Card虚拟机的上层执行。
因为Java虚拟机的指令比典型的机器码更稠密,这样做可以降低安装器的大小。
组件性可以使得在一个Java Card虚拟机实现上可以使用不同的安装器。
1.3Java Language Security一个Java虚拟机的基本属性是通过类文件校验实现的强大的安全性。
许多实现了Java Card 平台的设备可能太小不足以支持在自己设备上的校验。
这个考虑使得设计上允许在设备上认证但是并不信赖它。
CAP文件中校验相关的数据被和应用执行的真正数据分开放置。
到允许安全管理更灵活的被实现。
在Java Card设备上有几个提供语言级别安全的选项。
概念上最简单的是在CAP文件下载时和下载后验证文件内容。
这个选项通常在比较大的设备上可行。
其它的选项信赖一些捆绑的属性:安全终端的物理安全,在下载时候的算法校验过程,在下载之前预校验CAP文件。
Java Card平台规范在CAP文件安装和安全规则这儿尽量的少说。
因为智能卡在不同的安全需求的不同系统里作为安全的处理器,有必要允许很多灵活性来适应智能卡发行人和用户。
1.4Java Card Runtime Environment SecurityJava Card平台的标准运行环境叫做JCRE,JCRE由Java Card虚拟机以及Java Card API 的类构成,既然Java Card虚拟机有保证Java语言层安全的责任,JCRE保证附加的运行态的安全。
这部分的附加属性在JCRE规范中。
JCRE最基本的运行态安全特性是用一个应用防火墙把应用隔离开。
应用防火墙阻止一个应用创建的对象被其它的应用访问,阻止了对未授权的实例的属性和方法的访问(访问数组的长度类似)。
应用的隔绝是一个重要的安全属性,但是它需要一个机制来允许应用间在需要内部操作的时候共享对象。
JCRE允许使用共享接口对象(shareable interface object)的概念来进行这样的共享。
这些对象提供了一个应用让它的对象可能被其他应用使用的唯一的方式。
更多的使用共享接口对象的信息参见API手册中javacard.framework.Shareable接口的描述。
一些防火墙相关的属性的描述为共享接口提供了一定的参考。
应用防火墙还避免了对JCRE自身拥有的对象的未授权使用。
JCRE可以使用不在JCAPI中体现的机制使得它的对象可以被应用使用。
JCRE隔离和共享的相关属性可以在JCRE规范中得到体现。
2、A Subset of the Java Virtual Machine2.1 Why a Subset is Needed典型的卡片设备只有1.2K的RAM,16K的非易失性存储(EEPROM or flash)以及32K-48K 的ROM。
2.2 Java Card Platform Language SubsetJava Card平台的Applets用Java语言编写并用Java编译器编译。
Java Card技术应用Java语言的一个子集。
2.2.1 Unsupported Items2.2.1.1 Unsupported FeaturesDynamic Class Loading ,Security Manager ,Finalization ,Threads ,Cloning ,Access Control in Java Packages ,Typesafe Enums ,Enhanced for Loop ,Varargs ,Runtime Visible Metadata (Annotations) ,Assertions.2.2.1.2 Unsupported KeywordsNative, synchronized, transient , volatile ,strictfp , enum ,assert.2.2.1.3 Unsupported Typeschar, double, float, long,arrays of more than one dimension.2.2.1.4 C lasses总之,没有任何的Java语言核心API类在Java Card平台获得完全支持。
ng.package 包中的有些类得到支持而剩下的则不支持,例如不支持String, Thread类,以及像Boolean ,Integer这样的包装类。
SystemClass ng.System不被支持,Java Card平台提供javacard.framework.JCSystem 作为系统功能接口。
2.2.2 Supported Items如果一个语言特性没有被Java Card规范明确声明为不支持,那么它就属于支持子集的一部分,值得注意的支持特性在本节描述。
2.2.2.1 FeaturesPackages,Dynamic Object Creation,Virtual Methods, Interfaces, Exceptions, Generics, Static Import, Runtime Invisible Metadata (Annotations)2.2.2.2 Keywords2.2.2.3 TypesJava的类型boolean, byte, short, int是被支持的,Objects(类的实例和一维数组)也是支持的,数组可以包含被平台支持的原始数据类型,对象和其它数组。
有些java Card实现可能不支持int类型。
2.2.2.4 Classes大部分ng package中的类在java Card平台中不被支持。
下面的ng中的类被有限的支持。
Object同Java语言一样,java Card平台API类继承于ng.Object,类Object中的大部分方法都无法使用,但是Object本身被作为继承系统的根得以保留。
Throwable类Throwable和它的子类得以支持。